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.
This commit is contained in:
Johannes Mueller 2020-03-30 21:49:57 +02:00
parent bd92e290c0
commit 5774be46fe
2 changed files with 20 additions and 5 deletions

View file

@ -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<std::string, std::string> 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;
}
}

View file

@ -141,8 +141,8 @@ private:
TrackTemplateColumns track_template_columns;
Glib::RefPtr<Gtk::TreeStore> trk_template_model;
Gtk::TreeView trk_template_chooser;
Glib::RefPtr<Gtk::TreeStore> trk_template_model;
Gtk::TreeView trk_template_chooser;
void trk_template_row_selected ();
@ -163,6 +163,9 @@ private:
typedef std::vector<ChannelSetup> ChannelSetups;
ChannelSetups channel_setups;
int last_route_count;
bool route_count_set_by_template;
static std::vector<std::pair<std::string, std::string> > builtin_types;
static std::vector<std::string> channel_combo_strings;
static std::vector<std::string> bus_mode_strings;