From 72d9f9df468981dc06536a51db8f92b79d429c58 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 12 Nov 2009 01:14:21 +0000 Subject: JAG's new region layer editor, tweaked by me to (a) hide editor if we click in a location with just 1 region under the mouse (b) automatically update to reflect playlist modification outside of the layering editor (c) add a clock and a track name to give a bit more context to the editor git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6067 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/playlist.cc | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'libs/ardour/playlist.cc') diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 3bd4b84781..e8f51d361a 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -1371,6 +1372,21 @@ Playlist::regions_at (nframes_t frame) return find_regions_at (frame); } +uint32_t +Playlist::count_regions_at (nframes_t frame) +{ + RegionLock rlock (this); + uint32_t cnt = 0; + + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { + if ((*i)->covers (frame)) { + cnt++; + } + } + + return cnt; +} + boost::shared_ptr Playlist::top_region_at (nframes_t frame) @@ -1989,10 +2005,10 @@ Playlist::relayer () void Playlist::raise_region (boost::shared_ptr region) { - uint32_t rsz = regions.size(); + layer_t top = regions.size() - 1; layer_t target = region->layer() + 1U; - if (target >= rsz) { + if (target >= top) { /* its already at the effective top */ return; } @@ -2024,14 +2040,14 @@ Playlist::raise_region_to_top (boost::shared_ptr region) break; } - RegionList::size_type sz = regions.size(); + layer_t top = regions.size() - 1; - if (region->layer() >= (sz - 1)) { + if (region->layer() >= top) { /* already on the top */ return; } - move_region_to_layer (sz, region, 1); + move_region_to_layer (top, region, 1); /* mark the region's last_layer_op as now, so that it remains on top when doing future relayers (until something else takes over) */ @@ -2069,6 +2085,10 @@ Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr list layerinfo; layer_t dest; + _session.begin_reversible_command (_("change region layer")); + + XMLNode& before (get_state()); + { RegionLock rlock (const_cast (this)); @@ -2130,7 +2150,13 @@ Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr check_dependents (region, false); #endif - + + XMLNode& after (get_state()); + + _session.add_command (new MementoCommand(*this, &before, &after)); + + _session.commit_reversible_command (); + return 0; } -- cgit v1.2.3