forked from joejulian/gio
widget: fix bug how f.pos is calculated in widget.Float
The order of subtraction when calculating f.pos from value was wrong, so setting a minimum value for a Float never really worked, although min = 0 worked as intended which is why this probably went unnoticed. Signed-off-by: vsariola <5684185+vsariola@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ func (f *Float) Layout(gtx layout.Context, pointerMargin int, min, max float32)
|
||||
f.pos = xy / f.length
|
||||
value = min + (max-min)*f.pos
|
||||
} else if min != max {
|
||||
f.pos = value/(max-min) - min
|
||||
f.pos = (value - min) / (max - min)
|
||||
}
|
||||
// Unconditionally call setValue in case min, max, or value changed.
|
||||
f.setValue(value, min, max)
|
||||
|
||||
Reference in New Issue
Block a user