summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_drag.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-07-10 15:58:09 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-07-10 15:58:09 +0000
commit43c850cdf3bdc88e624a431a7fbd42e3e85fc7d3 (patch)
tree259cb0d6b630caa5bcc0cd9ea782bf5c8f67c93b /gtk2_ardour/editor_drag.cc
parente89bdcd9ebb774294119cf349b3faaf0fa9ffd1f (diff)
cleaner version of previous commit's fix for AutomationRangeDrag y fraction computation
git-svn-id: svn://localhost/ardour2/branches/3.0@13013 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r--gtk2_ardour/editor_drag.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 8157011c5a..42af2bb9fc 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -4106,7 +4106,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView
, _nothing_to_drag (false)
{
DEBUG_TRACE (DEBUG::Drags, "New AutomationRangeDrag\n");
- track_view = atv;
+ y_origin = atv->y_position();
setup (atv->lines ());
}
@@ -4120,7 +4120,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AudioRegionView* rv, l
list<boost::shared_ptr<AutomationLine> > lines;
lines.push_back (rv->get_gain_line ());
- track_view = &rv->get_time_axis_view();
+ y_origin = rv->get_time_axis_view().y_position();
setup (lines);
}
@@ -4162,6 +4162,12 @@ AutomationRangeDrag::setup (list<boost::shared_ptr<AutomationLine> > const & lin
/* Now ::lines contains the AutomationLines that somehow overlap our drag */
}
+double
+AutomationRangeDrag::y_fraction (boost::shared_ptr<AutomationLine> line, double global_y) const
+{
+ return 1.0 - ((global_y - y_origin) / line->height());
+}
+
void
AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
@@ -4170,7 +4176,7 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
/* Get line states before we start changing things */
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
i->state = &i->line->get_state ();
- i->original_fraction = 1 - ((_drags->current_pointer_y() - track_view->y_position()) / i->line->height());
+ i->original_fraction = y_fraction (i->line, _drags->current_pointer_y());
}
if (_ranges.empty()) {
@@ -4276,7 +4282,7 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
}
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
- i->line->start_drag_multiple (i->points, 1 - ((_drags->current_pointer_y() - track_view->y_position()) / i->line->height ()), i->state);
+ i->line->start_drag_multiple (i->points, y_fraction (i->line, _drags->current_pointer_y()), i->state);
}
}
@@ -4288,7 +4294,7 @@ AutomationRangeDrag::motion (GdkEvent*, bool /*first_move*/)
}
for (list<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
- float const f = 1 - ((_drags->current_pointer_y() - track_view->y_position()) / l->line->height());
+ float const f = y_fraction (l->line, _drags->current_pointer_y());
/* we are ignoring x position for this drag, so we can just pass in anything */
l->line->drag_motion (0, f, true, false);