Start line drag using canvas y coords.
authornick_m <mainsbridge@gmail.com>
Thu, 29 Oct 2015 12:37:01 +0000 (23:37 +1100)
committernick_m <mainsbridge@gmail.com>
Thu, 29 Oct 2015 12:37:01 +0000 (23:37 +1100)
- fixes #5759

gtk2_ardour/editor_drag.cc

index 52d2c698bd9125e4a7b3e6bc7132e0a43ff889d2..2421706ff251b0831f998c7541a2e85882ccbe30 100644 (file)
@@ -4317,12 +4317,12 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
           origin, and ditto for y.
        */
 
-       double cx = event->button.x;
-       double cy = event->button.y;
+       double mx = event->button.x;
+       double my = event->button.y;
 
-       _line->parent_group().canvas_to_item (cx, cy);
+       _line->parent_group().canvas_to_item (mx, my);
 
-       framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->samples_per_pixel);
+       framecnt_t const frame_within_region = (framecnt_t) floor (mx * _editor->samples_per_pixel);
 
        if (!_line->control_points_adjacent (frame_within_region, _before, _after)) {
                /* no adjacent points */
@@ -4332,8 +4332,13 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
        Drag::start_grab (event, _editor->cursors()->fader);
 
        /* store grab start in parent frame */
+       double const bx = _line->nth (_before)->get_x();
+       double const ax = _line->nth (_after)->get_x();
+       double const click_ratio = (mx - bx) / (ax - bx);
+
+       double const cy = ((_line->nth (_before)->get_y() * click_ratio) + (_line->nth (_after)->get_y() * (1 - click_ratio)));
 
-       _fixed_grab_x = cx;
+       _fixed_grab_x = mx;
        _fixed_grab_y = cy;
 
        double fraction = 1.0 - (cy / _line->height());