diff options
author | Carl Hetherington <carl@carlh.net> | 2011-09-07 11:56:23 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-09-07 11:56:23 +0000 |
commit | 932b0e9ec1d0f7fb506ccd13bf08a4efe5f91297 (patch) | |
tree | 472bc1d117ab0673946fbed601830dd8241108f3 /gtk2_ardour | |
parent | 174c0d6831573f24689b7f1f6d6256583f790da6 (diff) |
Update route colours when they are added to / removed
from groups which share colour (more of #4064).
git-svn-id: svn://localhost/ardour2/branches/3.0@10060 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/group_tabs.cc | 61 | ||||
-rw-r--r-- | gtk2_ardour/group_tabs.h | 10 |
2 files changed, 67 insertions, 4 deletions
diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc index 8deec1d70a..59c1b40e35 100644 --- a/gtk2_ardour/group_tabs.cc +++ b/gtk2_ardour/group_tabs.cc @@ -56,7 +56,16 @@ GroupTabs::set_session (Session* s) SessionHandlePtr::set_session (s); if (_session) { - _session->RouteGroupChanged.connect (_session_connections, invalidator (*this), boost::bind (&GroupTabs::set_dirty, this), gui_context()); + _session->RouteGroupPropertyChanged.connect ( + _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_group_property_changed, this, _1), gui_context() + ); + _session->RouteAddedToRouteGroup.connect ( + _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_added_to_route_group, this, _1, _2), gui_context() + ); + _session->RouteRemovedFromRouteGroup.connect ( + _session_connections, invalidator (*this), boost::bind (&GroupTabs::route_removed_from_route_group, this, _1, _2), gui_context() + ); + _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&GroupTabs::set_dirty, this), gui_context()); } } @@ -528,9 +537,7 @@ GroupTabs::set_group_color (RouteGroup* group, Gdk::Color color) for our routes. */ - for (RouteList::iterator i = group->route_list()->begin(); i != group->route_list()->end(); ++i) { - (*i)->gui_changed (X_("color"), 0); - } + emit_gui_changed_for_members (group); } /** @return the ID string to use for the GUI state of a route group */ @@ -577,3 +584,49 @@ GroupTabs::group_color (RouteGroup* group) return c; } +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); + + set_dirty (); +} + +void +GroupTabs::route_added_to_route_group (RouteGroup* rg, 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->gui_changed (X_("color"), 0); +} + +void +GroupTabs::route_removed_from_route_group (RouteGroup* rg, 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->gui_changed (X_("color"), 0); +} + +void +GroupTabs::emit_gui_changed_for_members (RouteGroup* rg) +{ + for (RouteList::iterator i = rg->route_list()->begin(); i != rg->route_list()->end(); ++i) { + (*i)->gui_changed (X_("color"), 0); + } +} diff --git a/gtk2_ardour/group_tabs.h b/gtk2_ardour/group_tabs.h index eaf03f6a22..059f3ce60b 100644 --- a/gtk2_ardour/group_tabs.h +++ b/gtk2_ardour/group_tabs.h @@ -30,6 +30,10 @@ class Editor; /** Parent class for tabs which represent route groups as colored tabs; * Currently used on the left-hand side of the editor and at the top of the mixer. + * + * This class also contains a fair bit of code to handle changes to route + * group colours; it seems a bit out of place, but I could not really think + * of a better place to put it. */ class GroupTabs : public CairoWidget, public ARDOUR::SessionHandlePtr { @@ -62,6 +66,8 @@ protected: }; private: + static void emit_gui_changed_for_members (ARDOUR::RouteGroup *); + /** Compute all the tabs for this widget. * @return Tabs. */ @@ -110,6 +116,10 @@ private: Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *); + void route_group_property_changed (ARDOUR::RouteGroup *); + void route_added_to_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>); + void route_removed_from_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>); + Gtk::Menu* _menu; std::list<Tab> _tabs; ///< current list of tabs Tab* _dragging; ///< tab being dragged, or 0 |