replace gross in array with vector instead

This commit is contained in:
Nikolaus Gullotta 2019-04-12 11:42:52 -05:00 committed by Nikolaus Gullotta
parent 40e5ad4e72
commit 645e53d796
No known key found for this signature in database
GPG key ID: 565F60578092AA31
3 changed files with 28 additions and 49 deletions

View file

@ -65,8 +65,8 @@ MixerSnapshotDialog::MixerSnapshotDialog(Session* s)
global_model = Gtk::ListStore::create(_columns);
local_model = Gtk::ListStore::create(_columns);
bootstrap_display_and_model(global_display, global_model, true);
bootstrap_display_and_model(local_display, local_model, false);
bootstrap_display_and_model(global_display, global_scroller, global_model, true);
bootstrap_display_and_model(local_display, local_scroller, local_model, false);
add(top_level_view_box);
@ -82,7 +82,7 @@ MixerSnapshotDialog::MixerSnapshotDialog(Session* s)
global_display.signal_button_press_event().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::button_press), true), false);
local_display.signal_button_press_event().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::button_press), false), false);
signal_show().connect(sigc::mem_fun(*this, &MixerSnapshotDialog::window_opened));
// signal_show().connect(sigc::mem_fun(*this, &MixerSnapshotDialog::window_opened));
set_session(s);
}
@ -242,7 +242,7 @@ void MixerSnapshotDialog::rename_snapshot(const string old_path)
}
}
bool MixerSnapshotDialog::bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<string>& display, Glib::RefPtr<ListStore> model, bool global)
bool MixerSnapshotDialog::bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<string>& display, Gtk::ScrolledWindow& scroller, Glib::RefPtr<ListStore> model, bool global)
{
if(!model) {
return false;
@ -262,10 +262,12 @@ bool MixerSnapshotDialog::bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<str
//newest snaps should be at the top
model->set_sort_column(6, SORT_DESCENDING);
//new stuff - see TODO
//flag setting columns
//dumb work around because we're doing an ifdef MIXBUS here
int col_count[] = {
/* dumb work around here because we're doing an #ifdef MIXBUS -
Basically, append_column() returns the no. of columns *after*
appending, we can just put this in a vector and use it later */
vector<int> column_counts {
#ifdef MIXBUS
display.append_column(_("EQ"), _columns.recall_eq),
display.append_column(_("Comp"), _columns.recall_comp),
@ -275,10 +277,8 @@ bool MixerSnapshotDialog::bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<str
display.append_column(_("VCAs"), _columns.recall_vcas),
};
// TODO make this a vector
int col_count_size = (sizeof(col_count)/sizeof(*col_count));
for(int i = 0; i < col_count_size; i++) {
int index = col_count[i] - 1; //the actual count at the time of appending
for(vector<int>::iterator i = column_counts.begin(); i != column_counts.end(); i++) {
int index = (*i) - 1; //the actual index at the time of appending
CellRendererToggle* cell = dynamic_cast<CellRendererToggle*>(display.get_column_cell_renderer(index));
string col_title = display.get_column(index)->get_title();
cell->property_activatable() = true;
@ -309,33 +309,18 @@ bool MixerSnapshotDialog::bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<str
vbox->pack_start(*add_remove);
vbox->set_size_request(800, -1);
if(global) {
btn_add->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snapshot), true));
btn_new->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snap_from_session), true));
btn_add->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snapshot), global));
btn_new->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snap_from_session), global));
global_scroller.set_border_width(10);
global_scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
global_scroller.add(global_display);
scroller.set_border_width(10);
scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
scroller.add(display);
Table* table = manage(new Table(3, 3));
table->set_size_request(-1, 400);
table->attach(global_scroller, 0, 3, 0, 5 );
table->attach(*vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5);
top_level_view_box.pack_start(*table);
} else {
btn_add->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snapshot), false));
btn_new->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &MixerSnapshotDialog::new_snap_from_session), false));
local_scroller.set_border_width(10);
local_scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
local_scroller.add(local_display);
Table* table = manage(new Table(3, 3));
table->set_size_request(-1, 400);
table->attach(local_scroller, 0, 3, 0, 5 );
table->attach(*vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5);
top_level_view_box.pack_start(*table);
}
Table* table = manage(new Table(3, 3));
table->set_size_request(-1, 400);
table->attach(scroller, 0, 3, 0, 5 );
table->attach(*vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5);
top_level_view_box.pack_start(*table);
ColumnInfo ci[] = {
{ 0, 0, ALIGN_CENTER, _("Favorite"), _("") },

View file

@ -58,7 +58,7 @@ class MixerSnapshotDialog : public ArdourWindow
void rename_snapshot(const std::string);
void remove_snapshot(const std::string);
bool bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<std::string>&, Glib::RefPtr<Gtk::ListStore>, bool);
bool bootstrap_display_and_model(Gtkmm2ext::DnDTreeView<std::string>&, Gtk::ScrolledWindow&, Glib::RefPtr<Gtk::ListStore>, bool);
void popup_context_menu(int, int64_t, std::string);
bool button_press(GdkEventButton*, bool);

