summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-12-30 23:41:17 +0000
committerCarl Hetherington <carl@carlh.net>2011-12-30 23:41:17 +0000
commitb93254f27550ddffbc9d6c0f043e4e24cfe536c2 (patch)
treecb125b9640e4985f3d1a6b56c16bb44d213a9d75 /libs
parent0be530821c5afb2bb7377efdb9eb886e350d0544 (diff)
Anywhere that deletes regions needs to use a rdiff() on the playlist
for the undo history, so that changes to regions' layering_index get stored in the undo record. Make Playlist::update use add_region_internal so that undone regions don't have their layering_index corrupted. Setup layering indices on relayer() so that deletion of regions causes an update. git-svn-id: svn://localhost/ardour2/branches/3.0@11123 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h4
-rw-r--r--libs/ardour/playlist.cc19
2 files changed, 20 insertions, 3 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 67cc1ccf54..626df720bd 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -378,6 +378,10 @@ public:
with its constituent regions
*/
virtual void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
+
+private:
+
+ void setup_layering_indices (RegionList const &) const;
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index d3a461ea9e..c11e55779c 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -653,6 +653,7 @@ Playlist::flush_notifications (bool from_undo)
PLAYLIST OPERATIONS
*************************************************************/
+/** Note: this calls set_layer (..., DBL_MAX) so it will reset the layering index of region */
void
Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition)
{
@@ -2097,7 +2098,7 @@ Playlist::flush_notifications (bool from_undo)
freeze ();
/* add the added regions */
for (RegionListProperty::ChangeContainer::iterator i = change.added.begin(); i != change.added.end(); ++i) {
- add_region ((*i), (*i)->position());
+ add_region_internal ((*i), (*i)->position());
}
/* remove the removed regions */
for (RegionListProperty::ChangeContainer::iterator i = change.removed.begin(); i != change.removed.end(); ++i) {
@@ -2371,13 +2372,19 @@ Playlist::set_layer (boost::shared_ptr<Region> region, double new_layer)
copy.insert (i, region);
- /* Then re-write layering indices */
+ setup_layering_indices (copy);
+}
+
+void
+Playlist::setup_layering_indices (RegionList const & regions) const
+{
uint64_t j = 0;
- for (RegionList::iterator k = copy.begin(); k != copy.end(); ++k) {
+ for (RegionList::const_iterator k = regions.begin(); k != regions.end(); ++k) {
(*k)->set_layering_index (j++);
}
}
+
/** Take the layering indices of each of our regions, compute the layers
* that they should be on, and write the layers back to the regions.
*/
@@ -2493,6 +2500,12 @@ Playlist::relayer ()
if (changed) {
notify_layering_changed ();
}
+
+ /* This relayer() may have been called as a result of a region removal, in which
+ case we need to setup layering indices so account for the one that has just
+ gone away.
+ */
+ setup_layering_indices (copy);
}
void