zntg/ui/style.go

116 lines
3.2 KiB
Go

package ui
import (
"image/color"
"opslag.de/schobers/zntg"
)
var defaultDimensions *Dimensions
var defaultFonts *Fonts
var defaultPalette *Palette
var defaultStyle *Style
type Dimensions struct {
OutlineWidth float32
ScrollbarWidth float32
TextPadding float32
}
type FontNames struct {
Default string
Tooltip string
}
type Palette struct {
// Background is the default background color.
Background color.Color
// Disabled is the color to use when the control is disabled.
Disabled color.Color
// Primary is used as a the main contrast color.
Primary color.Color
// PrimaryDark is a foreground version of the main contrast color.
PrimaryDark color.Color
// PrimaryHighlight is a light version of the main contrast color.
PrimaryHighlight color.Color
// PrimaryLight is a background version of the main contrast color.
PrimaryLight color.Color
// Secondary is used as a the secondary contrast color.
Secondary color.Color
// SecondaryDark is a foreground version of the secondary contrast color.
SecondaryDark color.Color
// SecondaryHighlight is a light version of the secondary contrast color.
SecondaryHighlight color.Color
// SecondaryLight is a background version of the secondary contrast color.
SecondaryLight color.Color
// ShadedBackground is a darker version of the background color.
ShadedBackground color.Color
// Text is the default text color.
Text color.Color
// TextNegative is the text color associated with a negative event.
TextNegative color.Color
// TextOnDisabled is text color rendered over an disabled control.
TextOnDisabled color.Color
// TextOnPrimary is the text color when used with the main contrast color as background.
TextOnPrimary color.Color
// TextOnSecondary is the text color when used with the secondary contrast color as background.
TextOnSecondary color.Color
// TextPositive is the text color associated with a positive event.
TextPositive color.Color
}
type Style struct {
Dimensions *Dimensions
Fonts *FontNames
Palette *Palette
}
func DefaultDimensions() *Dimensions {
return &Dimensions{
OutlineWidth: 2.,
ScrollbarWidth: 16.,
TextPadding: 8.,
}
}
func DefaultFontNames() *FontNames {
return &FontNames{
Default: "default",
Tooltip: "default",
}
}
func DefaultPalette() *Palette {
return &Palette{
Background: color.White,
Disabled: zntg.MustHexColor(`#BDBDBD`),
Primary: zntg.MustHexColor(`#3F51B5`),
PrimaryDark: zntg.MustHexColor(`#132584`),
PrimaryHighlight: zntg.MustHexColor(`#E8EAF6`),
PrimaryLight: zntg.MustHexColor(`#5E6EC7`),
Secondary: zntg.MustHexColor(`#FFA441`),
SecondaryDark: zntg.MustHexColor(`#C06605`),
SecondaryHighlight: zntg.MustHexColor(`#FFEFDD`),
SecondaryLight: zntg.MustHexColor(`#FFB564`),
ShadedBackground: zntg.MustHexColor(`#FAFAFA`),
Text: color.Black,
TextNegative: zntg.MustHexColor(`#FF4336`),
TextOnDisabled: zntg.MustHexColor(`#5C5C5C`),
TextOnPrimary: color.White,
TextOnSecondary: color.Black,
TextPositive: zntg.MustHexColor(`#4CAF50`),
}
}
func DefaultStyle() *Style {
return &Style{
Dimensions: DefaultDimensions(),
Fonts: DefaultFontNames(),
Palette: DefaultPalette(),
}
}