summaryrefslogtreecommitdiff
path: root/libs/canvas
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2014-07-18 08:47:45 -0500
committerBen Loftis <ben@harrisonconsoles.com>2014-07-18 08:47:45 -0500
commitb2b736d596123de52dac700db769ac4eb576da5c (patch)
treec800fa5fd3a84d3c7b0749ba3edb5b9fd89629ed /libs/canvas
parentac9219a3c884b69352ff5ab0d13f30fb15cf8e6e (diff)
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.
Diffstat (limited to 'libs/canvas')
-rw-r--r--libs/canvas/canvas/utils.h4
-rw-r--r--libs/canvas/utils.cc33
2 files changed, 37 insertions, 0 deletions
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<Cairo::Context>, Color);
+ extern LIBCANVAS_API void set_source_rgb_a (Cairo::RefPtr<Cairo::Context>, 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<Cairo::Context> context, Color colo
);
}
+void
+ArdourCanvas::set_source_rgb_a (Cairo::RefPtr<Cairo::Context> 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)
{