Allow to override region lock, and derive properties

This is required when adding locked regions to a playlist.
e.g. after a split or partition operation. It is only supposed
to be used from Playlist::add_region_internal() and
Playlist::partition_internal().
This commit is contained in:
Robin Gareus 2022-10-06 19:47:58 +02:00
parent ebf59d4426
commit 2f810ad34e
2 changed files with 61 additions and 26 deletions

View File

@ -61,7 +61,7 @@ namespace Properties {
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> right_of_split;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> hidden;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> position_locked;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> valid_transients;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> valid_transients; // used for signal only
LIBARDOUR_API extern PBD::PropertyDescriptor<timepos_t> start;
LIBARDOUR_API extern PBD::PropertyDescriptor<timecnt_t> length;
LIBARDOUR_API extern PBD::PropertyDescriptor<timepos_t> sync_position;
@ -71,8 +71,8 @@ namespace Properties {
LIBARDOUR_API extern PBD::PropertyDescriptor<float> stretch;
LIBARDOUR_API extern PBD::PropertyDescriptor<float> shift;
LIBARDOUR_API extern PBD::PropertyDescriptor<uint64_t> layering_index;
LIBARDOUR_API extern PBD::PropertyDescriptor<std::string> tags;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> contents; // type doesn't matter here
LIBARDOUR_API extern PBD::PropertyDescriptor<std::string> tags;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> contents; // type doesn't matter here, used for signal only
};
class Playlist;
@ -107,6 +107,8 @@ public:
/** Note: changing the name of a Region does not constitute an edit */
bool set_name (const std::string& str);
PBD::PropertyList derive_properties (bool with_times = true) const;
const DataType& data_type () const { return _type; }
Temporal::TimeDomain time_domain() const;
@ -261,7 +263,6 @@ public:
void cut_front (timepos_t const & new_position);
void cut_end (timepos_t const & new_position);
void set_layer (layer_t l); /* ONLY Playlist can call this */
void raise ();
void lower ();
void raise_to_top ();
@ -278,6 +279,13 @@ public:
void set_video_locked (bool yn);
void set_position_locked (bool yn);
/* ONLY Playlist can call this */
void set_layer (layer_t l);
void set_length_unchecked (timecnt_t const &);
void set_position_unchecked (timepos_t const &);
void modify_front_unchecked (timepos_t const & new_position, bool reset_fade);
void modify_end_unchecked (timepos_t const & new_position, bool reset_fade);
Temporal::timepos_t region_beats_to_absolute_time(Temporal::Beats beats) const;
/** Convert a timestamp in beats into timepos_t (both relative to region position) */
Temporal::timepos_t region_beats_to_region_time (Temporal::Beats beats) const {
@ -499,8 +507,6 @@ private:
void mid_thaw (const PBD::PropertyChange&);
void trim_to_internal (timepos_t const & position, timecnt_t const & length);
void modify_front (timepos_t const & new_position, bool reset_fade);
void modify_end (timepos_t const & new_position, bool reset_fade);
void maybe_uncopy ();

View File

@ -455,8 +455,17 @@ Region::set_length (timecnt_t const & len)
if (locked()) {
return;
}
if (_length == len) {
return;
}
if (_length == len || len.is_zero ()) {
set_length_unchecked (len);
}
void
Region::set_length_unchecked (timecnt_t const & len)
{
if (len.is_zero ()) {
return;
}
@ -474,7 +483,6 @@ Region::set_length (timecnt_t const & len)
return;
}
set_length_internal (l);
_whole_file = false;
first_edit ();
@ -644,7 +652,12 @@ Region::set_position (timepos_t const & pos)
if (!can_move()) {
return;
}
set_position_unchecked (pos);
}
void
Region::set_position_unchecked (timepos_t const & pos)
{
set_position_internal (pos);
/* do this even if the position is the same. this helps out
@ -840,28 +853,33 @@ Region::move_start (timecnt_t const & distance)
void
Region::trim_front (timepos_t const & new_position)
{
modify_front (new_position, false);
if (locked()) {
return;
}
modify_front_unchecked (new_position, false);
}
void
Region::cut_front (timepos_t const & new_position)
{
modify_front (new_position, true);
if (locked()) {
return;
}
modify_front_unchecked (new_position, true);
}
void
Region::cut_end (timepos_t const & new_endpoint)
{
modify_end (new_endpoint, true);
}
void
Region::modify_front (timepos_t const & new_position, bool reset_fade)
{
if (locked()) {
return;
}
modify_end_unchecked (new_endpoint, true);
}
void
Region::modify_front_unchecked (timepos_t const & new_position, bool reset_fade)
{
timepos_t last = end().decrement();
timepos_t source_zero;
@ -902,12 +920,8 @@ Region::modify_front (timepos_t const & new_position, bool reset_fade)
}
void
Region::modify_end (timepos_t const & new_endpoint, bool reset_fade)
Region::modify_end_unchecked (timepos_t const & new_endpoint, bool reset_fade)
{
if (locked()) {
return;
}
if (new_endpoint > position()) {
trim_to_internal (position(), position().distance (new_endpoint));
if (reset_fade) {
@ -925,7 +939,10 @@ Region::modify_end (timepos_t const & new_endpoint, bool reset_fade)
void
Region::trim_end (timepos_t const & new_endpoint)
{
modify_end (new_endpoint, false);
if (locked()) {
return;
}
modify_end_unchecked (new_endpoint, false);
}
void
@ -948,10 +965,6 @@ Region::trim_to_internal (timepos_t const & pos, timecnt_t const & len)
{
timepos_t new_start (len.time_domain());
if (locked()) {
return;
}
timecnt_t const start_shift = position().distance (pos);
if (start_shift.is_positive()) {
@ -1400,6 +1413,22 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang
return 0;
}
PropertyList
Region::derive_properties (bool with_times) const
{
PropertyList plist (properties ());
plist.remove (Properties::automatic);
plist.remove (Properties::sync_marked);
plist.remove (Properties::left_of_split);
plist.remove (Properties::valid_transients);
plist.remove (Properties::whole_file);
if (!with_times) {
plist.remove (Properties::start);
plist.remove (Properties::length);
}
return plist;
}
void
Region::suspend_property_changes ()
{