diff options
author | nick_m <mainsbridge@gmail.com> | 2013-10-24 01:27:13 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2013-10-24 01:27:13 +1100 |
commit | be69bf15dd2fbc414b35aa84167b863caf6d7677 (patch) | |
tree | 809ff4484f8d70960494bd664b293aad4a54f266 /gtk2_ardour | |
parent | 75271a17d8d4ed0003c4627e80a28feb68f5d9c9 (diff) |
New routes are placed after highest selected route.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 47 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/editor_routes.cc | 23 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.cc | 22 |
4 files changed, 90 insertions, 3 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index e3c446ecc2..46308fed98 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3223,6 +3223,51 @@ ARDOUR_UI::flush_trash () } void +ARDOUR_UI::setup_order_hint () +{ + uint32_t order_hint = 0; + + /* + we want the new routes to have their order keys set starting from + the highest order key in the selection + 1 (if available). + */ + + for (RouteUISelection::iterator s = mixer->selection().routes.begin(); s != mixer->selection().routes.end(); ++s) { + if ((*s)->route()->order_key() > order_hint) { + order_hint = (*s)->route()->order_key(); + } + } + + for (TrackSelection::iterator s = editor->get_selection().tracks.begin(); s != editor->get_selection().tracks.end(); ++s) { + RouteTimeAxisView* tav = dynamic_cast<RouteTimeAxisView*> (*s); + if (tav->route()->order_key() > order_hint) { + order_hint = tav->route()->order_key(); + } + } + + if (!mixer->selection().routes.empty() || !editor->get_selection().tracks.empty()) { + order_hint++; + } + + _session->set_order_hint (order_hint); + + /* create a gap in the existing route order keys to accomodate new routes.*/ + + boost::shared_ptr <RouteList> rd = _session->get_routes(); + for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) { + boost::shared_ptr<Route> rt (*ri); + + if (rt->is_monitor()) { + continue; + } + + if (rt->order_key () >= order_hint) { + rt->set_order_key (rt->order_key () + add_route_dialog->count()); + } + } +} + +void ARDOUR_UI::add_route (Gtk::Window* float_window) { int count; @@ -3256,6 +3301,8 @@ ARDOUR_UI::add_route (Gtk::Window* float_window) return; } + setup_order_hint(); + PBD::ScopedConnection idle_connection; if (count > 8) { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 20edfe03eb..130fc69581 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -582,6 +582,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void snapshot_session (bool switch_to_it); void rename_session (); + void setup_order_hint (); Mixer_UI *mixer; int create_mixer (); diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index a10e22f306..e0b562b494 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -600,9 +600,24 @@ EditorRoutes::active_changed (std::string const & path) void EditorRoutes::routes_added (list<RouteTimeAxisView*> routes) { - TreeModel::Row row; PBD::Unwinder<bool> at (_adding_routes, true); + bool from_scratch = (_model->children().size() == 0); + Gtk::TreeModel::Children::iterator insert_iter = _model->children().end(); + + for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) { + boost::shared_ptr<Route> r = (*it)[_columns.route]; + + if (r->order_key() == (routes.front()->route()->order_key() + routes.size())) { + insert_iter = it; + break; + } + } + + if(!from_scratch) { + _editor->selection->tracks.clear(); + } + suspend_redisplay (); _display.set_model (Glib::RefPtr<ListStore>()); @@ -611,7 +626,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes) boost::shared_ptr<MidiTrack> midi_trk = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route()); - row = *(_model->append ()); + TreeModel::Row row = *(_model->insert (insert_iter)); row[_columns.text] = (*x)->route()->name(); row[_columns.visible] = (*x)->marked_for_display(); @@ -635,6 +650,10 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes) row[_columns.solo_safe_state] = (*x)->route()->solo_safe(); row[_columns.name_editable] = true; + if (!from_scratch) { + _editor->selection->add(*x); + } + boost::weak_ptr<Route> wr ((*x)->route()); (*x)->route()->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context()); diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 8126a81e85..12cf87d793 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -313,6 +313,22 @@ Mixer_UI::hide_window (GdkEventAny *ev) void Mixer_UI::add_strips (RouteList& routes) { + bool from_scratch = track_model->children().size() == 0; + Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end(); + + for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) { + boost::shared_ptr<Route> r = (*it)[track_columns.route]; + + if (r->order_key() == (routes.front()->order_key() + routes.size())) { + insert_iter = it; + break; + } + } + + if(!from_scratch) { + _selection.clear_routes (); + } + MixerStrip* strip; try { @@ -359,11 +375,15 @@ Mixer_UI::add_strips (RouteList& routes) show_strip (strip); - TreeModel::Row row = *(track_model->append()); + TreeModel::Row row = *(track_model->insert(insert_iter)); row[track_columns.text] = route->name(); row[track_columns.visible] = strip->route()->is_master() ? true : strip->marked_for_display(); row[track_columns.route] = route; row[track_columns.strip] = strip; + + if (!from_scratch) { + _selection.add (strip); + } route->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::strip_property_changed, this, _1, strip), gui_context()); |