summaryrefslogtreecommitdiff
path: root/gtk2_ardour/mixer_ui.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-04-19 15:46:47 +0000
committerCarl Hetherington <carl@carlh.net>2011-04-19 15:46:47 +0000
commit480986bb603dd4465ecc083d930b392f1ea8f1d4 (patch)
tree03041a66cd700f041dd2be65d5dfc7e80ad755ca /gtk2_ardour/mixer_ui.cc
parentac2689f6610ca19ee0cb0bf78432967a9da4c5ba (diff)
Save route group reorderings in the session file. Link changes in the mixer and editor group lists (part of #3918).
git-svn-id: svn://localhost/ardour2/branches/3.0@9377 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/mixer_ui.cc')
-rw-r--r--gtk2_ardour/mixer_ui.cc39
1 files changed, 37 insertions, 2 deletions
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index b7fa89cfe2..e2c9932a40 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -124,7 +124,8 @@ Mixer_UI::Mixer_UI ()
active_cell->property_radio() = false;
group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
-
+ /* We use this to notice drag-and-drop reorders of the group list */
+ group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
group_display_scroller.add (group_display);
@@ -224,6 +225,8 @@ Mixer_UI::Mixer_UI ()
auto_rebinding = FALSE;
+ _in_group_rebuild = false;
+
MixerStrip::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::remove_strip, this, _1), gui_context());
MonitorSection::setup_knob_images ();
@@ -487,6 +490,7 @@ Mixer_UI::set_session (Session* sess)
_session->RouteAdded.connect (_session_connections, invalidator (*this), ui_bind (&Mixer_UI::add_strip, this, _1), gui_context());
_session->route_group_added.connect (_session_connections, invalidator (*this), ui_bind (&Mixer_UI::add_route_group, this, _1), gui_context());
_session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
+ _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
_session->config.ParameterChanged.connect (_session_connections, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
@@ -1100,7 +1104,9 @@ Mixer_UI::disable_all_route_groups ()
void
Mixer_UI::route_groups_changed ()
{
- ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed)
+ ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
+
+ _in_group_rebuild = true;
/* just rebuild the while thing */
@@ -1117,6 +1123,7 @@ Mixer_UI::route_groups_changed ()
_session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
_group_tabs->set_dirty ();
+ _in_group_rebuild = false;
}
void
@@ -1244,6 +1251,33 @@ Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeMo
}
}
+/** Called when a group model row is deleted, but also when the model is
+ * reordered by a user drag-and-drop; the latter is what we are
+ * interested in here.
+ */
+void
+Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
+{
+ if (_in_group_rebuild) {
+ return;
+ }
+
+ /* Re-write the session's route group list so that the new order is preserved */
+
+ list<RouteGroup*> new_list;
+
+ Gtk::TreeModel::Children children = group_model->children();
+ for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
+ RouteGroup* g = (*i)[group_columns.group];
+ if (g) {
+ new_list.push_back (g);
+ }
+ }
+
+ _session->reorder_route_groups (new_list);
+}
+
+
void
Mixer_UI::add_route_group (RouteGroup* group)
{
@@ -1648,3 +1682,4 @@ Mixer_UI::new_track_or_bus ()
{
ARDOUR_UI::instance()->add_route (this);
}
+