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:
Elias Naur
2020-05-11 11:29:05 +02:00
parent 669e4cc96a
commit c32b3fe43a
+1 -4
View File
@@ -31,7 +31,6 @@ type ButtonStyle struct {
type ButtonLayoutStyle struct {
Background color.RGBA
Color color.RGBA
CornerRadius unit.Value
Inset layout.Inset
}
@@ -63,7 +62,6 @@ func Button(th *Theme, txt string) ButtonStyle {
func ButtonLayout(th *Theme) ButtonLayoutStyle {
return ButtonLayoutStyle{
Background: th.Color.Primary,
Color: th.Color.InvText,
CornerRadius: unit.Dp(4),
Inset: layout.UniformInset(unit.Dp(12)),
}
@@ -83,9 +81,9 @@ func (b ButtonStyle) Layout(gtx *layout.Context, button *widget.Button) {
ButtonLayoutStyle{
Background: b.Background,
CornerRadius: b.CornerRadius,
Color: b.Color,
Inset: b.Inset,
}.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)
})
}
@@ -113,7 +111,6 @@ func (b ButtonLayoutStyle) Layout(gtx *layout.Context, button *widget.Button, w
gtx.Constraints.Height.Min = vmin
layout.Center.Layout(gtx, func() {
b.Inset.Layout(gtx, func() {
paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
w()
})
})