Added DisabledColor to button.

This commit is contained in:
Sander Schobers 2020-05-18 12:37:42 +02:00
parent 7f2e155edd
commit ea5e1a4989

View File

@ -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
}