pending_contents_change = false;
RegionAdded (boost::weak_ptr<Region> (r)); /* EMIT SIGNAL */
ContentsChanged (); /* EMIT SIGNAL */
+
}
}
*/
}
- if (((regions_changed || pending_contents_change) && !in_set_state) || pending_layering) {
+ /* notify about contents/region changes first so that layering changes
+ * in a UI will take place on the new contents.
+ */
+
+ if (regions_changed || pending_contents_change) {
+ pending_layering = true;
+ ContentsChanged (); /* EMIT SIGNAL */
+ }
+
+ for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
+ (*s)->clear_changes ();
+ RegionAdded (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
+ }
+
+ if ((regions_changed && !in_set_state) || pending_layering) {
relayer ();
}
+
+ coalesce_and_check_crossfades (crossfade_ranges);
+
+ if (!pending_range_moves.empty ()) {
+ /* We don't need to check crossfades for these as pending_bounds has
+ already covered it.
+ */
+ RangesMoved (pending_range_moves, from_undo);
+ }
+
+ if (!pending_region_extensions.empty ()) {
+ RegionsExtended (pending_region_extensions);
+ }
- if (regions_changed || pending_contents_change) {
- pending_contents_change = false;
- ContentsChanged (); /* EMIT SIGNAL */
- }
-
- for (s = pending_adds.begin(); s != pending_adds.end(); ++s) {
- (*s)->clear_changes ();
- RegionAdded (boost::weak_ptr<Region> (*s)); /* EMIT SIGNAL */
- }
-
- coalesce_and_check_crossfades (crossfade_ranges);
-
- if (!pending_range_moves.empty ()) {
- /* We don't need to check crossfades for these as pending_bounds has
- already covered it.
- */
- RangesMoved (pending_range_moves, from_undo);
- }
-
- if (!pending_region_extensions.empty ()) {
- RegionsExtended (pending_region_extensions);
- }
-
- clear_pending ();
+ clear_pending ();
- in_flush = false;
- }
+ in_flush = false;
+}
void
Playlist::clear_pending ()
void
Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, float times)
+ {
+ duplicate(region, position, region->length(), times);
+ }
+
+/** @param gap from the beginning of the region to the next beginning */
+ void
+ Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, framecnt_t gap, float times)
{
times = fabs (times);
boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
add_region_internal (copy, pos);
set_layer (copy, DBL_MAX);
- pos += region->length();
+ pos += gap;
}
if (floor (times) != times) {
save = true;
}
+ mark_session_dirty ();
+
return save;
}
void
Playlist::set_layer (boost::shared_ptr<Region> 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 ());
Playlist::setup_layering_indices (RegionList const & regions)
{
uint64_t j = 0;
- list<Evoral::Range<framepos_t> > xf;
for (RegionList::const_iterator k = regions.begin(); k != regions.end(); ++k) {
(*k)->set_layering_index (j++);
}
}
+struct LaterHigherSort {
+ bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> 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.
*/
vector<vector<RegionList> > layers;
layers.push_back (vector<RegionList> (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) {
}
}
+ RegionFactory::CompoundAssociations& cassocs (RegionFactory::compound_associations());
+ for (RegionFactory::CompoundAssociations::iterator it = cassocs.begin(); it != cassocs.end(); ++it) {
+ /* check if region is used in a compound */
+ if (it->second == r) {
+ /* region is referenced as 'original' of a compound */
+ ++cnt;
+ break;
+ }
+ if (r->whole_file() && r->max_source_level() > 0) {
+ /* region itself ia a compound.
+ * the compound regions are not referenced -> check regions inside compound
+ */
+ const SourceList& sl = r->sources();
+ for (SourceList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
+ boost::shared_ptr<PlaylistSource> ps = boost::dynamic_pointer_cast<PlaylistSource>(*s);
+ if (!ps) continue;
+ if (ps->playlist()->region_use_count(it->first)) {
+ // break out of both loops
+ return ++cnt;
+ }
+ }
+ }
+ }
return cnt;
}
}
boost::shared_ptr<Region> original (ca->second);
+ cassocs.erase(ca);
bool modified_region;
if (i == rl.begin()) {
for (vector<boost::shared_ptr<Region> >::iterator i = originals.begin(); i != originals.end(); ++i) {
add_region ((*i), (*i)->position());
set_layer((*i), (*i)->layer());
+ if (!RegionFactory::region_by_id((*i)->id())) {
+ RegionFactory::map_add(*i);
+ }
}
in_partition = false;
continue;
}
+ // XXX i->from can be > i->to - is this right? coverage() will return OverlapNone in this case
if (Evoral::coverage (i->from, i->to, j->from, j->to) != Evoral::OverlapNone) {
i->from = min (i->from, j->from);
i->to = max (i->to, j->to);