From b2b736d596123de52dac700db769ac4eb576da5c Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 18 Jul 2014 08:47:45 -0500 Subject: tweaks for the monitor section. refactoring of some buttons, using new ArdourKnob instead of VolumeController. New ArdourDisplay shows a controllables user value, and provides support for preset values (hardcoded at present). Further refactoring to come, so that ArdourWidgets are derived from a common class. Controllable now has more responsibility for scaling between internal, user, and interface (knob percent) values. This also needs more refactoring and might have some unintended consequences. tested with audio and nothing seems amiss, yet. --- libs/canvas/canvas/utils.h | 4 ++++ libs/canvas/utils.cc | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'libs/canvas') diff --git a/libs/canvas/canvas/utils.h b/libs/canvas/canvas/utils.h index e269ca215c..947e57cc7c 100644 --- a/libs/canvas/canvas/utils.h +++ b/libs/canvas/canvas/utils.h @@ -29,6 +29,10 @@ namespace ArdourCanvas { extern LIBCANVAS_API Color rgba_to_color (double r, double g, double b, double a); extern LIBCANVAS_API void set_source_rgba (Cairo::RefPtr, Color); + extern LIBCANVAS_API void set_source_rgb_a (Cairo::RefPtr, Color, float alpha); //override the color's alpha + + extern LIBCANVAS_API void set_source_rgba (cairo_t*, Color); + extern LIBCANVAS_API void set_source_rgb_a (cairo_t*, Color, float alpha); //override the color's alpha Distance LIBCANVAS_API distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at); diff --git a/libs/canvas/utils.cc b/libs/canvas/utils.cc index 99516c849b..b7571a7844 100644 --- a/libs/canvas/utils.cc +++ b/libs/canvas/utils.cc @@ -154,6 +154,39 @@ ArdourCanvas::set_source_rgba (Cairo::RefPtr context, Color colo ); } +void +ArdourCanvas::set_source_rgb_a (Cairo::RefPtr context, Color color, float alpha) +{ + context->set_source_rgba ( + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + alpha + ); +} + +void +ArdourCanvas::set_source_rgba (cairo_t *cr, Color color) +{ + cairo_set_source_rgba ( cr, + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + ((color >> 0) & 0xff) / 255.0 + ); +} + +void +ArdourCanvas::set_source_rgb_a (cairo_t *cr, Color color, float alpha) +{ + cairo_set_source_rgba ( cr, + ((color >> 24) & 0xff) / 255.0, + ((color >> 16) & 0xff) / 255.0, + ((color >> 8) & 0xff) / 255.0, + alpha + ); +} + ArdourCanvas::Distance ArdourCanvas::distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at) { -- cgit v1.2.3