fix up indentation caused by lack of .emacs
[ardour.git] / gtk2_ardour / automation_line.cc
index 83d77490aefeda81fe8db9770e4a5eacc59aae24..bf9bd159e76372e6e96006dfa28dc595daebbcef 100644 (file)
@@ -496,7 +496,7 @@ AutomationLine::model_representation (ControlPoint& cp, ModelRepresentation& mr)
        mr.xval = (nframes_t) floor (cp.get_x());
        mr.yval = 1.0 - (cp.get_y() / _height);
 
-        /* if xval has not changed, set it directly from the model to avoid rounding errors */
+       /* if xval has not changed, set it directly from the model to avoid rounding errors */
 
        if (mr.xval == trackview.editor.frame_to_unit((*cp.model)->when)) {
                mr.xval = (nframes_t) (*cp.model)->when;
@@ -605,6 +605,12 @@ AutomationLine::determine_visible_control_points (ALPoints& points)
 
                double tx = points[pi].x;
                double ty = points[pi].y;
+               
+               if (isnan (tx) || isnan (ty)) {
+                       warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
+                                                  _name) << endmsg;
+                       continue;
+               }
 
                /* now ensure that the control_points vector reflects the current curve
                   state, but don't plot control points too close together. also, don't
@@ -840,13 +846,29 @@ AutomationLine::line_drag (uint32_t i1, uint32_t i2, float fraction, bool with_p
        line_drag_cp1 = i1;
        line_drag_cp2 = i2;
        
+       //check if one of the control points on the line is in a selected range
+       bool range_found = false;
        ControlPoint *cp;
-
        for (uint32_t i = i1 ; i <= i2; i++) {
                cp = nth (i);
-               modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push);
+               if ( cp->selected )
+                       range_found = true;
        }
-
+       
+       if (range_found) {
+               for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+                       if ( (*i)->selected ) {
+                               modify_view_point (*(*i), trackview.editor.unit_to_frame ((*i)->get_x()), ((_height - (*i)->get_y()) /_height) + ydelta, with_push);
+                       }
+               }
+       } else {
+               ControlPoint *cp;
+               for (uint32_t i = i1 ; i <= i2; i++) {
+                       cp = nth (i);
+                       modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push);
+               }
+       }
+       
        if (line_points.size() > 1) {
                line->property_points() = line_points;
        }
@@ -1183,7 +1205,7 @@ AutomationLine::list_changed ()
 void
 AutomationLine::reset_callback (const AutomationList& events)
 {
-        ALPoints tmp_points;
+       ALPoints tmp_points;
        uint32_t npoints = events.size();
 
        if (npoints == 0) {
@@ -1198,7 +1220,7 @@ AutomationLine::reset_callback (const AutomationList& events)
        AutomationList::const_iterator ai;
 
        for (ai = events.const_begin(); ai != events.const_end(); ++ai) {
-
+               
                double translated_y = (*ai)->value;
                model_to_view_y (translated_y);