mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
widget/material: drop Padding from IconButtonStyle
Use Inset instead, matching the other buttons. Redefine Size to apply to the icon size, without padding. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -37,11 +37,12 @@ type ButtonLayoutStyle struct {
|
|||||||
|
|
||||||
type IconButtonStyle struct {
|
type IconButtonStyle struct {
|
||||||
Background color.RGBA
|
Background color.RGBA
|
||||||
Color color.RGBA
|
// Color is the icon color.
|
||||||
Icon *widget.Icon
|
Color color.RGBA
|
||||||
Size unit.Value
|
Icon *widget.Icon
|
||||||
Padding unit.Value
|
// Size is the icon size.
|
||||||
Inset layout.Inset
|
Size unit.Value
|
||||||
|
Inset layout.Inset
|
||||||
}
|
}
|
||||||
|
|
||||||
func Button(th *Theme, txt string) ButtonStyle {
|
func Button(th *Theme, txt string) ButtonStyle {
|
||||||
@@ -72,8 +73,8 @@ func IconButton(th *Theme, icon *widget.Icon) IconButtonStyle {
|
|||||||
Background: th.Color.Primary,
|
Background: th.Color.Primary,
|
||||||
Color: th.Color.InvText,
|
Color: th.Color.InvText,
|
||||||
Icon: icon,
|
Icon: icon,
|
||||||
Size: unit.Dp(56),
|
Size: unit.Dp(24),
|
||||||
Padding: unit.Dp(16),
|
Inset: layout.UniformInset(unit.Dp(12)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,8 +158,8 @@ func (b IconButtonStyle) Layout(gtx *layout.Context, button *widget.Clickable) {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
layout.Stacked(func() {
|
layout.Stacked(func() {
|
||||||
layout.UniformInset(b.Padding).Layout(gtx, func() {
|
b.Inset.Layout(gtx, func() {
|
||||||
size := gtx.Px(b.Size) - 2*gtx.Px(b.Padding)
|
size := gtx.Px(b.Size)
|
||||||
if b.Icon != nil {
|
if b.Icon != nil {
|
||||||
b.Icon.Color = b.Color
|
b.Icon.Color = b.Color
|
||||||
b.Icon.Layout(gtx, unit.Px(float32(size)))
|
b.Icon.Layout(gtx, unit.Px(float32(size)))
|
||||||
|
|||||||
Reference in New Issue
Block a user