mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
widget/material: accept nil icon in IconButton.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -111,13 +111,15 @@ func (b IconButton) Layout(gtx *layout.Context, button *widget.Button) {
|
|||||||
ico := st.Rigid(gtx, func() {
|
ico := st.Rigid(gtx, func() {
|
||||||
layout.UniformInset(b.Padding).Layout(gtx, func() {
|
layout.UniformInset(b.Padding).Layout(gtx, func() {
|
||||||
size := gtx.Px(b.Size) - gtx.Px(b.Padding)
|
size := gtx.Px(b.Size) - gtx.Px(b.Padding)
|
||||||
ico := b.Icon.image(size)
|
if b.Icon != nil {
|
||||||
ico.Add(gtx.Ops)
|
ico := b.Icon.image(size)
|
||||||
paint.PaintOp{
|
ico.Add(gtx.Ops)
|
||||||
Rect: f32.Rectangle{
|
paint.PaintOp{
|
||||||
Max: toPointF(ico.Size()),
|
Rect: f32.Rectangle{
|
||||||
},
|
Max: toPointF(ico.Size()),
|
||||||
}.Add(gtx.Ops)
|
},
|
||||||
|
}.Add(gtx.Ops)
|
||||||
|
}
|
||||||
gtx.Dimensions = layout.Dimensions{
|
gtx.Dimensions = layout.Dimensions{
|
||||||
Size: image.Point{X: size, Y: size},
|
Size: image.Point{X: size, Y: size},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user