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:
vsariola
2021-02-10 13:37:44 +02:00
committed by Elias Naur
parent 7286b075e2
commit a8a48bb809
+1 -1
View File
@@ -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)