summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2018-05-02 16:37:14 -0500
committerBen Loftis <ben@harrisonconsoles.com>2018-05-08 08:43:44 -0500
commite83301daaa2b83611e70b3eb2175b135f95af9d7 (patch)
tree2f4f5a0e4f097c7733ee9c3081aa34ba12c64715
parent81bff2edee31ad64693d5be3c06558714ea92722 (diff)
Replace the check for SnapPref, which went missing. Some functions (like playhead_to_next_grid) can request GridOnly.
-rw-r--r--gtk2_ardour/editor.cc36
1 files 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<samplepos_t>::iterator prev = region_boundary_cache.end ();
- vector<samplepos_t>::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<samplepos_t>::iterator prev = region_boundary_cache.begin();
+ vector<samplepos_t>::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);