summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_line.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-05-31 17:08:00 +0000
committerCarl Hetherington <carl@carlh.net>2012-05-31 17:08:00 +0000
commit411a534c38b0aa8a56623acfa36fe528f18a2bd2 (patch)
treeb838cc74374b93369acfe427e829ca35a8e805be /gtk2_ardour/automation_line.cc
parentd4af4d99e946d094e45c0463f7ba159802640478 (diff)
Handle discontiguous control point selections properly when dragging.
git-svn-id: svn://localhost/ardour2/branches/3.0@12505 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/automation_line.cc')
-rw-r--r--gtk2_ardour/automation_line.cc48
1 files changed, 28 insertions, 20 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index 7e72d3e7d4..7e8d70b8c8 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -465,7 +465,7 @@ AutomationLine::start_drag_common (double x, float fraction)
* @return x position and y fraction that were actually used (once clamped).
*/
pair<double, float>
-AutomationLine::drag_motion (double x, float fraction, bool ignore_x, bool with_push)
+AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push)
{
/* setup the points that are to be moved this time round */
list<ControlPoint*> points = _drag_points;
@@ -477,28 +477,36 @@ AutomationLine::drag_motion (double x, float fraction, bool ignore_x, bool with_
double dx = ignore_x ? 0 : (x - _drag_x);
double dy = fraction - _last_drag_fraction;
- /* find x limits */
- ControlPoint* before = 0;
- ControlPoint* after = 0;
+ for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
+ /* Find the points before and after this one on the control_points list */
+
+ ControlPoint* before = 0;
+ ControlPoint* after = 0;
+
+ ControlPoint* last = 0;
+ for (vector<ControlPoint*>::iterator j = control_points.begin(); j != control_points.end(); ++j) {
+
+ if (*j == *i) {
+ before = last;
+ vector<ControlPoint*>::iterator k = j;
+ ++k;
+ if (k != control_points.end()) {
+ after = *k;
+ }
+ break;
+ }
- for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- if ((*i)->get_x() < points.front()->get_x()) {
- before = *i;
- }
- if ((*i)->get_x() > points.back()->get_x() && after == 0) {
- after = *i;
+ last = *j;
}
- }
- double const before_x = before ? before->get_x() : 0;
- double const after_x = after ? after->get_x() : DBL_MAX;
+ /* Clamp dx for this point */
+ double const before_x = before ? before->get_x() : 0;
+ double const after_x = after ? after->get_x() : DBL_MAX;
- /* clamp x */
- for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
- if ((*i)->can_slide() && !ignore_x) {
- x = max (x, before_x);
- x = min (x, after_x);
- }
+ double tx = (*i)->get_x() + dx;
+ tx = max (tx, before_x);
+ tx = min (tx, after_x);
+ dx = tx - (*i)->get_x ();
}
/* clamp y */
@@ -514,7 +522,7 @@ AutomationLine::drag_motion (double x, float fraction, bool ignore_x, bool with_
pair<double, float> const clamped (_drag_x + dx, _last_drag_fraction + dy);
_drag_distance += dx;
- _drag_x = x;
+ _drag_x += dx;
_last_drag_fraction = fraction;
for (list<ControlPoint*>::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) {