Compare commits

..

No commits in common. "3127aad09a3a2d07a8f01e84cec2119c8c991b22" and "98fb8a3e014afc42119278aac0c32739167e45c3" have entirely different histories.

3 changed files with 54 additions and 55 deletions

View File

@ -7,7 +7,6 @@ import _ "image/png"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/data" import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/canvas" import "git.tebibyte.media/tomo/tomo/canvas"
import "git.tebibyte.media/tomo/backend/style"
//go:embed assets/icons-small.png //go:embed assets/icons-small.png
var atlasSmallBytes []byte var atlasSmallBytes []byte
@ -418,7 +417,7 @@ type iconTheme struct {
} }
// New creates a new fallback icon theme. // New creates a new fallback icon theme.
func New () style.IconSet { func New () tomo.IconSet {
return new(iconTheme) return new(iconTheme)
} }

View File

@ -8,20 +8,19 @@ import "regexp"
import "strings" import "strings"
import _ "image/png" import _ "image/png"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
import xdgIconTheme "git.tebibyte.media/tomo/xdg/icon-theme"
import "git.tebibyte.media/tomo/tomo/data" import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/canvas" import "git.tebibyte.media/tomo/tomo/canvas"
import "git.tebibyte.media/tomo/backend/style"
import xdgIconTheme "git.tebibyte.media/tomo/xdg/icon-theme"
type iconTheme struct { type iconTheme struct {
xdg xdgIconTheme.Theme xdg xdgIconTheme.Theme
fallback style.IconSet fallback tomo.IconSet
texturesSmall map[tomo.Icon] canvas.Texture texturesSmall map[tomo.Icon] canvas.Texture
texturesMedium map[tomo.Icon] canvas.Texture texturesMedium map[tomo.Icon] canvas.Texture
texturesLarge map[tomo.Icon] canvas.Texture texturesLarge map[tomo.Icon] canvas.Texture
} }
func FindThemeWarn (name string, fallback style.IconSet, path ...string) (style.IconSet, error) { func FindThemeWarn (name string, fallback tomo.IconSet, path ...string) (tomo.IconSet, error) {
this := &iconTheme { this := &iconTheme {
fallback: fallback, fallback: fallback,
texturesLarge: make(map[tomo.Icon] canvas.Texture), texturesLarge: make(map[tomo.Icon] canvas.Texture),

View File

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