Remove unused header include
[ardour.git] / gtk2_ardour / automation_line.cc
index 9840a5adae076c2a8aae3f50adeae75c5764bfac..f5d2669d0ab9b48f016fa1aef24c8744db74ed0e 100644 (file)
@@ -136,7 +136,11 @@ void
 AutomationLine::show ()
 {
        if (_visible & Line) {
-               if (alist->interpolation() != AutomationList::Discrete) {
+               /* Only show the line there are some points, otherwise we may show an out-of-date line
+                  when automation points have been removed (the line will still follow the shape of the
+                  old points).
+               */
+               if (alist->interpolation() != AutomationList::Discrete && control_points.size() >= 2) {
                        line->show();
                } else {
                        line->hide ();
@@ -246,7 +250,7 @@ AutomationLine::modify_point_y (ControlPoint& cp, double y)
        y = min (1.0, y);
        y = _height - (y * _height);
 
-       double const x = trackview.editor().frame_to_unit (_time_converter->to((*cp.model())->when) - _offset);
+       double const x = trackview.editor().frame_to_unit_unrounded (_time_converter->to((*cp.model())->when) - _offset);
 
        trackview.editor().session()->begin_reversible_command (_("automation event move"));
        trackview.editor().session()->add_command (
@@ -558,7 +562,9 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool
        }
 
        _drag_had_movement = true;
-       did_push = with_push;
+       if (with_push) {
+               did_push = with_push;
+       }
 
        return clamped;
 }
@@ -607,7 +613,7 @@ AutomationLine::sync_model_with_view_point (ControlPoint& cp, framecnt_t distanc
 
        /* if xval has not changed, set it directly from the model to avoid rounding errors */
 
-       if (view_x == trackview.editor().frame_to_unit (_time_converter->to ((*cp.model())->when)) - _offset) {
+       if (view_x == trackview.editor().frame_to_unit_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
                view_x = (*cp.model())->when - _offset;
        } else {
                view_x = trackview.editor().unit_to_frame (view_x);
@@ -619,11 +625,6 @@ AutomationLine::sync_model_with_view_point (ControlPoint& cp, framecnt_t distanc
        view_to_model_coord_y (view_y);
 
        alist->modify (cp.model(), view_x, view_y);
-
-       if (did_push) {
-               /* move all points after cp by the same distance */
-               alist->slide (cp.model()++, _time_converter->from (distance));
-       }
 }
 
 bool
@@ -633,7 +634,7 @@ AutomationLine::control_points_adjacent (double xval, uint32_t & before, uint32_
        ControlPoint *acp = 0;
        double unit_xval;
 
-       unit_xval = trackview.editor().frame_to_unit (xval);
+       unit_xval = trackview.editor().frame_to_unit_unrounded (xval);
 
        for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
 
@@ -817,7 +818,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events)
                 * zoom and scroll into account).
                 */
                        
-               tx = trackview.editor().frame_to_unit (tx);
+               tx = trackview.editor().frame_to_unit_unrounded (tx);
                
                /* convert from canonical view height (0..1.0) to actual
                 * height coordinates (using X11's top-left rooted system)