13
0

Rework region selection XML

Ensures that selection is restored in the same object type order
it was created in, which may some day make a difference.
This commit is contained in:
nick_m 2017-06-21 23:51:12 +10:00
parent 1d8548306b
commit 515cdb6b32
2 changed files with 32 additions and 23 deletions

View File

@ -3342,7 +3342,7 @@ Editor::separate_under_selected_regions ()
PlaylistState before;
before.playlist = playlist;
before.before = &playlist->get_state();
playlist->clear_changes ();
playlist->freeze ();
playlists.push_back(before);
}

View File

@ -1150,9 +1150,12 @@ Selection::get_state () const
}
}
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. */
@ -1225,8 +1228,6 @@ Selection::set_state (XMLNode const & node, int)
clear_time ();
clear_markers ();
RegionSelection selected_regions;
/* NOTE: stripable/time-axis-view selection is saved/restored by
* ARDOUR::CoreSelection, not this Selection object
*/
@ -1235,23 +1236,34 @@ Selection::set_state (XMLNode const & node, int)
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")) {
@ -1406,9 +1418,6 @@ Selection::set_state (XMLNode const & node, int)
}
// now add regions to selection at once
add (selected_regions);
return 0;
}