View file

@ -47,7 +47,6 @@ namespace PBD {
using namespace std;
using namespace ARDOUR;
MixerSnapshot::MixerSnapshot(Session* s)
: id(0)
, favorite(false)
@ -115,7 +114,6 @@ void MixerSnapshot::set_recall_io(bool yn) { set_flag(yn, RecallIO);};
void MixerSnapshot::set_recall_group(bool yn) { set_flag(yn, RecallGroup);};
void MixerSnapshot::set_recall_vca(bool yn) { set_flag(yn, RecallVCA);};
bool MixerSnapshot::has_specials()
{
if(empty()) {
@ -305,7 +303,7 @@ void MixerSnapshot::recall()
//vcas
for(vector<State>::const_iterator i = vca_states.begin(); i != vca_states.end(); i++) {
if(!get_recall_vca()) {
continue;
break;
}
State state = (*i);
@ -346,7 +344,7 @@ void MixerSnapshot::recall()
//groups
for(vector<State>::const_iterator i = group_states.begin(); i != group_states.end(); i++) {
if(!get_recall_group()) {
continue;
break;
}
State state = (*i);
@ -377,9 +375,6 @@ void MixerSnapshot::write(const string path)
node->set_property(X_("modified-with"), last_modified_with);
XMLNode* child;
// child = node->add_child ("ProgramVersion");
// child->set_property("modified-with", last_modified_with);
child = node->add_child("Routes");
for(vector<State>::iterator i = route_states.begin(); i != route_states.end(); i++) {
child->add_child_copy((*i).node);
@ -421,9 +416,9 @@ void MixerSnapshot::load(const string path)
root->get_property(X_("modified-with"), last_modified_with);
set_favorite(atoi(fav.c_str()));
XMLNode* route_node = find_named_node(*root, "Routes");
XMLNode* group_node = find_named_node(*root, "Groups");
XMLNode* vca_node = find_named_node(*root, "VCAS");
XMLNode* route_node = find_named_node(*root, "Routes");
XMLNode* group_node = find_named_node(*root, "Groups");
XMLNode* vca_node = find_named_node(*root, "VCAS");
if(route_node) {
XMLNodeList nlist = route_node->children();
@ -494,6 +489,7 @@ void MixerSnapshot::load_from_session(string path)
XMLNode& MixerSnapshot::sanitize_node(XMLNode& node)
{
vector<string> procs {"PRE"};
#ifndef MIXBUS
procs.push_back("EQ");
procs.push_back("Comp");
@ -504,7 +500,6 @@ XMLNode& MixerSnapshot::sanitize_node(XMLNode& node)
const string prop_name = "name";
for(vector<string>::const_iterator it = procs.begin(); it != procs.end(); it++) {
cout << (*it) << endl;
node.remove_node_and_delete(node_name, prop_name, (*it));
}
@ -544,7 +539,6 @@ XMLNode& MixerSnapshot::sanitize_node(XMLNode& node)
#endif
if(!get_recall_io()) {
cout << "removing IO node" << endl;
node.remove_node_and_delete("IO", "direction", "Input");
node.remove_node_and_delete("IO", "direction", "Output");
}