Ardour::Region - add method required to fix #6673.
authornick_m <mainsbridge@gmail.com>
Fri, 13 Nov 2015 16:05:53 +0000 (03:05 +1100)
committernick_m <mainsbridge@gmail.com>
Fri, 13 Nov 2015 16:05:53 +0000 (03:05 +1100)
libs/ardour/ardour/region.h
libs/ardour/region.cc

index 60999bf73aaa8c4e0228fda6e06bb1cb2a1ffc18..a8a1475fb8f7180d34bac5982da4f8c1230ed395 100644 (file)
@@ -212,6 +212,7 @@ class LIBARDOUR_API Region
        void set_length (framecnt_t);
        void set_start (framepos_t);
        void set_position (framepos_t);
+       void set_initial_position (framepos_t);
        void special_set_position (framepos_t);
        virtual void update_after_tempo_map_change ();
        void nudge_position (frameoffset_t);
index 516adb6ee593ed4cd2b6bb8bb60362122a15fb61..bd99403cb770b3e07368546f615c2092ea7ad3ef 100644 (file)
@@ -591,6 +591,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)
 {