mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
widget/material: handle elliptical icon buttons
This commit changes the ink-drawing code so that IconButtons that are not perfectly circular will still ink fully. Previously, an elliptical icon would only animate a circular sub-region. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -150,11 +150,11 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di
|
|||||||
func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||||
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
||||||
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
||||||
size := gtx.Constraints.Min.X
|
sizex, sizey := gtx.Constraints.Min.X, gtx.Constraints.Min.Y
|
||||||
sizef := float32(size)
|
sizexf, sizeyf := float32(sizex), float32(sizey)
|
||||||
rr := sizef * .5
|
rr := (sizexf + sizeyf) * .25
|
||||||
clip.RRect{
|
clip.RRect{
|
||||||
Rect: f32.Rectangle{Max: f32.Point{X: sizef, Y: sizef}},
|
Rect: f32.Rectangle{Max: f32.Point{X: sizexf, Y: sizeyf}},
|
||||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||||
}.Add(gtx.Ops)
|
}.Add(gtx.Ops)
|
||||||
background := b.Background
|
background := b.Background
|
||||||
|
|||||||
Reference in New Issue
Block a user