From f59949c3bbaa6c3630ed2dbc2eb19eb8d9cf509f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 3 May 2024 19:58:28 -0400 Subject: [PATCH] Integrated Wintergreen theme as default --- internal/registry/registry_unix.go | 3 + internal/theme/default/default.go | 231 +++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 internal/theme/default/default.go diff --git a/internal/registry/registry_unix.go b/internal/registry/registry_unix.go index b0a0bf6..d9b0449 100644 --- a/internal/registry/registry_unix.go +++ b/internal/registry/registry_unix.go @@ -3,8 +3,11 @@ package registry import "git.tebibyte.media/tomo/x" import "git.tebibyte.media/tomo/tomo" +import "git.tebibyte.media/tomo/tomo/theme" +import "git.tebibyte.media/tomo/nasin/internal/theme/default" func Init () error { + theme.SetTheme(defaultTheme.Theme()) tomo.Register(1, x.NewBackend) return nil } diff --git a/internal/theme/default/default.go b/internal/theme/default/default.go new file mode 100644 index 0000000..624958e --- /dev/null +++ b/internal/theme/default/default.go @@ -0,0 +1,231 @@ +package defaultTheme + +import "image/color" +import "git.tebibyte.media/tomo/tomo" +import "golang.org/x/image/font/basicfont" +import "git.tebibyte.media/tomo/tomo/theme" +import dataTheme "git.tebibyte.media/tomo/nasin/internal/theme" + +var colorFocus = color.RGBA { R: 61, G: 128, B: 143, A: 255 } +var colorInput = color.RGBA { R: 208, G: 203, B: 150, A: 255 } +var colorCarved = color.RGBA { R: 151, G: 160, B: 150, A: 255 } +var colorShadow = color.RGBA { R: 57, G: 59, B: 57, A: 255 } +var colorInputShadow = color.RGBA { R: 143, G: 146, B: 91, A: 255 } +var colorHighlight = color.RGBA { R: 207, G: 215, B: 210, A: 255 } +var colorBackground = color.RGBA { R: 169, G: 171, B: 168, A: 255 } +var colorCarvedPressed = color.RGBA { R: 129, G: 142, B: 137, A: 255 } +var colorForeground = color.Black +var colorOutline = color.Black + +var outline = tomo.Border { + Width: tomo.I(1), + Color: [4]color.Color { + colorOutline, + colorOutline, + colorOutline, + colorOutline, + }, +} + +var borderColorEngraved = [4]color.Color { colorShadow, colorHighlight, colorHighlight, colorShadow } +var borderColorLifted = [4]color.Color { colorHighlight, colorShadow, colorShadow, colorHighlight } +var borderColorInput = [4]color.Color { colorInputShadow, colorInput, colorInput, colorInputShadow } +var borderColorFocused = [4]color.Color { colorFocus, colorFocus, colorFocus, colorFocus } + +var rules = []dataTheme.Rule { + // *.*[*] + dataTheme.Rule { + Default: dataTheme.AS ( + dataTheme.AttrFace { Face: basicfont.Face7x13 }, + dataTheme.AttrTextColor { Color: theme.ColorForeground }, + dataTheme.AttrDotColor { Color: theme.ColorAccent }, + dataTheme.AttrGap { X: 8, Y: 8 }, + ), + }, + + // *.Button[*] + dataTheme.Rule { + Role: theme.R("", "Button", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorLifted, + }, + }, + dataTheme.AttrPadding(tomo.I(4, 8)), + dataTheme.AttrColor { Color: theme.ColorRaised }, + ), + Pressed: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1, 0, 0, 1), + Color: borderColorEngraved, + }, + }, + dataTheme.AttrPadding(tomo.I(5, 8, 4, 9)), + dataTheme.AttrColor { Color: colorCarvedPressed }, + ), + Focused: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorFocused, + }, + }, + dataTheme.AttrPadding(tomo.I(4, 8)), + ), + }, + + // *.TextInput[*] + dataTheme.Rule { + Role: theme.R("", "TextInput", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorInput, + }, + }, + dataTheme.AttrColor { Color: colorInput }, + dataTheme.AttrPadding(tomo.I(5, 4, 4, 5)), + ), + Focused: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorFocused, + }, + }, + ), + }, + + // *.NumberInput[*] + dataTheme.Rule { + Role: theme.R("", "NumberInput", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorInput, + }, + }, + dataTheme.AttrColor { Color: colorInput }, + dataTheme.AttrPadding(tomo.I(5, 4, 4, 5)), + ), + Focused: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorFocused, + }, + }, + ), + }, + + // *.Container[outer] + dataTheme.Rule { + Role: theme.R("", "Container", "outer"), + Default: dataTheme.AS ( + dataTheme.AttrColor { Color: theme.ColorBackground }, + dataTheme.AttrPadding(tomo.I(8)), + ), + }, + + // *.Heading[*] + dataTheme.Rule { + Role: theme.R("", "Heading", ""), + Default: dataTheme.AS ( + dataTheme.AttrAlign { X: tomo.AlignMiddle, Y: tomo.AlignMiddle }, + ), + }, + + // *.Separator[*] + dataTheme.Rule { + Role: theme.R("", "Separator", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + tomo.Border { + Width: tomo.I(1), + Color: borderColorEngraved, + }, + }, + ), + }, + + // *.Slider[*] + dataTheme.Rule { + Role: theme.R("", "Slider", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1, 0, 0, 1), + Color: borderColorEngraved, + }, + }, + dataTheme.AttrColor { Color: theme.ColorSunken }, + dataTheme.AttrPadding(tomo.I(0, 1, 1, 0)), + ), + Focused: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorFocused, + }, + }, + dataTheme.AttrPadding(tomo.I(0)), + ), + }, + + // *.Slider[horizontal] + dataTheme.Rule { + Role: theme.R("", "Slider", "horizontal"), + Default: dataTheme.AS(dataTheme.AttrMinimumSize { X: 48 }), + }, + + // *.Slider[vertical] + dataTheme.Rule { + Role: theme.R("", "Slider", "vertical"), + Default: dataTheme.AS(dataTheme.AttrMinimumSize { Y: 48 }), + }, + + // *.SliderHandle[*] + dataTheme.Rule { + Role: theme.R("", "SliderHandle", ""), + Default: dataTheme.AS ( + dataTheme.AttrBorder { + outline, + tomo.Border { + Width: tomo.I(1), + Color: borderColorLifted, + }, + }, + dataTheme.AttrColor { Color: theme.ColorRaised }, + dataTheme.AttrMinimumSize { X: 12, Y: 12, }, + ), + }, +} + +// Theme returns Wintergreen, the default Tomo theme. It is neutral-gray with +// green and turquoise accents. +func Theme () theme.Theme { + return &dataTheme.Theme { + Colors: map[theme.Color] color.Color { + theme.ColorBackground: colorBackground, + theme.ColorForeground: colorForeground, + theme.ColorRaised: colorCarved, + theme.ColorSunken: colorCarved, + theme.ColorAccent: colorFocus, + }, + Rules: rules, + } +}