diff options
author | Carl Hetherington <carl@carlh.net> | 2011-04-19 15:46:47 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-04-19 15:46:47 +0000 |
commit | 480986bb603dd4465ecc083d930b392f1ea8f1d4 (patch) | |
tree | 03041a66cd700f041dd2be65d5dfc7e80ad755ca /gtk2_ardour | |
parent | ac2689f6610ca19ee0cb0bf78432967a9da4c5ba (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')
-rw-r--r-- | gtk2_ardour/editor_route_groups.cc | 46 | ||||
-rw-r--r-- | gtk2_ardour/editor_route_groups.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.cc | 39 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.h | 3 |
4 files changed, 86 insertions, 4 deletions
diff --git a/gtk2_ardour/editor_route_groups.cc b/gtk2_ardour/editor_route_groups.cc index 319c48735c..2d77eb5bd9 100644 --- a/gtk2_ardour/editor_route_groups.cc +++ b/gtk2_ardour/editor_route_groups.cc @@ -54,6 +54,7 @@ EditorRouteGroups::EditorRouteGroups (Editor* e) : EditorComponent (e) , _all_group_active_button (_("No Selection = All Tracks")) , _in_row_change (false) + , _in_rebuild (false) { _model = ListStore::create (_columns); _display.set_model (_model); @@ -126,6 +127,11 @@ EditorRouteGroups::EditorRouteGroups (Editor* e) active_cell->property_radio() = false; _model->signal_row_changed().connect (sigc::mem_fun (*this, &EditorRouteGroups::row_change)); + /* What signal would you guess was emitted when the rows of your treeview are reordered + by a drag and drop? signal_rows_reordered? That would be far too easy. + No, signal_row_deleted(). + */ + _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRouteGroups::row_deleted)); _display.set_name ("EditGroupList"); _display.get_selection()->set_mode (SELECTION_SINGLE); @@ -406,7 +412,9 @@ EditorRouteGroups::add (RouteGroup* group) void EditorRouteGroups::groups_changed () { - ENSURE_GUI_THREAD (*this, &EditorRouteGroups::groups_changed) + ENSURE_GUI_THREAD (*this, &EditorRouteGroups::groups_changed); + + _in_rebuild = true; /* just rebuild the while thing */ @@ -415,6 +423,8 @@ EditorRouteGroups::groups_changed () if (_session) { _session->foreach_route_group (sigc::mem_fun (*this, &EditorRouteGroups::add)); } + + _in_rebuild = false; } void @@ -492,7 +502,12 @@ EditorRouteGroups::set_session (Session* s) arg.PropertyChanged.connect (all_route_groups_changed_connection, MISSING_INVALIDATOR, ui_bind (&EditorRouteGroups::all_group_changed, this, _1), gui_context()); _session->route_group_added.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&EditorRouteGroups::add, this, _1), gui_context()); - _session->route_group_removed.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&EditorRouteGroups::groups_changed, this), gui_context()); + _session->route_group_removed.connect ( + _session_connections, MISSING_INVALIDATOR, boost::bind (&EditorRouteGroups::groups_changed, this), gui_context() + ); + _session->route_groups_reordered.connect ( + _session_connections, MISSING_INVALIDATOR, boost::bind (&EditorRouteGroups::groups_changed, this), gui_context() + ); } PBD::PropertyChange pc; @@ -530,3 +545,30 @@ EditorRouteGroups::all_group_changed (const PropertyChange&) } } +/** Called when a 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 +EditorRouteGroups::row_deleted (Gtk::TreeModel::Path const &) +{ + if (_in_rebuild) { + /* We need to ignore this in cases where we're not doing a drag-and-drop + re-order. + */ + return; + } + + /* Re-write the session's route group list so that the new order is preserved */ + + list<RouteGroup*> new_list; + + Gtk::TreeModel::Children children = _model->children(); + for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) { + new_list.push_back ((*i)[_columns.routegroup]); + } + + _session->reorder_route_groups (new_list); +} + + diff --git a/gtk2_ardour/editor_route_groups.h b/gtk2_ardour/editor_route_groups.h index d881655467..b6bfb6c1cf 100644 --- a/gtk2_ardour/editor_route_groups.h +++ b/gtk2_ardour/editor_route_groups.h @@ -73,6 +73,7 @@ private: void run_new_group_dialog (); void all_group_toggled(); void all_group_changed (const PBD::PropertyChange&); + void row_deleted (Gtk::TreeModel::Path const &); Glib::RefPtr<Gtk::ListStore> _model; Glib::RefPtr<Gtk::TreeSelection> _selection; @@ -81,6 +82,7 @@ private: Gtk::VBox _display_packer; Gtk::ToggleButton _all_group_active_button; bool _in_row_change; + bool _in_rebuild; PBD::ScopedConnectionList _property_changed_connections; PBD::ScopedConnection all_route_groups_changed_connection; }; 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); } + diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 391e975df1..a94226fc16 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -189,6 +189,7 @@ class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public AR void route_groups_changed (); void route_group_name_edit (const std::string&, const std::string&); void route_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter); + void route_group_row_deleted (Gtk::TreeModel::Path const &); Gtk::Menu *track_menu; void track_column_click (gint); @@ -258,6 +259,8 @@ class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public AR static const int32_t default_width = 478; static const int32_t default_height = 765; + bool _in_group_rebuild; + friend class MixerGroupTabs; }; |