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>
This commit is contained in:
Elias Naur
2021-11-30 14:34:15 +01:00
parent 227c5a132b
commit e5c040be1b
+1 -1
View File
@@ -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()