Documentation
¶
Overview ¶
Package apptheme is what every lys-shell surface loads at start: the stylesheet bundle with its hot reload, the stylesheet font resolver, and the lys-shell icon registry on the icon search path.
Index ¶
- Constants
- func FollowDesktopFontSize(a *app.Application)
- func FontResolver(family string, weight int) (render.Font, bool)
- func IconNames() ([]string, error)
- func InstallWidgetTheme(p *styling.Palette, cfg *config.Config)
- func ReportMissingIcons(cfg *config.Config, sink config.DiagnosticSink)
- func Setup(a *app.Application) (stop func())
- func WidgetTheme(p *styling.Palette, cfg *config.Config) *widget.Theme
- type CompiledBundle
- type Theme
- func (t *Theme) Apply(b CompiledBundle)
- func (t *Theme) Attach(root interface{ ... })
- func (t *Theme) Bundle() string
- func (t *Theme) Precompile(cfg *config.Config)
- func (t *Theme) Reload()
- func (t *Theme) RenderPalette() *styling.Palette
- func (t *Theme) SetConfig(cfg *config.Config)
- func (t *Theme) WatchUserStyles(application *app.Application)
Constants ¶
const ComponentPriority = widget.StylePriorityUser + 200
ComponentPriority is a widget's own dynamic CSS - an album art or avatar background - above the bundle, so no bundle rule overrides it. A widget's plain inline style sits at user priority, under the bundle.
const Priority = widget.StylePriorityUser + 100
Priority is the bundle's provider priority: user priority + 100, above the per-widget variable providers (user priority).
Variables ¶
This section is empty.
Functions ¶
func FollowDesktopFontSize ¶
func FollowDesktopFontSize(a *app.Application)
FollowDesktopFontSize makes 1rem what it is in a GTK app on this desktop - the desktop font's size, GTK's "Sans 10" without one - now and on every change: the bundle sizes its text in rem.
func FontResolver ¶
FontResolver resolves the stylesheet's font-family and font-weight declarations through the system font store, so the bundle's --weight-* tokens and a user's font-family take effect. A family the store lacks declines, keeping the label's own face.
func IconNames ¶
IconNames lists the action icons on the icon search path, for a picker that offers them.
func InstallWidgetTheme ¶
InstallWidgetTheme installs WidgetTheme(p, cfg) and, the first time, the shell's theme-level button rule.
func ReportMissingIcons ¶
func ReportMissingIcons(cfg *config.Config, sink config.DiagnosticSink)
ReportMissingIcons sends sink a warning for each lys-shell icon cfg names that the icon theme Setup joined does not provide.
func Setup ¶
func Setup(a *app.Application) (stop func())
Setup is the process-wide half of a surface's start: the stylesheet fonts resolve through the system store, rem follows the desktop font (FollowDesktopFontSize), and lys-shell's icons join the icon search path. The returned function stops the icons watch.
func WidgetTheme ¶
WidgetTheme is lys-ui's theme built from the resolved palette, so every lys-ui widget and named color (@window_bg_color, @accent_bg_color, @borders, ...) paints from the same colors as the shell's stylesheet: the palette's own slots where lys-ui has one, the design tokens where the shell derives the role (hover and pressed fills, elevated surfaces, borders), the status colors, the global rounding at the global scale, and the animation switch. What the palette does not cover (chart series, shadows) comes from lys-ui's dark or light theme, whichever the background is.
Types ¶
type CompiledBundle ¶
type CompiledBundle struct {
// contains filtered or unexported fields
}
CompiledBundle is a bundle compiled off the loop, for Apply on it.
func Compile ¶
func Compile(cfg *config.Config) CompiledBundle
Compile reads the provider palette and the user's stylesheet and builds the bundle: file reads and string work, safe off the loop.
type Theme ¶
type Theme struct {
Sheet *widget.Stylesheet
// contains filtered or unexported fields
}
Theme owns the stylesheet: the bundle — the built-in CSS, the theme's :root variables, and the user's styles/index.css — attached to the roots that take it (the Go-painted surfaces keep their programmatic styling), plus the resolved palette the Go-painted surfaces read.
func New ¶
New resolves the palette, compiles the bundle and installs lys-ui's theme from the palette (WidgetTheme). A provider or user-stylesheet failure logs and falls back (the configured palette, no user CSS).
func (*Theme) Apply ¶
func (t *Theme) Apply(b CompiledBundle)
Apply takes a compiled bundle on the loop. A bundle equal to the loaded one touches nothing: no parse, no restyle of any root.
func (*Theme) Attach ¶
func (t *Theme) Attach(root interface{ AttachStylesheet(*widget.Stylesheet) })
Attach styles one root.
func (*Theme) Bundle ¶
Bundle builds the bundle's CSS: static, theme, the [animations] overrides (the --duration-* tokens and, with indicators off, the frozen looping animations), then user styles, resolving the palette on the way.
func (*Theme) Precompile ¶
Precompile compiles cfg's bundle off the loop, for the SetConfig to come.
func (*Theme) Reload ¶
func (t *Theme) Reload()
Reload recompiles the bundle into the attached stylesheet and reinstalls lys-ui's theme: every root restyles on the next frame.
func (*Theme) RenderPalette ¶
RenderPalette is the resolved palette as render colors, for the surfaces the stylesheet does not reach (OSD, popups, dropdowns).
func (*Theme) WatchUserStyles ¶
func (t *Theme) WatchUserStyles(application *app.Application)
WatchUserStyles reloads the bundle when the user stylesheet changed: the styles directory is watched on the loop (app.WatchFiles), and the stamp filters out changes to other files. Without inotify it polls once a second. A failed read keeps the stylesheet running: UserCSS logs and contributes nothing.