From 5774be46fe5dc7e877fa50ef709a16f8ed621c2f Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Mon, 30 Mar 2020 21:49:57 +0200 Subject: [PATCH] Remember the route count when route lua template sets it by "how_many" If the user has an audio interface with 32 inputs, there is the danger, that they click through the route template list and hit "Generic Audio Track" which then sets the number of routes to be added to 32. When they click back to e.g. "Audio Tracks" this number remains at 32. So they will accidentally add 32 audio tracks although they wanted just one. Somewhat inconvenient. By this commit we remember the number of routes to be added, when it is set by a lua template and thus can set it back when the user clicks back on a route type that does not set it. --- gtk2_ardour/add_route_dialog.cc | 18 +++++++++++++++--- gtk2_ardour/add_route_dialog.h | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/add_route_dialog.cc b/gtk2_ardour/add_route_dialog.cc index 090a14676e..9ab829e366 100644 --- a/gtk2_ardour/add_route_dialog.cc +++ b/gtk2_ardour/add_route_dialog.cc @@ -80,6 +80,8 @@ AddRouteDialog::AddRouteDialog () , strict_io_label (_("Pin Mode:")) , mode_label (_("Record Mode:")) , instrument_label (_("Instrument:")) + , last_route_count (1) + , route_count_set_by_template (false) , name_edited_by_user (false) { set_name ("AddRouteDialog"); @@ -380,6 +382,8 @@ AddRouteDialog::trk_template_row_selected () const string n = (*iter)[track_template_columns.name]; const string p = (*iter)[track_template_columns.path]; + bool route_count_now_set_by_template = false; + if (p.substr (0, 11) == "urn:ardour:") { /* lua script - meta-template */ const std::map rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11))); @@ -420,10 +424,13 @@ AddRouteDialog::trk_template_row_selected () name_template_entry.set_text (""); } - if ((it = rs.find ("how_many")) != rs.end()) { - if (atoi (it->second.c_str()) > 0) { - routes_adjustment.set_value (atoi (it->second.c_str())); + if ((it = rs.find ("how_many")) != rs.end() && atoi (it->second.c_str()) > 0) { + if (!route_count_set_by_template) { + last_route_count = routes_adjustment.get_value(); } + routes_adjustment.set_value (atoi (it->second.c_str())); + route_count_now_set_by_template = true; + route_count_set_by_template = true; } if ((it = rs.find ("track_mode")) != rs.end()) { @@ -489,6 +496,11 @@ AddRouteDialog::trk_template_row_selected () name_template_entry.set_sensitive (true); track_type_chosen (); } + + if (!route_count_now_set_by_template && route_count_set_by_template) { + routes_adjustment.set_value (last_route_count); + route_count_set_by_template = false; + } } diff --git a/gtk2_ardour/add_route_dialog.h b/gtk2_ardour/add_route_dialog.h index 053395562b..298577496b 100644 --- a/gtk2_ardour/add_route_dialog.h +++ b/gtk2_ardour/add_route_dialog.h @@ -141,8 +141,8 @@ private: TrackTemplateColumns track_template_columns; - Glib::RefPtr trk_template_model; - Gtk::TreeView trk_template_chooser; + Glib::RefPtr trk_template_model; + Gtk::TreeView trk_template_chooser; void trk_template_row_selected (); @@ -163,6 +163,9 @@ private: typedef std::vector ChannelSetups; ChannelSetups channel_setups; + int last_route_count; + bool route_count_set_by_template; + static std::vector > builtin_types; static std::vector channel_combo_strings; static std::vector bus_mode_strings;