~eliasnaur/gio

e5c040be1bf006bc6f9c52de44b145ba9c68fd05 — Elias Naur 5 months ago 227c5a1
widget/material: fix click area offset for Switch

The click area was mistakenly offset by half the track width, but it
really should be offset by half the thumb diameter.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
1 files changed, 1 insertions(+), 1 deletions(-)

M widget/material/switch.go
M widget/material/switch.go => widget/material/switch.go +1 -1
@@ 118,7 118,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
	// Set up click area.
	clickSize := gtx.Px(unit.Dp(40))
	clickOff := f32.Point{
		X: (float32(trackWidth) - float32(clickSize)) * .5,
		X: thumbRadius - float32(clickSize)*.5,
		Y: (float32(trackHeight)-float32(clickSize))*.5 + trackOff,
	}
	defer op.Offset(clickOff).Push(gtx.Ops).Pop()