Simplify grid next/prev logic

Round[Up/Down]Always does not need an offset to avoid snapping
to the same position.
This commit is contained in:
Robin Gareus 2022-03-04 19:39:02 +01:00
parent 9dabe047f1
commit 080bfdc2d0
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -7817,11 +7817,8 @@ Editor::playhead_forward_to_grid ()
_session->request_locate (0); _session->request_locate (0);
} }
} else { } else {
if (pos < timepos_t::max (pos.time_domain()).earlier (timepos_t (samplepos_t (3)))) { pos = snap_to_grid (pos, Temporal::RoundUpAlways, SnapToGrid_Scaled);
pos += timepos_t (samplepos_t (2)); _session->request_locate (pos.samples());
pos = snap_to_grid (pos, Temporal::RoundUpAlways, SnapToGrid_Scaled);
_session->request_locate (pos.samples());
}
} }
/* keep PH visible in window */ /* keep PH visible in window */
@ -7849,12 +7846,10 @@ Editor::playhead_backward_to_grid ()
_session->request_locate (0); _session->request_locate (0);
} }
} else { } else {
if (pos.samples() > 2) { if (pos.samples() == 0) {
pos.shift_earlier (timepos_t (samplepos_t (2))); return;
pos = snap_to_grid (pos, Temporal::RoundDownAlways, SnapToGrid_Scaled);
} else {
pos = timepos_t (samplepos_t (0));
} }
pos = snap_to_grid (pos, Temporal::RoundDownAlways, SnapToGrid_Scaled);
/* handle the case where we are rolling, and we're less than one-half second past the mark, /* handle the case where we are rolling, and we're less than one-half second past the mark,
* we want to go to the prior mark... * we want to go to the prior mark...