XMLNode* node = new XMLNode (X_("Selection"));
for (TrackSelection::const_iterator i = tracks.begin(); i != tracks.end(); ++i) {
- RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
+ StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (*i);
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (*i);
- if (rtv) {
- XMLNode* t = node->add_child (X_("RouteView"));
- t->set_property (X_("id"), rtv->route()->id ());
+ if (stv) {
+ XMLNode* t = node->add_child (X_("StripableView"));
+ t->set_property (X_("id"), stv->stripable()->id ());
} else if (atv) {
XMLNode* t = node->add_child (X_("AutomationView"));
- t->set_property (X_("id"), atv->parent_route()->id ());
+ t->set_property (X_("id"), atv->parent_stripable()->id ());
t->set_property (X_("parameter"), EventTypeMap::instance().to_symbol (atv->parameter ()));
}
}
- for (RegionSelection::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- XMLNode* r = node->add_child (X_("Region"));
- r->set_property (X_("id"), (*i)->region ()->id ());
+ if (!regions.empty()) {
+ XMLNode* parent = node->add_child (X_("Regions"));
+ for (RegionSelection::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+ XMLNode* r = parent->add_child (X_("Region"));
+ r->set_property (X_("id"), (*i)->region ()->id ());
+ }
}
/* midi region views have thir own internal selection. */
XMLNode* r = node->add_child (X_("ControlPoint"));
r->set_property (X_("type"), "track");
- r->set_property (X_("route-id"), atv->parent_route()->id ());
+ r->set_property (X_("route-id"), atv->parent_stripable()->id ());
r->set_property (X_("automation-list-id"), (*i)->line().the_list()->id ());
r->set_property (X_("parameter"), EventTypeMap::instance().to_symbol ((*i)->line().the_list()->parameter ()));
r->set_property (X_("view-index"), (*i)->view_index());
clear_time ();
clear_markers ();
- RegionSelection selected_regions;
-
/* NOTE: stripable/time-axis-view selection is saved/restored by
* ARDOUR::CoreSelection, not this Selection object
*/
XMLNodeList children = node.children ();
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- if ((*i)->name() == X_("Region")) {
+ if ((*i)->name() == X_("Regions")) {
+ RegionSelection selected_regions;
+ XMLNodeList children = (*i)->children ();
+ for (XMLNodeList::const_iterator ci = children.begin(); ci != children.end(); ++ci) {
+ PBD::ID id;
- if (!(*i)->get_property (X_("id"), id)) {
- assert(false);
+ if (!(*ci)->get_property (X_("id"), id)) {
+ continue;
+ }
+
+ RegionSelection rs;
+ editor->get_regionviews_by_id (id, rs);
+
+ if (!rs.empty ()) {
+ for (RegionSelection::const_iterator i = rs.begin(); i != rs.end(); ++i) {
+ selected_regions.push_back (*i);
+ }
+ } else {
+ /*
+ regionviews haven't been constructed - stash the region IDs
+ so we can identify them in Editor::region_view_added ()
+ */
+ regions.pending.push_back (id);
+ }
}
- RegionSelection rs;
- editor->get_regionviews_by_id (id, rs);
-
- if (!rs.empty ()) {
- selected_regions.insert (selected_regions.end(), rs.begin(), rs.end());
- } else {
- /*
- regionviews haven't been constructed - stash the region IDs
- so we can identify them in Editor::region_view_added ()
- */
- regions.pending.push_back (id);
+ if (!selected_regions.empty()) {
+ add (selected_regions);
}
} else if ((*i)->name() == X_("MIDINotes")) {
assert(false);
}
- RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (route_id);
+ StripableTimeAxisView* stv = editor->get_stripable_time_axis_by_id (route_id);
vector <ControlPoint *> cps;
- if (rtv) {
- boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().from_symbol (param));
+ if (stv) {
+ boost::shared_ptr<AutomationTimeAxisView> atv = stv->automation_child (EventTypeMap::instance().from_symbol (param));
if (atv) {
list<boost::shared_ptr<AutomationLine> > lines = atv->lines();
for (list<boost::shared_ptr<AutomationLine> > ::iterator li = lines.begin(); li != lines.end(); ++li) {
if (!(*i)->get_property (X_("start"), start) || !(*i)->get_property (X_("end"), end)) {
assert(false);
}
- set_preserving_all_ranges (start, end);
+
+ add (start, end);
} else if ((*i)->name() == X_("AutomationView")) {
assert (false);
}
- RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
+ StripableTimeAxisView* stv = editor->get_stripable_time_axis_by_id (id);
- if (rtv) {
- boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().from_symbol (param));
+ if (stv) {
+ boost::shared_ptr<AutomationTimeAxisView> atv = stv->automation_child (EventTypeMap::instance().from_symbol (param));
/* the automation could be for an entity that was never saved
in the session file. Don't freak out if we can't find
}
- // now add regions to selection at once
- add (selected_regions);
-
return 0;
}
void
Selection::toggle (TimeAxisView* track)
{
- if (dynamic_cast<VCATimeAxisView*> (track)) {
- return;
- }
-
TrackViewList tr;
tr.push_back (track);
toggle (tr);
void
Selection::add (TimeAxisView* track)
{
- if (dynamic_cast<VCATimeAxisView*> (track)) {
- return;
- }
-
TrackViewList tr;
tr.push_back (track);
add (tr);
void
Selection::remove (TimeAxisView* track)
{
- if (dynamic_cast<VCATimeAxisView*> (track)) {
- return;
- }
-
TrackViewList tvl;
tvl.push_back (track);
remove (tvl);
void
Selection::set (TimeAxisView* track)
{
- if (dynamic_cast<VCATimeAxisView*> (track)) {
- return;
- }
-
TrackViewList tvl;
tvl.push_back (track);
set (tvl);
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
+
+#if 1 // crazy optmization hack
+ /* check is the selection actually changed, ignore NO-OPs
+ *
+ * There are excessive calls from EditorRoutes::selection_changed():
+ * Every click calls selection_changed() even if it doesn't change.
+ * Also re-ordering tracks calls into this due to gtk's odd DnD signal
+ * messaging (row removed, re-added).
+ *
+ * Re-ordering a row results in at least 2 calls to selection_changed()
+ * without actual change. Calling selection.clear_stripables()
+ * and re-adding the same tracks every time in turn emits changed signals.
+ */
+ bool changed = false;
+ CoreSelection::StripableAutomationControls sac;
+ selection.get_stripables (sac);
+ for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
+ boost::shared_ptr<Stripable> s = (*i)->stripable ();
+ boost::shared_ptr<AutomationControl> c = (*i)->control ();
+ bool found = false;
+ for (CoreSelection::StripableAutomationControls::iterator j = sac.begin (); j != sac.end (); ++j) {
+ if (j->stripable == s && j->controllable == c) {
+ found = true;
+ sac.erase (j);
+ break;
+ }
+ }
+ if (!found) {
+ changed = true;
+ break;
+ }
+ }
+ if (!changed && sac.size() == 0) {
+ return;
+ }
+#endif
+
PresentationInfo::ChangeSuspender cs;
selection.clear_stripables ();