SequencePlayer: Forbid "selecting" an invalid frame number #2388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
With the current UI, it is possible to use the "previous frame" or "next frame" buttons of the Sequence Player to select negative frame numbers or frame numbers that are larger than the actual number of frames in the sequence.
Selecting an invalid frame number has no functional impact on the Sequence Player (it is not allowed on QtAliceVision's side) but it is still a glitch from a user standpoint.
When typing in a negative frame number, said number is immediately replaced by "0" (as it should). However, when typing in a frame number that is larger than the number of frames, no such check is performed.
We would like to disable the "previous frame" buttons when the selected frame ID is 0, since it makes no sense to go lower than that; conversely, we would like to disable the "next frame" buttons when the selected frame ID corresponds to the last frame.
The buttons should correctly be re-enabled when going in the opposite direction.
Implementation remarks
For the buttons, we take no action if we push the previous button when we are on the first frame (same for when we are on the last frame) and for typing, we apply min and max functions to force the entered number to be a valid frame number (if we are below 0, we consider that the user wants to retrieve the first frame, and similarly if we are after the last frame)