From ce1e05fc3d95ceb0f34480aa8a655347b8f3e624 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 8 May 2021 04:28:36 +0200 Subject: [PATCH] Update DnD min. movement threshold -- #8686 Previously x-axis threshold was in samples. This is useless unless zoomed in to the max. So in most cases the first-move was always in x-direction, making constrained y-axis drags near impossible. Furthermore the threshold for copy-drags was increased as per #8686 --- gtk2_ardour/editor_drag.cc | 4 ++-- gtk2_ardour/editor_drag.h | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 39e9b817c1..23f6ef1b30 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -439,13 +439,13 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll) return false; } - pair const threshold = move_threshold (); + pair const threshold = move_threshold (); bool const old_move_threshold_passed = _move_threshold_passed; if (!_move_threshold_passed) { - bool const xp = (::llabs (_drags->current_pointer_sample () - _raw_grab_sample) >= threshold.first); + bool const xp = (::fabs ((current_pointer_x () - _grab_x)) >= threshold.first); bool const yp = (::fabs ((current_pointer_y () - _grab_y)) >= threshold.second); _move_threshold_passed = ((xp && x_movement_matters()) || (yp && y_movement_matters())); diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 970f7756ca..b50153e8cf 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -197,8 +197,8 @@ public: return _preview_video; } - /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */ - virtual std::pair move_threshold () const { + /** @return minimum number of pixels (x, y) that should be considered a movement */ + virtual std::pair move_threshold () const { return std::make_pair (1, 1); } @@ -425,8 +425,12 @@ public: return true; } - std::pair move_threshold () const { - return std::make_pair (4, 4); + std::pair move_threshold () const { + if (_copy) { + return std::make_pair (6, 4); + } else { + return std::make_pair (2, 4); + } } void setup_pointer_sample_offset (); @@ -639,8 +643,8 @@ private: double y_to_region (double) const; ARDOUR::samplecnt_t grid_samples (samplepos_t) const; - /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */ - virtual std::pair move_threshold () const { + /** @return minimum number of pixels (x, y) that should be considered a movement */ + virtual std::pair move_threshold () const { return std::make_pair (0, 0); } @@ -672,8 +676,8 @@ private: double y_to_region (double) const; ARDOUR::samplecnt_t grid_samples (samplepos_t) const; - /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */ - virtual std::pair move_threshold () const { + /** @return minimum number of pixels (x, y) that should be considered a movement */ + virtual std::pair move_threshold () const { return std::make_pair (0, 0); } @@ -1139,8 +1143,9 @@ public: void finished (GdkEvent *, bool); void aborted (bool); - std::pair move_threshold () const { - return std::make_pair (8, 1); + /** @return minimum number of pixels (x, y) that should be considered a movement */ + std::pair move_threshold () const { + return std::make_pair (1, 1); } void do_select_things (GdkEvent *, bool); @@ -1297,7 +1302,8 @@ public: void finished (GdkEvent *, bool); void aborted (bool); - std::pair move_threshold () const { + /** @return minimum number of pixels (x, y) that should be considered a movement */ + std::pair move_threshold () const { return std::make_pair (4, 4); } @@ -1361,8 +1367,8 @@ public: return false; } - virtual std::pair move_threshold () const { - return std::make_pair (4, 4); + virtual std::pair move_threshold () const { + return std::make_pair (1, 4); } private: