non-primary music-locked regions follow tempo changes while dragging.
authornick_m <mainsbridge@gmail.com>
Mon, 30 Jan 2017 17:15:21 +0000 (04:15 +1100)
committernick_m <mainsbridge@gmail.com>
Sat, 4 Feb 2017 11:57:36 +0000 (22:57 +1100)
- the contents still don't update but position is much
          more wysiwyg.

gtk2_ardour/editor_drag.cc

index ac761dcb6cb13190ab9971d4933298677a961e2a..7624546347924e2fa60b79fa9060ab095cbd5629 100644 (file)
@@ -928,8 +928,13 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
        }
 
        /* Work out the change in x */
+       TempoMap& tmap = _editor->session()->tempo_map();
        MusicFrame pending_region_position (0, 0);
        double const x_delta = compute_x_delta (event, &pending_region_position);
+
+       double const last_pos_qn = tmap.exact_qn_at_frame (_last_position.frame, _last_position.division);
+       double const qn_delta = tmap.exact_qn_at_frame (pending_region_position.frame, pending_region_position.division) - last_pos_qn;
+
        _last_position = pending_region_position;
 
        /* calculate hidden tracks in current y-axis delta */
@@ -1173,7 +1178,14 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
                }
 
                /* Now move the region view */
-               rv->move (x_delta, y_delta);
+               if (rv->region()->position_lock_style() == MusicTime) {
+                       double const last_qn = tmap.quarter_note_at_frame (rv->get_position());
+                       framepos_t const x_pos_music = tmap.frame_at_quarter_note (last_qn + qn_delta);
+
+                       rv->set_position (x_pos_music, 0);
+               } else {
+                       rv->move (x_delta, y_delta);
+               }
 
        } /* foreach region */