Status bar zoom field does not consider custom values when using arrow keys or mouse scroll wheel
Issue Summary
Using the arrow keys or scroll wheel on the zoom field in the status bar has unexpected behavior when it was set to a custom value.
Actual Results
After setting a custom zoom level (one not in the predefined set of values), using the arrow keys or scroll wheel on the zoom combo box in the status bar will behave as if the smallest zoom value has been selected, rather than the behavior matching the current zoom level. For instance, if the current zoom level is 105%, using the up arrow or scrolling up, which should increase the zoom level, results in the zoom decreasing to 12% (the second lowest zoom level).
Expected Results
Using the arrow keys should move to the nearest item in the predefined set of values. For example, if the current zoom level is set to 105%, moving up should increase the zoom to 200%, and moving down should decrease it to 100%.
Steps to reproduce
- Set the zoom level to a value not in the set of zoom values in the status bar combo box that is > 12%. This can be done by control+dragging with the hand tool, or writing a number in the status bar field.
- Focus on the status bar zoom field.
- Press the down arrow key or scroll a little bit down with the scroll wheel.
- Observe that the zoom does not change at all, as if it was on 1% already.
- Press the up arrow key or scroll a little bit up with the scroll wheel.
- Observe that the zoom changes to 12%, as if it was previously on 1%, not the logical position where the custom value would be.
System Information
-
Pencil2D Version: ddcaedda5555dfc549a34571adfaf3dbea35b2b8
-
Operating System: Ubuntu 21.04
Developer Notes
This issue was first mentioned in #1442. I looked into possible solutions for this issue when reviewing that PR. We could override the wheel and keypress events and implement our own custom behavior for for the case where the number does not match any selected entry. However I think the better option would be to actually add a new item when the value is changed to something not already on the list, and place that item in the correct order. When the custom value is changed to another custom value, that entry would update, and change position on the list if necessary. When the custom values is changed to a non-custom value, the custom entry would be removed. Doing this we could rely upon the default implementation of the wheel and keypress event handlers. This does add some complexity though as we have to keep track of this item and make sure it is kept up-to-date.