mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
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:
@@ -118,7 +118,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
// Set up click area.
|
// Set up click area.
|
||||||
clickSize := gtx.Px(unit.Dp(40))
|
clickSize := gtx.Px(unit.Dp(40))
|
||||||
clickOff := f32.Point{
|
clickOff := f32.Point{
|
||||||
X: (float32(trackWidth) - float32(clickSize)) * .5,
|
X: thumbRadius - float32(clickSize)*.5,
|
||||||
Y: (float32(trackHeight)-float32(clickSize))*.5 + trackOff,
|
Y: (float32(trackHeight)-float32(clickSize))*.5 + trackOff,
|
||||||
}
|
}
|
||||||
defer op.Offset(clickOff).Push(gtx.Ops).Pop()
|
defer op.Offset(clickOff).Push(gtx.Ops).Pop()
|
||||||
|
|||||||
Reference in New Issue
Block a user