refactor flat_buttons into cairowidget, and add a canvas-like convenience function for setting cairo color with a Gtk::Color
This commit is contained in:
parent
5db98d9372
commit
e7a15027e8
@ -54,7 +54,6 @@ using namespace std;
|
||||
ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
|
||||
ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
|
||||
ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
|
||||
bool ArdourButton::_flat_buttons = false;
|
||||
|
||||
ArdourButton::ArdourButton (Element e)
|
||||
: _elements (e)
|
||||
@ -398,15 +397,17 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
|
||||
}
|
||||
|
||||
//inset
|
||||
cairo_arc (cr, 0, 0, _diameter/2, 0, 2 * M_PI);
|
||||
cairo_set_source (cr, led_inset_pattern);
|
||||
cairo_fill (cr);
|
||||
|
||||
if (!_flat_buttons) {
|
||||
cairo_arc (cr, 0, 0, _diameter/2, 0, 2 * M_PI);
|
||||
cairo_set_source (cr, led_inset_pattern);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
//black ring
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_arc (cr, 0, 0, _diameter/2-2, 0, 2 * M_PI);
|
||||
cairo_arc (cr, 0, 0, _diameter/2-1, 0, 2 * M_PI);
|
||||
cairo_fill(cr);
|
||||
|
||||
|
||||
//led color
|
||||
ArdourCanvas::set_source_rgba (cr, led_color);
|
||||
cairo_arc (cr, 0, 0, _diameter/2-3, 0, 2 * M_PI);
|
||||
@ -977,9 +978,3 @@ ArdourButton::add_elements (Element e)
|
||||
{
|
||||
_elements = (ArdourButton::Element) (_elements | e);
|
||||
}
|
||||
|
||||
void
|
||||
ArdourButton::set_flat_buttons (bool yn)
|
||||
{
|
||||
_flat_buttons = yn;
|
||||
}
|
||||
|
@ -45,9 +45,6 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
||||
static Element led_default_elements;
|
||||
static Element just_led_default_elements;
|
||||
|
||||
static void set_flat_buttons (bool yn);
|
||||
static bool flat_buttons() { return _flat_buttons; }
|
||||
|
||||
ArdourButton (Element e = default_elements);
|
||||
ArdourButton (const std::string&, Element e = default_elements);
|
||||
virtual ~ArdourButton ();
|
||||
@ -157,8 +154,6 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
||||
bool _focused;
|
||||
bool _fixed_colors_set;
|
||||
|
||||
static bool _flat_buttons;
|
||||
|
||||
void setup_led_rect ();
|
||||
void set_colors ();
|
||||
void color_handler ();
|
||||
|
@ -312,6 +312,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
|
||||
|
||||
ARDOUR::GUIIdle.connect (forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::gui_idle_handler, this), gui_context());
|
||||
|
||||
Config->ParameterChanged.connect ( forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::set_flat_buttons, this), gui_context() );
|
||||
set_flat_buttons();
|
||||
|
||||
/* lets get this party started */
|
||||
|
||||
setup_gtk_ardour_enums ();
|
||||
@ -4493,3 +4496,9 @@ ARDOUR_UI::transport_numpad_event (int num)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::set_flat_buttons ()
|
||||
{
|
||||
CairoWidget::set_flat_buttons( config()->get_flat_buttons() );
|
||||
}
|
||||
|
@ -466,6 +466,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||
void sync_blink (bool);
|
||||
void audition_blink (bool);
|
||||
void feedback_blink (bool);
|
||||
|
||||
void set_flat_buttons();
|
||||
|
||||
void soloing_changed (bool);
|
||||
void auditioning_changed (bool);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user