Restructure internal/theme
@ -7,7 +7,7 @@ import "git.tebibyte.media/tomo/nasin"
|
|||||||
import "git.tebibyte.media/tomo/objects"
|
import "git.tebibyte.media/tomo/objects"
|
||||||
import "git.tebibyte.media/tomo/tomo/input"
|
import "git.tebibyte.media/tomo/tomo/input"
|
||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/xdgicons"
|
import "git.tebibyte.media/tomo/nasin/internal/theme/icons/xdg"
|
||||||
|
|
||||||
const scrollIcons = true
|
const scrollIcons = true
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@ package registrar
|
|||||||
|
|
||||||
import "os"
|
import "os"
|
||||||
import "log"
|
import "log"
|
||||||
import "git.tebibyte.media/tomo/x"
|
import "git.tebibyte.media/tomo/backend/x"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/default"
|
import "git.tebibyte.media/tomo/nasin/internal/theme/icons/xdg"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/theme/xdgicons"
|
import "git.tebibyte.media/tomo/nasin/internal/theme/icons/fallback"
|
||||||
|
import "git.tebibyte.media/tomo/nasin/internal/theme/style/fallback"
|
||||||
|
|
||||||
func Init () error {
|
func Init () error {
|
||||||
theme := defaultTheme.Theme()
|
theme := fallbackStyle.New()
|
||||||
|
|
||||||
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
|
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
|
||||||
if iconThemeName != "" {
|
if iconThemeName != "" {
|
||||||
@ -20,8 +21,12 @@ func Init () error {
|
|||||||
log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err)
|
log.Printf("nasin: could not load icon theme '%s': %v", iconThemeName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if theme.IconTheme == nil {
|
||||||
|
theme.IconTheme = fallbackIcons.New()
|
||||||
|
}
|
||||||
|
|
||||||
tomo.SetTheme(theme)
|
tomo.SetTheme(theme)
|
||||||
tomo.Register(1, x.NewBackend)
|
tomo.Register(1, x.New)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
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 |
@ -1,4 +1,4 @@
|
|||||||
package defaultTheme
|
package fallbackIcons
|
||||||
|
|
||||||
import "bytes"
|
import "bytes"
|
||||||
import "image"
|
import "image"
|
||||||
@ -7,6 +7,7 @@ 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
|
||||||
@ -416,6 +417,11 @@ type iconTheme struct {
|
|||||||
texturesLarge map[tomo.Icon] canvas.Texture
|
texturesLarge map[tomo.Icon] canvas.Texture
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new fallback icon theme.
|
||||||
|
func New () dataTheme.IconTheme {
|
||||||
|
return new(iconTheme)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *iconTheme) ensure () {
|
func (this *iconTheme) ensure () {
|
||||||
if this.texturesSmall != nil { return }
|
if this.texturesSmall != nil { return }
|
||||||
this.texturesSmall = generateSource(atlasSmallBytes, 16)
|
this.texturesSmall = generateSource(atlasSmallBytes, 16)
|
@ -54,14 +54,14 @@ func (this *iconTheme) xdgIcon (name string, size tomo.IconSize) (canvas.Texture
|
|||||||
iconFile, err := os.Open(icon.Path)
|
iconFile, err := os.Open(icon.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this failing indicates a broken icon theme
|
// this failing indicates a broken icon theme
|
||||||
log.Println("nasin: icon file '%s' is inaccessible: %v", icon.Path, err)
|
log.Printf("nasin: icon file '%s' is inaccessible: %v\n", icon.Path, err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
iconImage, _, err := image.Decode(iconFile)
|
iconImage, _, err := image.Decode(iconFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this failing indicates a broken icon theme
|
// this failing indicates a broken icon theme
|
||||||
log.Println("nasin: icon file '%s' is broken: %v", icon.Path, err)
|
log.Printf("nasin: icon file '%s' is broken: %v\n", icon.Path, err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package defaultTheme
|
package fallbackStyle
|
||||||
|
|
||||||
import "image/color"
|
import "image/color"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
@ -295,4 +295,15 @@ var rules = []dataTheme.Rule {
|
|||||||
dataTheme.AttrColor { Color: tomo.ColorAccent },
|
dataTheme.AttrColor { Color: tomo.ColorAccent },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// *.File[*]
|
||||||
|
dataTheme.Rule {
|
||||||
|
Role: tomo.R("", "File", ""),
|
||||||
|
Default: dataTheme.AS (
|
||||||
|
dataTheme.AttrColor { Color: color.Transparent },
|
||||||
|
),
|
||||||
|
Focused: dataTheme.AS (
|
||||||
|
dataTheme.AttrColor { Color: tomo.ColorAccent },
|
||||||
|
),
|
||||||
|
},
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
package defaultTheme
|
package fallbackStyle
|
||||||
|
|
||||||
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 dataTheme "git.tebibyte.media/tomo/nasin/internal/theme"
|
||||||
|
|
||||||
// Theme returns Wintergreen, the default Tomo tomo. It is neutral-gray with
|
// New returns Wintergreen, the default Tomo tomo. It is neutral-gray with green
|
||||||
// green and turquoise accents.
|
// and turquoise accents.
|
||||||
func Theme () *dataTheme.Theme {
|
func New () *dataTheme.Theme {
|
||||||
return &dataTheme.Theme {
|
return &dataTheme.Theme {
|
||||||
Colors: map[tomo.Color] color.Color {
|
Colors: map[tomo.Color] color.Color {
|
||||||
tomo.ColorBackground: colorBackground,
|
tomo.ColorBackground: colorBackground,
|
||||||
@ -16,6 +16,5 @@ func Theme () *dataTheme.Theme {
|
|||||||
tomo.ColorAccent: colorFocus,
|
tomo.ColorAccent: colorFocus,
|
||||||
},
|
},
|
||||||
Rules: rules,
|
Rules: rules,
|
||||||
IconTheme: &iconTheme { },
|
|
||||||
}
|
}
|
||||||
}
|
}
|