summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_route_groups.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-07-04 13:44:01 +0000
committerCarl Hetherington <carl@carlh.net>2009-07-04 13:44:01 +0000
commit40b0b216de9df7a23cd2bbc7e257833db40cc877 (patch)
tree031a23cf89099ee11e9711b5239defe7860302e1 /gtk2_ardour/editor_route_groups.cc
parent36564e4f910bc31fa23a6e73da8440f6ad78a2fc (diff)
Add option to collect a route group, so that its member routes are reordered to be together in the editor. A few cleanups along the way.
git-svn-id: svn://localhost/ardour2/branches/3.0@5319 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_route_groups.cc')
-rw-r--r--gtk2_ardour/editor_route_groups.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_route_groups.cc b/gtk2_ardour/editor_route_groups.cc
index a9abf4889d..b459168dcb 100644
--- a/gtk2_ardour/editor_route_groups.cc
+++ b/gtk2_ardour/editor_route_groups.cc
@@ -187,6 +187,7 @@ EditorRouteGroups::menu (RouteGroup* g)
items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &EditorRouteGroups::edit), g)));
items.push_back (MenuElem (_("Fit to Window"), bind (mem_fun (*_editor, &Editor::fit_route_group), g)));
items.push_back (MenuElem (_("Subgroup"), bind (mem_fun (*this, &EditorRouteGroups::subgroup), g)));
+ items.push_back (MenuElem (_("Collect"), bind (mem_fun (*this, &EditorRouteGroups::collect), g)));
}
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &EditorRouteGroups::activate_all)));
@@ -665,4 +666,51 @@ EditorRouteGroups::connect_to_session (Session* s)
groups_changed ();
}
+/** Collect all members of a RouteGroup so that they are together in the Editor.
+ * @param g Group to collect.
+ */
+void
+EditorRouteGroups::collect (RouteGroup* g)
+{
+ list<Route*> routes = g->route_list ();
+ int const N = routes.size ();
+
+ list<Route*>::iterator i = routes.begin ();
+ Editor::TrackViewList::const_iterator j = _editor->get_track_views().begin();
+
+ int diff = 0;
+ int coll = -1;
+ while (i != routes.end() && j != _editor->get_track_views().end()) {
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
+ if (rtv) {
+
+ boost::shared_ptr<Route> r = rtv->route ();
+ int const k = r->order_key (N_ ("editor"));
+
+ if (*i == r.get()) {
+
+ if (coll == -1) {
+ coll = k;
+ diff = N - 1;
+ } else {
+ --diff;
+ }
+
+ r->set_order_key (N_ ("editor"), coll);
+
+ ++coll;
+ ++i;
+
+ } else {
+
+ r->set_order_key (N_ ("editor"), k + diff);
+
+ }
+ }
+
+ ++j;
+ }
+
+ _editor->_routes->sync_order_keys (N_ ("editor"));
+}