summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/automation_line.cc22
-rw-r--r--gtk2_ardour/automation_line.h2
-rw-r--r--gtk2_ardour/editor_drag.cc8
3 files changed, 17 insertions, 15 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index b304dcf2d4..03df016adf 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -237,7 +237,9 @@ AutomationLine::modify_point_y (ControlPoint& cp, double y)
trackview.editor().session()->set_dirty ();
}
-
+/** Move a view point to a new position (without changing the model)
+ * @param y New y position as a normalised fraction (0.0-1.0)
+ */
void
AutomationLine::modify_view_point (ControlPoint& cp, double x, double y, bool keep_x, bool with_push)
{
@@ -245,10 +247,6 @@ AutomationLine::modify_view_point (ControlPoint& cp, double x, double y, bool ke
uint32_t last_movable = UINT_MAX;
double x_limit = DBL_MAX;
- /* this just changes the current view. it does not alter
- the model in any way at all.
- */
-
/* clamp y-coord appropriately. y is supposed to be a normalized fraction (0.0-1.0),
and needs to be converted to a canvas unit distance.
*/
@@ -769,16 +767,13 @@ AutomationLine::start_drag_common (nframes_t x, float fraction)
/** Should be called to indicate motion during a drag.
* @param x New x position of the drag in frames, or 0 if x is being ignored.
* @param fraction New y fraction.
+ * @return x position and y fraction that were actually used (once clamped).
*/
-void
+pair<nframes_t, float>
AutomationLine::drag_motion (nframes_t x, float fraction, bool with_push)
{
int64_t const dx = x - drag_x;
- drag_distance += dx;
- drag_x = x;
-
double dy = fraction - _last_drag_fraction;
- _last_drag_fraction = fraction;
/* clamp y so that the "lowest" point hits the bottom but goes no further
and similarly with the "highest" and the top
@@ -793,6 +788,11 @@ AutomationLine::drag_motion (nframes_t x, float fraction, bool with_push)
}
}
+ pair<nframes_t, float> const clamped (drag_x + dx, _last_drag_fraction + dy);
+ drag_distance += dx;
+ drag_x += dx;
+ _last_drag_fraction += dy;
+
for (list<ControlPoint*>::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) {
modify_view_point (
@@ -810,6 +810,8 @@ AutomationLine::drag_motion (nframes_t x, float fraction, bool with_push)
_drag_had_movement = true;
did_push = with_push;
+
+ return clamped;
}
/** Should be called to indicate the end of a drag */
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index a4b0013d37..7f33481e55 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -78,7 +78,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
virtual void start_drag_single (ControlPoint*, nframes_t x, float);
virtual void start_drag_line (uint32_t, uint32_t, float);
virtual void start_drag_multiple (std::list<ControlPoint*>, float, XMLNode *);
- virtual void drag_motion (nframes_t, float, bool);
+ virtual std::pair<nframes_t, float> drag_motion (nframes_t, float, bool);
virtual void end_drag ();
ControlPoint* nth (uint32_t);
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 569f62cc78..66932e4097 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -2679,9 +2679,9 @@ ControlPointDrag::motion (GdkEvent* event, bool)
bool const push = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
- _point->line().drag_motion (cx_frames, fraction, push);
+ pair<nframes_t, float> const c = _point->line().drag_motion (cx_frames, fraction, push);
- _editor->set_verbose_canvas_cursor_text (_point->line().get_verbose_cursor_string (fraction));
+ _editor->set_verbose_canvas_cursor_text (_point->line().get_verbose_cursor_string (c.second));
}
void
@@ -2797,9 +2797,9 @@ LineDrag::motion (GdkEvent* event, bool)
}
/* we are ignoring x position for this drag, so we can just pass in 0 */
- _line->drag_motion (0, fraction, push);
+ pair<nframes_t, float> const c = _line->drag_motion (0, fraction, push);
- _editor->set_verbose_canvas_cursor_text (_line->get_verbose_cursor_string (fraction));
+ _editor->set_verbose_canvas_cursor_text (_line->get_verbose_cursor_string (c.second));
}
void