From 881b5a43e755860e91bf596bcac1f8c105b0a843 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 31 Aug 2011 19:14:12 +0000 Subject: Allow route groups to color their tracks (remainder of #4064). git-svn-id: svn://localhost/ardour2/branches/3.0@10043 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/group_tabs.cc | 9 +++++++++ gtk2_ardour/mixer_strip.cc | 4 ---- gtk2_ardour/route_group_dialog.cc | 16 ++++++++++------ gtk2_ardour/route_group_dialog.h | 1 + gtk2_ardour/route_time_axis.cc | 3 ++- gtk2_ardour/route_ui.cc | 16 ++++++++++++++++ gtk2_ardour/route_ui.h | 2 ++ gtk2_ardour/streamview.cc | 2 +- gtk2_ardour/streamview.h | 2 +- libs/ardour/ardour/route_group.h | 4 ++++ libs/ardour/route_group.cc | 29 +++++++++++++++++++++++++++-- 11 files changed, 73 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/group_tabs.cc b/gtk2_ardour/group_tabs.cc index ec80bc4291..2e35d84809 100644 --- a/gtk2_ardour/group_tabs.cc +++ b/gtk2_ardour/group_tabs.cc @@ -517,6 +517,15 @@ GroupTabs::set_group_color (RouteGroup* group, Gdk::Color color) char buf[64]; snprintf (buf, sizeof (buf), "%d:%d:%d", color.get_red(), color.get_green(), color.get_blue()); gui_state.set (group_gui_id (group), "color", buf); + + /* This is a bit of a hack, but this might change + our route's effective color, so emit gui_changed + for our routes. + */ + + for (RouteList::iterator i = group->route_list()->begin(); i != group->route_list()->end(); ++i) { + (*i)->gui_changed (X_("color"), 0); + } } /** @return the ID string to use for the GUI state of a route group */ diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 9f2f20b22a..ad2891408b 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -375,10 +375,6 @@ MixerStrip::set_route (boost::shared_ptr rt) revert_to_default_display (); - if (set_color_from_route()) { - set_color (unique_random_color()); - } - if (route()->is_master()) { solo_button->hide (); below_panner_box.hide (); diff --git a/gtk2_ardour/route_group_dialog.cc b/gtk2_ardour/route_group_dialog.cc index 6b1b5a3f91..bc497e4467 100644 --- a/gtk2_ardour/route_group_dialog.cc +++ b/gtk2_ardour/route_group_dialog.cc @@ -45,6 +45,7 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) , _select (_("Selection")) , _edit (_("Editing")) , _route_active (_("Route active state")) + , _share_color (_("Color")) { set_modal (true); set_skip_taskbar_hint (true); @@ -84,6 +85,7 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _name.set_text (_group->name ()); _active.set_active (_group->is_active ()); + _color.set_color (GroupTabs::group_color (_group)); VBox* options_box = manage (new VBox); options_box->set_spacing (6); @@ -102,10 +104,11 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _select.set_active (_group->is_select()); _edit.set_active (_group->is_edit()); _route_active.set_active (_group->is_route_active()); - _color.set_color (GroupTabs::group_color (_group)); + _share_color.set_active (_group->is_color()); _name.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); + _color.signal_color_set().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _gain.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _relative.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _mute.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); @@ -114,8 +117,8 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _select.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _edit.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _route_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); - _color.signal_color_set().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); - + _share_color.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); + gain_toggled (); Table* table = manage (new Table (11, 4, false)); @@ -138,7 +141,7 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) table->attach (_select, 1, 3, 6, 7, Gtk::FILL, Gtk::FILL, 0, 0); table->attach (_edit, 1, 3, 7, 8, Gtk::FILL, Gtk::FILL, 0, 0); table->attach (_route_active, 1, 3, 8, 9, Gtk::FILL, Gtk::FILL, 0, 0); - + table->attach (_share_color, 1, 3, 9, 10, Gtk::FILL, Gtk::FILL, 0, 0); options_box->pack_start (*table, false, true); main_vbox->pack_start (*options_box, false, true); @@ -206,10 +209,11 @@ RouteGroupDialog::update () plist.add (Properties::relative, _relative.get_active()); plist.add (Properties::active, _active.get_active()); plist.add (Properties::name, string (_name.get_text())); + plist.add (Properties::color, _share_color.get_active()); - GroupTabs::set_group_color (_group, _color.get_color ()); - _group->apply_changes (plist); + + GroupTabs::set_group_color (_group, _color.get_color ()); } void diff --git a/gtk2_ardour/route_group_dialog.h b/gtk2_ardour/route_group_dialog.h index 9fa242f7e0..c3d4798ce5 100644 --- a/gtk2_ardour/route_group_dialog.h +++ b/gtk2_ardour/route_group_dialog.h @@ -48,6 +48,7 @@ private: Gtk::CheckButton _select; Gtk::CheckButton _edit; Gtk::CheckButton _route_active; + Gtk::CheckButton _share_color; Gtk::Button* _ok; Gtk::ColorButton _color; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 6cf06a048d..66b0192119 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -914,7 +914,7 @@ void RouteTimeAxisView::route_color_changed () { if (_view) { - _view->apply_color (_color, StreamView::RegionColor); + _view->apply_color (color(), StreamView::RegionColor); } } @@ -2487,3 +2487,4 @@ RouteTimeAxisView::state_id() const { return string_compose ("rtav %1", _route->id().to_s()); } + diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index a1a7f49ebc..fc9d878b83 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -44,6 +44,7 @@ #include "mixer_strip.h" #include "automation_time_axis.h" #include "route_time_axis.h" +#include "group_tabs.h" #include "ardour/route.h" #include "ardour/event_type_map.h" @@ -1809,3 +1810,18 @@ RouteUI::route_gui_changed (string what_changed) } } } + +/** @return the color that this route should use; it maybe its own, + or it maybe that of its route group. +*/ +Gdk::Color +RouteUI::color () const +{ + RouteGroup* g = _route->route_group (); + + if (g && g->is_color()) { + return GroupTabs::group_color (g); + } + + return _color; +} diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 7ba9fe6144..e5f240ff5b 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -57,6 +57,8 @@ class RouteUI : public virtual AxisView virtual ~RouteUI(); + Gdk::Color color () const; + virtual void set_route (boost::shared_ptr); virtual void set_button_names () = 0; diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index b0c8cd93a4..55e2020874 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -357,7 +357,7 @@ StreamView::diskstream_changed () } void -StreamView::apply_color (Gdk::Color& color, ColorTarget target) +StreamView::apply_color (Gdk::Color color, ColorTarget target) { list::iterator i; diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 6e0c39ebc8..795fe0f687 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -89,7 +89,7 @@ public: }; Gdk::Color get_region_color () const { return region_color; } - void apply_color (Gdk::Color&, ColorTarget t); + void apply_color (Gdk::Color, ColorTarget t); uint32_t num_selected_regionviews () const; diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index 5ab78cdf76..1f6be864cd 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -44,6 +44,7 @@ namespace Properties { extern PBD::PropertyDescriptor select; extern PBD::PropertyDescriptor edit; extern PBD::PropertyDescriptor route_active; + extern PBD::PropertyDescriptor color; /* we use this, but its declared in region.cc */ extern PBD::PropertyDescriptor hidden; }; @@ -71,6 +72,7 @@ class RouteGroup : public SessionObject bool is_select () const { return _select.val(); } bool is_edit () const { return _edit.val(); } bool is_route_active () const { return _route_active.val(); } + bool is_color () const { return _color.val(); } bool empty() const {return routes->empty();} size_t size() const { return routes->size();} @@ -89,6 +91,7 @@ class RouteGroup : public SessionObject void set_select (bool yn); void set_edit (bool yn); void set_route_active (bool yn); + void set_color (bool yn); bool enabled_property (PBD::PropertyID); @@ -141,6 +144,7 @@ private: PBD::Property _select; PBD::Property _edit; PBD::Property _route_active; + PBD::Property _color; void remove_when_going_away (boost::weak_ptr); int set_state_2X (const XMLNode&, int); diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc index ae2545a3ea..0806ad7730 100644 --- a/libs/ardour/route_group.cc +++ b/libs/ardour/route_group.cc @@ -51,6 +51,7 @@ namespace ARDOUR { PropertyDescriptor select; PropertyDescriptor edit; PropertyDescriptor route_active; + PropertyDescriptor color; } } @@ -77,6 +78,8 @@ RouteGroup::make_property_quarks () DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for edit = %1\n", Properties::edit.property_id)); Properties::route_active.property_id = g_quark_from_static_string (X_("route-active")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for route-active = %1\n", Properties::route_active.property_id)); + Properties::color.property_id = g_quark_from_static_string (X_("color")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for color = %1\n", Properties::color.property_id)); } #define ROUTE_GROUP_DEFAULT_PROPERTIES _relative (Properties::relative, false) \ @@ -88,7 +91,8 @@ RouteGroup::make_property_quarks () , _recenable (Properties::recenable, false) \ , _select (Properties::select, false) \ , _edit (Properties::edit, false) \ - , _route_active (Properties::route_active, false) + , _route_active (Properties::route_active, false) \ + , _color (Properties::color, false) RouteGroup::RouteGroup (Session& s, const string &n) : SessionObject (s, n) @@ -107,6 +111,7 @@ RouteGroup::RouteGroup (Session& s, const string &n) add_property (_select); add_property (_edit); add_property (_route_active); + add_property (_color); } RouteGroup::~RouteGroup () @@ -282,6 +287,7 @@ RouteGroup::set_state_2X (const XMLNode& node, int /*version*/) _recenable = true; _edit = false; _route_active = true; + _color = false; } else if (node.name() == "EditGroup") { _gain = false; _mute = false; @@ -289,6 +295,7 @@ RouteGroup::set_state_2X (const XMLNode& node, int /*version*/) _recenable = false; _edit = true; _route_active = false; + _color = false; } return 0; @@ -357,6 +364,24 @@ RouteGroup::set_route_active (bool yn) _route_active = yn; } +void +RouteGroup::set_color (bool yn) +{ + if (is_color() == yn) { + return; + } + _color = yn; + + /* This is a bit of a hack, but this might change + our route's effective color, so emit gui_changed + for our routes. + */ + + for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { + (*i)->gui_changed (X_("color"), this); + } +} + void RouteGroup::set_active (bool yn, void* /*src*/) { @@ -399,7 +424,7 @@ RouteGroup::set_hidden (bool yn, void* /*src*/) } } - PropertyChanged (Properties::hidden); /* EMIT SIGNAL */ + send_change (Properties::hidden); _session.set_dirty (); } -- cgit v1.2.3