summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-12 01:14:21 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-12 01:14:21 +0000
commit72d9f9df468981dc06536a51db8f92b79d429c58 (patch)
tree3bd92133a8b3cecfed8729022baf8b779e60f6b6 /libs
parente19ff50c2c37a0a68b0e3a99a5ff7c894d601a5f (diff)
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
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h1
-rw-r--r--libs/ardour/playlist.cc38
2 files changed, 33 insertions, 6 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 9e30130d75..4848573f1e 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -103,6 +103,7 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
boost::shared_ptr<Playlist> copy (list<AudioRange>&, bool result_is_hidden = true);
int paste (boost::shared_ptr<Playlist>, nframes_t position, float times);
+ uint32_t count_regions_at (nframes_t frame);
RegionList* regions_at (nframes_t frame);
RegionList* regions_touched (nframes_t start, nframes_t end);
RegionList* regions_to_read (nframes_t start, nframes_t end);
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 <pbd/stl_delete.h>
#include <pbd/xml++.h>
#include <pbd/stacktrace.h>
+#include <pbd/memento_command.h>
#include <ardour/playlist.h>
#include <ardour/session.h>
@@ -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<Region>
Playlist::top_region_at (nframes_t frame)
@@ -1989,10 +2005,10 @@ Playlist::relayer ()
void
Playlist::raise_region (boost::shared_ptr<Region> 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> 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<Region>
list<LayerInfo> layerinfo;
layer_t dest;
+ _session.begin_reversible_command (_("change region layer"));
+
+ XMLNode& before (get_state());
+
{
RegionLock rlock (const_cast<Playlist *> (this));
@@ -2130,7 +2150,13 @@ Playlist::move_region_to_layer (layer_t target_layer, boost::shared_ptr<Region>
check_dependents (region, false);
#endif
-
+
+ XMLNode& after (get_state());
+
+ _session.add_command (new MementoCommand<Playlist>(*this, &before, &after));
+
+ _session.commit_reversible_command ();
+
return 0;
}