[Scummvm-git-logs] scummvm master -> 86d1853ab2e1a60374245c0747bab57eddbdd1d7

sev- noreply at scummvm.org
Mon Sep 11 20:22:30 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
86d1853ab2 GUI: Increase position range for a slider value


Commit: 86d1853ab2e1a60374245c0747bab57eddbdd1d7
    https://github.com/scummvm/scummvm/commit/86d1853ab2e1a60374245c0747bab57eddbdd1d7
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-09-11T22:22:26+02:00

Commit Message:
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).

Changed paths:
    gui/widget.cpp


diff --git a/gui/widget.cpp b/gui/widget.cpp
index 407c72ff2e8..cbb6cad0c4f 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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 -




More information about the Scummvm-git-logs mailing list