summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-08 14:41:29 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-08 14:41:29 -0400
commit92bb0e0d7f79bb7745d7c02b1dcfa5ea206edf31 (patch)
tree60f932e97986739c26493f0356957fd997a5153e
parentb86e1204ec9c4b85561520dfe46e5b3bee5d85ea (diff)
fix problem with calls to Editor::trackview_by_y_position() when using motion events. The coordinate passed in was in canvas space and the method expected trackview space
To handle any further issues like this, I generalized and added an optional argument specifying that the canvas=>trackview transform is required, thus centralizing where this done.
-rw-r--r--gtk2_ardour/editor.cc13
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_mouse.cc4
3 files changed, 13 insertions, 6 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 96aa51f4da..d63484c899 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -2421,7 +2421,8 @@ Editor::get_state ()
return *node;
}
-/** @param y y is an offset into the trackview area, in pixel units
+/** if @param trackview_relative_offset is true, @param y y is an offset into the trackview area, in pixel units
+ * if @param trackview_relative_offset is false, @param y y is a global canvas * coordinate, in pixel units
*
* @return pair: TimeAxisView that y is over, layer index.
*
@@ -2429,12 +2430,16 @@ Editor::get_state ()
* in stacked or expanded region display mode, otherwise 0.
*/
std::pair<TimeAxisView *, double>
-Editor::trackview_by_y_position (double y)
+Editor::trackview_by_y_position (double y, bool trackview_relative_offset)
{
+ if (!trackview_relative_offset) {
+ y -= _trackview_group->canvas_origin().y;
+ }
+
if (y < 0) {
return std::make_pair ( (TimeAxisView *) 0, 0);
}
-
+
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
std::pair<TimeAxisView*, double> const r = (*iter)->covers_y_position (y);
@@ -2443,6 +2448,8 @@ Editor::trackview_by_y_position (double y)
return r;
}
}
+
+ return std::make_pair ( (TimeAxisView *) 0, 0);
}
/** Snap a position to the grid, if appropriate, taking into account current
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 0d640c1f9d..eb79b35d23 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1054,7 +1054,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
/* track views */
TrackViewList track_views;
- std::pair<TimeAxisView*, double> trackview_by_y_position (double);
+ std::pair<TimeAxisView*, double> trackview_by_y_position (double, bool trackview_relative_offset = true);
RouteTimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
TrackViewList get_tracks_for_range_action () const;
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index cb9571bf5d..3230614aed 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -2839,7 +2839,7 @@ Editor::set_internal_edit (bool yn)
}
/** Update _join_object_range_state which indicate whether we are over the top or bottom half of a region view,
- * used by the `join object/range' tool mode.
+ * used by the `join object/range' tool mode. Coordinates in canvas space.
*/
void
Editor::update_join_object_range_location (double /*x*/, double y)
@@ -2864,7 +2864,7 @@ Editor::update_join_object_range_location (double /*x*/, double y)
}
/* XXX: maybe we should make entered_track work in all cases, rather than resorting to this */
- pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
+ pair<TimeAxisView*, int> tvp = trackview_by_y_position (y, false);
if (tvp.first) {