From e83301daaa2b83611e70b3eb2175b135f95af9d7 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Wed, 2 May 2018 16:37:14 -0500 Subject: [PATCH] Replace the check for SnapPref, which went missing. Some functions (like playhead_to_next_grid) can request GridOnly. --- gtk2_ardour/editor.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d2d258b68c..f6661b74b0 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2829,7 +2829,7 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref samplepos_t best = max_samplepos; // this records the best snap-result we've found so far /* check snap-to-marker */ - if (UIConfiguration::instance().get_snap_to_marks()) { + if ( (pref == SnapToAny) && UIConfiguration::instance().get_snap_to_marks()) { if (for_mark) { return; } @@ -2839,31 +2839,31 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref } /* check snap-to-region-{start/end/sync} */ - if (UIConfiguration::instance().get_snap_to_region_start() || UIConfiguration::instance().get_snap_to_region_end() || UIConfiguration::instance().get_snap_to_region_sync()) { + if ( + (pref == SnapToAny) && + (UIConfiguration::instance().get_snap_to_region_start() || UIConfiguration::instance().get_snap_to_region_end() || UIConfiguration::instance().get_snap_to_region_sync()) + ) { if (!region_boundary_cache.empty()) { - vector::iterator prev = region_boundary_cache.end (); - vector::iterator next = region_boundary_cache.end (); - - if (direction > 0) { - next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), presnap); - } else { - next = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), presnap); - } - + vector::iterator prev = region_boundary_cache.begin(); + vector::iterator next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), presnap); if (next != region_boundary_cache.begin ()) { prev = next; prev--; } - samplepos_t const p = (prev == region_boundary_cache.end()) ? region_boundary_cache.front () : *prev; - samplepos_t const n = (next == region_boundary_cache.end()) ? region_boundary_cache.back () : *next; - - if (presnap > (p + n) / 2) { - test = n; - } else { - test = p; + if ((direction == RoundUpMaybe || direction == RoundUpAlways)) + test = *next; + else if ((direction == RoundDownMaybe || direction == RoundDownAlways)) + test = *prev; + else if (direction == 0) { + if ((presnap - *prev) < (*next - presnap)) { + test = *prev; + } else { + test = *next; + } } + } check_best_snap(presnap, test, dist, best); -- 2.30.2