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
This commit is contained in:
parent
ac2689f661
commit
480986bb60
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -398,12 +398,14 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
|||
|
||||
void add_route_group (RouteGroup *);
|
||||
void remove_route_group (RouteGroup&);
|
||||
void reorder_route_groups (std::list<RouteGroup*>);
|
||||
|
||||
RouteGroup* route_group_by_name (std::string);
|
||||
RouteGroup& all_route_group() const;
|
||||
|
||||
PBD::Signal1<void,RouteGroup*> route_group_added;
|
||||
PBD::Signal0<void> route_group_removed;
|
||||
PBD::Signal0<void> route_groups_reordered;
|
||||
|
||||
void foreach_route_group (boost::function<void(RouteGroup*)> f) {
|
||||
for (std::list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
|
||||
|
|
|
@ -2298,9 +2298,21 @@ Session::remove_route_group (RouteGroup& rg)
|
|||
|
||||
route_group_removed (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Set a new order for our route groups, without adding or removing any.
|
||||
* @param groups Route group list in the new order.
|
||||
*/
|
||||
void
|
||||
Session::reorder_route_groups (list<RouteGroup*> groups)
|
||||
{
|
||||
_route_groups = groups;
|
||||
|
||||
route_groups_reordered (); /* EMIT SIGNAL */
|
||||
set_dirty ();
|
||||
}
|
||||
|
||||
|
||||
RouteGroup *
|
||||
Session::route_group_by_name (string name)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue