Update verbose cursor correctly when y drags are clamped.
authorCarl Hetherington <carl@carlh.net>
Fri, 8 Jan 2010 19:55:37 +0000 (19:55 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 8 Jan 2010 19:55:37 +0000 (19:55 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6469 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_line.cc
gtk2_ardour/automation_line.h
gtk2_ardour/editor_drag.cc

index b304dcf2d462f9b1128e2320da268ea562be0b74..03df016adf277df5d3701a4cc52231a19ddb4038 100644 (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 */
index a4b0013d3785c6aae1852690b4c9c60a66bb8b59..7f33481e55bed9722bfe07cf2e529f3db978a9a1 100644 (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);
index 569f62cc78b5cdb25d5f12cabbb0fd503a75dd18..66932e40973668e43b2ccfca351ac73eb72ed1b3 100644 (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