summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_canvas.cc43
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_drag.h8
-rw-r--r--gtk2_ardour/editor_mouse.cc6
-rw-r--r--gtk2_ardour/editor_routes.cc1
-rw-r--r--gtk2_ardour/time_axis_view.cc33
6 files changed, 49 insertions, 44 deletions
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 96236c3138..4776ffee00 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -442,9 +442,12 @@ Editor::autoscroll_fudge_threshold () const
}
/** @param allow_horiz true to allow horizontal autoscroll, otherwise false.
+ *
* @param allow_vert true to allow vertical autoscroll, otherwise false.
+ *
* @param moving_left true if we are moving left, so we only want to autoscroll on the left of the canvas,
* otherwise false, so we only want to autoscroll on the right of the canvas.
+ *
* @param moving_up true if we are moving up, so we only want to autoscroll at the top of the canvas,
* otherwise false, so we only want to autoscroll at the bottom of the canvas.
*/
@@ -479,14 +482,17 @@ Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert, bool moving_left, b
/* Note whether we're fudging the autoscroll (see autoscroll_fudge_threshold) */
_autoscroll_fudging = (distance < autoscroll_fudge_threshold ());
+ /* ty is in canvas-coordinate space */
+
double const ty = _drags->current_pointer_y();
+ ArdourCanvas::Rect visible = _track_canvas->visible_area();
autoscroll_y = 0;
autoscroll_x = 0;
- if (ty < 0 && moving_up && allow_vert) {
+ if (ty < visible.y0 && moving_up && allow_vert) {
autoscroll_y = -1;
startit = true;
- } else if (ty > _visible_canvas_height && !moving_up && allow_vert) {
+ } else if (ty > visible.y1 && !moving_up && allow_vert) {
autoscroll_y = 1;
startit = true;
}
@@ -532,8 +538,7 @@ Editor::autoscroll_canvas ()
framepos_t new_frame;
framepos_t limit = max_framepos - current_page_samples();
double new_pixel;
- double target_pixel;
-
+
if (autoscroll_x_distance != 0) {
if (autoscroll_x > 0) {
@@ -572,6 +577,8 @@ Editor::autoscroll_canvas ()
new_frame = leftmost_frame;
}
+ cerr << "new frame = " << new_frame << " current = " << leftmost_frame << endl;
+
double vertical_pos = vertical_adjustment.get_value();
if (autoscroll_y < 0) {
@@ -582,31 +589,11 @@ Editor::autoscroll_canvas ()
new_pixel = vertical_pos - autoscroll_y_distance;
}
- target_pixel = _drags->current_pointer_y() - autoscroll_y_distance;
- target_pixel = max (target_pixel, 0.0);
-
} else if (autoscroll_y > 0) {
- double const top_of_bottom_of_canvas = _full_canvas_height - _visible_canvas_height;
-
- if (vertical_pos > _full_canvas_height - autoscroll_y_distance) {
- new_pixel = _full_canvas_height;
- } else {
- new_pixel = vertical_pos + autoscroll_y_distance;
- }
-
- new_pixel = min (top_of_bottom_of_canvas, new_pixel);
-
- target_pixel = _drags->current_pointer_y() + autoscroll_y_distance;
-
- /* don't move to the full canvas height because the item will be invisible
- (its top edge will line up with the bottom of the visible canvas.
- */
-
- target_pixel = min (target_pixel, _full_canvas_height - 10);
+ new_pixel = min (_full_canvas_height - _visible_canvas_height, min (_full_canvas_height, (vertical_adjustment.get_value() + autoscroll_y_distance)));
} else {
- target_pixel = _drags->current_pointer_y();
new_pixel = vertical_pos;
}
@@ -619,7 +606,9 @@ Editor::autoscroll_canvas ()
reset_x_origin (new_frame);
}
- vertical_adjustment.set_value (new_pixel);
+ if (new_pixel != vertical_pos) {
+ vertical_adjustment.set_value (new_pixel);
+ }
/* fake an event. */
@@ -689,7 +678,6 @@ Editor::left_track_canvas (GdkEventCrossing */*ev*/)
{
DropDownKeys ();
within_track_canvas = false;
- //cerr << "left track canvas\n";
set_entered_track (0);
set_entered_regionview (0);
reset_canvas_action_sensitivity (false);
@@ -699,7 +687,6 @@ Editor::left_track_canvas (GdkEventCrossing */*ev*/)
bool
Editor::entered_track_canvas (GdkEventCrossing */*ev*/)
{
- //cerr << "entered track canvas\n";
within_track_canvas = true;
reset_canvas_action_sensitivity (true);
return FALSE;
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index a68493f93b..ec279e5c08 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -2392,7 +2392,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
_grab_zoom = _editor->samples_per_pixel;
- framepos_t where = _editor->canvas_event_frame (event, 0, 0);
+ framepos_t where = _editor->canvas_event_frame (event);
_editor->snap_to_with_modifier (where, event);
diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h
index df55270e54..3f4c82d2d0 100644
--- a/gtk2_ardour/editor_drag.h
+++ b/gtk2_ardour/editor_drag.h
@@ -74,12 +74,12 @@ public:
return !_drags.empty ();
}
- /** @return current pointer x position in trackview coordinates */
+ /** @return current pointer x position in canvas coordinates */
double current_pointer_x () const {
return _current_pointer_x;
}
- /** @return current pointer y position in trackview coordinates */
+ /** @return current pointer y position in canvas coordinates */
double current_pointer_y () const {
return _current_pointer_y;
}
@@ -93,8 +93,8 @@ private:
Editor* _editor;
std::list<Drag*> _drags;
bool _ending; ///< true if end_grab or abort is in progress, otherwise false
- double _current_pointer_x; ///< trackview x of the current pointer
- double _current_pointer_y; ///< trackview y of the current pointer
+ double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
+ double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
};
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index c769cdb4af..b2ee2777cf 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1376,7 +1376,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
//not rolling, range mode click + join_play_range : locate the PH here
if ( !_drags->active () && !_session->transport_rolling() && ( effective_mouse_mode() == MouseRange ) && Config->get_always_play_range() ) {
- framepos_t where = canvas_event_frame (event, 0, 0);
+ framepos_t where = canvas_event_frame (event);
snap_to(where);
_session->request_locate (where, false);
}
@@ -1425,7 +1425,7 @@ Editor::button_release_dispatch (GdkEventButton* ev)
bool
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
- framepos_t where = canvas_event_frame (event, 0, 0);
+ framepos_t where = canvas_event_frame (event);
AutomationTimeAxisView* atv = 0;
if (pre_press_cursor) {
@@ -1452,7 +1452,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
were_dragging = true;
}
- update_region_layering_order_editor ();
+ update_region_layering_order_editor ();
/* edit events get handled here */
diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc
index b700556402..10f2c3f5ed 100644
--- a/gtk2_ardour/editor_routes.cc
+++ b/gtk2_ardour/editor_routes.cc
@@ -535,7 +535,6 @@ EditorRoutes::redisplay ()
_editor->reset_controls_layout_height (position);
_editor->reset_controls_layout_width ();
_editor->_full_canvas_height = position;
- _editor->vertical_adjustment.set_upper (_editor->_full_canvas_height);
if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
/*
diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc
index 8aa3e53639..bea828a6ad 100644
--- a/gtk2_ardour/time_axis_view.cc
+++ b/gtk2_ardour/time_axis_view.cc
@@ -31,6 +31,7 @@
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/selector.h>
+#include "canvas/canvas.h"
#include "canvas/rectangle.h"
#include "canvas/debug.h"
@@ -357,15 +358,33 @@ bool
TimeAxisView::controls_ebox_motion (GdkEventMotion* ev)
{
if (_resize_drag_start >= 0) {
- /* (ab)use the DragManager to do autoscrolling; adjust the event coordinates
- into the world coordinate space that DragManager::motion_handler is expecting,
- and then fake a DragManager motion event so that when maybe_autoscroll
- asks DragManager for the current pointer position it will get the correct
- answers.
+
+ /* (ab)use the DragManager to do autoscrolling - basically we
+ * are pretending that the drag is taking place over the canvas
+ * (which perhaps in the glorious future, when track headers
+ * and the canvas are unified, will actually be true.)
+ *
+ * First, translate the event coordinates into the canvas
+ * coordinate space that DragManager::motion_handler is
+ * expecting (this requires translation into the *window*
+ * coordinates for the track canvas window, and then conversion
+ * from window to canvas coordinate spaces).
+ *
+ * Then fake a DragManager motion event so that when
+ * maybe_autoscroll asks DragManager for the current pointer
+ * position it will get the correct answers.
*/
+
int tx, ty;
- controls_ebox.translate_coordinates (*control_parent, ev->x, ev->y, tx, ty);
- ev->y = ty;
+ controls_ebox.translate_coordinates (*_editor.get_track_canvas(), ev->x, ev->y, tx, ty);
+
+ /* x-axis of track headers is not shared with the canvas, but
+ the y-axis is, so we we can get a valid translation here.
+ */
+
+ Duple canvas_coord = _editor.get_track_canvas()->canvas()->window_to_canvas (Duple (tx, ty));
+ ev->y = (int) floor (canvas_coord.y);
+
_editor.drags()->motion_handler ((GdkEvent *) ev, false);
_editor.maybe_autoscroll (false, true, false, ev->y_root < _resize_drag_start);