diff options
author | Robin Gareus <robin@gareus.org> | 2020-04-05 20:09:42 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-05 20:24:11 +0200 |
commit | 14a2a50e9330756025a980a1197e4e7d42debcb7 (patch) | |
tree | 8e75225280d28145a8a092bc03274dad317682d8 /gtk2_ardour/editor.cc | |
parent | 6b9bdbf0ff81551a4f6af20433a6f469d67a0dfe (diff) |
Simplify snap-to magnetic distance calc
Diffstat (limited to 'gtk2_ardour/editor.cc')
-rw-r--r-- | gtk2_ardour/editor.cc | 18 |
1 files 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); |