mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
widget/material: remove Inset from ButtonLayoutStyle
ButtonLayout is for custom button content; insets belong to the custom content, not the button. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -34,7 +34,6 @@ type ButtonStyle struct {
|
|||||||
type ButtonLayoutStyle struct {
|
type ButtonLayoutStyle struct {
|
||||||
Background color.RGBA
|
Background color.RGBA
|
||||||
CornerRadius unit.Value
|
CornerRadius unit.Value
|
||||||
Inset layout.Inset
|
|
||||||
Button *widget.Clickable
|
Button *widget.Clickable
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ func ButtonLayout(th *Theme, button *widget.Clickable) ButtonLayoutStyle {
|
|||||||
Button: button,
|
Button: button,
|
||||||
Background: th.Color.Primary,
|
Background: th.Color.Primary,
|
||||||
CornerRadius: unit.Dp(4),
|
CornerRadius: unit.Dp(4),
|
||||||
Inset: layout.UniformInset(unit.Dp(12)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +108,12 @@ func (b ButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
return ButtonLayoutStyle{
|
return ButtonLayoutStyle{
|
||||||
Background: b.Background,
|
Background: b.Background,
|
||||||
CornerRadius: b.CornerRadius,
|
CornerRadius: b.CornerRadius,
|
||||||
Inset: b.Inset,
|
|
||||||
Button: b.Button,
|
Button: b.Button,
|
||||||
}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
return b.Inset.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
return widget.Label{Alignment: text.Middle}.Layout(gtx, b.shaper, b.Font, b.TextSize, b.Text)
|
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
||||||
|
return widget.Label{Alignment: text.Middle}.Layout(gtx, b.shaper, b.Font, b.TextSize, b.Text)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +141,7 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di
|
|||||||
}),
|
}),
|
||||||
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
|
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
|
||||||
gtx.Constraints.Min = min
|
gtx.Constraints.Min = min
|
||||||
return layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
return layout.Center.Layout(gtx, w)
|
||||||
return b.Inset.Layout(gtx, w)
|
|
||||||
})
|
|
||||||
}),
|
}),
|
||||||
layout.Expanded(b.Button.Layout),
|
layout.Expanded(b.Button.Layout),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user