Update fallback style

This commit is contained in:
Sasha Koshka 2024-08-10 21:55:05 -04:00
parent fee4e584e7
commit 1feb5f4ab1

View File

@ -7,8 +7,8 @@ import _ "embed"
import _ "image/png"
import "image/color"
import "git.tebibyte.media/tomo/tomo"
import "golang.org/x/image/font/basicfont"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/backend/style"
var colorFocus = color.RGBA { R: 61, G: 128, B: 143, A: 255 }
var colorInput = color.RGBA { R: 208, G: 203, B: 150, A: 255 }
@ -55,7 +55,7 @@ func newCloserCookie (closer io.Closer) event.Cookie {
// New returns Wintergreen, the default Tomo style. It is neutral-gray with
// green and turquoise accents.
func New () (*tomo.Style, event.Cookie) {
func New () (*style.Style, event.Cookie) {
atlasImage, _, err := image.Decode(bytes.NewReader(atlasBytes))
if err != nil { panic(err) }
atlasTexture := tomo.NewTexture(atlasImage)
@ -68,17 +68,16 @@ func New () (*tomo.Style, event.Cookie) {
cookie := event.MultiCookie(newCloserCookie(atlasTexture))
rules := []tomo.Rule {
rules := []style.Rule {
// *.*
tomo.Ru(tomo.AS (
tomo.AFace (basicfont.Face7x13 ),
style.Ru(style.AS (
tomo.ATextColor (tomo.ColorForeground),
tomo.ADotColor (tomo.ColorAccent ),
tomo.AGap (8, 8 ),
), tomo.R("", "")),
// *.Button
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -91,7 +90,7 @@ rules := []tomo.Rule {
), tomo.R("", "Button")),
// *.Button[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -102,7 +101,7 @@ rules := []tomo.Rule {
), tomo.R("", "Button"), "focused"),
// *.Button[pressed]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -115,7 +114,7 @@ rules := []tomo.Rule {
), tomo.R("", "Button"), "pressed"),
// *.TextInput
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -127,7 +126,7 @@ rules := []tomo.Rule {
), tomo.R("", "TextInput")),
// *.TextInput[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -137,7 +136,7 @@ rules := []tomo.Rule {
), tomo.R("", "TextInput"), "focused"),
// *.TextView
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -149,12 +148,12 @@ rules := []tomo.Rule {
), tomo.R("", "TextView")),
// *.NumberInput
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AGap(0, 0),
), tomo.R("", "NumberInput")),
// *.Container[sunken]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -167,13 +166,13 @@ rules := []tomo.Rule {
), tomo.R("", "Container"), "sunken"),
// *.Container[outer]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrColor { Color: tomo.ColorBackground },
tomo.AttrPadding(tomo.I(8)),
), tomo.R("", "Container"), "outer"),
// *.Container[menu]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -186,12 +185,12 @@ rules := []tomo.Rule {
), tomo.R("", "Container"), "menu"),
// *.Heading
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AAlign(tomo.AlignMiddle, tomo.AlignMiddle),
), tomo.R("", "Heading")),
// *.Separator
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(1),
@ -201,7 +200,7 @@ rules := []tomo.Rule {
), tomo.R("", "Separator")),
// *.Slider
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -214,7 +213,7 @@ rules := []tomo.Rule {
), tomo.R("", "Slider")),
// *.Slider[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -225,17 +224,17 @@ rules := []tomo.Rule {
), tomo.R("", "Slider"), "focused"),
// *.Slider[horizontal]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AMinimumSize(48, 0),
), tomo.R("", "Slider"), "horizontal"),
// *.Slider[vertical]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AMinimumSize(0, 48),
), tomo.R("", "Slider"), "vertical"),
// *.SliderHandle
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -255,17 +254,17 @@ rules := []tomo.Rule {
), tomo.R("", "SliderHandle")),
// *.SliderHandle[horizontal]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ATexture(textureHandleHorizontal),
), tomo.R("", "SliderHandle"), "horizontal"),
// *.ScrollContainer
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AGap(0, 0),
), tomo.R("", "ScrollContainer")),
// *.Checkbox
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -280,7 +279,7 @@ rules := []tomo.Rule {
), tomo.R("", "Checkbox")),
// *.Checkbox[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
outline,
tomo.Border {
@ -291,39 +290,39 @@ rules := []tomo.Rule {
), tomo.R("", "Checkbox"), "focused"),
// *.Checkbox[checked]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ATexture(textureCheckboxChecked),
), tomo.R("", "Checkbox"), "checked"),
// *.MenuItem
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrPadding(tomo.I(4)),
tomo.AttrGap { X: 4, Y: 4 },
tomo.AttrColor { Color: color.Transparent },
), tomo.R("", "MenuItem")),
// *MenuItem[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrColor { Color: tomo.ColorAccent },
), tomo.R("", "MenuItem"), "focused"),
// *.MenuItem[hovered]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrColor { Color: tomo.ColorAccent },
), tomo.R("", "MenuItem"), "hovered"),
// *.File
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrColor { Color: color.Transparent },
), tomo.R("", "File")),
// *.File[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrColor { Color: tomo.ColorAccent },
), tomo.R("", "File"), "focused"),
// *.TearLine
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.ABorder (
tomo.Border {
Width: tomo.I(3),
@ -339,7 +338,7 @@ rules := []tomo.Rule {
), tomo.R("", "TearLine")),
// *.TearLine[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(3),
@ -349,7 +348,7 @@ rules := []tomo.Rule {
), tomo.R("", "TearLine"), "focused"),
// *.TearLine[hovered]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(3),
@ -359,7 +358,7 @@ rules := []tomo.Rule {
), tomo.R("", "TearLine"), "hovered"),
// *.Calendar
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(0, 1, 1, 0),
@ -373,37 +372,37 @@ rules := []tomo.Rule {
), tomo.R("", "Calendar")),
// *.CalendarGrid
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrGap { X: 2, Y: 2 },
), tomo.R("", "CalendarGrid")),
// *.CalendarWeekdayHeader
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrPadding(tomo.I(2)),
tomo.AttrColor { Color: colorCalendarWeekdayHeader },
), tomo.R("", "CalendarWeekdayHeader")),
// *.CalendarDay[weekday]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrPadding(tomo.I(2)),
tomo.AttrMinimumSize { X: 32, Y: 32 },
tomo.AttrColor { Color: colorCalendarDay },
), tomo.R("", "CalendarDay"), "weekday"),
// *.CalendarDay[weekend]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrPadding(tomo.I(2)),
tomo.AttrMinimumSize { X: 32, Y: 32 },
tomo.AttrColor { Color: colorCalendarWeekend },
), tomo.R("", "CalendarDay"), "weekend"),
// *.TabbedContainer
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AGap(0, 0),
), tomo.R("", "TabbedContainer")),
// *.TabRow
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(1, 1, 0, 1),
@ -420,7 +419,7 @@ rules := []tomo.Rule {
), tomo.R("", "TabRow")),
// *.TabSpacer[left]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(0, 0, 1, 0),
@ -435,7 +434,7 @@ rules := []tomo.Rule {
), tomo.R("", "TabSpacer")),
// *.TabSpacer[right]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(1, 0, 0, 0),
@ -461,7 +460,7 @@ rules := []tomo.Rule {
), tomo.R("", "TabSpacer"), "right"),
// *.Tab
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(1, 0, 0, 0),
@ -488,7 +487,7 @@ rules := []tomo.Rule {
), tomo.R("", "Tab")),
// *.Tab[active]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
tomo.Border {
Width: tomo.I(1, 0, 0, 1),
@ -504,7 +503,7 @@ rules := []tomo.Rule {
), tomo.R("", "Tab"), "active"),
// *.Swatch
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
},
@ -512,7 +511,7 @@ rules := []tomo.Rule {
), tomo.R("", "Swatch")),
// *.Swatch[focused]
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -523,7 +522,7 @@ rules := []tomo.Rule {
), tomo.R("", "Swatch"), "focused"),
// *.ColorPickerMap
tomo.Ru(tomo.AS (
style.Ru(style.AS (
tomo.AttrBorder {
outline,
tomo.Border {
@ -536,7 +535,7 @@ rules := []tomo.Rule {
), tomo.R("", "ColorPickerMap")),
}
return &tomo.Style {
return &style.Style {
Rules: rules,
Colors: map[tomo.Color] color.Color {
tomo.ColorBackground: colorBackground,