diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2014-08-27 10:55:01 -0500 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2014-08-27 10:55:01 -0500 |
commit | e7a15027e8358fdd5f3806416e9757f56d178736 (patch) | |
tree | f1de310352f062dcec2d4ed69a4c75a13450e7c9 /libs | |
parent | 5db98d9372e44d9bb68932ebd369cad271b4b991 (diff) |
refactor flat_buttons into cairowidget, and add a canvas-like convenience function for setting cairo color with a Gtk::Color
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/cairo_widget.cc | 17 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/cairo_widget.h | 8 |
2 files changed, 24 insertions, 1 deletions
diff --git a/libs/gtkmm2ext/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc index 47c0fdb9c1..033a66f908 100644 --- a/libs/gtkmm2ext/cairo_widget.cc +++ b/libs/gtkmm2ext/cairo_widget.cc @@ -24,6 +24,17 @@ static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info"; +bool CairoWidget::_flat_buttons = false; + +void CairoWidget::set_source_rgb_a( cairo_t* cr, Gdk::Color col, float a) //ToDo: this one and the Canvas version should be in a shared file (?) +{ + float r = col.get_red_p (); + float g = col.get_green_p (); + float b = col.get_blue_p (); + + cairo_set_source_rgba(cr, r, g, b, a); +} + CairoWidget::CairoWidget () : _active_state (Gtkmm2ext::Off) , _visual_state (Gtkmm2ext::NoVisualState) @@ -186,3 +197,9 @@ CairoWidget::provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Col g_object_set_data (G_OBJECT(w.gobj()), has_cairo_widget_background_info, (void*) 0xfeedface); } + +void +CairoWidget::set_flat_buttons (bool yn) +{ + _flat_buttons = yn; +} diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h index fff63b9ed9..9f0487798a 100644 --- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h @@ -69,6 +69,11 @@ public: virtual void render (cairo_t *, cairo_rectangle_t*) = 0; + static void set_flat_buttons (bool yn); + static bool flat_buttons() { return _flat_buttons; } + + static void set_source_rgb_a( cairo_t* cr, Gdk::Color, float a=1.0 ); + protected: /** Render the widget to the given Cairo context */ virtual bool on_expose_event (GdkEventExpose *); @@ -85,7 +90,8 @@ protected: Gtkmm2ext::ActiveState _active_state; Gtkmm2ext::VisualState _visual_state; bool _need_bg; - + + static bool _flat_buttons; bool _grabbed; private: |