diff --git a/libs/gtkmm2ext/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc index 12a27a1ed3..f542e13a03 100644 --- a/libs/gtkmm2ext/cairo_widget.cc +++ b/libs/gtkmm2ext/cairo_widget.cc @@ -42,6 +42,18 @@ void CairoWidget::set_source_rgb_a( cairo_t* cr, Gdk::Color col, float a) //ToD cairo_set_source_rgba(cr, r, g, b, a); } +void CairoWidget::set_source_rgb_a( cairo_t* cr, Gtkmm2ext::Color col, float a) //ToDo: this one and the Canvas version should be in a shared file (?) +{ + int ir, ig, ib; + UINT_TO_RGB (col, &ir, &ig, &ib); + + const float r = ir / 256.; + const float g = ig / 256.; + const float b = ib / 256.; + + cairo_set_source_rgba(cr, r, g, b, a); +} + CairoWidget::CairoWidget () : _active_state (Gtkmm2ext::Off) , _visual_state (Gtkmm2ext::NoVisualState) diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h index 9af68d00e4..7efc333f36 100644 --- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h @@ -28,6 +28,7 @@ #include "gtkmm2ext/visibility.h" #include "gtkmm2ext/cairo_canvas.h" #include "gtkmm2ext/cairo_theme.h" +#include "gtkmm2ext/colors.h" #include "gtkmm2ext/widget_state.h" /** A parent class for widgets that are rendered using Cairo. @@ -89,6 +90,7 @@ public: static void set_source_rgb_a( cairo_t* cr, Gdk::Color, float a=1.0 ); + static void set_source_rgb_a( cairo_t* cr, Gtkmm2ext::Color, float a=1.0 ); /* set_focus_handler() will cause all button-press events on any CairoWidget to invoke this slot/functor/function/method/callback.