2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <pangomm/layout.h>
26 #include "pbd/compose.h"
27 #include "pbd/error.h"
28 #include "pbd/stacktrace.h"
30 #include "gtkmm2ext/utils.h"
31 #include "gtkmm2ext/rgb_macros.h"
32 #include "gtkmm2ext/gui_thread.h"
34 #include "ardour/rc_configuration.h" // for widget prelight preference
36 #include "ardour_button.h"
37 #include "ardour_ui.h"
38 #include "global_signals.h"
42 #define REFLECTION_HEIGHT 2
52 ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
53 ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
54 ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
55 bool ArdourButton::_flat_buttons = false;
57 ArdourButton::ArdourButton (Element e)
59 , _tweaks (Tweaks (0))
63 , _corner_radius (4.0)
70 , fill_start_inactive_color (0)
71 , fill_end_inactive_color (0)
72 , fill_start_active_color (0)
73 , fill_end_active_color (0)
74 , text_active_color(0)
75 , text_inactive_color(0)
77 , led_inactive_color(0)
79 , fill_pattern_active (0)
81 , led_inset_pattern (0)
82 , reflection_pattern (0)
84 , _act_on_release (true)
86 , _fixed_diameter (true)
87 , _distinct_led_click (false)
90 , _fixed_colors_set (false)
92 ARDOUR_UI_UTILS::ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
95 ArdourButton::ArdourButton (const std::string& str, Element e)
97 , _tweaks (Tweaks (0))
101 , _corner_radius (4.0)
108 , fill_start_inactive_color (0)
109 , fill_end_inactive_color (0)
110 , fill_start_active_color (0)
111 , fill_end_active_color (0)
112 , text_active_color(0)
113 , text_inactive_color(0)
114 , led_active_color(0)
115 , led_inactive_color(0)
117 , fill_pattern_active (0)
119 , led_inset_pattern (0)
120 , reflection_pattern (0)
122 , _act_on_release (true)
124 , _fixed_diameter (true)
125 , _distinct_led_click (false)
128 , _fixed_colors_set (false)
133 ArdourButton::~ArdourButton()
138 cairo_pattern_destroy (shine_pattern);
142 cairo_pattern_destroy (fill_pattern);
145 if (fill_pattern_active) {
146 cairo_pattern_destroy (fill_pattern_active);
149 if (led_inset_pattern) {
150 cairo_pattern_destroy (led_inset_pattern);
153 if (reflection_pattern) {
154 cairo_pattern_destroy (reflection_pattern);
160 ArdourButton::set_text (const std::string& str)
164 if (!_layout && !_text.empty()) {
165 _layout = Pango::Layout::create (get_pango_context());
169 _layout->set_text (str);
176 ArdourButton::set_markup (const std::string& str)
181 _layout = Pango::Layout::create (get_pango_context());
184 _layout->set_markup (str);
189 ArdourButton::set_angle (const double angle)
195 ArdourButton::set_alignment (const float xa, const float ya)
202 ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
204 void (*rounded_function)(cairo_t*, double, double, double, double, double);
206 switch (_corner_mask) {
207 case 0x1: /* upper left only */
208 rounded_function = Gtkmm2ext::rounded_top_left_rectangle;
210 case 0x2: /* upper right only */
211 rounded_function = Gtkmm2ext::rounded_top_right_rectangle;
213 case 0x3: /* upper only */
214 rounded_function = Gtkmm2ext::rounded_top_rectangle;
216 /* should really have functions for lower right, lower left,
217 lower only, but for now, we don't
220 rounded_function = Gtkmm2ext::rounded_rectangle;
223 if (!_fixed_diameter) {
224 _diameter = std::min (get_width(), get_height());
229 if ((_elements & Body)==Body) {
230 if (_elements & Edge) {
232 cairo_set_source_rgba (cr, 0, 0, 0, 1);
233 rounded_function(cr, 0, 0, get_width(), get_height(), _corner_radius);
236 rounded_function (cr, 1, 1, get_width()-2, get_height()-2, _corner_radius - 1.5);
238 rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
241 if (active_state() == Gtkmm2ext::ImplicitActive) {
243 if (!(_tweaks & ImplicitUsesSolidColor)) {
244 cairo_set_source (cr, fill_pattern);
246 cairo_set_source (cr, fill_pattern_active);
250 if (!(_tweaks & ImplicitUsesSolidColor)) {
252 UINT_TO_RGBA (fill_end_active_color, &r, &g, &b, &a);
253 cairo_set_line_width (cr, 1.0);
254 rounded_function (cr, 2, 2, get_width()-4, get_height()-4, _corner_radius - 1.5);
255 cairo_set_source_rgba (cr, r/255.0, g/255.0, b/255.0, a/255.0);
259 } else if (active_state() == Gtkmm2ext::ExplicitActive || ((_elements & Indicator)==Indicator) ) {
262 cairo_set_source (cr, fill_pattern_active);
268 cairo_set_source (cr, fill_pattern);
274 if ( ((_elements & Inset)==Inset) && (active_state() != Gtkmm2ext::ExplicitActive) ) {
276 if ( !_flat_buttons ) {
277 float rheight = get_height()*0.5-REFLECTION_HEIGHT;
278 Gtkmm2ext::rounded_rectangle (cr, 2, 3, get_width()-4, rheight, _corner_radius-1);
279 cairo_set_source (cr, shine_pattern);
283 if (active_state() == Gtkmm2ext::ExplicitActive) {
285 UINT_TO_RGBA (fill_start_active_color, &r, &g, &b, &a);
286 cairo_set_line_width (cr, 2.0);
287 rounded_function (cr, 2, 2, get_width()-4, get_height()-4, _corner_radius - 2.0);
288 cairo_set_source_rgba (cr, r/255.0, g/255.0, b/255.0, a/255.0);
293 UINT_TO_RGBA (fill_start_inactive_color, &r, &g, &b, &a);
294 cairo_set_line_width (cr, 2.0);
295 rounded_function (cr, 2, 2, get_width()-4, get_height()-4, _corner_radius - 2.0);
296 cairo_set_source_rgba (cr, r/255.0, g/255.0, b/255.0, a/255.0);
305 x = (get_width() - _pixbuf->get_width())/2.0;
306 y = (get_height() - _pixbuf->get_height())/2.0;
308 //if this is a DropDown with an icon, then we need to
309 //move the icon left slightly to accomomodate the arrow
310 if (((_elements & Menu)==Menu)) {
312 cairo_translate (cr, -8,0 );
315 cairo_rectangle (cr, x, y, _pixbuf->get_width(), _pixbuf->get_height());
316 gdk_cairo_set_source_pixbuf (cr, _pixbuf->gobj(), x, y);
319 //..and then return to our previous drawing position
320 if (((_elements & Menu)==Menu)) {
329 if (get_width() < 75) {
335 if ( !_pixbuf && ((_elements & Text)==Text) && !_text.empty()) {
337 cairo_rectangle (cr, 2, 1, get_width()-4, get_height()-2);
341 cairo_set_source_rgba (cr, text_r, text_g, text_b, text_a);
343 if ( (_elements & Menu) == Menu) {
344 cairo_move_to (cr, text_margin, get_height()/2.0 - _text_height/2.0);
345 pango_cairo_show_layout (cr, _layout->gobj());
346 } else if ( (_elements & Indicator) == Indicator) {
348 cairo_move_to (cr, text_margin + _diameter + 4, get_height()/2.0 - _text_height/2.0);
350 cairo_move_to (cr, text_margin, get_height()/2.0 - _text_height/2.0);
352 pango_cairo_show_layout (cr, _layout->gobj());
360 cairo_save (cr); // TODO retain rotataion.. adj. LED,...
361 cairo_rotate(cr, _angle * M_PI / 180.0);
362 cairo_device_to_user(cr, &ww, &wh);
363 xa = (ww - _text_width) * _xalign;
364 ya = (wh - _text_height) * _yalign;
366 /* quick hack for left/bottom alignment at -90deg
367 * TODO this should be generalized incl rotation.
368 * currently only 'user' of this API is meter_strip.cc
370 if (_xalign < 0) xa = (ww * fabs(_xalign) + text_margin);
372 // TODO honor left/right text_margin with min/max()
374 cairo_move_to (cr, xa, ya);
375 pango_cairo_update_layout(cr, _layout->gobj());
376 pango_cairo_show_layout (cr, _layout->gobj());
379 /* use old center'ed layout for follow up items - until rotation/aligment code is completed */
380 cairo_move_to (cr, (get_width() - _text_width)/2.0, get_height()/2.0 - _text_height/2.0);
385 if (((_elements & Menu)==Menu)) {
390 cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
391 cairo_move_to(cr, get_width() - ((_diameter/2.0) + 6.0), get_height()/2.0 +_diameter/4);
392 cairo_rel_line_to(cr, -_diameter/2, -_diameter/2);
393 cairo_rel_line_to(cr, _diameter, 0);
394 cairo_close_path(cr);
395 cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
396 cairo_fill_preserve(cr);
397 cairo_set_source_rgba (cr, 0, 0, 0, 0.8);
398 cairo_set_line_width(cr, 0.5);
404 if (((_elements & Indicator)==Indicator)) {
406 /* move to the center of the indicator/led */
410 if (_elements & Text) {
412 cairo_translate (cr, text_margin + (_diameter/2.0), get_height()/2.0);
414 cairo_translate (cr, get_width() - ((_diameter/2.0) + 4.0), get_height()/2.0);
417 cairo_translate (cr, get_width()/2.0, get_height()/2.0);
421 cairo_arc (cr, 0, 0, _diameter/2, 0, 2 * M_PI);
422 cairo_set_source (cr, led_inset_pattern);
426 cairo_set_source_rgb (cr, 0, 0, 0);
427 cairo_arc (cr, 0, 0, _diameter/2-2, 0, 2 * M_PI);
431 cairo_set_source_rgba (cr, led_r, led_g, led_b, led_a);
432 cairo_arc (cr, 0, 0, _diameter/2-3, 0, 2 * M_PI);
439 /* a partially transparent gray layer to indicate insensitivity */
441 if ((visual_state() & Gtkmm2ext::Insensitive)) {
442 rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
443 cairo_set_source_rgba (cr, 0.505, 0.517, 0.525, 0.6);
448 bool show_reflection = (active_state() == Gtkmm2ext::ExplicitActive);
449 show_reflection &= !_flat_buttons;
450 show_reflection &= !((_elements & Indicator)==Indicator);
451 if ( show_reflection ) {
452 float rheight = get_height()*0.5-REFLECTION_HEIGHT;
453 Gtkmm2ext::rounded_rectangle (cr, 2, get_height()*0.5-1, get_width()-4, rheight, _corner_radius-1);
454 cairo_set_source (cr, shine_pattern);
458 /* if requested, show hovering */
460 if (ARDOUR::Config->get_widget_prelight()
461 && !((visual_state() & Gtkmm2ext::Insensitive))) {
463 rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
464 cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
469 rounded_function (cr, 1.5, 1.5, get_width() - 3, get_height() - 3, _corner_radius);
470 cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.8);
472 cairo_set_dash (cr, &dashes, 1, 0);
473 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
474 cairo_set_line_width (cr, 1.0);
476 cairo_set_dash (cr, 0, 0, 0);
481 ArdourButton::set_diameter (float d)
483 _diameter = (d*2) + 5.0;
485 if (_diameter != 0.0) {
486 _fixed_diameter = true;
494 ArdourButton::set_corner_radius (float r)
501 ArdourButton::on_size_request (Gtk::Requisition* req)
506 CairoWidget::on_size_request (req);
508 if ((_elements & Text) && !_text.empty()) {
509 _layout->get_pixel_size (_text_width, _text_height);
510 if (_text_width + _diameter < 75) {
524 if ((_elements & Indicator) && _fixed_diameter) {
526 req->width = _pixbuf->get_width() + lrint (_diameter) + xpad;
527 req->height = max (_pixbuf->get_height(), (int) lrint (_diameter)) + ypad;
529 req->width = _text_width + lrint (_diameter) + xpad * 2; // margin left+right * 2
530 req->height = max (_text_height, (int) lrint (_diameter)) + ypad;
534 req->width = _pixbuf->get_width() + xpad;
535 req->height = _pixbuf->get_height() + ypad;
537 req->width = _text_width + xpad;
538 req->height = _text_height + ypad;
541 req->width += _corner_radius;
545 * This sets the colors used for rendering based on the name of the button, and
546 * thus uses information from the GUI config data.
549 ArdourButton::set_colors ()
551 if (_fixed_colors_set) {
554 std::string name = get_name();
556 border_color = ARDOUR_UI::config()->color_by_name ("button border");
558 fill_start_active_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start active", name));
559 fill_end_active_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end active", name));
561 fill_start_inactive_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start", name));
562 fill_end_inactive_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end", name));
564 text_active_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: text active", name));
565 text_inactive_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: text", name));
567 led_active_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: led active", name));
568 led_inactive_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: led", name));
571 * This sets the colors used for rendering based on two fixed values, rather
572 * than basing them on the button name, and thus information in the GUI config
575 void ArdourButton::set_fixed_colors (const uint32_t color_active, const uint32_t color_inactive)
577 _fixed_colors_set = true;
579 fill_start_active_color = fill_end_active_color = color_active;
581 unsigned char r, g, b, a;
582 UINT_TO_RGBA(color_active, &r, &g, &b, &a);
584 double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
585 (max (double(g), 255.) - min (double(g), 255.)) +
586 (max (double(b), 255.) - min (double(b), 255.));
588 double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
589 (max (double(g), 0.) - min (double(g), 0.)) +
590 (max (double(b), 0.) - min (double(b), 0.));
593 text_inactive_color = (white_contrast > black_contrast) ?
594 RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
595 RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
597 fill_start_inactive_color = fill_end_inactive_color = color_inactive;
599 /* XXX what about led colors ? */
602 set_name (""); /* this will trigger a "style-changed" message and then set_colors() */
606 ArdourButton::build_patterns ()
608 uint32_t start_color;
615 cairo_pattern_destroy (shine_pattern);
620 cairo_pattern_destroy (fill_pattern);
624 if (fill_pattern_active) {
625 cairo_pattern_destroy (fill_pattern_active);
626 fill_pattern_active = 0;
629 if (_elements & Body) {
632 end_color = start_color = fill_start_active_color;
634 start_color = fill_start_active_color;
635 end_color = fill_end_active_color;
637 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
644 shine_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
645 cairo_pattern_add_color_stop_rgba (shine_pattern, 0, 1,1,1,0.0);
646 cairo_pattern_add_color_stop_rgba (shine_pattern, 0.5, 1,1,1,0.1);
647 cairo_pattern_add_color_stop_rgba (shine_pattern, 0.7, 1,1,1,0.2);
648 cairo_pattern_add_color_stop_rgba (shine_pattern, 1, 1,1,1,0.1);
650 fill_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()-3);
652 end_color = start_color = fill_start_inactive_color;
654 start_color = fill_start_inactive_color;
655 end_color = fill_end_inactive_color;
657 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
658 cairo_pattern_add_color_stop_rgba (fill_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0);
659 UINT_TO_RGBA (end_color, &r, &g, &b, &a);
660 cairo_pattern_add_color_stop_rgba (fill_pattern, 1, r/255.0,g/255.0,b/255.0, a/255.0);
662 fill_pattern_active = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()-3);
664 if (active_state() == Gtkmm2ext::ImplicitActive && (_tweaks & ImplicitUsesSolidColor)) {
665 end_color = start_color = led_active_color;
667 end_color = start_color = fill_end_active_color;
670 if (active_state() == Gtkmm2ext::ImplicitActive && (_tweaks & ImplicitUsesSolidColor)) {
671 end_color = start_color = led_active_color;
673 start_color = fill_start_active_color;
674 end_color = fill_end_active_color;
677 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
678 cairo_pattern_add_color_stop_rgba (fill_pattern_active, 0, r/255.0,g/255.0,b/255.0, a/255.0);
679 UINT_TO_RGBA (end_color, &r, &g, &b, &a);
680 cairo_pattern_add_color_stop_rgba (fill_pattern_active, 1, r/255.0,g/255.0,b/255.0, a/255.0);
683 if (led_inset_pattern) {
684 cairo_pattern_destroy (led_inset_pattern);
687 if (reflection_pattern) {
688 cairo_pattern_destroy (reflection_pattern);
691 if (_elements & Indicator) {
692 led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
693 cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
694 cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
696 reflection_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter/2-3);
697 cairo_pattern_add_color_stop_rgba (reflection_pattern, 0, 1,1,1, active_state() ? 0.4 : 0.2);
698 cairo_pattern_add_color_stop_rgba (reflection_pattern, 1, 1,1,1, 0.0);
701 if (active_state() == Gtkmm2ext::ExplicitActive || ((_tweaks & ImplicitUsesSolidColor) && active_state() == Gtkmm2ext::ImplicitActive)) {
702 text_color = text_active_color;
703 led_color = led_active_color;
705 text_color = text_inactive_color;
706 led_color = led_inactive_color;
709 UINT_TO_RGBA (text_color, &r, &g, &b, &a);
714 UINT_TO_RGBA (led_color, &r, &g, &b, &a);
724 ArdourButton::set_led_left (bool yn)
730 ArdourButton::on_button_press_event (GdkEventButton *ev)
732 if ((_elements & Indicator) && _led_rect && _distinct_led_click) {
733 if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
734 ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
739 if (_tweaks & ShowClick) {
740 set_active_state (Gtkmm2ext::ExplicitActive);
743 if (binding_proxy.button_press_handler (ev)) {
747 if (!_act_on_release) {
749 _action->activate ();
758 ArdourButton::on_button_release_event (GdkEventButton *ev)
760 if (_hovering && (_elements & Indicator) && _led_rect && _distinct_led_click) {
761 if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
762 ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
763 signal_led_clicked(); /* EMIT SIGNAL */
768 if (_tweaks & ShowClick) {
769 unset_active_state ();
775 if (_act_on_release) {
777 _action->activate ();
787 ArdourButton::set_distinct_led_click (bool yn)
789 _distinct_led_click = yn;
794 ArdourButton::color_handler ()
802 ArdourButton::on_size_allocate (Allocation& alloc)
804 CairoWidget::on_size_allocate (alloc);
810 ArdourButton::set_controllable (boost::shared_ptr<Controllable> c)
812 watch_connection.disconnect ();
813 binding_proxy.set_controllable (c);
817 ArdourButton::watch ()
819 boost::shared_ptr<Controllable> c (binding_proxy.get_controllable ());
822 warning << _("button cannot watch state of non-existing Controllable\n") << endmsg;
826 c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourButton::controllable_changed, this), gui_context());
830 ArdourButton::controllable_changed ()
832 float val = binding_proxy.get_controllable()->get_value();
834 if (fabs (val) >= 0.5f) {
835 set_active_state (Gtkmm2ext::ExplicitActive);
837 unset_active_state ();
842 ArdourButton::set_related_action (RefPtr<Action> act)
844 Gtkmm2ext::Activatable::set_related_action (act);
848 action_tooltip_changed ();
850 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
853 tact->signal_toggled().connect (sigc::mem_fun (*this, &ArdourButton::action_toggled));
856 _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &ArdourButton::action_sensitivity_changed));
857 _action->connect_property_changed ("visible", sigc::mem_fun (*this, &ArdourButton::action_visibility_changed));
858 _action->connect_property_changed ("tooltip", sigc::mem_fun (*this, &ArdourButton::action_tooltip_changed));
863 ArdourButton::action_toggled ()
865 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
868 if (tact->get_active()) {
869 set_active_state (Gtkmm2ext::ExplicitActive);
871 unset_active_state ();
877 ArdourButton::on_style_changed (const RefPtr<Gtk::Style>&)
884 ArdourButton::on_name_changed ()
891 ArdourButton::setup_led_rect ()
895 if (get_width() < 75) {
901 if (_elements & Indicator) {
902 _led_rect = new cairo_rectangle_t;
904 if (_elements & Text) {
906 _led_rect->x = text_margin;
908 _led_rect->x = get_width() - text_margin - _diameter/2.0;
912 _led_rect->x = get_width()/2.0 - _diameter/2.0;
915 _led_rect->y = get_height()/2.0 - _diameter/2.0;
916 _led_rect->width = _diameter;
917 _led_rect->height = _diameter;
926 ArdourButton::set_image (const RefPtr<Gdk::Pixbuf>& img)
933 ArdourButton::set_active_state (Gtkmm2ext::ActiveState s)
935 bool changed = (_active_state != s);
936 CairoWidget::set_active_state (s);
944 ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
946 bool changed = (_visual_state != s);
947 CairoWidget::set_visual_state (s);
956 ArdourButton::on_focus_in_event (GdkEventFocus* ev)
960 return CairoWidget::on_focus_in_event (ev);
964 ArdourButton::on_focus_out_event (GdkEventFocus* ev)
968 return CairoWidget::on_focus_out_event (ev);
972 ArdourButton::on_key_release_event (GdkEventKey *ev) {
974 (ev->keyval == GDK_KEY_space || ev->keyval == GDK_Return))
978 _action->activate ();
982 return CairoWidget::on_key_release_event (ev);
986 ArdourButton::on_enter_notify_event (GdkEventCrossing* ev)
990 if (ARDOUR::Config->get_widget_prelight()) {
994 return CairoWidget::on_enter_notify_event (ev);
998 ArdourButton::on_leave_notify_event (GdkEventCrossing* ev)
1002 if (ARDOUR::Config->get_widget_prelight()) {
1006 return CairoWidget::on_leave_notify_event (ev);
1010 ArdourButton::set_tweaks (Tweaks t)
1019 ArdourButton::action_sensitivity_changed ()
1021 if (_action->property_sensitive ()) {
1022 set_visual_state (Gtkmm2ext::VisualState (visual_state() & ~Gtkmm2ext::Insensitive));
1024 set_visual_state (Gtkmm2ext::VisualState (visual_state() | Gtkmm2ext::Insensitive));
1031 ArdourButton::action_visibility_changed ()
1033 if (_action->property_visible ()) {
1041 ArdourButton::action_tooltip_changed ()
1043 string str = _action->property_tooltip().get_value();
1044 ARDOUR_UI::instance()->set_tip (*this, str);
1048 ArdourButton::set_rounded_corner_mask (int mask)
1050 _corner_mask = mask;
1055 ArdourButton::set_elements (Element e)
1061 ArdourButton::add_elements (Element e)
1063 _elements = (ArdourButton::Element) (_elements | e);
1067 ArdourButton::set_flat_buttons (bool yn)