X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fregion.cc;h=9d81cc5907830a24c5b76549f8bd49a8e5808e57;hb=f21094937a2ae7dae7929de3ed883d93ed12b66b;hp=3a31fe254c0b8447d7206b4aff0da68f65108c66;hpb=2592a320d42dd4a157ee16101c042d875d3142be;p=ardour.git diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 3a31fe254c..9d81cc5907 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -53,7 +54,6 @@ Region::Region (nframes_t start, nframes_t length, const string& name, layer_t l /* basic Region constructor */ _flags = flags; - _playlist = 0; _read_data_count = 0; _frozen = 0; pending_changed = Change (0); @@ -75,7 +75,6 @@ Region::Region (boost::shared_ptr other, nframes_t offset, nframes _frozen = 0; pending_changed = Change (0); - _playlist = 0; _read_data_count = 0; _start = other->_start + offset; @@ -99,7 +98,6 @@ Region::Region (boost::shared_ptr other) _frozen = 0; pending_changed = Change (0); - _playlist = 0; _read_data_count = 0; _first_edit = EditChangesID; @@ -125,7 +123,6 @@ Region::Region (const XMLNode& node) { _frozen = 0; pending_changed = Change (0); - _playlist = 0; _read_data_count = 0; _start = 0; _sync_position = _start; @@ -147,7 +144,7 @@ Region::~Region () } void -Region::set_playlist (Playlist* pl) +Region::set_playlist (boost::weak_ptr pl) { _playlist = pl; } @@ -205,9 +202,11 @@ Region::maybe_uncopy () void Region::first_edit () { - if (_first_edit != EditChangesNothing && _playlist) { + boost::shared_ptr pl (playlist()); - _name = _playlist->session().new_region_name (_name); + if (_first_edit != EditChangesNothing && pl) { + + _name = pl->session().new_region_name (_name); _first_edit = EditChangesNothing; send_change (NameChanged); @@ -215,10 +214,32 @@ Region::first_edit () } } +bool +Region::at_natural_position () const +{ + boost::shared_ptr pl (playlist()); + + if (!pl) { + return false; + } + + boost::shared_ptr whole_file_region = get_parent(); + + if (whole_file_region) { + if (_position == whole_file_region->position() + _start) { + return true; + } + } + + return false; +} + void Region::move_to_natural_position (void *src) { - if (!_playlist) { + boost::shared_ptr pl (playlist()); + + if (!pl) { return; } @@ -278,7 +299,11 @@ Region::set_position_on_top (nframes_t pos, void *src) _position = pos; } - _playlist->raise_region_to_top (boost::shared_ptr(this)); + boost::shared_ptr pl (playlist()); + + if (pl) { + pl->raise_region_to_top (shared_from_this ()); + } /* do this even if the position is the same. this helps out a GUI that has moved its representation already. @@ -665,42 +690,37 @@ Region::sync_position() const void Region::raise () { - if (_playlist == 0) { - return; + boost::shared_ptr pl (playlist()); + if (pl) { + pl->raise_region (shared_from_this ()); } - - _playlist->raise_region (boost::shared_ptr(this)); } void Region::lower () { - if (_playlist == 0) { - return; + boost::shared_ptr pl (playlist()); + if (pl) { + pl->lower_region (shared_from_this ()); } - - _playlist->lower_region (boost::shared_ptr(this)); } void Region::raise_to_top () { - - if (_playlist == 0) { - return; + boost::shared_ptr pl (playlist()); + if (pl) { + pl->raise_region_to_top (shared_from_this()); } - - _playlist->raise_region_to_top (boost::shared_ptr(this)); } void Region::lower_to_bottom () { - if (_playlist == 0) { - return; + boost::shared_ptr pl (playlist()); + if (pl) { + pl->lower_region_to_bottom (shared_from_this()); } - - _playlist->lower_region_to_bottom (boost::shared_ptr(this)); } void