Update verbose cursor correctly when y drags are clamped.

git-svn-id: svn://localhost/ardour2/branches/3.0@6469 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-01-08 19:55:37 +00:00
parent b408ec00fa
commit c115b3d71c
3 changed files with 17 additions and 15 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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