summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_drag.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2015-10-29 23:37:01 +1100
committernick_m <mainsbridge@gmail.com>2015-10-29 23:37:01 +1100
commit36dd7f8d9d602d5e609277e0c2cf0cd8454eac72 (patch)
tree82da0ba296cff7fe92f0772b91b85f696abbd753 /gtk2_ardour/editor_drag.cc
parentbe69dd279b51f9d8a716253d00c99ab7b08b7105 (diff)
Start line drag using canvas y coords.
- fixes #5759
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r--gtk2_ardour/editor_drag.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 52d2c698bd..2421706ff2 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -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());