Fix double separator on session range context menu.
[ardour.git] / gtk2_ardour / ardour_button.cc
1 /*
2     Copyright (C) 2010 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include <iostream>
21 #include <cmath>
22 #include <algorithm>
23
24 #include <pangomm/layout.h>
25
26 #include "pbd/compose.h"
27 #include "pbd/error.h"
28
29 #include "gtkmm2ext/utils.h"
30 #include "gtkmm2ext/rgb_macros.h"
31 #include "gtkmm2ext/gui_thread.h"
32
33 #include "ardour/rc_configuration.h" // for widget prelight preference
34
35 #include "ardour_button.h"
36 #include "ardour_ui.h"
37 #include "global_signals.h"
38
39 #include "i18n.h"
40
41 using namespace Gdk;
42 using namespace Gtk;
43 using namespace Glib;
44 using namespace PBD;
45 using std::max;
46 using std::min;
47 using namespace std;
48
49 ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
50 ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
51 ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
52
53 ArdourButton::ArdourButton (Element e)
54         : _elements (e)
55         , _tweaks (Tweaks (0))
56         , _text_width (0)
57         , _text_height (0)
58         , _diameter (11.0)
59         , _corner_radius (5.0)
60         , _corner_mask (0xf)
61         , edge_pattern (0)
62         , active_pattern (0)
63         , inactive_pattern (0)
64         , led_inset_pattern (0)
65         , reflection_pattern (0)
66         , _led_rect (0)
67         , _act_on_release (true)
68         , _led_left (false)
69         , _fixed_diameter (true)
70         , _distinct_led_click (false)
71         , _hovering (false)
72 {
73         ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
74 }
75
76 ArdourButton::ArdourButton (const std::string& str, Element e)
77         : _elements (e)
78         , _text_width (0)
79         , _text_height (0)
80         , _diameter (11.0)
81         , _corner_radius (9.0)
82         , edge_pattern (0)
83         , active_pattern (0)
84         , inactive_pattern (0)
85         , led_inset_pattern (0)
86         , reflection_pattern (0)
87         , _led_rect (0)
88         , _act_on_release (true)
89         , _led_left (false)
90         , _fixed_diameter (true)
91         , _distinct_led_click (false)
92         , _hovering (false)
93 {
94         set_text (str);
95 }
96
97 ArdourButton::~ArdourButton()
98 {
99         delete _led_rect;
100
101         if (edge_pattern) {
102                 cairo_pattern_destroy (edge_pattern);
103         }
104
105         if (active_pattern) {
106                 cairo_pattern_destroy (active_pattern);
107         }
108
109         if (inactive_pattern) {
110                 cairo_pattern_destroy (inactive_pattern);
111         }
112 }
113
114 void
115 ArdourButton::set_text (const std::string& str)
116 {
117         _text = str;
118
119         if (!_layout && !_text.empty()) {
120                 _layout = Pango::Layout::create (get_pango_context());
121         } 
122
123         if (_layout) {
124                 _layout->set_text (str);
125         }
126
127         queue_resize ();
128 }
129
130 void
131 ArdourButton::set_markup (const std::string& str)
132 {
133         _text = str;
134
135         if (!_layout) {
136                 _layout = Pango::Layout::create (get_pango_context());
137         } 
138
139         _layout->set_text (str);
140         queue_resize ();
141 }
142
143 void
144 ArdourButton::render (cairo_t* cr)
145 {
146         void (*rounded_function)(cairo_t*, double, double, double, double, double);
147
148         switch (_corner_mask) {
149         case 0x1: /* upper left only */
150                 rounded_function = Gtkmm2ext::rounded_top_left_rectangle;
151                 break;
152         case 0x2: /* upper right only */
153                 rounded_function = Gtkmm2ext::rounded_top_right_rectangle;
154                 break;
155         case 0x3: /* upper only */
156                 rounded_function = Gtkmm2ext::rounded_top_rectangle;
157                 break;
158                 /* should really have functions for lower right, lower left,
159                    lower only, but for now, we don't
160                 */
161         default:
162                 rounded_function = Gtkmm2ext::rounded_rectangle;
163         }
164
165         if (!_fixed_diameter) {
166                 _diameter = std::min (get_width(), get_height());
167         }
168
169         if (_elements & Edge) {
170                 rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
171                 cairo_set_source (cr, edge_pattern);
172                 cairo_fill (cr);
173         }
174
175         if (_elements & Body) {
176                 if (_elements & Edge) {
177                         rounded_function (cr, 1, 1, get_width()-2, get_height()-2, _corner_radius - 1.0);
178                 } else {
179                         rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius - 1.0);
180                 }
181
182                 if (active_state() == Gtkmm2ext::ImplicitActive) {
183                         cairo_set_source (cr, inactive_pattern);
184                         cairo_fill_preserve (cr);
185                         cairo_set_line_width (cr, 2.0);
186                         cairo_set_source (cr, active_pattern);
187                         cairo_stroke (cr);
188                 } else if (active_state() == Gtkmm2ext::ExplicitActive) {
189                         cairo_set_source (cr, active_pattern);
190                         cairo_fill (cr);
191                 } else {
192                         cairo_set_source (cr, inactive_pattern);
193                         cairo_fill (cr);
194                 }
195         }
196
197         if (_pixbuf) {
198
199                 double x,y;
200                 x = (get_width() - _pixbuf->get_width())/2.0;
201                 y = (get_height() - _pixbuf->get_height())/2.0;
202
203                 cairo_rectangle (cr, x, y, _pixbuf->get_width(), _pixbuf->get_height());
204                 gdk_cairo_set_source_pixbuf (cr, _pixbuf->gobj(), x, y);
205                 cairo_fill (cr);
206         }
207
208         /* text, if any */
209
210         int text_margin;
211
212         if (get_width() < 75) {
213                 text_margin = 3;
214         } else {
215                 text_margin = 10;
216         }
217
218         if ((_elements & Text) && !_text.empty()) {
219
220                 cairo_new_path (cr);    
221
222                 if (_elements & Indicator) {
223                         if (_led_left) {
224                                 cairo_move_to (cr, text_margin + _diameter + 4, get_height()/2.0 - _text_height/2.0);
225                         } else {
226                                 cairo_move_to (cr, text_margin, get_height()/2.0 - _text_height/2.0);
227                         }
228                 } else {
229                         /* center text */
230                         cairo_move_to (cr, (get_width() - _text_width)/2.0, get_height()/2.0 - _text_height/2.0);
231                 }
232
233                 cairo_set_source_rgba (cr, text_r, text_g, text_b, text_a);
234                 pango_cairo_show_layout (cr, _layout->gobj());
235         } 
236
237         if (_elements & Indicator) {
238
239                 /* move to the center of the indicator/led */
240
241                 cairo_save (cr);
242
243                 if (_elements & Text) {
244                         if (_led_left) {
245                                 cairo_translate (cr, text_margin + (_diameter/2.0), get_height()/2.0);
246                         } else {
247                                 cairo_translate (cr, get_width() - ((_diameter/2.0) + 4.0), get_height()/2.0);
248                         }
249                 } else {
250                         cairo_translate (cr, get_width()/2.0, get_height()/2.0);
251                 }
252                 
253                 //inset
254                 cairo_arc (cr, 0, 0, _diameter/2, 0, 2 * M_PI);
255                 cairo_set_source (cr, led_inset_pattern);
256                 cairo_fill (cr);
257                 
258                 //black ring
259                 cairo_set_source_rgb (cr, 0, 0, 0);
260                 cairo_arc (cr, 0, 0, _diameter/2-2, 0, 2 * M_PI);
261                 cairo_fill(cr);
262                 
263                 //led color
264                 cairo_set_source_rgba (cr, led_r, led_g, led_b, led_a);
265                 cairo_arc (cr, 0, 0, _diameter/2-3, 0, 2 * M_PI);
266                 cairo_fill(cr);
267                 
268                 //reflection
269                 cairo_scale(cr, 0.7, 0.7);
270                 cairo_arc (cr, 0, 0, _diameter/2-3, 0, 2 * M_PI);
271                 cairo_set_source (cr, reflection_pattern);
272                 cairo_fill (cr);
273
274                 cairo_restore (cr);
275
276         }
277
278
279         /* a partially transparent gray layer to indicate insensitivity */
280
281         if ((visual_state() & Gtkmm2ext::Insensitive)) {
282                 rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
283                 cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.5);
284                 cairo_fill (cr);
285         }
286
287         /* if requested, show hovering */
288         
289         if (ARDOUR::Config->get_widget_prelight()) {
290                 if (_hovering) {
291                         rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
292                         cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
293                         cairo_fill (cr);
294                 }
295         }
296 }
297
298 void
299 ArdourButton::set_diameter (float d)
300 {
301         _diameter = (d*2) + 5.0;
302
303         if (_diameter != 0.0) {
304                 _fixed_diameter = true;
305         }
306
307         set_colors ();
308 }
309
310 void
311 ArdourButton::set_corner_radius (float r)
312 {
313         _corner_radius = r;
314         set_dirty ();
315 }
316
317 void
318 ArdourButton::on_size_request (Gtk::Requisition* req)
319 {
320         int xpad = 0;
321         int ypad = 6;
322
323         CairoWidget::on_size_request (req);
324
325         if ((_elements & Text) && !_text.empty()) {
326                 _layout->get_pixel_size (_text_width, _text_height);
327                 if (_text_width + _diameter < 75) {
328                         xpad = 7;
329                 } else {
330                         xpad = 20;
331                 }
332         } else {
333                 _text_width = 0;
334                 _text_height = 0;
335         }
336
337         if (_pixbuf) {
338                 xpad = 6;
339         }
340
341         if ((_elements & Indicator) && _fixed_diameter) {
342                 if (_pixbuf) {
343                         req->width = _pixbuf->get_width() + lrint (_diameter) + xpad;
344                         req->height = max (_pixbuf->get_height(), (int) lrint (_diameter)) + ypad;
345                 } else {
346                         req->width = _text_width + lrint (_diameter) + xpad;
347                         req->height = max (_text_height, (int) lrint (_diameter)) + ypad;
348                 }
349         } else {
350                 if (_pixbuf) {
351                         req->width = _pixbuf->get_width() + xpad;
352                         req->height = _pixbuf->get_height() + ypad;
353                 }  else {
354                         req->width = _text_width + xpad;
355                         req->height = _text_height + ypad;
356                 }
357         }
358 }
359
360 void
361 ArdourButton::set_colors ()
362 {
363         uint32_t start_color;
364         uint32_t end_color;
365         uint32_t r, g, b, a;
366         uint32_t text_color;
367         uint32_t led_color;
368
369         /* we use the edge of the button to show Selected state, so the
370          * color/pattern used there will vary depending on that
371          */
372         
373         if (edge_pattern) {
374                 cairo_pattern_destroy (edge_pattern);
375                 edge_pattern = 0;
376         }
377
378         if (_elements & Edge) {
379
380                 edge_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
381                 if (visual_state() & Gtkmm2ext::Selected) {
382                         start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: border start selected", get_name()));
383                         end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: border end selected", get_name()));
384                 } else {
385                         start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: border start", get_name()));
386                         end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: border end", get_name()));
387                 }
388                 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
389                 cairo_pattern_add_color_stop_rgba (edge_pattern, 0, r/255.0,g/255.0,b/255.0, 0.7);
390                 UINT_TO_RGBA (end_color, &r, &g, &b, &a);
391                 cairo_pattern_add_color_stop_rgba (edge_pattern, 1, r/255.0,g/255.0,b/255.0, 0.7);
392         }
393
394         if (active_pattern) {
395                 cairo_pattern_destroy (active_pattern);
396                 active_pattern = 0;
397         }
398
399         if (inactive_pattern) {
400                 cairo_pattern_destroy (inactive_pattern);
401                 inactive_pattern = 0;
402         }
403
404         if (_elements & Body) {
405
406                 active_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
407                 start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start active", get_name()));
408                 end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end active", get_name()));
409                 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
410
411                 active_r = r/255.0;
412                 active_g = g/255.0;
413                 active_b = b/255.0;
414                 active_a = a/255.0;
415
416                 cairo_pattern_add_color_stop_rgba (active_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0);
417                 UINT_TO_RGBA (end_color, &r, &g, &b, &a);
418                 cairo_pattern_add_color_stop_rgba (active_pattern, 1, r/255.0,g/255.0,b/255.0, a/255.0);
419
420                 inactive_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
421                 start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start", get_name()));
422                 end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end", get_name()));
423                 UINT_TO_RGBA (start_color, &r, &g, &b, &a);
424                 cairo_pattern_add_color_stop_rgba (inactive_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0);
425                 UINT_TO_RGBA (end_color, &r, &g, &b, &a);
426                 cairo_pattern_add_color_stop_rgba (inactive_pattern, 1, r/255.0,g/255.0,b/255.0, a/255.0);
427         }
428
429         if (led_inset_pattern) {
430                 cairo_pattern_destroy (led_inset_pattern);
431         }
432         
433         if (reflection_pattern) {
434                 cairo_pattern_destroy (reflection_pattern);
435         }
436
437         if (_elements & Indicator) {
438                 led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
439                 cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
440                 cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
441
442                 reflection_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter/2-3);
443                 cairo_pattern_add_color_stop_rgba (reflection_pattern, 0, 1,1,1, active_state() ? 0.4 : 0.2);
444                 cairo_pattern_add_color_stop_rgba (reflection_pattern, 1, 1,1,1, 0.0);
445         }
446         
447         /* text and LED colors */
448
449         if (active_state() == Gtkmm2ext::ExplicitActive) {
450                 text_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: text active", get_name()));
451                 led_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: led active", get_name()));
452         } else {
453                 text_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: text", get_name()));
454                 led_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: led", get_name()));
455         }
456
457         UINT_TO_RGBA (text_color, &r, &g, &b, &a);
458         text_r = r/255.0;
459         text_g = g/255.0;
460         text_b = b/255.0;
461         text_a = a/255.0;
462         UINT_TO_RGBA (led_color, &r, &g, &b, &a);
463         led_r = r/255.0;
464         led_g = g/255.0;
465         led_b = b/255.0;
466         led_a = a/255.0;
467
468         set_dirty ();
469 }
470
471 void
472 ArdourButton::set_led_left (bool yn)
473 {
474         _led_left = yn;
475 }
476
477 bool
478 ArdourButton::on_button_press_event (GdkEventButton *ev)
479 {
480         if ((_elements & Indicator) && _led_rect && _distinct_led_click) {
481                 if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width && 
482                     ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
483                         return true;
484                 }
485         }
486
487         if (_tweaks & ShowClick) {
488                 set_active_state (Gtkmm2ext::ExplicitActive);
489         }
490
491         if (binding_proxy.button_press_handler (ev)) {
492                 return true;
493         }
494
495         if (!_act_on_release) {
496                 if (_action) {
497                         _action->activate ();
498                         return true;
499                 }
500         }
501
502         return false;
503 }
504
505 bool
506 ArdourButton::on_button_release_event (GdkEventButton *ev)
507 {
508         if ((_elements & Indicator) && _led_rect && _distinct_led_click) {
509                 if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width && 
510                     ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
511                         signal_led_clicked(); /* EMIT SIGNAL */
512                         return true;
513                 }
514         }
515
516         if (_tweaks & ShowClick) {
517                 unset_active_state ();
518         }
519
520         signal_clicked ();
521
522         if (_act_on_release) {
523                 if (_action) {
524                         _action->activate ();
525                         return true;
526                 }
527         }
528
529
530         return false;
531 }
532
533 void
534 ArdourButton::set_distinct_led_click (bool yn)
535 {
536         _distinct_led_click = yn;
537         setup_led_rect ();
538 }
539
540 void
541 ArdourButton::color_handler ()
542 {
543         set_colors ();
544         set_dirty ();
545 }
546
547 void
548 ArdourButton::on_size_allocate (Allocation& alloc)
549 {
550         CairoWidget::on_size_allocate (alloc);
551         setup_led_rect ();
552         set_colors ();
553 }
554
555 void
556 ArdourButton::set_controllable (boost::shared_ptr<Controllable> c)
557 {
558         watch_connection.disconnect ();
559         binding_proxy.set_controllable (c);
560 }
561
562 void
563 ArdourButton::watch ()
564 {
565         boost::shared_ptr<Controllable> c (binding_proxy.get_controllable ());
566
567         if (!c) {
568                 warning << _("button cannot watch state of non-existing Controllable\n") << endmsg;
569                 return;
570         }
571
572         c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourButton::controllable_changed, this), gui_context());
573 }
574
575 void
576 ArdourButton::controllable_changed ()
577 {
578         float val = binding_proxy.get_controllable()->get_value();
579
580         if (fabs (val) >= 0.5f) {
581                 set_active_state (Gtkmm2ext::ExplicitActive);
582         } else {
583                 unset_active_state ();
584         }
585 }
586
587 void
588 ArdourButton::set_related_action (RefPtr<Action> act)
589 {
590         Gtkmm2ext::Activatable::set_related_action (act);
591
592         if (_action) {
593
594                 action_tooltip_changed ();
595
596                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
597                 if (tact) {
598                         action_toggled ();
599                         tact->signal_toggled().connect (sigc::mem_fun (*this, &ArdourButton::action_toggled));
600                 } 
601
602                 _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &ArdourButton::action_sensitivity_changed));
603                 _action->connect_property_changed ("visible", sigc::mem_fun (*this, &ArdourButton::action_visibility_changed));
604                 _action->connect_property_changed ("tooltip", sigc::mem_fun (*this, &ArdourButton::action_tooltip_changed));
605         }
606 }
607
608 void
609 ArdourButton::action_toggled ()
610 {
611         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
612
613         if (tact) {
614                 if (tact->get_active()) {
615                         set_active_state (Gtkmm2ext::ExplicitActive);
616                 } else {
617                         unset_active_state ();
618                 }
619         }
620 }       
621
622 void
623 ArdourButton::on_style_changed (const RefPtr<Gtk::Style>&)
624 {
625         set_colors ();
626 }
627
628 void
629 ArdourButton::setup_led_rect ()
630 {
631         int text_margin;
632
633         if (get_width() < 75) {
634                 text_margin = 3;
635         } else {
636                 text_margin = 10;
637         }
638
639         if (_elements & Indicator) {
640                 _led_rect = new cairo_rectangle_t;
641                 
642                 if (_elements & Text) {
643                         if (_led_left) {
644                                 _led_rect->x = text_margin;
645                         } else {
646                                 _led_rect->x = get_width() - text_margin - _diameter/2.0;
647                         }
648                 } else {
649                         /* centered */
650                         _led_rect->x = get_width()/2.0 - _diameter/2.0;
651                 }
652
653                 _led_rect->y = get_height()/2.0 - _diameter/2.0;
654                 _led_rect->width = _diameter;
655                 _led_rect->height = _diameter;
656
657         } else {
658                 delete _led_rect;
659                 _led_rect = 0;
660         }
661 }
662
663 void
664 ArdourButton::set_image (const RefPtr<Gdk::Pixbuf>& img)
665 {
666         _pixbuf = img;
667         queue_draw ();
668 }
669
670 void
671 ArdourButton::set_active_state (Gtkmm2ext::ActiveState s)
672 {
673         bool changed = (_active_state != s);
674         CairoWidget::set_active_state (s);
675         if (changed) {
676                 set_colors ();
677         }
678 }
679         
680 void
681 ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
682 {
683         bool changed = (_visual_state != s);
684         CairoWidget::set_visual_state (s);
685         if (changed) {
686                 set_colors ();
687         }
688 }
689         
690 bool
691 ArdourButton::on_enter_notify_event (GdkEventCrossing* ev)
692 {
693         _hovering = true;
694
695         if (ARDOUR::Config->get_widget_prelight()) {
696                 queue_draw ();
697         }
698
699         return CairoWidget::on_enter_notify_event (ev);
700 }
701
702 bool
703 ArdourButton::on_leave_notify_event (GdkEventCrossing* ev)
704 {
705         _hovering = false;
706
707         if (ARDOUR::Config->get_widget_prelight()) {
708                 queue_draw ();
709         }
710
711         return CairoWidget::on_leave_notify_event (ev);
712 }
713
714 void
715 ArdourButton::set_tweaks (Tweaks t)
716 {
717         if (_tweaks != t) {
718                 _tweaks = t;
719                 queue_draw ();
720         }
721 }
722
723 void
724 ArdourButton::action_sensitivity_changed ()
725 {
726         if (_action->property_sensitive ()) {
727                 set_visual_state (Gtkmm2ext::VisualState (visual_state() & ~Gtkmm2ext::Insensitive));
728         } else {
729                 set_visual_state (Gtkmm2ext::VisualState (visual_state() | Gtkmm2ext::Insensitive));
730         }
731         
732 }
733
734
735 void
736 ArdourButton::action_visibility_changed ()
737 {
738         if (_action->property_visible ()) {
739                 show ();
740         } else {
741                 hide ();
742         }
743 }
744
745 void
746 ArdourButton::action_tooltip_changed ()
747 {
748         string str = _action->property_tooltip().get_value();
749         ARDOUR_UI::instance()->set_tip (*this, str);
750 }
751
752 void
753 ArdourButton::set_rounded_corner_mask (int mask)
754 {
755         _corner_mask = mask;
756         queue_draw ();
757 }
758
759 void
760 ArdourButton::set_elements (Element e)
761 {
762         _elements = e;
763         set_colors ();
764 }