From 14a2a50e9330756025a980a1197e4e7d42debcb7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 5 Apr 2020 20:09:42 +0200 Subject: Simplify snap-to magnetic distance calc --- gtk2_ardour/editor.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 24cc133006..a6b5a34d49 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3020,22 +3020,18 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref check_best_snap (presnap, post.sample, dist, best); } + if (max_samplepos == best) { + return; + } + /* now check "magnetic" state: is the grid within reasonable on-screen distance to trigger a snap? * this also helps to avoid snapping to somewhere the user can't see. (i.e.: I clicked on a region and it disappeared!!) * ToDo: Perhaps this should only occur if EditPointMouse? */ - int snap_threshold_s = pixel_to_sample (uic.get_snap_threshold()); - if (ensure_snap) { - start.set (best, 0); + samplecnt_t snap_threshold_s = pixel_to_sample (uic.get_snap_threshold ()); + + if (!ensure_snap && ::llabs (presnap - best) > snap_threshold_s) { return; - } else if (presnap > best) { - if (presnap > (best+ snap_threshold_s)) { - best = presnap; - } - } else if (presnap < best) { - if (presnap < (best - snap_threshold_s)) { - best = presnap; - } } start.set (best, 0); -- cgit v1.2.3