zntg/ui/style.go
Sander Schobers 19daffd110 Added UI elements.
Reversed order of operands when comparing with nil/0 .
2019-03-05 21:52:18 +01:00

83 lines
1.6 KiB
Go

package ui
import "image/color"
var defaultDimensions *Dimensions
var defaultFonts *Fonts
var defaultPalette *Palette
var defaultStyle *Style
type Dimensions struct {
ScrollbarWidth float32
TextPadding float32
}
type Fonts struct {
Default string
}
type Palette struct {
Background color.Color
Primary color.Color
PrimaryHighlight color.Color
ShadedBackground color.Color
Text color.Color
TextDisabled color.Color
TextOnPrimary color.Color
}
type Style struct {
Dimensions *Dimensions
Fonts *Fonts
Palette *Palette
}
func DefaultDimensions() *Dimensions {
if defaultDimensions == nil {
defaultDimensions = &Dimensions{
ScrollbarWidth: 16.,
TextPadding: 8.,
}
}
return defaultDimensions
}
func DefaultFonts() *Fonts {
if defaultFonts == nil {
defaultFonts = &Fonts{
Default: "default",
}
}
return defaultFonts
}
func DefaultPalette() *Palette {
if defaultPalette == nil {
defaultPalette = &Palette{
Background: color.White,
Primary: RGBA(0x3F, 0x51, 0xB5, 0xFF),
PrimaryHighlight: RGBA(0x5C, 0x6B, 0xC0, 0xFF),
ShadedBackground: RGBA(0xFA, 0xFA, 0xFA, 0xFF),
Text: color.Black,
TextDisabled: RGBA(0xBD, 0xBD, 0xBD, 0xFF),
TextOnPrimary: color.White,
}
}
return defaultPalette
}
func DefaultStyle() *Style {
if defaultStyle == nil {
defaultStyle = &Style{
Dimensions: DefaultDimensions(),
Fonts: DefaultFonts(),
Palette: DefaultPalette(),
}
}
return defaultStyle
}
func RGBA(r, g, b, a byte) *color.RGBA {
return &color.RGBA{R: r, G: g, B: b, A: a}
}