Added DisabledColor to button.
This commit is contained in:
parent
7f2e155edd
commit
ea5e1a4989
13
ui/button.go
13
ui/button.go
@ -9,7 +9,9 @@ import (
|
|||||||
type Button struct {
|
type Button struct {
|
||||||
ControlBase
|
ControlBase
|
||||||
|
|
||||||
|
DisabledColor color.Color
|
||||||
HoverColor color.Color
|
HoverColor color.Color
|
||||||
|
|
||||||
Icon string // optional: icon to display in front of the text.
|
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).
|
IconHeight float32 // overrides the height of the icon (overrides auto-scaling when text is provided).
|
||||||
Text string
|
Text string
|
||||||
@ -107,6 +109,13 @@ func (b *Button) Notify(ctx Context, state interface{}) bool {
|
|||||||
return b.ControlBase.Notify(ctx, state)
|
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 {
|
func (b *Button) fillColor(p *Palette) color.Color {
|
||||||
if b.Type == ButtonTypeIcon {
|
if b.Type == ButtonTypeIcon {
|
||||||
return nil
|
return nil
|
||||||
@ -114,11 +123,11 @@ func (b *Button) fillColor(p *Palette) color.Color {
|
|||||||
|
|
||||||
if b.Disabled {
|
if b.Disabled {
|
||||||
if b.Background != nil {
|
if b.Background != nil {
|
||||||
return p.Disabled
|
return b.disabledColor(p)
|
||||||
}
|
}
|
||||||
switch b.Type {
|
switch b.Type {
|
||||||
case ButtonTypeContained:
|
case ButtonTypeContained:
|
||||||
return p.Disabled
|
return b.disabledColor(p)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user