+
+ emit_gui_changed_for_members (rl);
+}
+
+/** Set the color of the tab of a route group */
+void
+GroupTabs::set_group_color (RouteGroup* group, uint32_t color)
+{
+ assert (group);
+ PresentationInfo::ChangeSuspender cs;
+ group->set_rgba (color);
+}
+
+/** @return the ID string to use for the GUI state of a route group */
+string
+GroupTabs::group_gui_id (RouteGroup* group)
+{
+ assert (group);
+
+ char buf[64];
+ snprintf (buf, sizeof (buf), "route_group %s", group->id().to_s().c_str ());
+
+ return buf;
+}
+
+/** @return the color to use for a route group tab */
+uint32_t
+GroupTabs::group_color (RouteGroup* group)
+{
+ assert (group);
+
+ /* prefer libardour color, if set */
+ uint32_t rgba = group->rgba ();
+ if (rgba != 0) {
+ return rgba;
+ }
+
+ /* backwards compatibility, load old color */
+
+ GUIObjectState& gui_state = *ARDOUR_UI::instance()->gui_object_state;
+ string const gui_id = group_gui_id (group);
+ bool empty;
+ string const color = gui_state.get_string (gui_id, "color", &empty);
+
+ if (empty) {
+ /* no color has yet been set, so use a random one */
+ uint32_t c = gdk_color_to_rgba (unique_random_color (_used_colors));
+ set_group_color (group, c);
+ return c;
+ }
+
+ int r, g, b;
+
+ /* for historical reasons, colors are stored as 16 bit values. */
+
+ sscanf (color.c_str(), "%d:%d:%d", &r, &g, &b);
+
+ r /= 256;
+ g /= 256;
+ b /= 256;
+
+ group->migrate_rgba (RGBA_TO_UINT (r, g, b, 255));
+ gui_state.remove_node (gui_id);
+
+ return RGBA_TO_UINT (r, g, b, 255);
+}
+
+void
+GroupTabs::route_group_property_changed (RouteGroup* rg)
+{
+ /* This is a bit of a hack, but this might change
+ our route's effective color, so emit gui_changed
+ for our routes.
+ */
+
+ emit_gui_changed_for_members (rg->route_list ());
+
+ set_dirty ();
+}
+
+void
+GroupTabs::route_added_to_route_group (RouteGroup*, boost::weak_ptr<Route> w)
+{
+ /* Similarly-spirited hack as in route_group_property_changed */
+
+ boost::shared_ptr<Route> r = w.lock ();
+ if (!r) {
+ return;
+ }
+
+ r->presentation_info().PropertyChanged (Properties::color);
+
+ set_dirty ();
+}
+
+void
+GroupTabs::route_removed_from_route_group (RouteGroup*, boost::weak_ptr<Route> w)
+{
+ /* Similarly-spirited hack as in route_group_property_changed */
+
+ boost::shared_ptr<Route> r = w.lock ();
+ if (!r) {
+ return;
+ }
+
+ r->presentation_info().PropertyChanged (Properties::color);
+
+ set_dirty ();
+}
+
+void
+GroupTabs::emit_gui_changed_for_members (boost::shared_ptr<RouteList> rl)
+{
+ PresentationInfo::ChangeSuspender cs;
+
+ for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+ (*i)->presentation_info().PropertyChanged (Properties::color);
+ }