rationalize MVC and functionality in editor route group list

git-svn-id: svn://localhost/ardour2/branches/3.0@10923 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-12-07 02:04:36 +00:00
parent 06b52150ba
commit 14b64b0710
2 changed files with 98 additions and 120 deletions

View File

@ -75,6 +75,7 @@ EditorRouteGroups::EditorRouteGroups (Editor* e)
_display.append_column (*color_column); _display.append_column (*color_column);
_display.append_column ("", _columns.text); _display.append_column ("", _columns.text);
_display.append_column ("", _columns.is_visible);
_display.append_column ("", _columns.gain); _display.append_column ("", _columns.gain);
_display.append_column ("", _columns.gain_relative); _display.append_column ("", _columns.gain_relative);
_display.append_column ("", _columns.mute); _display.append_column ("", _columns.mute);
@ -84,7 +85,6 @@ EditorRouteGroups::EditorRouteGroups (Editor* e)
_display.append_column ("", _columns.select); _display.append_column ("", _columns.select);
_display.append_column ("", _columns.edits); _display.append_column ("", _columns.edits);
_display.append_column ("", _columns.active_state); _display.append_column ("", _columns.active_state);
_display.append_column ("", _columns.is_visible);
TreeViewColumn* col; TreeViewColumn* col;
Gtk::Label* l; Gtk::Label* l;
@ -92,16 +92,16 @@ EditorRouteGroups::EditorRouteGroups (Editor* e)
ColumnInfo ci[] = { ColumnInfo ci[] = {
{ 0, _("Col"), _("Group Tab Color") }, { 0, _("Col"), _("Group Tab Color") },
{ 1, _("Name"), _("Name of Group") }, { 1, _("Name"), _("Name of Group") },
{ 2, S_("group|G"), _("Sharing Gain?") }, { 2, _("V"), _("Group is visible?") },
{ 3, S_("relative|Rel"), _("Relevative Gain Changes?") }, { 3, S_("group|G"), _("Sharing Gain?") },
{ 4, S_("mute|M"), _("Sharing Mute?") }, { 4, S_("relative|Rel"), _("Relevative Gain Changes?") },
{ 5, S_("solo|S"), _("Sharing Solo?") }, { 5, S_("mute|M"), _("Sharing Mute?") },
{ 6, _("Rec"), _("Sharing Record-enable Status?") }, { 6, S_("solo|S"), _("Sharing Solo?") },
{ 7, S_("monitoring|Mon"), _("Sharing Monitoring Choice?") }, { 7, _("Rec"), _("Sharing Record-enable Status?") },
{ 8, S_("selection|Sel"), _("Sharing Selected Status?") }, { 8, S_("monitoring|Mon"), _("Sharing Monitoring Choice?") },
{ 9, S_("editing|E"), _("Sharing Editing?") }, { 9, S_("selection|Sel"), _("Sharing Selected Status?") },
{ 10, S_("active|A"), _("Sharing Active Status?") }, { 10, S_("editing|E"), _("Sharing Editing?") },
{ 11, _("Show"), _("Group is visible?") }, { 11, S_("active|A"), _("Sharing Active Status?") },
{ -1, 0, 0 } { -1, 0, 0 }
}; };
@ -237,6 +237,7 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
int celly; int celly;
bool ret = false; bool ret = false;
Gdk::Color c; Gdk::Color c;
bool val;
bool const p = _display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly); bool const p = _display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly);
@ -261,6 +262,8 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
return true; return true;
} }
group = (*iter)[_columns.routegroup];
switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
case 0: case 0:
c = (*iter)[_columns.gdkcolor]; c = (*iter)[_columns.gdkcolor];
@ -273,8 +276,7 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
break; break;
case RESPONSE_ACCEPT: case RESPONSE_ACCEPT:
c = color_dialog.get_colorsel()->get_current_color(); c = color_dialog.get_colorsel()->get_current_color();
(*iter)[_columns.gdkcolor] = c; GroupTabs::set_group_color (group, c);
GroupTabs::set_group_color ((*iter)[_columns.routegroup], c);
ARDOUR_UI::config()->set_dirty (); ARDOUR_UI::config()->set_dirty ();
break; break;
@ -288,112 +290,86 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
break; break;
case 1: case 1:
if (Keyboard::is_edit_event (ev)) { if (Keyboard::is_edit_event (ev) && group) {
if ((iter = _model->get_iter (path))) { /* we'll be editing now ... */
if ((group = (*iter)[_columns.routegroup]) != 0) { ret = true;
ret = true;
}
}
} }
break; break;
case 2: case 2:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.is_visible];
bool gain = (*iter)[_columns.gain]; /* note subtle logic inverse here: we set the new value with
(*iter)[_columns.gain] = !gain; "val", rather than !val, because we're using ::set_hidden()
ret = true; not a (non-existent) ::set_visible() call.
} */
group->set_hidden (val, this);
ret = true;
break; break;
case 3: case 3:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.gain];
bool gain_relative = (*iter)[_columns.gain_relative]; group->set_gain (!val);
(*iter)[_columns.gain_relative] = !gain_relative; ret = true;
ret = true;
}
break; break;
case 4: case 4:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.gain_relative];
bool mute = (*iter)[_columns.mute]; group->set_relative (!val, this);
(*iter)[_columns.mute] = !mute; ret = true;
ret = true;
}
break; break;
case 5: case 5:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.mute];
bool solo = (*iter)[_columns.solo]; group->set_mute (!val);
(*iter)[_columns.solo] = !solo; ret = true;
ret = true;
}
break; break;
case 6: case 6:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.solo];
bool record = (*iter)[_columns.record]; group->set_solo (!val);
(*iter)[_columns.record] = !record; ret = true;
ret = true;
}
break; break;
case 7: case 7:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.record];
bool monitoring = (*iter)[_columns.monitoring]; group->set_recenable (!val);
(*iter)[_columns.monitoring] = !monitoring; ret = true;
ret = true;
}
break; break;
case 8: case 8:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.monitoring];
bool select = (*iter)[_columns.select]; group->set_monitoring (!val);
(*iter)[_columns.select] = !select; ret = true;
ret = true;
}
break; break;
case 9: case 9:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.select];
bool edits = (*iter)[_columns.edits]; group->set_select (!val);
(*iter)[_columns.edits] = !edits; ret = true;
ret = true;
}
break; break;
case 10: case 10:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.edits];
bool active_state = (*iter)[_columns.active_state]; group->set_edit (!val);
(*iter)[_columns.active_state] = !active_state; ret = true;
ret = true;
}
break; break;
case 11: case 11:
if ((iter = _model->get_iter (path))) { val = (*iter)[_columns.active_state];
bool is_visible = (*iter)[_columns.is_visible]; group->set_active (!val, this);
(*iter)[_columns.is_visible] = !is_visible; ret = true;
ret = true;
}
break; break;
default: default:
break; break;
} }
#ifdef GTKOSX
if (ret) {
_display.queue_draw();
}
#endif
return ret; return ret;
} }
void void
EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter) EditorRouteGroups::row_change (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter)
{ {
RouteGroup* group; RouteGroup* group;
@ -426,14 +402,12 @@ EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel
plist.add (Properties::edit, val); plist.add (Properties::edit, val);
val = (*iter)[_columns.active_state]; val = (*iter)[_columns.active_state];
plist.add (Properties::route_active, val); plist.add (Properties::route_active, val);
val = (*iter)[_columns.is_visible];
GroupTabs::set_group_color ((*iter)[_columns.routegroup], (*iter)[_columns.gdkcolor]); plist.add (Properties::hidden, !val);
group->set_hidden (!(*iter)[_columns.is_visible], this);
/* XXX set color here */
group->apply_changes (plist); group->apply_changes (plist);
GroupTabs::set_group_color ((*iter)[_columns.routegroup], (*iter)[_columns.gdkcolor]);
} }
void void
@ -507,6 +481,12 @@ EditorRouteGroups::property_changed (RouteGroup* group, const PropertyChange& ch
for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
if (group == (*iter)[_columns.routegroup]) { if (group == (*iter)[_columns.routegroup]) {
/* we could check the PropertyChange and only set
* appropriate fields. but the amount of saved by doing
* that is pretty minimal, and this is nice and simple.
*/
(*iter)[_columns.text] = group->name(); (*iter)[_columns.text] = group->name();
(*iter)[_columns.gain] = group->is_gain (); (*iter)[_columns.gain] = group->is_gain ();
(*iter)[_columns.gain_relative] = group->is_relative (); (*iter)[_columns.gain_relative] = group->is_relative ();
@ -519,15 +499,13 @@ EditorRouteGroups::property_changed (RouteGroup* group, const PropertyChange& ch
(*iter)[_columns.active_state] = group->is_route_active (); (*iter)[_columns.active_state] = group->is_route_active ();
(*iter)[_columns.is_visible] = !group->is_hidden(); (*iter)[_columns.is_visible] = !group->is_hidden();
(*iter)[_columns.gdkcolor] = GroupTabs::group_color (group); (*iter)[_columns.gdkcolor] = GroupTabs::group_color (group);
break;
} }
} }
_in_row_change = false; _in_row_change = false;
if (change.contains (Properties::name) || change.contains (Properties::color) || change.contains (Properties::active)) {
_editor->_group_tabs->set_dirty ();
}
for (TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) { for (TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) {
if ((*i)->route_group() == group) { if ((*i)->route_group() == group) {
if (group->is_hidden ()) { if (group->is_hidden ()) {

View File

@ -39,7 +39,9 @@ private:
struct Columns : public Gtk::TreeModel::ColumnRecord { struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns () { Columns () {
add (gdkcolor);
add (text); add (text);
add (is_visible);
add (gain); add (gain);
add (gain_relative); add (gain_relative);
add (mute); add (mute);
@ -49,12 +51,12 @@ private:
add (select); add (select);
add (edits); add (edits);
add (active_state); add (active_state);
add (is_visible);
add (gdkcolor);
add (routegroup); add (routegroup);
} }
Gtk::TreeModelColumn<Gdk::Color> gdkcolor;
Gtk::TreeModelColumn<std::string> text; Gtk::TreeModelColumn<std::string> text;
Gtk::TreeModelColumn<bool> is_visible;
Gtk::TreeModelColumn<bool> gain; Gtk::TreeModelColumn<bool> gain;
Gtk::TreeModelColumn<bool> gain_relative; Gtk::TreeModelColumn<bool> gain_relative;
Gtk::TreeModelColumn<bool> mute; Gtk::TreeModelColumn<bool> mute;
@ -64,8 +66,6 @@ private:
Gtk::TreeModelColumn<bool> select; Gtk::TreeModelColumn<bool> select;
Gtk::TreeModelColumn<bool> edits; Gtk::TreeModelColumn<bool> edits;
Gtk::TreeModelColumn<bool> active_state; Gtk::TreeModelColumn<bool> active_state;
Gtk::TreeModelColumn<bool> is_visible;
Gtk::TreeModelColumn<Gdk::Color> gdkcolor;
Gtk::TreeModelColumn<ARDOUR::RouteGroup*> routegroup; Gtk::TreeModelColumn<ARDOUR::RouteGroup*> routegroup;
}; };