X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=7e60bff2e34ffc0c98a125780eef574dea03776b;hb=4c42a77441e74356cd909d994e270d1e1314aad4;hp=7e34738001a50b6e39a6575b3830c9ab651287e8;hpb=1bff57131a2b0a88f00dfb281db6f3d73c4e8b3b;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 7e34738001..7e60bff2e3 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -507,15 +507,22 @@ AutomationLine::ContiguousControlPoints::ContiguousControlPoints (AutomationLine void AutomationLine::ContiguousControlPoints::compute_x_bounds () { - if (!empty()) { + uint32_t sz = size(); + + if (sz > 0 && sz < line.npoints()) { + /* determine the limits on x-axis motion for this contiguous range of control points */ - + if (front()->view_index() > 0) { before_x = line.nth (front()->view_index() - 1)->get_x(); } - + + /* if our last point has a point after it in the line, + we have an "after" bound + */ + if (back()->view_index() < (line.npoints() - 2)) { after_x = line.nth (back()->view_index() + 1)->get_x(); } @@ -583,13 +590,12 @@ AutomationLine::start_drag_common (double x, float fraction) * @return x position and y fraction that were actually used (once clamped). */ pair -AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push) +AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push, uint32_t& final_index) { if (_drag_points.empty()) { return pair (x,fraction); } - double dx = ignore_x ? 0 : (x - _drag_x); double dy = fraction - _last_drag_fraction; @@ -663,15 +669,19 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool (*ccp)->move (dx, dy); } if (with_push) { - uint32_t i = contiguous_points.back()->back()->view_index () + 1; + final_index = contiguous_points.back()->back()->view_index () + 1; ControlPoint* p; + uint32_t i = final_index; while ((p = nth (i)) != 0 && p->can_slide()) { p->move_to (p->get_x() + dx, p->get_y(), ControlPoint::Full); reset_line_coords (*p); ++i; } } - + + /* update actual line coordinates (will queue a redraw) + */ + if (line_points.size() > 1) { line->property_points() = line_points; } @@ -688,7 +698,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool /** Should be called to indicate the end of a drag */ void -AutomationLine::end_drag () +AutomationLine::end_drag (bool with_push, uint32_t final_index) { if (!_drag_had_movement) { return; @@ -696,6 +706,16 @@ AutomationLine::end_drag () alist->freeze (); sync_model_with_view_points (_drag_points); + + if (with_push) { + ControlPoint* p; + uint32_t i = final_index; + while ((p = nth (i)) != 0 && p->can_slide()) { + sync_model_with_view_point (*p); + ++i; + } + } + alist->thaw (); update_pending = false; @@ -821,9 +841,7 @@ AutomationLine::remove_point (ControlPoint& cp) * @param result Filled in with selectable things; in this case, ControlPoints. */ void -AutomationLine::get_selectables ( - framepos_t start, framepos_t end, double botfrac, double topfrac, list& results - ) +AutomationLine::get_selectables (framepos_t start, framepos_t end, double botfrac, double topfrac, list& results) { /* convert fractions to display coordinates with 0 at the top of the track */ double const bot_track = (1 - topfrac) * trackview.current_height ();