Restructure internal theme
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@ -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 dataTheme "git.tebibyte.media/tomo/nasin/internal/theme"
|
|
||||||
|
|
||||||
//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 () dataTheme.IconTheme {
|
func New () tomo.Icons {
|
||||||
return new(iconTheme)
|
return new(iconTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,17 +11,16 @@ import "git.tebibyte.media/tomo/tomo"
|
|||||||
import xdgIconTheme "git.tebibyte.media/tomo/xdg/icon-theme"
|
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/nasin/internal/theme"
|
|
||||||
|
|
||||||
type iconTheme struct {
|
type iconTheme struct {
|
||||||
xdg xdgIconTheme.Theme
|
xdg xdgIconTheme.Theme
|
||||||
fallback theme.IconTheme
|
fallback tomo.Icons
|
||||||
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 theme.IconTheme, path ...string) (theme.IconTheme, error) {
|
func FindThemeWarn (name string, fallback tomo.Icons, path ...string) (tomo.Icons, error) {
|
||||||
this := &iconTheme {
|
this := &iconTheme {
|
||||||
fallback: fallback,
|
fallback: fallback,
|
||||||
texturesLarge: make(map[tomo.Icon] canvas.Texture),
|
texturesLarge: make(map[tomo.Icon] canvas.Texture),
|
||||||
@ -3,36 +3,37 @@ package registrar
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
import "log"
|
import "log"
|
||||||
import "git.tebibyte.media/tomo/backend/x"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import dataTheme "git.tebibyte.media/tomo/nasin/internal/theme"
|
import "git.tebibyte.media/tomo/backend/x"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/icons/xdg"
|
import "git.tebibyte.media/tomo/nasin/internal/style"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/icons/fallback"
|
import "git.tebibyte.media/tomo/nasin/internal/icons/xdg"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/style/fallback"
|
import "git.tebibyte.media/tomo/nasin/internal/icons/fallback"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/style/aluminum"
|
import "git.tebibyte.media/tomo/nasin/internal/style/fallback"
|
||||||
|
import "git.tebibyte.media/tomo/nasin/internal/style/aluminum"
|
||||||
|
|
||||||
func Init () error {
|
func Init () error {
|
||||||
var theme *dataTheme.Theme
|
var styl *style.Style
|
||||||
// TODO eventually get rid of this when we make a file format for
|
// TODO eventually get rid of this when we make a file format for
|
||||||
// storing visual styles
|
// storing visual styles
|
||||||
if os.Getenv("TOMO_USE_ALUMINUM_STYLE") != "" {
|
if os.Getenv("TOMO_USE_ALUMINUM_STYLE") != "" {
|
||||||
theme = aluminumStyle.New()
|
styl = aluminumStyle.New()
|
||||||
} else {
|
} else {
|
||||||
theme = fallbackStyle.New()
|
styl = fallbackStyle.New()
|
||||||
}
|
}
|
||||||
theme.IconTheme = fallbackIcons.New()
|
icons := fallbackIcons.New()
|
||||||
|
|
||||||
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
|
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
|
||||||
if iconThemeName != "" {
|
if iconThemeName != "" {
|
||||||
iconTheme, err := xdgIcons.FindThemeWarn(iconThemeName, theme.IconTheme)
|
xdgIconTheme, err := xdgIcons.FindThemeWarn(iconThemeName, icons)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
theme.IconTheme = iconTheme
|
icons = xdgIconTheme
|
||||||
} else {
|
} else {
|
||||||
log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err)
|
log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tomo.SetTheme(theme)
|
tomo.SetStyle(styl)
|
||||||
|
tomo.SetIcons(icons)
|
||||||
tomo.Register(1, x.New)
|
tomo.Register(1, x.New)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,11 @@ package aluminumStyle
|
|||||||
|
|
||||||
import "image/color"
|
import "image/color"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import dataTheme "git.tebibyte.media/tomo/nasin/internal/theme"
|
import "git.tebibyte.media/tomo/nasin/internal/style"
|
||||||
|
|
||||||
// New returns Aluminum, a futuristic, bluish-white style.
|
// New returns Aluminum, a futuristic, bluish-white style.
|
||||||
func New () *dataTheme.Theme {
|
func New () *style.Style {
|
||||||
return &dataTheme.Theme {
|
return &style.Style {
|
||||||
Colors: map[tomo.Color] color.Color {
|
Colors: map[tomo.Color] color.Color {
|
||||||
tomo.ColorBackground: colorBackground,
|
tomo.ColorBackground: colorBackground,
|
||||||
tomo.ColorForeground: colorForeground,
|
tomo.ColorForeground: colorForeground,
|
||||||
@ -3,7 +3,7 @@ package aluminumStyle
|
|||||||
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 "golang.org/x/image/font/basicfont"
|
||||||
import dataTheme "git.tebibyte.media/tomo/nasin/internal/theme"
|
import "git.tebibyte.media/tomo/nasin/internal/style"
|
||||||
|
|
||||||
func hex (color uint32) (c color.RGBA) {
|
func hex (color uint32) (c color.RGBA) {
|
||||||
c.A = uint8(color)
|
c.A = uint8(color)
|
||||||
@ -62,66 +62,66 @@ var borderTearPadFocused = border(0x7391c080, 0x7391c080, 0x7391c080, 0x7391c080
|
|||||||
var borderInnerShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 1, 0, 0, 1)
|
var borderInnerShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 1, 0, 0, 1)
|
||||||
var borderOuterShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 0, 1, 1, 0)
|
var borderOuterShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 0, 1, 1, 0)
|
||||||
|
|
||||||
var rules = []dataTheme.Rule {
|
var rules = []style.Rule {
|
||||||
// *.*[*]
|
// *.*[*]
|
||||||
dataTheme.Rule {
|
style.Rule {
|
||||||
Default: dataTheme.AS (
|
Default: style.AS (
|
||||||
dataTheme.AttrFace { Face: basicfont.Face7x13 },
|
style.AttrFace { Face: basicfont.Face7x13 },
|
||||||
dataTheme.AttrTextColor { Color: tomo.ColorForeground },
|
style.AttrTextColor { Color: tomo.ColorForeground },
|
||||||
dataTheme.AttrDotColor { Color: colorDot },
|
style.AttrDotColor { Color: colorDot },
|
||||||
dataTheme.AttrGap { X: 8, Y: 8 },
|
style.AttrGap { X: 8, Y: 8 },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
// *.Button[*]
|
// *.Button[*]
|
||||||
dataTheme.Rule {
|
style.Rule {
|
||||||
Role: tomo.R("", "Button", ""),
|
Role: tomo.R("", "Button", ""),
|
||||||
Default: dataTheme.AS (
|
Default: style.AS (
|
||||||
dataTheme.AttrBorder {
|
style.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderGap,
|
borderGap,
|
||||||
borderLifted,
|
borderLifted,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(4, 8)),
|
style.AttrPadding(tomo.I(4, 8)),
|
||||||
dataTheme.AttrColor { Color: tomo.ColorRaised },
|
style.AttrColor { Color: tomo.ColorRaised },
|
||||||
),
|
),
|
||||||
Pressed: dataTheme.AS (
|
Pressed: style.AS (
|
||||||
dataTheme.AttrBorder {
|
style.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderGap,
|
borderGap,
|
||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(5, 8, 4, 9)),
|
style.AttrPadding(tomo.I(5, 8, 4, 9)),
|
||||||
dataTheme.AttrColor { Color: colorRaisedPressed },
|
style.AttrColor { Color: colorRaisedPressed },
|
||||||
),
|
),
|
||||||
Focused: dataTheme.AS (
|
Focused: style.AS (
|
||||||
dataTheme.AttrBorder {
|
style.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderGap,
|
borderGap,
|
||||||
borderLiftedFocused,
|
borderLiftedFocused,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(4, 8)),
|
style.AttrPadding(tomo.I(4, 8)),
|
||||||
dataTheme.AttrColor { Color: colorRaisedFocused },
|
style.AttrColor { Color: colorRaisedFocused },
|
||||||
),
|
),
|
||||||
Hovered: dataTheme.AS (
|
Hovered: style.AS (
|
||||||
dataTheme.AttrColor { Color: colorRaisedHovered },
|
style.AttrColor { Color: colorRaisedHovered },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
// *.TextInput[*]
|
// *.TextInput[*]
|
||||||
dataTheme.Rule {
|
style.Rule {
|
||||||
Role: tomo.R("", "TextInput", ""),
|
Role: tomo.R("", "TextInput", ""),
|
||||||
Default: dataTheme.AS (
|
Default: style.AS (
|
||||||
dataTheme.AttrBorder {
|
style.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderGap,
|
borderGap,
|
||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||
},
|
},
|
||||||
dataTheme.AttrColor { Color: tomo.ColorSunken },
|
style.AttrColor { Color: tomo.ColorSunken },
|
||||||
dataTheme.AttrPadding(tomo.I(5, 4, 4, 5)),
|
style.AttrPadding(tomo.I(5, 4, 4, 5)),
|
||||||
),
|
),
|
||||||
Focused: dataTheme.AS (
|
Focused: style.AS (
|
||||||
dataTheme.AttrBorder {
|
style.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderFocused,
|
borderFocused,
|
||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||