diff options
-rw-r--r-- | gtk2_ardour/editor_actions.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_group_tabs.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_routes.cc | 107 | ||||
-rw-r--r-- | gtk2_ardour/editor_routes.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/mixer_group_tabs.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.cc | 186 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.h | 9 | ||||
-rw-r--r-- | libs/ardour/ardour/route.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/route.cc | 73 | ||||
-rw-r--r-- | libs/ardour/session.cc | 67 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 13 |
12 files changed, 268 insertions, 208 deletions
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 5412a6a8c2..e274170982 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1482,6 +1482,10 @@ Editor::parameter_changed (std::string p) } } else if (p == "show-region-gain") { set_gain_envelope_visibility (); + } else if (p == "remote-model") { + if (_routes) { + _routes->reset_remote_control_ids (); + } } } diff --git a/gtk2_ardour/editor_group_tabs.cc b/gtk2_ardour/editor_group_tabs.cc index cb85544669..f9e2bc3a19 100644 --- a/gtk2_ardour/editor_group_tabs.cc +++ b/gtk2_ardour/editor_group_tabs.cc @@ -201,5 +201,5 @@ EditorGroupTabs::selected_routes () const void EditorGroupTabs::sync_order_keys () { - _editor->_routes->sync_order_keys_from_model (); + _editor->_routes->sync_order_keys_from_treeview (); } diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index 39e31f59d4..242a013583 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -221,6 +221,7 @@ EditorRoutes::EditorRoutes (Editor* e) _display.get_selection()->set_mode (SELECTION_SINGLE); _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter)); _display.set_reorderable (true); + _display.set_name (X_("MixerTrackDisplayList")); _display.set_rules_hint (true); _display.set_size_request (100, -1); _display.add_object_drag (_columns.route.index(), "routes"); @@ -281,7 +282,7 @@ EditorRoutes::EditorRoutes (Editor* e) _display.set_enable_search (false); - Route::SyncOrderKeys.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::sync_model_from_order_keys, this, _1), gui_context()); + Route::SyncOrderKeys.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::sync_treeview_from_order_keys, this, _1), gui_context()); } bool @@ -550,14 +551,14 @@ EditorRoutes::route_deleted (Gtk::TreeModel::Path const &) as when a row/route is actually deleted. */ DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n"); - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); } void EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/) { DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n"); - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); } void @@ -664,7 +665,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes) /* now update route order keys from the treeview/track display order */ - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); } void @@ -760,7 +761,7 @@ EditorRoutes::update_visibility () /* force route order keys catch up with visibility changes */ - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); resume_redisplay (); } @@ -799,7 +800,57 @@ EditorRoutes::show_track_in_display (TimeAxisView& tv) } void -EditorRoutes::sync_order_keys_from_model () +EditorRoutes::reset_remote_control_ids () +{ + if (Config->get_remote_model() != EditorOrdered || !_session || _session->deletion_in_progress()) { + return; + } + + TreeModel::Children rows = _model->children(); + + if (rows.empty()) { + return; + } + + + DEBUG_TRACE (DEBUG::OrderKeys, "editor reset remote control ids\n"); + + TreeModel::Children::iterator ri; + bool rid_change = false; + uint32_t rid = 1; + uint32_t invisible_key = UINT32_MAX; + + for (ri = rows.begin(); ri != rows.end(); ++ri) { + + boost::shared_ptr<Route> route = (*ri)[_columns.route]; + bool visible = (*ri)[_columns.visible]; + + + if (!route->is_master() && !route->is_monitor()) { + + uint32_t new_rid = (visible ? rid : invisible_key--); + + if (new_rid != route->remote_control_id()) { + route->set_remote_control_id_from_order_key (EditorSort, new_rid); + rid_change = true; + } + + if (visible) { + rid++; + } + + } + } + + if (rid_change) { + /* tell the world that we changed the remote control IDs */ + _session->notify_remote_id_change (); + } +} + + +void +EditorRoutes::sync_order_keys_from_treeview () { if (_ignore_reorder || !_session || _session->deletion_in_progress()) { return; @@ -811,30 +862,60 @@ EditorRoutes::sync_order_keys_from_model () return; } - DEBUG_TRACE (DEBUG::OrderKeys, "editor sync order keys from model\n"); + + DEBUG_TRACE (DEBUG::OrderKeys, "editor sync order keys from treeview\n"); TreeModel::Children::iterator ri; bool changed = false; + bool rid_change = false; uint32_t order = 0; + uint32_t rid = 1; + uint32_t invisible_key = UINT32_MAX; + + for (ri = rows.begin(); ri != rows.end(); ++ri) { - for (ri = rows.begin(); ri != rows.end(); ++ri, ++order) { boost::shared_ptr<Route> route = (*ri)[_columns.route]; + bool visible = (*ri)[_columns.visible]; + uint32_t old_key = route->order_key (EditorSort); if (order != old_key) { route->set_order_key (EditorSort, order); + changed = true; } + + if ((Config->get_remote_model() == EditorOrdered) && !route->is_master() && !route->is_monitor()) { + + uint32_t new_rid = (visible ? rid : invisible_key--); + + if (new_rid != route->remote_control_id()) { + route->set_remote_control_id_from_order_key (EditorSort, new_rid); + rid_change = true; + } + + if (visible) { + rid++; + } + + } + + ++order; } if (changed) { /* tell the world that we changed the editor sort keys */ _session->sync_order_keys (EditorSort); } + + if (rid_change) { + /* tell the world that we changed the remote control IDs */ + _session->notify_remote_id_change (); + } } void -EditorRoutes::sync_model_from_order_keys (RouteSortOrderKey src) +EditorRoutes::sync_treeview_from_order_keys (RouteSortOrderKey src) { /* Some route order key(s) for `src' has been changed, make sure that we update out tree/list model and GUI to reflect the change. @@ -886,9 +967,9 @@ EditorRoutes::sync_model_from_order_keys (RouteSortOrderKey src) boost::shared_ptr<Route> route = (*ri)[_columns.route]; uint32_t new_order = route->order_key (EditorSort); - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("editor change order for %1 from %2 to %3\n", + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("EDITOR change order for %1 from %2 to %3\n", route->name(), old_order, new_order)); - + neworder[new_order] = old_order; if (old_order != new_order) { @@ -957,7 +1038,7 @@ EditorRoutes::set_all_tracks_visibility (bool yn) /* force route order keys catch up with visibility changes */ - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); resume_redisplay (); } @@ -1019,7 +1100,7 @@ EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn) /* force route order keys catch up with visibility changes */ - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); resume_redisplay (); } diff --git a/gtk2_ardour/editor_routes.h b/gtk2_ardour/editor_routes.h index 008304303f..4933a9496f 100644 --- a/gtk2_ardour/editor_routes.h +++ b/gtk2_ardour/editor_routes.h @@ -59,9 +59,10 @@ public: std::list<TimeAxisView*> views () const; void hide_all_tracks (bool); void clear (); - void sync_order_keys_from_model (); -private: + void sync_order_keys_from_treeview (); + void reset_remote_control_ids (); +private: void initial_display (); void on_input_active_changed (std::string const &); void on_tv_rec_enable_changed (std::string const &); @@ -71,7 +72,7 @@ private: void on_tv_solo_safe_toggled (std::string const &); void build_menu (); void show_menu (); - void sync_model_from_order_keys (ARDOUR::RouteSortOrderKey); + void sync_treeview_from_order_keys (ARDOUR::RouteSortOrderKey); void route_deleted (Gtk::TreeModel::Path const &); void visible_changed (std::string const &); void active_changed (std::string const &); diff --git a/gtk2_ardour/mixer_group_tabs.cc b/gtk2_ardour/mixer_group_tabs.cc index f3121a5ca9..4a56b01fcd 100644 --- a/gtk2_ardour/mixer_group_tabs.cc +++ b/gtk2_ardour/mixer_group_tabs.cc @@ -192,5 +192,5 @@ MixerGroupTabs::selected_routes () const void MixerGroupTabs::sync_order_keys () { - _mixer->sync_order_keys_from_model (); + _mixer->sync_order_keys_from_treeview (); } diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index b83be455d0..a4175e7d91 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -28,7 +28,6 @@ #include <gtkmm/accelmap.h> #include "pbd/convert.h" -#include "pbd/stacktrace.h" #include "pbd/unwind.h" #include <glibmm/thread.h> @@ -94,7 +93,7 @@ Mixer_UI::Mixer_UI () /* allow this window to become the key focus window */ set_flags (CAN_FOCUS); - Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_model_from_order_keys, this, _1), gui_context()); + Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_order_keys, this, _1), gui_context()); scroller_base.set_flags (Gtk::CAN_FOCUS); scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); @@ -366,7 +365,7 @@ Mixer_UI::add_strips (RouteList& routes) } } - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); redisplay_track_list (); } @@ -395,7 +394,52 @@ Mixer_UI::remove_strip (MixerStrip* strip) } void -Mixer_UI::sync_order_keys_from_model () +Mixer_UI::reset_remote_control_ids () +{ + if (Config->get_remote_model() != MixerOrdered || !_session || _session->deletion_in_progress()) { + return; + } + + TreeModel::Children rows = track_model->children(); + + if (rows.empty()) { + return; + } + + DEBUG_TRACE (DEBUG::OrderKeys, "mixer resets remote control ids after remote model change\n"); + + TreeModel::Children::iterator ri; + bool rid_change = false; + uint32_t rid = 1; + uint32_t invisible_key = UINT32_MAX; + + for (ri = rows.begin(); ri != rows.end(); ++ri) { + boost::shared_ptr<Route> route = (*ri)[track_columns.route]; + bool visible = (*ri)[track_columns.visible]; + + if (!route->is_master() && !route->is_monitor()) { + + uint32_t new_rid = (visible ? rid : invisible_key--); + + if (new_rid != route->remote_control_id()) { + route->set_remote_control_id_from_order_key (MixerSort, new_rid); + rid_change = true; + } + + if (visible) { + rid++; + } + } + } + + if (rid_change) { + /* tell the world that we changed the remote control IDs */ + _session->notify_remote_id_change (); + } +} + +void +Mixer_UI::sync_order_keys_from_treeview () { if (ignore_reorder || !_session || _session->deletion_in_progress()) { return; @@ -411,26 +455,53 @@ Mixer_UI::sync_order_keys_from_model () TreeModel::Children::iterator ri; bool changed = false; + bool rid_change = false; uint32_t order = 0; + uint32_t rid = 1; + uint32_t invisible_key = UINT32_MAX; - for (ri = rows.begin(); ri != rows.end(); ++ri, ++order) { + for (ri = rows.begin(); ri != rows.end(); ++ri) { boost::shared_ptr<Route> route = (*ri)[track_columns.route]; + bool visible = (*ri)[track_columns.visible]; + uint32_t old_key = route->order_key (MixerSort); - if (old_key != order) { + if (order != old_key) { route->set_order_key (MixerSort, order); changed = true; } + + if ((Config->get_remote_model() == MixerOrdered) && !route->is_master() && !route->is_monitor()) { + + uint32_t new_rid = (visible ? rid : invisible_key--); + + if (new_rid != route->remote_control_id()) { + route->set_remote_control_id_from_order_key (MixerSort, new_rid); + rid_change = true; + } + + if (visible) { + rid++; + } + + } + + ++order; } - + if (changed) { /* tell everyone that we changed the mixer sort keys */ _session->sync_order_keys (MixerSort); } + + if (rid_change) { + /* tell the world that we changed the remote control IDs */ + _session->notify_remote_id_change (); + } } void -Mixer_UI::sync_model_from_order_keys (RouteSortOrderKey src) +Mixer_UI::sync_treeview_from_order_keys (RouteSortOrderKey src) { if (!_session || _session->deletion_in_progress()) { return; @@ -465,7 +536,7 @@ Mixer_UI::sync_model_from_order_keys (RouteSortOrderKey src) vector<int> neworder; TreeModel::Children rows = track_model->children(); - uint32_t n = 0; + uint32_t old_order = 0; bool changed = false; if (rows.empty()) { @@ -474,18 +545,18 @@ Mixer_UI::sync_model_from_order_keys (RouteSortOrderKey src) neworder.assign (rows.size(), 0); - for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++n) { + for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) { boost::shared_ptr<Route> route = (*ri)[track_columns.route]; - uint32_t o = route->order_key (MixerSort); + uint32_t new_order = route->order_key (MixerSort); - neworder[o] = n; + neworder[new_order] = old_order; - if (o != n) { + if (old_order != new_order) { changed = true; } - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("mixer change order for %1 to %2\n", - route->name(), route->order_key (MixerSort))); + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("MIXER change order for %1 from %2 to %3\n", + route->name(), old_order, new_order)); } if (changed) { @@ -680,6 +751,50 @@ Mixer_UI::session_going_away () } void +Mixer_UI::track_visibility_changed (std::string const & path) +{ + if (_session && _session->deletion_in_progress()) { + return; + } + + TreeIter iter; + + if ((iter = track_model->get_iter (path))) { + MixerStrip* strip = (*iter)[track_columns.strip]; + if (strip) { + bool visible = (*iter)[track_columns.visible]; + + if (strip->set_marked_for_display (!visible)) { + update_track_visibility (); + } + } + } +} + +void +Mixer_UI::update_track_visibility () +{ + TreeModel::Children rows = track_model->children(); + TreeModel::Children::iterator i; + + { + Unwinder<bool> uw (no_track_list_redisplay, true); + + for (i = rows.begin(); i != rows.end(); ++i) { + MixerStrip *strip = (*i)[track_columns.strip]; + (*i)[track_columns.visible] = strip->marked_for_display (); + } + + /* force route order keys catch up with visibility changes + */ + + sync_order_keys_from_treeview (); + } + + redisplay_track_list (); +} + +void Mixer_UI::show_strip (MixerStrip* ms) { TreeModel::Children rows = track_model->children(); @@ -851,7 +966,7 @@ void Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/) { DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n"); - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); } void @@ -861,7 +976,7 @@ Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) as when a row/route is actually deleted. */ DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n"); - sync_order_keys_from_model (); + sync_order_keys_from_treeview (); } void @@ -1008,43 +1123,9 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) return true; } - TreeIter iter; - TreeModel::Path path; - TreeViewColumn* column; - int cellx; - int celly; - - if (!track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { - return false; - } - - switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { - case 0: - /* allow normal processing to occur */ - return false; - - case 1: /* visibility */ - if ((iter = track_model->get_iter (path))) { - MixerStrip* strip = (*iter)[track_columns.strip]; - if (strip) { - - if (!strip->route()->is_master() && !strip->route()->is_monitor()) { - bool visible = (*iter)[track_columns.visible]; - (*iter)[track_columns.visible] = !visible; - redisplay_track_list (); - } - } - } - return true; - - default: - break; - } - return false; } - void Mixer_UI::build_track_menu () { @@ -1659,6 +1740,8 @@ Mixer_UI::parameter_changed (string const & p) for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) { (*i)->set_width_enum (s ? Narrow : Wide, this); } + } else if (p == "remote-model") { + reset_remote_control_ids (); } } @@ -1701,6 +1784,7 @@ Mixer_UI::setup_track_display () CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (1)); track_list_visible_cell->property_activatable() = true; track_list_visible_cell->property_radio() = false; + track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed)); track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false); diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index ab0223aa4d..90af35822b 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -166,9 +166,11 @@ class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public AR void initial_track_display (); void show_track_list_menu (); - + void set_all_strips_visibility (bool yn); void set_all_audio_visibility (int tracks, bool yn); + void track_visibility_changed (std::string const & path); + void update_track_visibility (); void hide_all_routes (); void show_all_routes (); @@ -244,8 +246,9 @@ class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public AR Width _strip_width; - void sync_order_keys_from_model (); - void sync_model_from_order_keys (ARDOUR::RouteSortOrderKey); + void sync_order_keys_from_treeview (); + void sync_treeview_from_order_keys (ARDOUR::RouteSortOrderKey); + void reset_remote_control_ids (); bool ignore_reorder; void parameter_changed (std::string const &); diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 22ecb19123..62a694071f 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -423,7 +423,7 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, void set_remote_control_id (uint32_t id, bool notify_class_listeners = true); uint32_t remote_control_id () const; - void set_remote_control_id_from_order_key (RouteSortOrderKey); + void set_remote_control_id_from_order_key (RouteSortOrderKey, uint32_t order_key); /* for things concerned about *this* route's RID */ @@ -531,8 +531,6 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, int set_state_2X (const XMLNode&, int); void set_processor_state_2X (XMLNodeList const &, int); - static uint32_t order_key_cnt; - typedef std::map<RouteSortOrderKey,uint32_t> OrderKeys; OrderKeys order_keys; uint32_t _remote_control_id; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index bc14805074..780c68f2b0 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -234,8 +234,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b); }; + void notify_remote_id_change (); void sync_order_keys (RouteSortOrderKey); - void sync_remote_id_from_order_keys (RouteSortOrderKey); template<class T> void foreach_route (T *obj, void (T::*func)(Route&)); template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>)); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 80b738e003..de4a583291 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -66,7 +66,6 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -uint32_t Route::order_key_cnt = 0; PBD::Signal1<void,RouteSortOrderKey> Route::SyncOrderKeys; PBD::Signal0<void> Route::RemoteControlIDChange; @@ -286,19 +285,12 @@ Route::sync_order_keys (RouteSortOrderKey base) for (OrderKeys::iterator k = order_keys.begin(); k != order_keys.end(); ++k) { - if (is_master() || is_monitor()) { - /* don't sync the sort keys for master/monitor, - * since they are not part of the normal ordering. - */ - continue; - } - if (k->first != base) { DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1 set key for %2 to %3 from %4\n", name(), enum_2_string (k->first), i->second, - base)); + enum_2_string (base))); k->second = i->second; } @@ -306,66 +298,17 @@ Route::sync_order_keys (RouteSortOrderKey base) } void -Route::set_remote_control_id_from_order_key (RouteSortOrderKey key) +Route::set_remote_control_id_from_order_key (RouteSortOrderKey key, uint32_t rid) { if (is_master() || is_monitor() || is_hidden()) { /* hard-coded remote IDs, or no remote ID */ return; } - uint32_t n = order_keys[key]; - - /* we have a nasty glitch in an otherwise fairly clean system here. - - in theory, a route's remote control ID is determined by the order - key matching the current remote model (for UserOrdered, the user - controls everything). its one greater, because order keys are zero - based and remote control IDs start at one. - - but ... an order key for the master bus may place it before or even - within normal routes, yet its remote control ID (like the monitor - bus) is hardcoded to MasterBusRemoteControlID. this means that all - routes ordered after it (in whatever controls the EditorSort or - MixerSort ordering) will end up with a remote control ID that is one - too large. - - we therefore check on the master bus ordering, and adjust - later-sorted routes remote control ID to avoid this "off by one" - error, which keeps remote control ID's contiguous and "right". - - ideally, this would be done in a UI layer, where this logic - is really understood and has meaning, rather than in libardour where - its fundamentally meaningless. - */ - - switch (Config->get_remote_model()) { - case UserOrdered: - break; - case EditorOrdered: - if (key == EditorSort) { - boost::shared_ptr<Route> master = _session.master_out(); - if (master && n > 0 && n > master->order_key (EditorSort)) { - --n; - } - _remote_control_id = n + 1; - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: from order key %2, set edit-based RID to %3\n", - name(), n, _remote_control_id)); - RemoteControlIDChanged (); /* EMIT SIGNAL * (per-route) */ - } - break; - - case MixerOrdered: - if (key == MixerSort) { - boost::shared_ptr<Route> master = _session.master_out(); - if (master && n > 0 && n > master->order_key (MixerSort)) { - --n; - } - _remote_control_id = n + 1; - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: from order key %2, set mix-based RID to %3\n", - name(), n, _remote_control_id)); - RemoteControlIDChanged (); /* EMIT SIGNAL (per-route) */ - } - break; + if (_remote_control_id != rid) { + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), rid)); + _remote_control_id = rid; + RemoteControlIDChanged (); /* EMIT SIGNAL (per-route) */ } /* don't emit the class-level RID signal RemoteControlIDChange here, @@ -389,8 +332,8 @@ Route::set_order_key (RouteSortOrderKey key, uint32_t n) order_keys[key] = n; - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1 order key %2 set to %3 (chk=%4)\n", - name(), enum_2_string (key), n, order_key (key))); + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1 order key %2 set to %3\n", + name(), enum_2_string (key), order_key (key))); _session.set_dirty (); } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 47f39d96b7..59667b2fce 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2206,22 +2206,6 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output } RouteAdded (new_routes); /* EMIT SIGNAL */ - - /* we added at least one new route, and everyone who needs to has now - * handled this event. This means that route order keys are correctly - * set and we can now ensure that remote control IDs are set. - */ - - switch (Config->get_remote_model()) { - case UserOrdered: - break; - case MixerOrdered: - sync_remote_id_from_order_keys (MixerSort); - break; - case EditorOrdered: - sync_remote_id_from_order_keys (EditorSort); - break; - } } void @@ -4713,7 +4697,7 @@ Session::next_control_id () const } void -Session::sync_order_keys (RouteSortOrderKey sort_key_changed) +Session::notify_remote_id_change () { if (deletion_in_progress()) { return; @@ -4727,6 +4711,14 @@ Session::sync_order_keys (RouteSortOrderKey sort_key_changed) default: break; } +} + +void +Session::sync_order_keys (RouteSortOrderKey sort_key_changed) +{ + if (deletion_in_progress()) { + return; + } /* tell everyone that something has happened to the sort keys and let them sync up with the change(s) @@ -4738,46 +4730,7 @@ Session::sync_order_keys (RouteSortOrderKey sort_key_changed) Route::SyncOrderKeys (sort_key_changed); /* EMIT SIGNAL */ - /* ensure that remote control IDs are in sync with the relevant - order keys. - */ - - sync_remote_id_from_order_keys (sort_key_changed); -} - -void -Session::sync_remote_id_from_order_keys (RouteSortOrderKey sort_key_changed) -{ - /* update remote control IDs if that makes sense */ - - bool do_update = false; - - DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("sync RID to order key %1\n", enum_2_string (sort_key_changed))); - - switch (Config->get_remote_model()) { - case UserOrdered: - break; - case EditorOrdered: - if (sort_key_changed == EditorSort) { - do_update = true; - } - break; - case MixerOrdered: - if (sort_key_changed == MixerSort) { - do_update = true; - } - break; - } - - if (do_update) { - DEBUG_TRACE (DEBUG::OrderKeys, "\tactually update + signal\n"); - boost::shared_ptr<RouteList> r = routes.reader(); - for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - (*i)->set_remote_control_id_from_order_key (sort_key_changed); - } - - Route::RemoteControlIDChange (); /* EMIT SIGNAL - static */ - } + DEBUG_TRACE (DEBUG::OrderKeys, "\tsync done\n"); } bool diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index a3460dddfb..6661d33c9a 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3507,16 +3507,9 @@ Session::config_changed (std::string p, bool ours) } else if (p == "history-depth") { set_history_depth (Config->get_history_depth()); } else if (p == "remote-model") { - switch (Config->get_remote_model()) { - case UserOrdered: - break; - case MixerOrdered: - sync_remote_id_from_order_keys (MixerSort); - break; - case EditorOrdered: - sync_remote_id_from_order_keys (EditorSort); - break; - } + /* XXX DO SOMETHING HERE TO TELL THE GUI THAT WE NEED + TO SET REMOTE ID'S + */ } else if (p == "sync-all-route-ordering") { /* sync to editor order unless mixer is used for remote IDs |