cairowidget: add supplementary set_source_rgb_a() method that uses the uint32 Color type
This commit is contained in:
parent
5dbcd76cb1
commit
e0d33bb726
@ -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)
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user