summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-08-26 00:06:21 +0000
committerCarl Hetherington <carl@carlh.net>2009-08-26 00:06:21 +0000
commit28af0265b5867a4ad9bd35e2d98eadd7f1264693 (patch)
tree11d63ba1b446de353c4b28f6e822d0549b2f5499 /libs
parent33328b868dd29bfe80c8b4acc664358f8530bcd5 (diff)
When a track is in "stacked" mode, allow regions to be moved to different layers by dragging
and dropping. In stacked mode, the relayering by "recently added / moved etc. is higher" setting is ignored, and regions are put on the layer that they are dropped to, unless: 1. they are dropped so that they overlap another region on the same layer, in which case they are put on the layer above that one. 2. they are dropped such that they could be put on a lower layer with no audible difference, in which case they are put on the lower layer. git-svn-id: svn://localhost/ardour2/branches/3.0@5590 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h13
-rw-r--r--libs/ardour/ardour/region.h13
-rw-r--r--libs/ardour/playlist.cc34
-rw-r--r--libs/ardour/region.cc9
4 files changed, 63 insertions, 6 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index db928abab8..ffca22c725 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -159,6 +159,13 @@ class Playlist : public SessionObject,
void drop_regions ();
+ bool explicit_relayering () const {
+ return _explicit_relayering;
+ }
+ void set_explicit_relayering (bool e) {
+ _explicit_relayering = e;
+ }
+
protected:
friend class Session;
@@ -215,6 +222,12 @@ class Playlist : public SessionObject,
nframes_t freeze_length;
bool auto_partition;
+ /** true if relayering should be done using region's current layers and their `pending explicit relayer'
+ * flags; otherwise false if relayering should be done using the layer-model (most recently moved etc.)
+ * Explicit relayering is used by tracks in stacked regionview mode.
+ */
+ bool _explicit_relayering;
+
void init (bool hide);
bool holding_state () const {
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index 6a51ae75f5..c28e70bb5f 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -265,7 +265,15 @@ class Region
return 0;
}
- void invalidate_transients ();
+ void invalidate_transients ();
+
+ void set_pending_explicit_relayer (bool p) {
+ _pending_explicit_relayer = p;
+ }
+
+ bool pending_explicit_relayer () const {
+ return _pending_explicit_relayer;
+ }
protected:
friend class RegionFactory;
@@ -331,6 +339,9 @@ class Region
SourceList _sources;
/** Used when timefx are applied, so we can always use the original source */
SourceList _master_sources;
+
+ /** true if this region has had its layer explicitly set since the playlist last relayered */
+ bool _pending_explicit_relayer;
boost::weak_ptr<ARDOUR::Playlist> _playlist;
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 4202b7052f..d63b643d2d 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -60,6 +60,23 @@ struct RegionSortByLayer {
}
};
+struct RegionSortByLayerWithPending {
+ bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+
+ double p = a->layer ();
+ if (a->pending_explicit_relayer()) {
+ p += 0.5;
+ }
+
+ double q = b->layer ();
+ if (b->pending_explicit_relayer()) {
+ q += 0.5;
+ }
+
+ return p < q;
+ }
+};
+
struct RegionSortByPosition {
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
return a->position() < b->position();
@@ -246,6 +263,7 @@ Playlist::init (bool hide)
_frozen = false;
layer_op_counter = 0;
freeze_length = 0;
+ _explicit_relayering = false;
Modified.connect (mem_fun (*this, &Playlist::mark_session_dirty));
}
@@ -1981,15 +1999,23 @@ Playlist::relayer ()
RegionList copy = regions;
- /* sort according to the model */
+ /* sort according to the model and the layering mode that we're in */
+
+ if (_explicit_relayering) {
+
+ copy.sort (RegionSortByLayerWithPending ());
- if (_session.config.get_layer_model() == MoveAddHigher || _session.config.get_layer_model() == AddHigher) {
- RegionSortByLastLayerOp cmp;
- copy.sort (cmp);
+ } else if (_session.config.get_layer_model() == MoveAddHigher || _session.config.get_layer_model() == AddHigher) {
+
+ copy.sort (RegionSortByLastLayerOp ());
+
}
for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) {
+ /* reset the pending explicit relayer flag for every region, now that we're relayering */
+ (*i)->set_pending_explicit_relayer (false);
+
/* find the time divisions that this region covers */
int const start_division = floor ( ((*i)->position() - start) / division_size);
int end_division = floor ( ((*i)->position() + (*i)->length() - start) / division_size );
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 1f90a0761b..0e0df08284 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -78,6 +78,7 @@ Region::Region (Session& s, nframes_t start, nframes_t length, const string& nam
, _read_data_count(0)
, _pending_changed(Change (0))
, _last_layer_op(0)
+ , _pending_explicit_relayer (false)
{
/* no sources at this point */
}
@@ -104,7 +105,7 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length
, _read_data_count(0)
, _pending_changed(Change (0))
, _last_layer_op(0)
-
+ , _pending_explicit_relayer (false)
{
_sources.push_back (src);
_master_sources.push_back (src);
@@ -136,6 +137,7 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
, _read_data_count(0)
, _pending_changed(Change (0))
, _last_layer_op(0)
+ , _pending_explicit_relayer (false)
{
use_sources (srcs);
assert(_sources.size() > 0);
@@ -145,6 +147,7 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
: SessionObject(other->session(), name)
, _type (other->data_type())
+ , _pending_explicit_relayer (false)
{
_start = other->_start + offset;
@@ -184,6 +187,7 @@ Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes
Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
: SessionObject(other->session(), name)
, _type (other->data_type())
+ , _pending_explicit_relayer (false)
{
/* create a new Region exactly like another but starting at 0 in its sources */
@@ -256,6 +260,7 @@ Region::Region (boost::shared_ptr<const Region> other)
, _read_data_count(0)
, _pending_changed(Change(0))
, _last_layer_op(other->_last_layer_op)
+ , _pending_explicit_relayer (false)
{
_flags = Flag (_flags | DoNotSendPropertyChanges);
@@ -289,6 +294,7 @@ Region::Region (const SourceList& srcs, const XMLNode& node)
, _read_data_count(0)
, _pending_changed(Change(0))
, _last_layer_op(0)
+ , _pending_explicit_relayer (false)
{
use_sources (srcs);
@@ -318,6 +324,7 @@ Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
, _read_data_count(0)
, _pending_changed(Change(0))
, _last_layer_op(0)
+ , _pending_explicit_relayer (false)
{
_sources.push_back (src);