summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_drag.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-08-20 22:43:10 +0000
committerCarl Hetherington <carl@carlh.net>2010-08-20 22:43:10 +0000
commit822ee79d840f20036b5729277f90e641cb0bb06f (patch)
tree404c5ce1e05c0b3fdca2473910974de5ddf9aed7 /gtk2_ardour/editor_drag.cc
parentb2bf4eee3d9ca63a34415c75e877b8c97d6b5f13 (diff)
Limit region-based automation to the edges of regions. Fixes #3201.
git-svn-id: svn://localhost/ardour2/branches/3.0@7662 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r--gtk2_ardour/editor_drag.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index d4b918adf2..1e3823961e 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -2736,12 +2736,12 @@ 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
- _time_axis_view_grab_x = _point->get_x();
- _time_axis_view_grab_y = _point->get_y();
+ _fixed_grab_x = _point->get_x();
+ _fixed_grab_y = _point->get_y();
float const fraction = 1 - (_point->get_y() / _point->line().height());
- _point->line().start_drag_single (_point, _time_axis_view_grab_x, fraction);
+ _point->line().start_drag_single (_point, _fixed_grab_x, fraction);
_editor->set_verbose_canvas_cursor (_point->line().get_verbose_cursor_string (fraction),
event->button.x + 10, event->button.y + 10);
@@ -2760,9 +2760,10 @@ ControlPointDrag::motion (GdkEvent* event, bool)
dy *= 0.1;
}
- /* coordinate in TimeAxisView's space */
- double cx = _time_axis_view_grab_x + _cumulative_x_drag + dx;
- double cy = _time_axis_view_grab_y + _cumulative_y_drag + dy;
+ /* coordinate in pixels relative to the start of the region (for region-based automation)
+ or track (for track-based automation) */
+ double cx = _fixed_grab_x + _cumulative_x_drag + dx;
+ double cy = _fixed_grab_y + _cumulative_y_drag + dy;
// calculate zero crossing point. back off by .01 to stay on the
// positive side of zero
@@ -2774,25 +2775,27 @@ ControlPointDrag::motion (GdkEvent* event, bool)
}
if (_x_constrained) {
- cx = _time_axis_view_grab_x;
+ cx = _fixed_grab_x;
}
if (_y_constrained) {
- cy = _time_axis_view_grab_y;
+ cy = _fixed_grab_y;
}
- _cumulative_x_drag = cx - _time_axis_view_grab_x;
- _cumulative_y_drag = cy - _time_axis_view_grab_y;
+ _cumulative_x_drag = cx - _fixed_grab_x;
+ _cumulative_y_drag = cy - _fixed_grab_y;
cx = max (0.0, cx);
cy = max (0.0, cy);
cy = min ((double) _point->line().height(), cy);
- nframes64_t cx_frames = _editor->unit_to_frame (cx);
-
+ framepos_t cx_frames = _editor->unit_to_frame (cx);
+
if (!_x_constrained) {
_editor->snap_to_with_modifier (cx_frames, event);
}
+ cx_frames = min (cx_frames, _point->line().maximum_time());
+
float const fraction = 1.0 - (cy / _point->line().height());
bool const push = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
@@ -2875,8 +2878,8 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
/* store grab start in parent frame */
- _time_axis_view_grab_x = cx;
- _time_axis_view_grab_y = cy;
+ _fixed_grab_x = cx;
+ _fixed_grab_y = cy;
double fraction = 1.0 - (cy / _line->height());
@@ -2897,9 +2900,9 @@ LineDrag::motion (GdkEvent* event, bool)
dy *= 0.1;
}
- double cy = _time_axis_view_grab_y + _cumulative_y_drag + dy;
+ double cy = _fixed_grab_y + _cumulative_y_drag + dy;
- _cumulative_y_drag = cy - _time_axis_view_grab_y;
+ _cumulative_y_drag = cy - _fixed_grab_y;
cy = max (0.0, cy);
cy = min ((double) _line->height(), cy);