From 73d2d44652c5a39e1f213bdda7872b78d61648d3 Mon Sep 17 00:00:00 2001 From: nick_m Date: Thu, 12 Mar 2015 03:46:11 +1100 Subject: Add route dialog is never a transient window. Fixes a hack where it's transient parent was used to give an order hint (for the order key of any new tracks). This commit adds a new combobox "insert_at" to let the user tell us where they want new tracks to go. --- gtk2_ardour/add_route_dialog.cc | 26 ++++++++++++++++++++++++++ gtk2_ardour/add_route_dialog.h | 8 ++++++++ gtk2_ardour/ardour_ui.cc | 39 ++++++++++++++++++++------------------- gtk2_ardour/ardour_ui.h | 2 +- 4 files changed, 55 insertions(+), 20 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/add_route_dialog.cc b/gtk2_ardour/add_route_dialog.cc index 3b1cd47bfc..24e9ca81df 100644 --- a/gtk2_ardour/add_route_dialog.cc +++ b/gtk2_ardour/add_route_dialog.cc @@ -80,6 +80,12 @@ AddRouteDialog::AddRouteDialog () track_bus_combo.append_text (_("Busses")); track_bus_combo.set_active (0); + insert_at_combo.append_text (_("Editor Selection")); + insert_at_combo.append_text (_("Mixer Selection")); + insert_at_combo.append_text (_("End")); + + insert_at_combo.set_active (0); + VBox* vbox = manage (new VBox); Gtk::Label* l; @@ -151,6 +157,12 @@ AddRouteDialog::AddRouteDialog () table2->attach (route_group_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0); ++n; + /* New route will be inserted at.. */ + l = manage (new Label (_("Insert at:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false)); + table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0); + table2->attach (insert_at_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0); + ++n; + options_box->pack_start (*table2, false, true); vbox->pack_start (*options_box, false, true); @@ -538,6 +550,20 @@ AddRouteDialog::group_changed () } } +AddRouteDialog::InsertAt +AddRouteDialog::insert_at () +{ + std::string str = insert_at_combo.get_active_text(); + + if (str == _("Editor Selection")) { + return EditorSelection; + } else if (str == _("Mixer Selection")){ + return MixerSelection; + } + + return End; +} + bool AddRouteDialog::channel_separator (const Glib::RefPtr &, const Gtk::TreeModel::iterator &i) { diff --git a/gtk2_ardour/add_route_dialog.h b/gtk2_ardour/add_route_dialog.h index 3a5501e15f..9f11528e58 100644 --- a/gtk2_ardour/add_route_dialog.h +++ b/gtk2_ardour/add_route_dialog.h @@ -67,6 +67,12 @@ class AddRouteDialog : public ArdourDialog ARDOUR::TrackMode mode(); ARDOUR::RouteGroup* route_group (); + enum InsertAt { + EditorSelection, + MixerSelection, + End + }; + InsertAt insert_at(); private: Gtk::Entry name_template_entry; @@ -80,6 +86,8 @@ class AddRouteDialog : public ArdourDialog Gtk::ComboBoxText mode_combo; Gtk::ComboBoxText route_group_combo; InstrumentSelector instrument_combo; + Gtk::Label insert_at_label; + Gtk::ComboBoxText insert_at_combo; std::vector route_templates; diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 8b8a7cdef2..9ff0190918 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3424,7 +3424,7 @@ ARDOUR_UI::flush_trash () } void -ARDOUR_UI::setup_order_hint () +ARDOUR_UI::setup_order_hint (AddRouteDialog::InsertAt place) { uint32_t order_hint = 0; @@ -3432,7 +3432,7 @@ ARDOUR_UI::setup_order_hint () we want the new routes to have their order keys set starting from the highest order key in the selection + 1 (if available). */ - if (add_route_dialog->get_transient_for () == mixer->get_toplevel()) { + if (place == AddRouteDialog::MixerSelection) { 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(); @@ -3443,7 +3443,7 @@ ARDOUR_UI::setup_order_hint () order_hint++; } - } else { + } else if (place == AddRouteDialog::EditorSelection){ for (TrackSelection::iterator s = editor->get_selection().tracks.begin(); s != editor->get_selection().tracks.end(); ++s) { RouteTimeAxisView* tav = dynamic_cast (*s); if (tav && tav->route() && tav->route()->order_key() > order_hint) { @@ -3454,28 +3454,34 @@ ARDOUR_UI::setup_order_hint () if (!editor->get_selection().tracks.empty()) { order_hint++; } + } else { + /** AddRouteDialog::End + * an order hint of '0' means place new routes at the end. + * do nothing + */ } _session->set_order_hint (order_hint); /* create a gap in the existing route order keys to accomodate new routes.*/ + if (order_hint != 0) { + boost::shared_ptr rd = _session->get_routes(); + for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) { + boost::shared_ptr rt (*ri); - boost::shared_ptr rd = _session->get_routes(); - for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) { - boost::shared_ptr rt (*ri); - - if (rt->is_monitor()) { - continue; - } + if (rt->is_monitor()) { + continue; + } - if (rt->order_key () >= order_hint) { - rt->set_order_key (rt->order_key () + add_route_dialog->count()); + 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) +ARDOUR_UI::add_route (Gtk::Window* /* ignored */) { int count; @@ -3488,11 +3494,6 @@ ARDOUR_UI::add_route (Gtk::Window* float_window) return; } - if (float_window) { - add_route_dialog->unset_transient_for (); - add_route_dialog->set_transient_for (*float_window); - } - ResponseType r = (ResponseType) add_route_dialog->run (); add_route_dialog->hide(); @@ -3509,7 +3510,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window) return; } - setup_order_hint(); + setup_order_hint(add_route_dialog->insert_at()); string template_path = add_route_dialog->track_template(); DisplaySuspender ds; diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 0124d3c8f2..66b6610f40 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -609,7 +609,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void snapshot_session (bool switch_to_it); void rename_session (); - void setup_order_hint (); + void setup_order_hint (AddRouteDialog::InsertAt); int create_mixer (); int create_editor (); -- cgit v1.2.3