From ea5e1a4989eb83e691c585a45a9984a774e1c459 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Mon, 18 May 2020 12:37:42 +0200 Subject: [PATCH] Added DisabledColor to button. --- ui/button.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 }