#include <ardour/playlist_factory.h>
#include <ardour/transient_detector.h>
+#include <boost/lexical_cast.hpp>
+
#include "i18n.h"
using namespace std;
init (hide);
first_set_state = false;
_name = nom;
-
+ _set_sort_id();
}
Playlist::Playlist (Session& sess, const XMLNode& node, bool hide)
{
init (hide);
_name = "unnamed"; /* reset by set_state */
+ _set_sort_id();
/* set state called by derived class */
}
/* GoingAway must be emitted by derived classes */
}
+void
+Playlist::_set_sort_id ()
+{
+ /*
+ Playlists are given names like <track name>.<id>
+ or <track name>.<edit group name>.<id> where id
+ is an integer. We extract the id and sort by that.
+ */
+
+ size_t dot_position = _name.find_last_of(".");
+ if (dot_position == string::npos)
+ {
+ _sort_id = 0;
+ }
+ else
+ {
+ string t = _name.substr(dot_position + 1);
+
+ try
+ {
+ _sort_id = boost::lexical_cast<int>(t);
+ }
+ catch (boost::bad_lexical_cast e)
+ {
+ _sort_id = 0;
+ }
+ }
+}
+
void
Playlist::set_name (string str)
{
}
_name = name;
+ _set_sort_id();
+
NameChanged(); /* EMIT SIGNAL */
}
new_regions.push_back (region);
/* "front" ***** */
-
+
current->freeze ();
thawlist.push_back (current);
- current->trim_end (pos2, this);
-
+ current->cut_end (pos2, this);
+
} else if (overlap == OverlapEnd) {
/*
current->freeze ();
thawlist.push_back (current);
- current->trim_end (pos2, this);
+ current->cut_end (pos2, this);
} else if (overlap == OverlapStart) {
}
}
+void
+Playlist::shift (nframes64_t at, nframes64_t distance, bool move_intersected, bool ignore_music_glue)
+{
+ RegionLock rlock (this);
+ RegionList copy (regions);
+ RegionList fixup;
+
+ for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
+
+ if ((*r)->last_frame() < at) {
+ /* too early */
+ continue;
+ }
+
+ if (at > (*r)->first_frame() && at < (*r)->last_frame()) {
+ /* intersected region */
+ if (!move_intersected) {
+ continue;
+ }
+ }
+
+ /* do not move regions glued to music time - that
+ has to be done separately.
+ */
+
+ if (!ignore_music_glue && (*r)->positional_lock_style() != Region::AudioTime) {
+ fixup.push_back (*r);
+ continue;
+ }
+
+ (*r)->set_position ((*r)->position() + distance, this);
+ }
+
+ for (RegionList::iterator r = fixup.begin(); r != fixup.end(); ++r) {
+ (*r)->recompute_position_from_lock_style ();
+ }
+}
+
+void
+Playlist::split (nframes64_t at)
+{
+ RegionLock rlock (this);
+ RegionList copy (regions);
+
+ /* use a copy since this operation can modify the region list
+ */
+
+ for (RegionList::iterator r = copy.begin(); r != copy.end(); ++r) {
+ _split_region (*r, at);
+ }
+}
+
void
Playlist::split_region (boost::shared_ptr<Region> region, nframes_t playlist_position)
{
RegionLock rl (this);
+ _split_region (region, playlist_position);
+}
+void
+Playlist::_split_region (boost::shared_ptr<Region> region, nframes_t playlist_position)
+{
if (!region->covers (playlist_position)) {
return;
}
pos = r->last_frame ();
break;
case SyncPoint:
- pos = r->adjust_to_sync (r->first_frame());
+ pos = r->sync_position ();
+ // r->adjust_to_sync (r->first_frame());
break;
}
if (prop->name() == X_("name")) {
_name = prop->value();
+ _set_sort_id();
} else if (prop->name() == X_("orig_diskstream_id")) {
_orig_diskstream_id = prop->value ();
} else if (prop->name() == X_("frozen")) {
- _frozen = (prop->value() == X_("yes"));
+ _frozen = string_is_affirmative (prop->value());
}
}
Playlist::raise_region_to_top (boost::shared_ptr<Region> region)
{
/* does nothing useful if layering mode is later=higher */
- if ((Config->get_layer_model() == MoveAddHigher) ||
- (Config->get_layer_model() == AddHigher)) {
- timestamp_layer_op (region);
- relayer ();
+ switch (Config->get_layer_model()) {
+ case LaterHigher:
+ return;
+ }
+
+ RegionList::size_type sz = regions.size();
+
+ if (region->layer() >= (sz - 1)) {
+ /* already on the top */
+ return;
}
+
+ move_region_to_layer (sz, 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)
+ */
+ timestamp_layer_op (region);
}
void
Playlist::lower_region_to_bottom (boost::shared_ptr<Region> region)
{
/* does nothing useful if layering mode is later=higher */
- if ((Config->get_layer_model() == MoveAddHigher) ||
- (Config->get_layer_model() == AddHigher)) {
- region->set_last_layer_op (0);
- relayer ();
+ switch (Config->get_layer_model()) {
+ case LaterHigher:
+ return;
}
+
+ if (region->layer() == 0) {
+ /* already on the bottom */
+ return;
+ }
+
+ move_region_to_layer (0, region, -1);
+ /* force region's last layer op to zero so that it stays at the bottom
+ when doing future relayers
+ */
+ region->set_last_layer_op (0);
}
int
void
Playlist::timestamp_layer_op (boost::shared_ptr<Region> region)
{
-// struct timeval tv;
-// gettimeofday (&tv, 0);
region->set_last_layer_op (++layer_op_counter);
}