32b6569488d89b794d595a55b360732377e45c6c
[ardour.git] / gtk2_ardour / group_tabs.cc
1 /*
2     Copyright (C) 2009 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 <gtkmm/stock.h>
21 #include "ardour/session.h"
22 #include "ardour/route_group.h"
23 #include "ardour/route.h"
24
25 #include "gui_thread.h"
26 #include "route_group_dialog.h"
27 #include "group_tabs.h"
28 #include "keyboard.h"
29 #include "i18n.h"
30 #include "ardour_ui.h"
31 #include "rgb_macros.h"
32 #include "ui_config.h"
33 #include "utils.h"
34
35 using namespace std;
36 using namespace Gtk;
37 using namespace ARDOUR;
38 using namespace ARDOUR_UI_UTILS;
39 using Gtkmm2ext::Keyboard;
40
41 list<Gdk::Color> GroupTabs::_used_colors;
42
43 GroupTabs::GroupTabs ()
44         : _menu (0)
45         , _dragging (0)
46         , _dragging_new_tab (0)
47 {
48         add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
49         UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &GroupTabs::queue_draw));
50 }
51
52 GroupTabs::~GroupTabs ()
53 {
54         delete _menu;
55 }
56
57 void
58 GroupTabs::set_session (Session* s)
59 {
60         SessionHandlePtr::set_session (s);
61
62         if (_session) {
63                 _session->RouteGroupPropertyChanged.connect (
64                         _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_group_property_changed, this, _1), gui_context()
65                         );
66                 _session->RouteAddedToRouteGroup.connect (
67                         _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_added_to_route_group, this, _1, _2), gui_context()
68                         );
69                 _session->RouteRemovedFromRouteGroup.connect (
70                         _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_removed_from_route_group, this, _1, _2), gui_context()
71                         );
72
73                 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&GroupTabs::set_dirty, this, (cairo_rectangle_t*)0), gui_context());
74         }
75 }
76
77
78 /** Handle a size request.
79  *  @param req GTK requisition
80  */
81 void
82 GroupTabs::on_size_request (Gtk::Requisition *req)
83 {
84         /* Use a dummy, small width and the actual height that we want */
85         req->width = 16;
86         req->height = 16;
87 }
88
89 bool
90 GroupTabs::on_button_press_event (GdkEventButton* ev)
91 {
92         using namespace Menu_Helpers;
93
94         double const p = primary_coordinate (ev->x, ev->y);
95
96         list<Tab>::iterator prev;
97         list<Tab>::iterator next;
98         Tab* t = click_to_tab (p, &prev, &next);
99
100         _drag_min = prev != _tabs.end() ? prev->to : 0;
101         _drag_max = next != _tabs.end() ? next->from : extent ();
102
103         if (ev->button == 1) {
104
105                 if (t == 0) {
106                         Tab n;
107                         n.from = n.to = p;
108                         _dragging_new_tab = true;
109
110                         if (next == _tabs.end()) {
111                                 _tabs.push_back (n);
112                                 t = &_tabs.back ();
113                         } else {
114                                 list<Tab>::iterator j = _tabs.insert (next, n);
115                                 t = &(*j);
116                         }
117
118                 } else {
119                         _dragging_new_tab = false;
120                         _initial_dragging_routes = routes_for_tab (t);
121                 }
122
123                 _dragging = t;
124                 _drag_moved = false;
125                 _drag_first = p;
126
127                 double const h = (t->from + t->to) / 2;
128                 if (p < h) {
129                         _drag_moving = t->from;
130                         _drag_fixed = t->to;
131                         _drag_offset = p - t->from;
132                 } else {
133                         _drag_moving = t->to;
134                         _drag_fixed = t->from;
135                         _drag_offset = p - t->to;
136                 }
137
138         } else if (ev->button == 3) {
139
140                 RouteGroup* g = t ? t->group : 0;
141
142                 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier) && g) {
143                         /* edit */
144                         RouteGroupDialog d (g, false);
145                         d.do_run ();
146                 } else {
147                         Menu* m = get_menu (g, true);
148                         if (m) {
149                                 m->popup (ev->button, ev->time);
150                         }
151                 }
152         }
153
154         return true;
155 }
156
157
158 bool
159 GroupTabs::on_motion_notify_event (GdkEventMotion* ev)
160 {
161         if (_dragging == 0) {
162                 return false;
163         }
164
165         double const p = primary_coordinate (ev->x, ev->y);
166
167         if (p != _drag_first) {
168                 _drag_moved = true;
169         }
170
171         _drag_moving = p - _drag_offset;
172
173         _dragging->from = min (_drag_moving, _drag_fixed);
174         _dragging->to = max (_drag_moving, _drag_fixed);
175
176         _dragging->from = max (_dragging->from, _drag_min);
177         _dragging->to = min (_dragging->to, _drag_max);
178
179         set_dirty ();
180         queue_draw ();
181
182         gdk_event_request_motions(ev);
183
184         return true;
185 }
186
187
188 bool
189 GroupTabs::on_button_release_event (GdkEventButton*)
190 {
191         if (_dragging == 0) {
192                 return false;
193         }
194
195         if (!_drag_moved) {
196
197                 if (_dragging->group) {
198                         /* toggle active state */
199                         _dragging->group->set_active (!_dragging->group->is_active (), this);
200                 }
201
202         } else {
203                 /* finish drag */
204                 RouteList routes = routes_for_tab (_dragging);
205
206                 if (!routes.empty()) {
207                         if (_dragging_new_tab) {
208                                 RouteGroup* g = create_and_add_group ();
209                                 if (g) {
210                                         for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
211                                                 g->add (*i);
212                                         }
213                                 }
214                         } else {
215                                 boost::shared_ptr<RouteList> r = _session->get_routes ();
216                                 for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
217
218                                         bool const was_in_tab = find (
219                                                 _initial_dragging_routes.begin(), _initial_dragging_routes.end(), *i
220                                                 ) != _initial_dragging_routes.end ();
221
222                                         bool const now_in_tab = find (routes.begin(), routes.end(), *i) != routes.end();
223
224                                         if (was_in_tab && !now_in_tab) {
225                                                 _dragging->group->remove (*i);
226                                         } else if (!was_in_tab && now_in_tab) {
227                                                 _dragging->group->add (*i);
228                                         }
229                                 }
230                         }
231                 }
232
233                 set_dirty ();
234                 queue_draw ();
235         }
236
237         _dragging = 0;
238         _initial_dragging_routes.clear ();
239
240         return true;
241 }
242
243 void
244 GroupTabs::render (cairo_t* cr, cairo_rectangle_t*)
245 {
246         if (_dragging == 0) {
247                 _tabs = compute_tabs ();
248         }
249
250         /* background */
251
252         Gdk::Color c = get_style()->get_base (Gtk::STATE_NORMAL);
253
254         cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
255         cairo_rectangle (cr, 0, 0, get_width(), get_height());
256         cairo_fill (cr);
257
258         /* tabs */
259
260         for (list<Tab>::const_iterator i = _tabs.begin(); i != _tabs.end(); ++i) {
261                 draw_tab (cr, *i);
262         }
263 }
264
265
266 /** Convert a click position to a tab.
267  *  @param c Click position.
268  *  @param prev Filled in with the previous tab to the click, or _tabs.end().
269  *  @param next Filled in with the next tab after the click, or _tabs.end().
270  *  @return Tab under the click, or 0.
271  */
272
273 GroupTabs::Tab *
274 GroupTabs::click_to_tab (double c, list<Tab>::iterator* prev, list<Tab>::iterator* next)
275 {
276         *prev = *next = _tabs.end ();
277         Tab* under = 0;
278
279         list<Tab>::iterator i = _tabs.begin ();
280         while (i != _tabs.end()) {
281
282                 if (i->from > c) {
283                         *next = i;
284                         break;
285                 }
286
287                 if (i->to < c) {
288                         *prev = i;
289                         ++i;
290                         continue;
291                 }
292
293                 if (i->from <= c && c < i->to) {
294                         under = &(*i);
295                 }
296
297                 ++i;
298         }
299
300         return under;
301 }
302
303 Gtk::Menu*
304 GroupTabs::get_menu (RouteGroup* g, bool TabArea)
305 {
306         using namespace Menu_Helpers;
307
308         delete _menu;
309
310         _menu = new Menu;
311         _menu->set_name ("ArdourContextMenu");
312         MenuList& items = _menu->items();
313
314         if (!TabArea) {
315                 items.push_back (MenuElem (_("Create New Group ..."), hide_return (sigc::mem_fun(*this, &GroupTabs::create_and_add_group))));
316                 items.push_back (MenuElem (_("Create New Control Master ..."), hide_return (sigc::mem_fun(*this, &GroupTabs::create_and_add_master))));
317                 items.push_back (MenuElem (_("Create New Group & Control Master ..."), hide_return (sigc::mem_fun(*this, &GroupTabs::create_and_add_group_with_master))));
318         }
319
320         Menu* new_from = new Menu;
321         {
322                 MenuList& f = new_from->items ();
323                 f.push_back (MenuElem (_("Selection..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_selection), false, false)));
324                 f.push_back (MenuElem (_("Record Enabled..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_rec_enabled), false, false)));
325                 f.push_back (MenuElem (_("Soloed..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_soloed), false, false)));
326         }
327         items.push_back (MenuElem (_("Create New Group From"), *new_from));
328
329         new_from = new Menu;
330         {
331                 MenuList& f = new_from->items ();
332                 f.push_back (MenuElem (_("Selection..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_selection), true, false)));
333                 f.push_back (MenuElem (_("Record Enabled..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_rec_enabled), true, false)));
334                 f.push_back (MenuElem (_("Soloed..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_soloed), true, false)));
335         }
336         items.push_back (MenuElem (_("Create New Master From"), *new_from));
337
338         new_from = new Menu;
339         {
340                 MenuList& f = new_from->items ();
341                 f.push_back (MenuElem (_("Selection..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_selection), true, true)));
342                 f.push_back (MenuElem (_("Record Enabled..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_rec_enabled), true, true)));
343                 f.push_back (MenuElem (_("Soloed..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::new_from_soloed), true, true)));
344         }
345         items.push_back (MenuElem (_("Create New Group & Master From"), *new_from));
346
347         Menu* vca_menu;
348
349         if (g) {
350                 items.push_back (MenuElem (_("Edit Group..."), sigc::bind (sigc::mem_fun (*this, &GroupTabs::edit_group), g)));
351                 items.push_back (MenuElem (_("Collect Group"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::collect), g)));
352                 items.push_back (MenuElem (_("Remove Group"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::remove_group), g)));
353                 items.push_back (SeparatorElem());
354                 if (g->has_subgroup()) {
355                         items.push_back (MenuElem (_("Remove Subgroup Bus"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::un_subgroup), g)));
356                 } else {
357                         items.push_back (MenuElem (_("Add New Subgroup Bus"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::subgroup), g, false, PreFader)));
358                 }
359                 items.push_back (MenuElem (_("Add New Aux Bus (pre-fader)"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::subgroup), g, true, PreFader)));
360                 items.push_back (MenuElem (_("Add New Aux Bus (post-fader)"), sigc::bind (sigc::mem_fun (*this, &GroupTabs::subgroup), g, true, PostFader)));
361                 items.push_back (SeparatorElem());
362
363                 vca_menu = new Menu;
364                 MenuList& f (vca_menu->items());
365                 f.push_back (MenuElem ("New", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 0)));
366                 f.push_back (MenuElem ("VCA 1", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 1)));
367                 items.push_back (MenuElem (_("Assign Group to Control Master..."), *vca_menu));
368         }
369
370         add_menu_items (_menu, g);
371
372         items.push_back (SeparatorElem());
373         items.push_back (MenuElem (_("Enable All Groups"), sigc::mem_fun(*this, &GroupTabs::activate_all)));
374         items.push_back (MenuElem (_("Disable All Groups"), sigc::mem_fun(*this, &GroupTabs::disable_all)));
375         items.push_back (SeparatorElem());
376
377         vca_menu = new Menu;
378         {
379                 MenuList& f (vca_menu->items());
380                 f.push_back (MenuElem ("New", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 0)));
381                 f.push_back (MenuElem ("VCA 1", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 1)));
382
383         }
384
385         items.push_back (MenuElem (_("Assign Selection to Control Master..."), *vca_menu));
386
387         vca_menu = new Menu;
388         {
389                 MenuList& f (vca_menu->items());
390                 f.push_back (MenuElem ("New", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 0)));
391                 f.push_back (MenuElem ("VCA 1", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_recenabled_to_master), 1)));
392
393         }
394         items.push_back (MenuElem (_("Assign Record Enabled to Control Master..."), *vca_menu));
395
396         vca_menu = new Menu;
397         {
398                 MenuList& f (vca_menu->items());
399                 f.push_back (MenuElem ("New", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_selection_to_master), 0)));
400                 f.push_back (MenuElem ("VCA 1", sigc::bind (sigc::mem_fun (*this, &GroupTabs::assign_soloed_to_master), 1)));
401
402         }
403         items.push_back (MenuElem (_("Assign Soloed to Control Master...")));
404
405         return _menu;
406
407 }
408
409 void
410 GroupTabs::assign_selection_to_master (uint32_t which)
411 {
412 }
413
414 void
415 GroupTabs::assign_recenabled_to_master (uint32_t which)
416 {
417 }
418
419 void
420 GroupTabs::assign_soloed_to_master (uint32_t which)
421 {
422 }
423
424 void
425 GroupTabs::new_from_selection (bool just_master, bool with_master)
426 {
427         RouteList rl = selected_routes ();
428         if (rl.empty()) {
429                 return;
430         }
431
432         run_new_group_dialog (rl, with_master);
433 }
434
435 void
436 GroupTabs::new_from_rec_enabled (bool just_master, bool with_master)
437 {
438         boost::shared_ptr<RouteList> rl = _session->get_routes ();
439
440         RouteList rec_enabled;
441
442         for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
443                 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track> (*i));
444                 if (trk && trk->rec_enable_control()->get_value()) {
445                         rec_enabled.push_back (*i);
446                 }
447         }
448
449         if (rec_enabled.empty()) {
450                 return;
451         }
452
453         run_new_group_dialog (rec_enabled, with_master);
454 }
455
456 void
457 GroupTabs::new_from_soloed (bool just_master, bool with_master)
458 {
459         boost::shared_ptr<RouteList> rl = _session->get_routes ();
460
461         RouteList soloed;
462
463         for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
464                 if (!(*i)->is_master() && (*i)->soloed()) {
465                         soloed.push_back (*i);
466                 }
467         }
468
469         if (soloed.empty()) {
470                 return;
471         }
472
473         run_new_group_dialog (soloed, with_master);
474 }
475
476 void
477 GroupTabs::run_new_group_dialog (RouteList const & rl, bool with_master)
478 {
479         RouteGroup* g = new RouteGroup (*_session, "");
480         RouteGroupDialog d (g, true);
481
482         if (d.do_run ()) {
483                 delete g;
484         } else {
485                 _session->add_route_group (g);
486                 for (RouteList::const_iterator i = rl.begin(); i != rl.end(); ++i) {
487                         g->add (*i);
488                 }
489         }
490 }
491
492 RouteGroup *
493 GroupTabs::create_and_add_group () const
494 {
495         RouteGroup* g = new RouteGroup (*_session, "");
496         RouteGroupDialog d (g, true);
497
498         if (d.do_run ()) {
499                 delete g;
500                 return 0;
501         }
502
503         _session->add_route_group (g);
504         return g;
505 }
506
507 RouteGroup *
508 GroupTabs::create_and_add_master () const
509 {
510         return 0;
511 }
512
513 RouteGroup *
514 GroupTabs::create_and_add_group_with_master () const
515 {
516         RouteGroup* g = new RouteGroup (*_session, "");
517         RouteGroupDialog d (g, true);
518
519         if (d.do_run ()) {
520                 delete g;
521                 return 0;
522         }
523
524         _session->add_route_group (g);
525         return g;
526 }
527
528 void
529 GroupTabs::edit_group (RouteGroup* g)
530 {
531         RouteGroupDialog d (g, false);
532         d.do_run ();
533 }
534
535 void
536 GroupTabs::subgroup (RouteGroup* g, bool aux, Placement placement)
537 {
538         g->make_subgroup (aux, placement);
539 }
540
541 void
542 GroupTabs::un_subgroup (RouteGroup* g)
543 {
544         g->destroy_subgroup ();
545 }
546
547 struct CollectSorter {
548         bool operator () (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
549                 return a->presentation_info () < b->presentation_info();
550         }
551 };
552
553 struct OrderSorter {
554         bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
555                 return a->presentation_info() < b->presentation_info();
556         }
557 };
558
559 /** Collect all members of a RouteGroup so that they are together in the Editor or Mixer.
560  *  @param g Group to collect.
561  */
562 void
563 GroupTabs::collect (RouteGroup* g)
564 {
565         boost::shared_ptr<RouteList> group_routes = g->route_list ();
566         group_routes->sort (CollectSorter ());
567         int const N = group_routes->size ();
568
569         RouteList::iterator i = group_routes->begin ();
570         boost::shared_ptr<RouteList> routes = _session->get_routes ();
571         routes->sort (OrderSorter ());
572         RouteList::const_iterator j = routes->begin ();
573
574         int diff = 0;
575         int coll = -1;
576         while (i != group_routes->end() && j != routes->end()) {
577
578                 PresentationInfo::order_t const k = (*j)->presentation_info ().group_order();
579
580                 if (*i == *j) {
581
582                         if (coll == -1) {
583                                 coll = k;
584                                 diff = N - 1;
585                         } else {
586                                 --diff;
587                         }
588
589                         (*j)->set_presentation_group_order_explicit (coll);
590
591                         ++coll;
592                         ++i;
593
594                 } else {
595
596                         (*j)->set_presentation_group_order_explicit (k + diff);
597
598                 }
599
600                 ++j;
601         }
602
603         _session->notify_presentation_info_change ();
604 }
605
606 void
607 GroupTabs::activate_all ()
608 {
609         _session->foreach_route_group (
610                 sigc::bind (sigc::mem_fun (*this, &GroupTabs::set_activation), true)
611                 );
612 }
613
614 void
615 GroupTabs::disable_all ()
616 {
617         _session->foreach_route_group (
618                 sigc::bind (sigc::mem_fun (*this, &GroupTabs::set_activation), false)
619                 );
620 }
621
622 void
623 GroupTabs::set_activation (RouteGroup* g, bool a)
624 {
625         g->set_active (a, this);
626 }
627
628 void
629 GroupTabs::remove_group (RouteGroup* g)
630 {
631         _session->remove_route_group (*g);
632 }
633
634 /** Set the color of the tab of a route group */
635 void
636 GroupTabs::set_group_color (RouteGroup* group, uint32_t color)
637 {
638         assert (group);
639         uint32_t r, g, b, a;
640
641         UINT_TO_RGBA (color, &r, &g, &b, &a);
642
643         /* Hack to disallow black route groups; force a dark grey instead */
644
645         if (r == 0 && g == 0 && b == 0) {
646                 r = 25;
647                 g = 25;
648                 b = 25;
649         }
650
651         GUIObjectState& gui_state = *ARDOUR_UI::instance()->gui_object_state;
652
653         char buf[64];
654
655         /* for historical reasons the colors must be stored as 16 bit color
656          * values. Ugh.
657          */
658
659         snprintf (buf, sizeof (buf), "%d:%d:%d", (r<<8), (g<<8), (b<<8));
660         gui_state.set_property (group_gui_id (group), "color", buf);
661
662         /* the group color change notification */
663
664         PBD::PropertyChange change;
665         change.add (Properties::color);
666         group->PropertyChanged (change);
667
668         /* This is a bit of a hack, but this might change
669            our route's effective color, so emit gui_changed
670            for our routes.
671         */
672
673         emit_gui_changed_for_members (group);
674 }
675
676 /** @return the ID string to use for the GUI state of a route group */
677 string
678 GroupTabs::group_gui_id (RouteGroup* group)
679 {
680         assert (group);
681
682         char buf[64];
683         snprintf (buf, sizeof (buf), "route_group %s", group->id().to_s().c_str ());
684
685         return buf;
686 }
687
688 /** @return the color to use for a route group tab */
689 uint32_t
690 GroupTabs::group_color (RouteGroup* group)
691 {
692         assert (group);
693
694         GUIObjectState& gui_state = *ARDOUR_UI::instance()->gui_object_state;
695         string const gui_id = group_gui_id (group);
696         bool empty;
697         string const color = gui_state.get_string (gui_id, "color", &empty);
698
699         if (empty) {
700                 /* no color has yet been set, so use a random one */
701                 uint32_t c = gdk_color_to_rgba (unique_random_color (_used_colors));
702                 set_group_color (group, c);
703                 return c;
704         }
705
706         int r, g, b;
707
708         /* for historical reasons, colors are stored as 16 bit values.
709          */
710
711         sscanf (color.c_str(), "%d:%d:%d", &r, &g, &b);
712
713         r /= 256;
714         g /= 256;
715         b /= 256;
716
717         return RGBA_TO_UINT (r, g, b, 255);
718 }
719
720 void
721 GroupTabs::route_group_property_changed (RouteGroup* rg)
722 {
723         /* This is a bit of a hack, but this might change
724            our route's effective color, so emit gui_changed
725            for our routes.
726         */
727
728         emit_gui_changed_for_members (rg);
729
730         set_dirty ();
731 }
732
733 void
734 GroupTabs::route_added_to_route_group (RouteGroup*, boost::weak_ptr<Route> w)
735 {
736         /* Similarly-spirited hack as in route_group_property_changed */
737
738         boost::shared_ptr<Route> r = w.lock ();
739         if (!r) {
740                 return;
741         }
742
743         r->gui_changed (X_("color"), 0);
744
745         set_dirty ();
746 }
747
748 void
749 GroupTabs::route_removed_from_route_group (RouteGroup*, boost::weak_ptr<Route> w)
750 {
751         /* Similarly-spirited hack as in route_group_property_changed */
752
753         boost::shared_ptr<Route> r = w.lock ();
754         if (!r) {
755                 return;
756         }
757
758         r->gui_changed (X_("color"), 0);
759
760         set_dirty ();
761 }
762
763 void
764 GroupTabs::emit_gui_changed_for_members (RouteGroup* rg)
765 {
766         for (RouteList::iterator i = rg->route_list()->begin(); i != rg->route_list()->end(); ++i) {
767                 (*i)->gui_changed (X_("color"), 0);
768         }
769 }