mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 15:15:41 +01:00
get substitutions into a working state
This commit is contained in:
parent
85ec750c70
commit
ff02990080
6 changed files with 220 additions and 87 deletions
|
|
@ -103,95 +103,95 @@ void MixerSnapshotSubstitutionDialog::fill_combo_box(ComboBoxText* box, const st
|
|||
}
|
||||
}
|
||||
|
||||
void MixerSnapshotSubstitutionDialog::on_response(int r)
|
||||
{
|
||||
if(r == RESPONSE_CANCEL) {
|
||||
substitutions.clear();
|
||||
close_self();
|
||||
return;
|
||||
}
|
||||
// void MixerSnapshotSubstitutionDialog::on_response(int r)
|
||||
// {
|
||||
// if(r == RESPONSE_CANCEL) {
|
||||
// substitutions.clear();
|
||||
// close_self();
|
||||
// return;
|
||||
// }
|
||||
|
||||
vector<MixerSnapshot::State> dirty = _snapshot->get_routes();
|
||||
vector<MixerSnapshot::State> clean = _snapshot->get_routes();
|
||||
vector<MixerSnapshot::State> new_s;
|
||||
vector<MixerSnapshot::State> del_s;
|
||||
// vector<MixerSnapshot::State> dirty = _snapshot->get_routes();
|
||||
// vector<MixerSnapshot::State> clean = _snapshot->get_routes();
|
||||
// vector<MixerSnapshot::State> new_s;
|
||||
// vector<MixerSnapshot::State> del_s;
|
||||
|
||||
if(r == RESPONSE_ACCEPT) {
|
||||
for(vector<route_combo>::iterator c = substitutions.begin(); c != substitutions.end(); c++) {
|
||||
string route_name = (*c).first->name();
|
||||
string subst_name = (*c).second->get_active_text();
|
||||
int n = 0;
|
||||
for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
MixerSnapshot::State state = (*s);
|
||||
if(route_name == state.name) {
|
||||
//state and substitution are matches
|
||||
if(route_name == subst_name) {
|
||||
break;
|
||||
}
|
||||
// if(r == RESPONSE_ACCEPT) {
|
||||
// for(vector<route_combo>::iterator c = substitutions.begin(); c != substitutions.end(); c++) {
|
||||
// string route_name = (*c).first->name();
|
||||
// string subst_name = (*c).second->get_active_text();
|
||||
// int n = 0;
|
||||
// for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
// MixerSnapshot::State state = (*s);
|
||||
// if(route_name == state.name) {
|
||||
// //state and substitution are matches
|
||||
// if(route_name == subst_name) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
//empty sub - erase it
|
||||
if(subst_name == " --- ") {
|
||||
del_s.push_back(state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(subst_name == " --- ") {
|
||||
break;
|
||||
}
|
||||
// //empty sub - erase it
|
||||
// if(subst_name == " --- ") {
|
||||
// del_s.push_back(state);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if(subst_name == " --- ") {
|
||||
// break;
|
||||
// }
|
||||
|
||||
bool route_state_exists = state_exists(route_name);
|
||||
bool subst_state_exists = state_exists(subst_name);
|
||||
// bool route_state_exists = state_exists(route_name);
|
||||
// bool subst_state_exists = state_exists(subst_name);
|
||||
|
||||
//state exists but we are picking a different source
|
||||
if(route_name != subst_name) {
|
||||
if(route_state_exists && subst_state_exists) {
|
||||
XMLNode copy (get_state_by_name(subst_name).node);
|
||||
state.node = copy;
|
||||
state.name = route_name;
|
||||
}
|
||||
// //state exists but we are picking a different source
|
||||
// if(route_name != subst_name) {
|
||||
// if(route_state_exists && subst_state_exists) {
|
||||
// XMLNode copy (get_state_by_name(subst_name).node);
|
||||
// state.node = copy;
|
||||
// state.name = route_name;
|
||||
// }
|
||||
|
||||
//state did *not* exist, make it and add the substitute node
|
||||
if(!route_state_exists && subst_state_exists) {
|
||||
//copy the substitute node
|
||||
XMLNode copy (get_state_by_name(subst_name).node);
|
||||
// //state did *not* exist, make it and add the substitute node
|
||||
// if(!route_state_exists && subst_state_exists) {
|
||||
// //copy the substitute node
|
||||
// XMLNode copy (get_state_by_name(subst_name).node);
|
||||
|
||||
MixerSnapshot::State s {
|
||||
"",
|
||||
route_name,
|
||||
copy
|
||||
};
|
||||
// MixerSnapshot::State s {
|
||||
// "",
|
||||
// route_name,
|
||||
// copy
|
||||
// };
|
||||
|
||||
new_s.push_back(s);
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// new_s.push_back(s);
|
||||
// }
|
||||
// }
|
||||
// n++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
for(vector<MixerSnapshot::State>::iterator s = new_s.begin(); s != new_s.end(); s++) {
|
||||
dirty.push_back((*s));
|
||||
}
|
||||
// for(vector<MixerSnapshot::State>::iterator s = new_s.begin(); s != new_s.end(); s++) {
|
||||
// dirty.push_back((*s));
|
||||
// }
|
||||
|
||||
for(vector<MixerSnapshot::State>::iterator d = del_s.begin(); d != del_s.end(); d++) {
|
||||
for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
if((*d).id == (*s).id) {
|
||||
dirty.erase(s);
|
||||
s--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(vector<MixerSnapshot::State>::iterator d = del_s.begin(); d != del_s.end(); d++) {
|
||||
// for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
// if((*d).id == (*s).id) {
|
||||
// dirty.erase(s);
|
||||
// s--;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
cout << (*s).name << endl;
|
||||
}
|
||||
substitutions.clear();
|
||||
_snapshot->set_route_states(dirty);
|
||||
_snapshot->recall();
|
||||
_snapshot->set_route_states(clean);
|
||||
close_self();
|
||||
}
|
||||
// for(vector<MixerSnapshot::State>::iterator s = dirty.begin(); s != dirty.end(); s++) {
|
||||
// cout << (*s).name << endl;
|
||||
// }
|
||||
// substitutions.clear();
|
||||
// _snapshot->set_route_states(dirty);
|
||||
// _snapshot->recall();
|
||||
// _snapshot->set_route_states(clean);
|
||||
// close_self();
|
||||
// }
|
||||
|
||||
bool MixerSnapshotSubstitutionDialog::state_exists(const string name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,11 +33,16 @@ class MixerSnapshotSubstitutionDialog : public ArdourDialog
|
|||
{
|
||||
public:
|
||||
MixerSnapshotSubstitutionDialog(ARDOUR::MixerSnapshot*);
|
||||
ARDOUR::MixerSnapshot* get_snapshot() { return _snapshot;};
|
||||
void set_snapshot(ARDOUR::MixerSnapshot* new_snapshot) {_snapshot = new_snapshot;};
|
||||
|
||||
std::vector<route_combo> get_substitutions() {return substitutions;};
|
||||
void clear_substitutions() {substitutions.clear();};
|
||||
|
||||
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);
|
||||
void on_response(int);
|
||||
|
||||
std::vector<route_combo> substitutions;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,15 +44,13 @@
|
|||
#include "ardour_ui.h"
|
||||
#include "editor.h"
|
||||
#include "utils.h"
|
||||
#include "mixer_snapshots.h"
|
||||
#include "gui_thread.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
#include "pbd/basename.h"
|
||||
#include "pbd/gstdio_compat.h"
|
||||
|
||||
#include "mixer_snapshots.h"
|
||||
|
||||
#include "gui_thread.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace PBD;
|
||||
using namespace Gtk;
|
||||
|
|
@ -237,13 +235,110 @@ bool MixerSnapshotList::button_press (GdkEventButton* ev)
|
|||
|
||||
if (iter) {
|
||||
MixerSnapshot* snapshot = (*iter)[_columns.snapshot];
|
||||
snapshot->recall();
|
||||
|
||||
MixerSnapshotSubstitutionDialog* sub_dialog = new MixerSnapshotSubstitutionDialog(snapshot);
|
||||
sub_dialog->signal_response().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotList::substitution_dialog_response), sub_dialog));
|
||||
sub_dialog->show_all();
|
||||
sub_dialog->set_position(WIN_POS_MOUSE);
|
||||
sub_dialog->present();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MixerSnapshotList::substitution_dialog_response(int response, MixerSnapshotSubstitutionDialog* dialog)
|
||||
{
|
||||
if(!dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(response != RESPONSE_ACCEPT) {
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
|
||||
MixerSnapshot* snapshot = dialog->get_snapshot();
|
||||
if(!snapshot) {
|
||||
delete dialog;
|
||||
return;
|
||||
}
|
||||
|
||||
vector<MixerSnapshot::State> clean = snapshot->get_routes();
|
||||
vector<MixerSnapshot::State> dirty;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//DEBUG OUTPUT
|
||||
printf("\nDirty States ------------------------------------------\n");
|
||||
for(vector<MixerSnapshot::State>::const_iterator i = dirty.begin(); i != dirty.end(); i++) {
|
||||
string name;
|
||||
(*i).node.get_property(X_("name"), name);
|
||||
printf("\nState {id:%s, name:%s, node:%s}\n", (*i).id.c_str(), (*i).name.c_str(), name.c_str());
|
||||
}
|
||||
printf("\n-------------------------------------------------------\n");
|
||||
|
||||
//this needs to be called to drop it's shared route ptrs
|
||||
pairs.clear();
|
||||
dialog->clear_substitutions();
|
||||
delete dialog;
|
||||
|
||||
//swap the vectors Indiana Jones style and then recall
|
||||
snapshot->set_route_states(dirty);
|
||||
snapshot->recall();
|
||||
snapshot->set_route_states(clean);
|
||||
}
|
||||
|
||||
|
||||
/* Pop up the snapshot display context menu.
|
||||
* @param button Button used to open the menu.
|
||||
|
|
@ -326,7 +421,7 @@ void MixerSnapshotList::rename_snapshot(TreeModel::iterator& iter)
|
|||
if(jter) {
|
||||
const string name = (*jter)[_columns.name];
|
||||
const string prompt = string_compose(
|
||||
_("Do you really want to overwrite snapshot \"%1\" ?\n(this cannot be undone)"),
|
||||
_("Do you really want to overwrite snapshot \"%1\" ?\n(this cannot be undone)"),
|
||||
name
|
||||
);
|
||||
|
||||
|
|
@ -362,9 +457,9 @@ void MixerSnapshotList::promote_snapshot(TreeModel::iterator& iter)
|
|||
//let the user know that this was successful.
|
||||
if(_session->snapshot_manager().promote(snapshot)) {
|
||||
const string label = snapshot->get_label();
|
||||
|
||||
|
||||
const string notification = string_compose(
|
||||
_("Snapshot \"%1\" is now available to all sessions.\n"),
|
||||
_("Snapshot \"%1\" is now available to all sessions.\n"),
|
||||
label
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <sigc++/trackable.h>
|
||||
|
||||
#include "mixer_snapshot_substitution_dialog.h"
|
||||
|
||||
#include "ardour/mixer_snapshot.h"
|
||||
#include "ardour/mixer_snapshot_manager.h"
|
||||
|
||||
|
|
@ -98,6 +100,8 @@ private:
|
|||
bool _bug_user;
|
||||
bool _global;
|
||||
|
||||
void substitution_dialog_response(int, MixerSnapshotSubstitutionDialog*);
|
||||
|
||||
bool button_press (GdkEventButton *);
|
||||
void selection_changed ();
|
||||
void popup_context_menu (int, int32_t, Gtk::TreeModel::iterator&);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ class LIBARDOUR_API MixerSnapshot
|
|||
);
|
||||
};
|
||||
|
||||
MixerSnapshot::State get_route_state_by_name(const std::string&);
|
||||
bool route_state_exists(const std::string&);
|
||||
|
||||
std::vector<State> get_routes() {return route_states;};
|
||||
std::vector<State> get_groups() {return group_states;};
|
||||
std::vector<State> get_vcas() {return vca_states;};
|
||||
|
|
|
|||
|
|
@ -689,3 +689,29 @@ XMLNode& MixerSnapshot::sanitize_node(XMLNode& node)
|
|||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
MixerSnapshot::State MixerSnapshot::get_route_state_by_name(const string& name)
|
||||
{
|
||||
State route_state {string(), string(), XMLNode("")};
|
||||
for(vector<MixerSnapshot::State>::iterator i = route_states.begin(); i != route_states.end(); i++) {
|
||||
const string state_name = (*i).name;
|
||||
if(state_name == name) {
|
||||
route_state.id = (*i).id;
|
||||
route_state.name = state_name;
|
||||
route_state.node = (*i).node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return route_state;
|
||||
}
|
||||
|
||||
bool MixerSnapshot::route_state_exists(const string& name)
|
||||
{
|
||||
for(vector<MixerSnapshot::State>::iterator i = route_states.begin(); i != route_states.end(); i++) {
|
||||
const string state_name = (*i).name;
|
||||
if(state_name == name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue