13
0

control point drag: fix the way bounding-to-region is computed

This commit is contained in:
Paul Davis 2023-02-06 20:52:53 -07:00
parent 2de76147d2
commit e883c39e7a
3 changed files with 16 additions and 5 deletions

View File

@ -539,8 +539,13 @@ AutomationLine::ContiguousControlPoints::clamp_dx (double dx)
} }
tx = cp->get_x() + dx; // new possible position if we just add the motion tx = cp->get_x() + dx; // new possible position if we just add the motion
tx = max (tx, 0.);
tx = min (tx, region_limit);
tx = max (tx, before_x); // can't move later than following point tx = max (tx, before_x); // can't move later than following point
tx = min (tx, after_x); // can't move earlier than preceding point tx = min (tx, after_x); // can't move earlier than preceding point
return tx - cp->get_x (); return tx - cp->get_x ();
} }
@ -637,8 +642,10 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool
*/ */
if (dx < 0 || ((dx > 0) && !with_push)) { if (dx < 0 || ((dx > 0) && !with_push)) {
for (vector<CCP>::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) { const timepos_t rl (maximum_time() + _offset);
dx = (*ccp)->clamp_dx (dx); double region_limit = trackview.editor().duration_to_pixels_unrounded (timecnt_t (rl, get_origin()));
for (auto const & ccp : contiguous_points){
dx = ccp->clamp_dx (dx, region_limit);
} }
} }

View File

@ -194,7 +194,7 @@ protected:
class ContiguousControlPoints : public std::list<ControlPoint*> { class ContiguousControlPoints : public std::list<ControlPoint*> {
public: public:
ContiguousControlPoints (AutomationLine& al); ContiguousControlPoints (AutomationLine& al);
double clamp_dx (double dx); double clamp_dx (double dx, double region_limit);
void move (double dx, double dvalue); void move (double dx, double dvalue);
void compute_x_bounds (PublicEditor& e); void compute_x_bounds (PublicEditor& e);
private: private:

View File

@ -4775,6 +4775,7 @@ ControlPointDrag::motion (GdkEvent* event, bool first_motion)
cy = zero_gain_y; cy = zero_gain_y;
} }
/* cx_pos is in absolute timeline units */
timepos_t cx_pos (timepos_t (pixel_to_time (cx)) + snap_delta (event->button.state)); timepos_t cx_pos (timepos_t (pixel_to_time (cx)) + snap_delta (event->button.state));
if (need_snap) { if (need_snap) {
@ -4782,7 +4783,9 @@ ControlPointDrag::motion (GdkEvent* event, bool first_motion)
} }
cx_pos.shift_earlier (snap_delta (event->button.state)); cx_pos.shift_earlier (snap_delta (event->button.state));
cx_pos = min (cx_pos, _point->line().maximum_time() + _point->line().offset());
/* total number of pixels (canvas window units) to move */
double px = _editor->time_to_pixel_unrounded (cx_pos);
float const fraction = 1.0 - (cy / _point->line().height()); float const fraction = 1.0 - (cy / _point->line().height());
@ -4791,8 +4794,9 @@ ControlPointDrag::motion (GdkEvent* event, bool first_motion)
_editor->begin_reversible_command (_("automation event move")); _editor->begin_reversible_command (_("automation event move"));
_point->line().start_drag_single (_point, _fixed_grab_x, initial_fraction); _point->line().start_drag_single (_point, _fixed_grab_x, initial_fraction);
} }
pair<float, float> result; pair<float, float> result;
result = _point->line().drag_motion (_editor->time_to_pixel_unrounded (cx_pos), fraction, false, _pushing, _final_index); result = _point->line().drag_motion (px, fraction, false, _pushing, _final_index);
show_verbose_cursor_text (_point->line().get_verbose_cursor_relative_string (result.first, result.second)); show_verbose_cursor_text (_point->line().get_verbose_cursor_relative_string (result.first, result.second));
} }