Fix various snap issues when dragging control points (AutomationRegionView).
authornick_m <mainsbridge@gmail.com>
Sat, 15 Oct 2016 16:47:10 +0000 (03:47 +1100)
committernick_m <mainsbridge@gmail.com>
Sat, 15 Oct 2016 16:47:10 +0000 (03:47 +1100)
gtk2_ardour/automation_line.h
gtk2_ardour/editor_drag.cc

index d51e437bdd7fea04607c9524f9bed7775241860c..a6df048354d0842a5f5b594ead4e58beee8e4d81 100644 (file)
@@ -154,6 +154,7 @@ public:
        }
 
        void set_offset (ARDOUR::framecnt_t);
+       ARDOUR::framecnt_t offset () { return _offset; }
        void set_width (ARDOUR::framecnt_t);
 
        framepos_t session_position (ARDOUR::AutomationList::const_iterator) const;
index bbe0aca4280e256a15b9ac4bebbfde9696c24d12..99481f38a282cd3558e3c5e54c2fddb0b06d05ac 100644 (file)
@@ -4327,7 +4327,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
 
        // start the grab at the center of the control point so
        // the point doesn't 'jump' to the mouse after the first drag
-       _fixed_grab_x = _point->get_x();
+       _fixed_grab_x = _point->get_x() + _editor->sample_to_pixel_unrounded (_point->line().offset());
        _fixed_grab_y = _point->get_y();
 
        framepos_t pos = _editor->pixel_to_sample (_fixed_grab_x);
@@ -4385,13 +4385,12 @@ ControlPointDrag::motion (GdkEvent* event, bool first_motion)
        }
 
        framepos_t cx_frames = _editor->pixel_to_sample (cx) + snap_delta (event->button.state);
-
        if (!_x_constrained && need_snap) {
                _editor->snap_to_with_modifier (cx_frames, event);
        }
 
        cx_frames -= snap_delta (event->button.state);
-       cx_frames = min (cx_frames, _point->line().maximum_time());
+       cx_frames = min (cx_frames, _point->line().maximum_time() + _point->line().offset());
 
        float const fraction = 1.0 - (cy / _point->line().height());