fix typo
[ardour.git] / libs / ardour / region.cc
index 1b9793313df485b1c081c701d086fb3cab33e3f5..91196598700c02880c022c9a540d297dc9135914 100644 (file)
@@ -273,7 +273,7 @@ Region::Region (boost::shared_ptr<const Region> other)
        /* override state that may have been incorrectly inherited from the other region
         */
 
-       _position = 0;
+       _position = other->_position;
        _locked = false;
        _whole_file = false;
        _hidden = false;
@@ -284,7 +284,8 @@ Region::Region (boost::shared_ptr<const Region> other)
        _position_lock_style = other->_position_lock_style;
        _first_edit = other->_first_edit;
 
-       _start = 0; // It seems strange _start is not inherited here?
+       _start = other->_start;
+       _beat = other->_beat;
 
        /* sync pos is relative to start of file. our start-in-file is now zero,
           so set our sync position to whatever the the difference between
@@ -326,6 +327,7 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
        , _last_length (other->_last_length)
        , _last_position(other->_last_position) \
        , _first_edit (EditChangesNothing)
+       , _beat (0.0)
        , _layer (other->_layer)
 {
        register_properties ();
@@ -333,7 +335,7 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
        /* override state that may have been incorrectly inherited from the other region
         */
 
-       _position = 0;
+       _position = other->_position + offset;
        _locked = false;
        _whole_file = false;
        _hidden = false;
@@ -342,6 +344,7 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
        set_master_sources (other->_master_sources);
 
        _start = other->_start + offset;
+       _beat = _session.tempo_map().beat_at_frame (_position);
 
        /* if the other region had a distinct sync point
           set, then continue to use it as best we can.
@@ -438,7 +441,6 @@ Region::set_length (framecnt_t len)
                }
 
 
-               _last_length = _length;
                set_length_internal (len);
                _whole_file = false;
                first_edit ();
@@ -456,6 +458,7 @@ Region::set_length (framecnt_t len)
 void
 Region::set_length_internal (framecnt_t len)
 {
+       _last_length = _length;
        _length = len;
 }
 
@@ -578,7 +581,19 @@ Region::set_position (framepos_t pos)
        /* do this even if the position is the same. this helps out
           a GUI that has moved its representation already.
        */
-       send_change (Properties::position);
+       PropertyChange p_and_l;
+
+       p_and_l.add (Properties::position);
+       /* Currently length change due to position change is only implemented
+          for MidiRegion (Region has no length in beats).
+          Notify a length change regardless (its more efficient for MidiRegions),
+          and when Region has a _length_beats we will need it here anyway).
+       */
+       if (position_lock_style() == MusicTime) {
+               p_and_l.add (Properties::length);
+       }
+
+       send_change (p_and_l);
 
 }
 
@@ -632,20 +647,18 @@ Region::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
        if (_position != pos) {
                _position = pos;
 
+               if (allow_bbt_recompute) {
+                       recompute_position_from_lock_style ();
+               }
                /* check that the new _position wouldn't make the current
                   length impossible - if so, change the length.
 
                   XXX is this the right thing to do?
                */
-
                if (max_framepos - _length < _position) {
                        _last_length = _length;
                        _length = max_framepos - _position;
                }
-
-               if (allow_bbt_recompute) {
-                       recompute_position_from_lock_style ();
-               }
        }
 }
 
@@ -917,6 +930,7 @@ Region::trim_to_internal (framepos_t position, framecnt_t length)
                what_changed.add (Properties::start);
        }
 
+
        /* Set position before length, otherwise for MIDI regions this bad thing happens:
         * 1. we call set_length_internal; length in beats is computed using the region's current
         *    (soon-to-be old) position
@@ -1821,4 +1835,3 @@ Region::latest_possible_frame () const
 
        return _position + (minlen - _start) - 1;
 }
-