package fallbackStyle import "io" import "bytes" import "image" import _ "embed" import _ "image/png" import "image/color" import "git.tebibyte.media/tomo/tomo" 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 } var colorCarved = color.RGBA { R: 151, G: 160, B: 150, A: 255 } var colorGutter = color.RGBA { R: 116, G: 132, B: 126, A: 255 } var colorShadow = color.RGBA { R: 57, G: 59, B: 57, A: 255 } var colorShade = color.RGBA { A: 128 } 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 colorCalendarWeekdayHeader = color.RGBA { R: 194, G: 162, B: 132, A: 255 } var colorCalendarWeekend = color.RGBA { R: 165, G: 185, B: 120, A: 255 } var colorCalendarDay = color.RGBA { R: 194, G: 189, B: 132, A: 255 } var colorInactive = color.RGBA { R: 131, G: 147, B: 134, A: 255 } var outline = tomo.Border { Width: tomo.I(1), Color: [4]color.Color { colorOutline, colorOutline, colorOutline, colorOutline, }, } var borderColorOutline = [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 borderColorShade = [4]color.Color { colorShade, colorShade, colorShade, colorShade } //go:embed assets/atlas.png var atlasBytes []byte type closerCookie struct { io.Closer } func (cookie closerCookie) Close () { cookie.Closer.Close() } func newCloserCookie (closer io.Closer) event.Cookie { return closerCookie { Closer: closer } } // New returns Wintergreen, the default Tomo style. It is neutral-gray with // green and turquoise accents. func New () (*style.Style, event.Cookie) { atlasImage, _, err := image.Decode(bytes.NewReader(atlasBytes)) if err != nil { panic(err) } atlasTexture := tomo.NewTexture(atlasImage) textureCheckboxChecked := atlasTexture.SubTexture(image.Rect( 0, 0, 12, 11)) // textureCorkboard := atlasTexture.SubTexture(image.Rect(16, 0, 28, 12)) textureTearLine := atlasTexture.SubTexture(image.Rect(16, 12, 18, 13)) textureHandleVertical := atlasTexture.SubTexture(image.Rect(28, 0, 29, 2)) textureHandleHorizontal := atlasTexture.SubTexture(image.Rect(28, 0, 30, 1)) cookie := event.MultiCookie(newCloserCookie(atlasTexture)) rules := []style.Rule { // *.* style.Ru(style.AS ( tomo.ATextColor (tomo.ColorForeground), tomo.ADotColor (tomo.ColorAccent ), tomo.AGap (8, 8 ), ), tomo.R("", "")), // *.Button style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorLifted, }, }, tomo.AttrPadding(tomo.I(4, 8)), tomo.AttrColor { Color: tomo.ColorRaised }, ), tomo.R("", "Button")), // *.Button[focused] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }, }, ), tomo.R("", "Button"), "focused"), // *.Button[pressed] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrPadding(tomo.I(5, 8, 4, 9)), tomo.AttrColor { Color: colorCarvedPressed }, ), tomo.R("", "Button"), "pressed"), // *.TextInput style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorInput, }), tomo.AColor(colorInput), tomo.APadding(5, 4, 4, 5), ), tomo.R("", "TextInput")), // *.TextInput[focused] style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }), ), tomo.R("", "TextInput"), "focused"), // *.TextView style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }), tomo.AColor(tomo.ColorSunken), tomo.APadding(8), ), tomo.R("", "TextView")), // *.NumberInput style.Ru(style.AS ( tomo.AGap(0, 0), ), tomo.R("", "NumberInput")), // *.Container[sunken] style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }), tomo.AColor(tomo.ColorSunken), // tomo.ATexture(textureCorkboard), tomo.APadding(8), ), tomo.R("", "Container"), "sunken"), // *.Container[outer] style.Ru(style.AS ( tomo.AttrColor { Color: tomo.ColorBackground }, tomo.AttrPadding(tomo.I(8)), ), tomo.R("", "Container"), "outer"), // *.Container[menu] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorLifted, }, }, tomo.AttrColor { Color: tomo.ColorBackground }, tomo.AttrGap { }, ), tomo.R("", "Container"), "menu"), // *.Heading style.Ru(style.AS ( tomo.AAlign(tomo.AlignMiddle, tomo.AlignMiddle), ), tomo.R("", "Heading")), // *.Heading style.Ru(style.AS ( tomo.APadding(4, 8), ), tomo.R("", "Heading"), "menu"), // *.Separator style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(1), Color: borderColorEngraved, }, }, ), tomo.R("", "Separator")), // *.Slider style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrColor { Color: colorGutter }, tomo.AttrPadding(tomo.I(0, 1, 1, 0)), ), tomo.R("", "Slider")), // *.Slider[focused] style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }), tomo.APadding(0), ), tomo.R("", "Slider"), "focused"), // *.Slider[horizontal] style.Ru(style.AS ( tomo.AMinimumSize(48, 0), ), tomo.R("", "Slider"), "horizontal"), // *.Slider[vertical] style.Ru(style.AS ( tomo.AMinimumSize(0, 48), ), tomo.R("", "Slider"), "vertical"), // *.SliderHandle style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorLifted, }, tomo.Border { Width: tomo.I(1), Color: [4]color.Color { tomo.ColorRaised, tomo.ColorRaised, tomo.ColorRaised, tomo.ColorRaised, }, }), tomo.AColor(nil), tomo.ATexture(textureHandleVertical), tomo.AMinimumSize(12, 12), ), tomo.R("", "SliderHandle")), // *.SliderHandle[horizontal] style.Ru(style.AS ( tomo.ATexture(textureHandleHorizontal), ), tomo.R("", "SliderHandle"), "horizontal"), // *.Scrollbar style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrColor { Color: colorGutter }, tomo.AttrPadding(tomo.I(0, 1, 1, 0)), ), tomo.R("", "Scrollbar")), // *.Scrollbar[focused] style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }), tomo.APadding(0), ), tomo.R("", "Scrollbar"), "focused"), // *.Scrollbar[horizontal] style.Ru(style.AS ( tomo.AMinimumSize(48, 0), ), tomo.R("", "Scrollbar"), "horizontal"), // *.Scrollbar[vertical] style.Ru(style.AS ( tomo.AMinimumSize(0, 48), ), tomo.R("", "Scrollbar"), "vertical"), // *.ScrollbarHandle style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorLifted, }, tomo.Border { Width: tomo.I(1), Color: [4]color.Color { tomo.ColorRaised, tomo.ColorRaised, tomo.ColorRaised, tomo.ColorRaised, }, }), tomo.AColor(nil), tomo.ATexture(textureHandleVertical), tomo.AMinimumSize(12, 12), ), tomo.R("", "ScrollbarHandle")), // *.ScrollbarHandle[horizontal] style.Ru(style.AS ( tomo.ATexture(textureHandleHorizontal), ), tomo.R("", "ScrollbarHandle"), "horizontal"), // *.ScrollContainer style.Ru(style.AS ( tomo.AGap(0, 0), ), tomo.R("", "ScrollContainer")), // *.Checkbox style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }), tomo.AColor(tomo.ColorSunken), tomo.APadding(0, 1, 1, 0), tomo.AMinimumSize(19, 19), tomo.ATexture(nil), tomo.ATextureMode(tomo.TextureModeCenter), ), tomo.R("", "Checkbox")), // *.Checkbox[focused] style.Ru(style.AS ( tomo.ABorder ( outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }), tomo.APadding(0), ), tomo.R("", "Checkbox"), "focused"), // *.Checkbox[checked] style.Ru(style.AS ( tomo.ATexture(textureCheckboxChecked), ), tomo.R("", "Checkbox"), "checked"), // *.MenuItem 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] style.Ru(style.AS ( tomo.AttrColor { Color: tomo.ColorAccent }, ), tomo.R("", "MenuItem"), "focused"), // *.MenuItem[hovered] style.Ru(style.AS ( tomo.AttrColor { Color: tomo.ColorAccent }, ), tomo.R("", "MenuItem"), "hovered"), // *.File style.Ru(style.AS ( tomo.AttrColor { Color: color.Transparent }, ), tomo.R("", "File")), // *.File[focused] style.Ru(style.AS ( tomo.AttrColor { Color: tomo.ColorAccent }, ), tomo.R("", "File"), "focused"), // *.TearLine style.Ru(style.AS ( tomo.ABorder ( tomo.Border { Width: tomo.I(3), Color: [4]color.Color { color.Transparent, color.Transparent, color.Transparent, color.Transparent, }, }), tomo.ATexture(textureTearLine), tomo.APadding(1, 0, 0, 1), ), tomo.R("", "TearLine")), // *.TearLine[focused] style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(3), Color: borderColorFocused, }, }, ), tomo.R("", "TearLine"), "focused"), // *.TearLine[hovered] style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(3), Color: borderColorFocused, }, }, ), tomo.R("", "TearLine"), "hovered"), // *.Calendar style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(0, 1, 1, 0), Color: borderColorShade, }, outline, }, tomo.AttrColor { Color: colorInput }, tomo.AttrPadding(tomo.I(2)), tomo.AttrGap { X: 2, Y: 2 }, ), tomo.R("", "Calendar")), // *.CalendarGrid style.Ru(style.AS ( tomo.AttrGap { X: 2, Y: 2 }, ), tomo.R("", "CalendarGrid")), // *.CalendarWeekdayHeader style.Ru(style.AS ( tomo.AttrPadding(tomo.I(2)), tomo.AttrColor { Color: colorCalendarWeekdayHeader }, ), tomo.R("", "CalendarWeekdayHeader")), // *.CalendarDay[weekday] 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] style.Ru(style.AS ( tomo.AttrPadding(tomo.I(2)), tomo.AttrMinimumSize { X: 32, Y: 32 }, tomo.AttrColor { Color: colorCalendarWeekend }, ), tomo.R("", "CalendarDay"), "weekend"), // *.TabbedContainer style.Ru(style.AS ( tomo.AGap(0, 0), ), tomo.R("", "TabbedContainer")), // *.TabRow style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(1, 1, 0, 1), Color: borderColorOutline, }, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrGap { X: 0, Y: 0 }, tomo.AttrColor { Color: colorGutter }, tomo.AttrPadding(tomo.I(1, 0, 0, 0)), ), tomo.R("", "TabRow")), // *.TabSpacer[left] style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(0, 0, 1, 0), Color: borderColorEngraved, }, tomo.Border { Width: tomo.I(0, 0, 1, 0), Color: borderColorOutline, }, }, tomo.AttrMinimumSize { X: 1 }, ), tomo.R("", "TabSpacer")), // *.TabSpacer[right] style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(1, 0, 0, 0), Color: [4]color.Color { colorGutter, colorGutter, colorGutter, colorGutter, }, }, tomo.Border { Width: tomo.I(0, 0, 1, 0), Color: borderColorEngraved, }, tomo.Border { Width: tomo.I(0, 0, 1, 1), Color: borderColorOutline, }, tomo.Border { Width: tomo.I(0, 0, 0, 1), Color: borderColorShade, }, }, tomo.AttrMinimumSize { X: 3 }, ), tomo.R("", "TabSpacer"), "right"), // *.Tab style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(1, 0, 0, 0), Color: [4]color.Color { colorGutter, colorGutter, colorGutter, colorGutter, }, }, tomo.Border { Width: tomo.I(0, 0, 1, 0), Color: borderColorEngraved, }, tomo.Border { Width: tomo.I(1, 0, 1, 1), Color: borderColorOutline, }, tomo.Border { Width: tomo.I(1, 1, 0, 1), Color: borderColorLifted, }, }, tomo.AttrPadding(tomo.I(4, 8, 4, 8)), tomo.AttrColor { Color: tomo.ColorRaised }, ), tomo.R("", "Tab")), // *.Tab[active] style.Ru(style.AS ( tomo.AttrBorder { tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorOutline, }, tomo.Border { Width: tomo.I(1, 1, 0, 1), Color: borderColorLifted, }, }, tomo.AttrPadding(tomo.I(4, 8, 7, 8)), tomo.AttrColor { Color: tomo.ColorBackground }, ), tomo.R("", "Tab"), "active"), // *.Swatch style.Ru(style.AS ( tomo.AttrBorder { outline, }, tomo.AttrMinimumSize { X: 19, Y: 19 }, ), tomo.R("", "Swatch")), // *.Swatch[focused] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }, }, ), tomo.R("", "Swatch"), "focused"), // *.ColorPickerMap style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrColor { Color: tomo.ColorSunken }, tomo.AttrMinimumSize { X: 128, Y: 128 }, ), tomo.R("", "ColorPickerMap")), // *.Dropdown style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorLifted, }, }, tomo.AttrPadding(tomo.I(4, 8)), tomo.AttrColor { Color: tomo.ColorRaised }, ), tomo.R("", "Dropdown")), // *.Dropdown[focused] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1), Color: borderColorFocused, }, }, ), tomo.R("", "Dropdown"), "focused"), // *.Dropdown[pressed] style.Ru(style.AS ( tomo.AttrBorder { outline, tomo.Border { Width: tomo.I(1, 0, 0, 1), Color: borderColorEngraved, }, }, tomo.AttrPadding(tomo.I(5, 8, 4, 9)), tomo.AttrColor { Color: colorCarvedPressed }, ), tomo.R("", "Dropdown"), "pressed"), } return &style.Style { Rules: rules, Colors: map[tomo.Color] color.Color { tomo.ColorBackground: colorBackground, tomo.ColorForeground: colorForeground, tomo.ColorRaised: colorCarved, tomo.ColorSunken: colorCarved, tomo.ColorAccent: colorFocus, }, }, cookie }