GUI: Increase position range for a slider value

This makes it so that half the space before and after a slider value is assigned to that value

Currently for sliders with small value range, the only ways to set them to the highest value is
to either use the mouse wheel scroll, or click and drag, or click at a pixel of the far edge of the slider.
This PR addresses the final option, making it a bit easier to get the final value when using simple clicks.
It still uses integer division to get the slider value from the click position, but "divides" the space between
two values in half, assigning the first half to the left (smaller) value and the right half to the right (higher).

This was inspired mainly for touchsreen interfaces where simple tap is the main form of interaction
(and mouse wheel or click and drag may not be supported or more difficult to pull through).
This commit is contained in:
antoniou79 2023-09-08 18:18:04 +03:00 committed by Eugene Sandulenko
parent bd6f8be687
commit 86d1853ab2

View File

@ -922,7 +922,7 @@ int SliderWidget::valueToPos(int value) {
}
int SliderWidget::posToValue(int pos) {
return (pos) * (_valueMax - _valueMin) / (_w - 1) + _valueMin;
return (((pos) * 2 * (_valueMax - _valueMin) / (_w - 1) + 1) / 2 + _valueMin);
}
#pragma mark -