fix problem with calls to Editor::trackview_by_y_position() when using motion events...
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Jun 2014 18:41:29 +0000 (14:41 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Jun 2014 18:41:29 +0000 (14:41 -0400)
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.

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_mouse.cc

index 96aa51f4da33847469889786aa826c8b560e2abe..d63484c8996e08da661b101d76e82ef99052bc5a 100644 (file)
@@ -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
index 0d640c1f9d762675a1c2c41878044faf4a88ddca..eb79b35d2385746c71df347efa24201f64205928 100644 (file)
@@ -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;
index cb9571bf5d7e6f0b7115b5c0beb46f3e289716da..3230614aedf1d8e78d0858c75a5d5ed7cc2bd548 100644 (file)
@@ -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) {