Files
prevara/theme.go
2025-11-30 16:45:22 +00:00

42 lines
1.2 KiB
Go

package gel
import (
"github.com/p9c/p9/pkg/gel/gio/font"
"github.com/p9c/p9/pkg/gel/gio/text"
"github.com/p9c/p9/pkg/gel/gio/unit"
"github.com/p9c/p9/pkg/opts/binary"
"github.com/p9c/p9/pkg/qu"
)
// Theme contains the styling configuration for gel widgets including colors,
// fonts, text sizing, and icon caching. It provides factory methods for creating
// themed widgets and manages the visual appearance of the user interface.
type Theme struct {
quit qu.C
shaper *text.Shaper
collection Collection
TextSize unit.Sp
*Colors
icons map[string]*Icon
scrollBarSize int
Dark *binary.Opt
iconCache IconCache
WidgetPool *Pool
}
// NewTheme creates a new theme to use for rendering a user interface
func NewTheme(dark *binary.Opt, fontCollection []font.FontFace, quit qu.C) (th *Theme) {
textSize := GetScaledTextSize(unit.Sp(16))
th = &Theme{
quit: quit,
shaper: text.NewShaper(text.NoSystemFonts(), text.WithCollection(fontCollection)),
collection: fontCollection,
TextSize: textSize,
Colors: newColors(),
scrollBarSize: 0,
iconCache: make(IconCache),
}
th.SetDarkTheme(dark.True())
return
}