~eliasnaur/gio

a8a48bb809950438139221c7e43f1ee9969b16dd — vsariola 4 months ago 7286b07
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>
1 files changed, 1 insertions(+), 1 deletions(-)

M widget/float.go
M widget/float.go => widget/float.go +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)