mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
widget/material: drop Color from ButtonLayoutStyle
Setting a ColorOp before calling a widget function is too subtle. Let the widget manage its color instead. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -31,7 +31,6 @@ type ButtonStyle struct {
|
|||||||
|
|
||||||
type ButtonLayoutStyle struct {
|
type ButtonLayoutStyle struct {
|
||||||
Background color.RGBA
|
Background color.RGBA
|
||||||
Color color.RGBA
|
|
||||||
CornerRadius unit.Value
|
CornerRadius unit.Value
|
||||||
Inset layout.Inset
|
Inset layout.Inset
|
||||||
}
|
}
|
||||||
@@ -63,7 +62,6 @@ func Button(th *Theme, txt string) ButtonStyle {
|
|||||||
func ButtonLayout(th *Theme) ButtonLayoutStyle {
|
func ButtonLayout(th *Theme) ButtonLayoutStyle {
|
||||||
return ButtonLayoutStyle{
|
return ButtonLayoutStyle{
|
||||||
Background: th.Color.Primary,
|
Background: th.Color.Primary,
|
||||||
Color: th.Color.InvText,
|
|
||||||
CornerRadius: unit.Dp(4),
|
CornerRadius: unit.Dp(4),
|
||||||
Inset: layout.UniformInset(unit.Dp(12)),
|
Inset: layout.UniformInset(unit.Dp(12)),
|
||||||
}
|
}
|
||||||
@@ -83,9 +81,9 @@ func (b ButtonStyle) Layout(gtx *layout.Context, button *widget.Button) {
|
|||||||
ButtonLayoutStyle{
|
ButtonLayoutStyle{
|
||||||
Background: b.Background,
|
Background: b.Background,
|
||||||
CornerRadius: b.CornerRadius,
|
CornerRadius: b.CornerRadius,
|
||||||
Color: b.Color,
|
|
||||||
Inset: b.Inset,
|
Inset: b.Inset,
|
||||||
}.Layout(gtx, button, func() {
|
}.Layout(gtx, button, func() {
|
||||||
|
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
||||||
widget.Label{Alignment: text.Middle}.Layout(gtx, b.shaper, b.Font, b.TextSize, b.Text)
|
widget.Label{Alignment: text.Middle}.Layout(gtx, b.shaper, b.Font, b.TextSize, b.Text)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -113,7 +111,6 @@ func (b ButtonLayoutStyle) Layout(gtx *layout.Context, button *widget.Button, w
|
|||||||
gtx.Constraints.Height.Min = vmin
|
gtx.Constraints.Height.Min = vmin
|
||||||
layout.Center.Layout(gtx, func() {
|
layout.Center.Layout(gtx, func() {
|
||||||
b.Inset.Layout(gtx, func() {
|
b.Inset.Layout(gtx, func() {
|
||||||
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
|
|
||||||
w()
|
w()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user