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
1 changed files with 5 additions and 10 deletions

View File

@ -7817,11 +7817,8 @@ Editor::playhead_forward_to_grid ()
_session->request_locate (0);
}
} else {
if (pos < timepos_t::max (pos.time_domain()).earlier (timepos_t (samplepos_t (3)))) {
pos += timepos_t (samplepos_t (2));
pos = snap_to_grid (pos, Temporal::RoundUpAlways, SnapToGrid_Scaled);
_session->request_locate (pos.samples());
}
pos = snap_to_grid (pos, Temporal::RoundUpAlways, SnapToGrid_Scaled);
_session->request_locate (pos.samples());
}
/* keep PH visible in window */
@ -7849,12 +7846,10 @@ Editor::playhead_backward_to_grid ()
_session->request_locate (0);
}
} else {
if (pos.samples() > 2) {
pos.shift_earlier (timepos_t (samplepos_t (2)));
pos = snap_to_grid (pos, Temporal::RoundDownAlways, SnapToGrid_Scaled);
} else {
pos = timepos_t (samplepos_t (0));
if (pos.samples() == 0) {
return;
}
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,
* we want to go to the prior mark...