From 13f34f392248e6457d1afed010fcdcbfda890328 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sun, 10 May 2015 03:15:50 +1000 Subject: Layering - the return of "later is higher". Currently we don't do anything special on layering prefs change (relayer only occurs when each playlist is first edited). The idea here is that "undo" is still available to restore previous layering in case of any surprises. --- libs/ardour/playlist.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'libs/ardour/playlist.cc') diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index d121ee04ff..20a2ef0197 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2333,7 +2333,10 @@ struct RelayerSort { void Playlist::set_layer (boost::shared_ptr region, double new_layer) { - /* Remove the layer we are setting from our region list, and sort it */ + /* Remove the layer we are setting from our region list, and sort it + * using the layer indeces. + */ + RegionList copy = regions.rlist(); copy.remove (region); copy.sort (RelayerSort ()); @@ -2362,6 +2365,12 @@ Playlist::setup_layering_indices (RegionList const & regions) } } +struct LaterHigherSort { + bool operator () (boost::shared_ptr a, boost::shared_ptr b) { + return a->position() < b->position(); + } +}; + /** 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. */ @@ -2396,9 +2405,16 @@ Playlist::relayer () vector > layers; layers.push_back (vector (divisions)); - /* Sort our regions into layering index order */ + /* Sort our regions into layering index order (for manual layering) or position order (for later is higher)*/ RegionList copy = regions.rlist(); - copy.sort (RelayerSort ()); + switch (Config->get_layer_model()) { + case LaterHigher: + copy.sort (LaterHigherSort ()); + break; + case Manual: + copy.sort (RelayerSort ()); + break; + } DEBUG_TRACE (DEBUG::Layering, "relayer() using:\n"); for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) { -- cgit v1.2.3