hotfix process-graph: include internal-send -> internal return
[ardour.git] / libs / ardour / region.cc
index 1784cdbf3c1acac7cf3a64ec1299aefa4af40e77..3bd51e1f18ff229ec5bd7e5776f074f3b0686995 100644 (file)
@@ -270,6 +270,7 @@ Region::Region (boost::shared_ptr<const Region> other)
        _hidden = false;
 
        use_sources (other->_sources);
+       set_master_sources (other->_master_sources);
 
        _position_lock_style = other->_position_lock_style;
        _first_edit = other->_first_edit;
@@ -301,17 +302,6 @@ Region::Region (boost::shared_ptr<const Region> other)
                _sync_position = _start;
        }
 
-       if (Profile->get_sae()) {
-               /* reset sync point to start if its ended up
-                  outside region bounds.
-               */
-
-               if (_sync_position < _start || _sync_position >= _start + _length) {
-                       _sync_marked = false;
-                       _sync_position = _start;
-               }
-       }
-
        assert (_type == other->data_type());
 }
 
@@ -340,6 +330,7 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
        _hidden = false;
 
        use_sources (other->_sources);
+       set_master_sources (other->_master_sources);
 
        _start = other->_start + offset;
 
@@ -360,17 +351,6 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
                _sync_position = _start;
        }
 
-       if (Profile->get_sae()) {
-               /* reset sync point to start if its ended up
-                  outside region bounds.
-               */
-
-               if (_sync_position < _start || _sync_position >= _start + _length) {
-                       _sync_marked = false;
-                       _sync_position = _start;
-               }
-       }
-
        assert (_type == other->data_type());
 }
 
@@ -591,6 +571,44 @@ Region::set_position (framepos_t pos)
 
 }
 
+/** A gui may need to create a region, then place it in an initial
+ *  position determined by the user.
+ *  When this takes place within one gui operation, we have to reset
+ *  _last_position to prevent an implied move.
+ */
+void
+Region::set_initial_position (framepos_t pos)
+{
+       if (!can_move()) {
+               return;
+       }
+
+       if (_position != pos) {
+               _position = pos;
+
+               /* 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;
+               }
+
+               recompute_position_from_lock_style ();
+               /* ensure that this move doesn't cause a range move */
+               _last_position = _position;
+       }
+
+
+       /* do this even if the position is the same. this helps out
+          a GUI that has moved its representation already.
+       */
+       send_change (Properties::position);
+}
+
 void
 Region::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
 {
@@ -599,7 +617,7 @@ Region::set_position_internal (framepos_t pos, bool allow_bbt_recompute)
           e.g. Playlist::notify_region_moved doesn't use an out-of-date last_position.
        */
        _last_position = _position;
-       
+
        if (_position != pos) {
                _position = pos;
 
@@ -1138,7 +1156,7 @@ Region::state ()
        XMLNode *node = new XMLNode ("Region");
        char buf[64];
        char buf2[64];
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
        const char* fe = NULL;
 
        /* custom version of 'add_properties (*node);'
@@ -1284,6 +1302,10 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c
                }
        }
 
+       // saved property is invalid, region-transients are not saved
+       if (_transients.size() == 0){
+               _valid_transients = false;
+       }
 
        return 0;
 }
@@ -1515,7 +1537,7 @@ Region::source_length(uint32_t n) const
 }
 
 bool
-Region::verify_length (framecnt_t len)
+Region::verify_length (framecnt_t& len)
 {
        if (source() && (source()->destructive() || source()->length_mutable())) {
                return true;
@@ -1738,4 +1760,4 @@ Region::latest_possible_frame () const
 
        return _position + (minlen - _start) - 1;
 }
-       
+