diff --git a/ui/button.go b/ui/button.go index caf6426..aca5cf8 100644 --- a/ui/button.go +++ b/ui/button.go @@ -9,7 +9,9 @@ import ( type Button struct { ControlBase - HoverColor color.Color + DisabledColor color.Color + HoverColor color.Color + Icon string // optional: icon to display in front of the text. IconHeight float32 // overrides the height of the icon (overrides auto-scaling when text is provided). Text string @@ -107,6 +109,13 @@ func (b *Button) Notify(ctx Context, state interface{}) bool { return b.ControlBase.Notify(ctx, state) } +func (b *Button) disabledColor(p *Palette) color.Color { + if b.DisabledColor != nil { + return b.DisabledColor + } + return p.Disabled +} + func (b *Button) fillColor(p *Palette) color.Color { if b.Type == ButtonTypeIcon { return nil @@ -114,11 +123,11 @@ func (b *Button) fillColor(p *Palette) color.Color { if b.Disabled { if b.Background != nil { - return p.Disabled + return b.disabledColor(p) } switch b.Type { case ButtonTypeContained: - return p.Disabled + return b.disabledColor(p) default: return nil }