From 9b9e5b3da76b853ce0e958d9d4d45e164a25cb90 Mon Sep 17 00:00:00 2001 From: Nikolaus Gullotta Date: Mon, 12 Aug 2019 10:55:27 -0500 Subject: [PATCH] allow the user to set all selected to the same state... this code is ugly but it works for now --- .../mixer_snapshot_substitution_dialog.cc | 10 +- .../mixer_snapshot_substitution_dialog.h | 3 + gtk2_ardour/mixer_snapshots.cc | 95 +++++++++++-------- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/gtk2_ardour/mixer_snapshot_substitution_dialog.cc b/gtk2_ardour/mixer_snapshot_substitution_dialog.cc index f5986bffa3..8cd57cc76c 100644 --- a/gtk2_ardour/mixer_snapshot_substitution_dialog.cc +++ b/gtk2_ardour/mixer_snapshot_substitution_dialog.cc @@ -71,11 +71,11 @@ MixerSnapshotSubstitutionDialog::MixerSnapshotSubstitutionDialog(MixerSnapshot* n++; } - ComboBoxText* sel_combo = manage(new ComboBoxText()); - Label* sel = manage(new Label(_("All Selected: "))); - fill_combo_box(sel_combo, ""); - table->attach(*sel, 0, 1, n, n+1); - table->attach(*sel_combo, 1, 2, n, n+1); + selection_combo = manage(new ComboBoxText()); + Label* selection_combo_text = manage(new Label(_("All Selected: "), ALIGN_LEFT, ALIGN_CENTER, false)); + fill_combo_box(selection_combo, ""); + table->attach(*selection_combo_text, 0, 1, n, n+1); + table->attach(*selection_combo, 1, 2, n, n+1); n++; diff --git a/gtk2_ardour/mixer_snapshot_substitution_dialog.h b/gtk2_ardour/mixer_snapshot_substitution_dialog.h index b29097d2e4..3e7050973c 100644 --- a/gtk2_ardour/mixer_snapshot_substitution_dialog.h +++ b/gtk2_ardour/mixer_snapshot_substitution_dialog.h @@ -39,11 +39,14 @@ public: std::vector get_substitutions() {return substitutions;}; void clear_substitutions() {substitutions.clear();}; + std::string get_selection_combo_active_text() {return selection_combo->get_active_text();}; + private: bool state_exists(const std::string); ARDOUR::MixerSnapshot::State get_state_by_name(const std::string); void fill_combo_box(Gtk::ComboBoxText*, const std::string); + Gtk::ComboBoxText* selection_combo; std::vector substitutions; ARDOUR::MixerSnapshot* _snapshot; diff --git a/gtk2_ardour/mixer_snapshots.cc b/gtk2_ardour/mixer_snapshots.cc index 299e77a9aa..80e84bc624 100644 --- a/gtk2_ardour/mixer_snapshots.cc +++ b/gtk2_ardour/mixer_snapshots.cc @@ -270,52 +270,69 @@ void MixerSnapshotList::substitution_dialog_response(int response, MixerSnapshot vector::const_iterator p; vector pairs = dialog->get_substitutions(); - for(p = pairs.begin(); p != pairs.end(); p++) { - boost::shared_ptr route = (*p).first; - ComboBoxText* cb = (*p).second; - if(!route || !cb) { - continue; - } + const string selected_state = dialog->get_selection_combo_active_text(); + bool state_exists = snapshot->route_state_exists(selected_state); + //set all selected routes to this selected state + if(state_exists) { + XMLNode node (snapshot->get_route_state_by_name(selected_state).node); + RouteList rl = PublicEditor::instance().get_selection().tracks.routelist(); + for(RouteList::const_iterator i = rl.begin(); i != rl.end(); i++) { + if((*i)->is_monitor() || (*i)->is_master() || (*i)->is_auditioner()) { + continue; + } - if(route->is_monitor() || route->is_master() || route->is_auditioner()) { - continue; - } - - const string name = route->name(); - const string at = cb->get_active_text(); - - printf( - "*** begining work for route %s, with substitution state %s\n", - name.c_str(), - at.c_str() - ); - - //do not recall this state - if(at == " --- ") { - continue; - } - - const bool route_state_exists = snapshot->route_state_exists(name); - const bool subst_state_exists = snapshot->route_state_exists(at); - if(route_state_exists && subst_state_exists) { - XMLNode copy (snapshot->get_route_state_by_name(at).node); + XMLNode copy (node); MixerSnapshot::State new_state { string(), - name, + (*i)->name(), copy }; + dirty.push_back(new_state); - continue; - } else if(!route_state_exists && subst_state_exists) { - XMLNode copy (snapshot->get_route_state_by_name(at).node); - MixerSnapshot::State new_state { - string(), - name, - copy - }; - dirty.push_back(new_state); - continue; + } + } else { + for(p = pairs.begin(); p != pairs.end(); p++) { + boost::shared_ptr route = (*p).first; + ComboBoxText* cb = (*p).second; + + if(!route || !cb) { + continue; + } + + if(route->is_monitor() || route->is_master() || route->is_auditioner()) { + continue; + } + + const string name = route->name(); + const string at = cb->get_active_text(); + + //do not recall this state + if(at == " --- ") { + continue; + } + + const bool route_state_exists = snapshot->route_state_exists(name); + const bool subst_state_exists = snapshot->route_state_exists(at); + if(route_state_exists && subst_state_exists) { + XMLNode copy (snapshot->get_route_state_by_name(at).node); + MixerSnapshot::State new_state { + string(), + name, + copy + }; + dirty.push_back(new_state); + continue; + } else if(!route_state_exists && subst_state_exists) { + XMLNode copy (snapshot->get_route_state_by_name(at).node); + MixerSnapshot::State new_state { + string(), + name, + copy + }; + dirty.push_back(new_state); + continue; + } } }