allow the user to set all selected to the same state... this code is ugly but it works for now

This commit is contained in:
Nikolaus Gullotta 2019-08-12 10:55:27 -05:00 committed by Nikolaus Gullotta
parent 60a8a5178c
commit 9b9e5b3da7
No known key found for this signature in database
GPG key ID: 565F60578092AA31
3 changed files with 64 additions and 44 deletions

View file

@ -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++;

View file

@ -39,11 +39,14 @@ public:
std::vector<route_combo> 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<route_combo> substitutions;
ARDOUR::MixerSnapshot* _snapshot;

View file

@ -270,52 +270,69 @@ void MixerSnapshotList::substitution_dialog_response(int response, MixerSnapshot
vector<route_combo>::const_iterator p;
vector<route_combo> pairs = dialog->get_substitutions();
for(p = pairs.begin(); p != pairs.end(); p++) {
boost::shared_ptr<Route> 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> 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;
}
}
}