Colors now operate more sensibly

This commit is contained in:
Sasha Koshka 2023-08-09 15:13:19 -04:00
parent 487471d7a9
commit c785fb461c

View File

@ -24,12 +24,18 @@ func R (pack, object string) Role {
}
// Color represents a color ID.
type Color int; const {
type Color int; const (
ColorBackground Color = iota
ColorForeground
ColorRaised
ColorSunken
ColorAccent
)
// RGBA satisfies the color.Color interface.
func (id Color) RGBA () (r, g, b, a uint32) {
if current == nil { return }
return current.RGBA(id)
}
// Theme is an object that can apply a visual style to different objects.
@ -39,8 +45,8 @@ type Theme interface {
// closing the returned cookie will remove them.
Apply (tomo.Object, Role) event.Cookie
// Color returns a color for the corresponding color ID.
Color (Color) color.Color
// RGBA returns the RGBA values of the corresponding color ID.
RGBA (Color) (r, g, b, a uint32)
}
var current Theme
@ -58,8 +64,3 @@ func Apply (object tomo.Object, role Role) event.Cookie {
return current.Apply(object, role)
}
// Color returns a color for the corresponding color ID.
func Color (id Color) color.Color {
if current == nil { return color.Black }
return current.Color(id)
}