Documentation
¶
Index ¶
- Constants
- Variables
- func CollectThemeImages(data []byte) ([]string, error)
- func ComposeAtlasImage(results []packResult, w, h int) *image.NRGBA
- func EncodeAtlasPNG(img image.Image) ([]byte, error)
- func EncodeThemeBinary(themeJSON, atlasJSON, atlasPNG []byte) ([]byte, error)
- func GenerateAtlasJSON(results []packResult, w, h int) ([]byte, error)
- func ParseGradient(s string, colorMap map[string]sg.Color) (*render.GradientColors, error)
- func ResolveBgFallbacks(p *BackgroundProperty)
- func ResolveColorFallbacks(p *ColorProperty)
- func ResolveFloatFallbacks(p *FloatProperty)
- func SplitDefaultGlyphs(pngData []byte) (map[string]image.Image, error)
- func ValidateTheme(t *Theme, components ...string) error
- type AccordionConfig
- type AccordionGroup
- type AnimatedImageConfig
- type AnimatedImageGroup
- type BackgroundProperty
- type BadgeConfig
- type BadgeGroup
- type ButtonConfig
- type ButtonGroup
- type CalendarSelectorConfig
- type CalendarSelectorGroup
- type CheckboxConfig
- type CheckboxGroup
- type ColorPickerConfig
- type ColorPickerGroup
- type ColorProperty
- type Config
- type DataTableConfig
- type DataTableGroup
- type DecodedThemeBinary
- type DragHandleConfig
- type DragHandleGroup
- type FloatProperty
- type GradientEditorConfig
- type GradientEditorGroup
- type IconButtonConfig
- type IconButtonGroup
- type ImageConfig
- type ImageCropperConfig
- type ImageCropperGroup
- type ImageGroup
- type InputFieldConfig
- type InputFieldGroup
- type KeybindInputConfig
- type KeybindInputGroup
- type LabelConfig
- type LabelGroup
- type ListConfig
- type ListGroup
- type MaskedInputConfig
- type MaskedInputGroup
- type MenuBarConfig
- type MenuBarGroup
- type MenuPopupConfig
- type MenuPopupGroup
- type MeterBarConfig
- type MeterBarGroup
- type NavDrawerConfig
- type NavDrawerGroup
- type OptionRotatorChevronGroup
- type OptionRotatorConfig
- type OptionRotatorGroup
- type PanelConfig
- type PanelGroup
- type PopoverConfig
- type PopoverGroup
- type PropertyInspectorConfig
- type PropertyInspectorGroup
- type RadioConfig
- type RadioGroup
- type RichTextConfig
- type RichTextEditorConfig
- type RichTextEditorGroup
- type RichTextGroup
- type ScrollBarConfig
- type ScrollBarGroup
- type SearchBoxConfig
- type SearchBoxGroup
- type SelectConfig
- type SelectGroup
- type ShadowConfig
- type SliderConfig
- type SliderGroup
- type SortableListConfig
- type SortableListGroup
- type SortableTreeListConfig
- type SortableTreeListGroup
- type SpriteRef
- type StatWebConfig
- type StatWebGroup
- type TabsConfig
- type TabsGroup
- type TagBarConfig
- type TagBarGroup
- type TagConfig
- type TagGroup
- type TextAreaConfig
- type TextAreaGroup
- type TextInputConfig
- type TextInputGroup
- type Theme
- type ThemeAtlasInput
- type ThemeAtlasOutput
- type TileListConfig
- type TileListGroup
- type TimePickerConfig
- type TimePickerGroup
- type ToastConfig
- type ToastGroup
- type ToggleButtonBarConfig
- type ToggleButtonBarGroup
- type ToggleConfig
- type ToggleGroup
- type ToolBarConfig
- type ToolBarGroup
- type TooltipConfig
- type TooltipGroup
- type TreeListConfig
- type TreeListGroup
- type TreeTableConfig
- type TreeTableGroup
- type UserConfig
- type UserGroup
- type Variant
- type WindowConfig
- type WindowGroup
Constants ¶
const DefaultGlyphSize = 48
DefaultGlyphSize is the pixel dimension of each icon cell in the default glyphs spritesheet (48x48 per cell, packed left-to-right).
Variables ¶
var DefaultGlyphNames = []string{
"chevron-right",
"chevron-down",
"chevron-left",
"chevron-up",
"arrow-up",
"arrow-down",
"close-x",
"plus",
"minus",
"checkmark",
"search",
"hamburger",
"filter",
"radio-dot",
"grip-dots-v",
"grip-dots-h",
"grip-dots-square",
"grip-lines-v",
"grip-lines-h",
"password-dot",
}
DefaultGlyphNames lists every icon in the default spritesheet in order. Index i occupies pixels [i*48, 0] to [(i+1)*48, 48].
var DefaultTheme = &defaultTheme
DefaultTheme is the fallback theme used when no explicit theme is set.
var DefaultThemeRef = &DefaultTheme
DefaultThemeRef is a pointer to the canonical DefaultTheme variable. It is initially set to &DefaultTheme (pointing at this package's variable), but the root willowui package overwrites it with &willowui.DefaultTheme at init time so that the widget package always reads the root's variable when the user reassigns willowui.DefaultTheme.
Functions ¶
func CollectThemeImages ¶
CollectThemeImages extracts all nine-slice image paths from theme JSON without loading them. Use this for prebaked atlas tooling.
func ComposeAtlasImage ¶
ComposeAtlasImage draws all packed results onto a new NRGBA image.
func EncodeAtlasPNG ¶
EncodeAtlasPNG encodes an atlas image as PNG bytes.
func EncodeThemeBinary ¶
EncodeThemeBinary encodes a compiled theme into the WUIT binary format. themeJSON is the original theme JSON (colors, components, etc.). atlasJSON is the atlas region map. atlasPNG is the packed atlas image encoded as PNG. Any of atlasJSON/atlasPNG may be nil (no atlas).
func GenerateAtlasJSON ¶
GenerateAtlasJSON produces TexturePacker-compatible hash-format JSON from pack results. This is the format willow.LoadAtlas expects.
func ParseGradient ¶
parseGradient parses a gradient string in one of three formats:
- gradient(topLeft, topRight, bottomRight, bottomLeft) — 4 colors
- gradientV(top, bottom) — vertical: TL=TR=top, BL=BR=bottom
- gradientH(left, right) — horizontal: TL=BL=left, TR=BR=right
Each color argument is resolved through resolveColorString (supports hex, rgb(), rgba(), $reference). ParseGradient is exported for testing from the root package.
func ResolveBgFallbacks ¶
func ResolveBgFallbacks(p *BackgroundProperty)
ResolveBgFallbacks fills unset (BgNone) states using the fallback chain.
func ResolveColorFallbacks ¶
func ResolveColorFallbacks(p *ColorProperty)
ResolveColorFallbacks fills unset (zero) states using the fallback chain.
func ResolveFloatFallbacks ¶
func ResolveFloatFallbacks(p *FloatProperty)
ResolveFloatFallbacks fills unset (NaN) states using the fallback chain. Any remaining NaN after fallback resolution is set to 0.
func SplitDefaultGlyphs ¶
SplitDefaultGlyphs decodes pngData (the default-glyphs.png spritesheet) and returns individual 48x48 sub-images keyed by name.
func ValidateTheme ¶
ValidateTheme checks that the given theme defines configs for all the named component types. Returns an error listing any missing configs. Use at boot to catch incomplete themes early.
Types ¶
type AccordionConfig ¶
type AccordionConfig = Config[AccordionGroup]
type AccordionGroup ¶
type AccordionGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
HeaderBackground BackgroundProperty
HeaderHoverBg BackgroundProperty
HeaderTextColor ColorProperty
HeaderHeight float64
HeaderPadding render.Insets
HeaderIconSize float64
HeaderIconGap float64
ChevronColor ColorProperty
ChevronSize float64
ExpandIcon SpriteRef // theme icon for collapsed section (default: built-in chevron)
CollapseIcon SpriteRef // theme icon for expanded section (default: built-in chevron)
ContentBackground BackgroundProperty
ContentPadding render.Insets
DividerColor ColorProperty
DividerHeight float64
AnimationDuration float64 // seconds, default 0.2
CornerRadius float64
}
AccordionGroup defines the visual properties for Accordion components.
type AnimatedImageConfig ¶
type AnimatedImageConfig = Config[AnimatedImageGroup]
type AnimatedImageGroup ¶
type AnimatedImageGroup struct {
Background BackgroundProperty
CornerRadius float64
}
AnimatedImageGroup defines the visual properties for AnimatedImage components.
type BackgroundProperty ¶
type BackgroundProperty [core.StateCount]core.Background
BackgroundProperty holds a background value for each component state.
func NewSolidBgPropStates ¶
func NewSolidBgPropStates(m map[core.ComponentState]sg.Color) BackgroundProperty
NewSolidBgPropStates creates a BackgroundProperty from explicit state colors. Unset states are filled via the fallback chain.
func NewSolidBgPropUniform ¶
func NewSolidBgPropUniform(c sg.Color) BackgroundProperty
NewSolidBgPropUniform creates a BackgroundProperty where all states have the same solid color.
func (*BackgroundProperty) Resolve ¶
func (p *BackgroundProperty) Resolve(s core.ComponentState) core.Background
Resolve returns the background for the given state.
type BadgeConfig ¶
type BadgeConfig = Config[BadgeGroup]
type BadgeGroup ¶
type BadgeGroup struct {
Background BackgroundProperty
TextColor ColorProperty
CornerRadius float64 // -1 = pill
Padding render.Insets
DotSize float64 // diameter in dot mode, default 8
}
BadgeGroup defines the visual properties for Badge components.
type ButtonConfig ¶
type ButtonConfig = Config[ButtonGroup]
type ButtonGroup ¶
type ButtonGroup struct {
Background BackgroundProperty
TextColor ColorProperty
Border ColorProperty
BorderWidth float64
Padding render.Insets
CornerRadius float64
OffsetX FloatProperty
OffsetY FloatProperty
TextOffsetX FloatProperty
TextOffsetY FloatProperty
FocusColor ColorProperty
FocusRingWidth float64
}
ButtonGroup defines the visual properties for Button components.
type CalendarSelectorConfig ¶
type CalendarSelectorConfig = Config[CalendarSelectorGroup]
type CalendarSelectorGroup ¶
type CalendarSelectorGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
HeaderBackground BackgroundProperty
HeaderTextColor ColorProperty
WeekdayTextColor ColorProperty
WeekdayBackground BackgroundProperty
DayTextColor ColorProperty
DayBackground BackgroundProperty
DayHoverBg BackgroundProperty
DaySelectedBg BackgroundProperty
DaySelectedColor ColorProperty
DayTodayBg BackgroundProperty
DayTodayColor ColorProperty
DayMutedColor ColorProperty
DaySize float64
DayCornerRadius float64
TriggerBackground BackgroundProperty
TriggerTextColor ColorProperty
TriggerBorderColor ColorProperty
}
CalendarSelectorGroup defines the visual properties for CalendarSelector components.
type CheckboxConfig ¶
type CheckboxConfig = Config[CheckboxGroup]
type CheckboxGroup ¶
type CheckboxGroup struct {
BoxColor ColorProperty
CheckColor ColorProperty
CheckIcon SpriteRef // theme icon for the check mark
FocusColor ColorProperty
FocusRingWidth float64
}
CheckboxGroup defines the visual properties for Checkbox components.
type ColorPickerConfig ¶
type ColorPickerConfig = Config[ColorPickerGroup]
type ColorPickerGroup ¶
type ColorPickerGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
SwatchBorderColor ColorProperty
SwatchBorderWidth float64
SwatchCornerRadius float64
PopupWidth float64 // default 280
SVFieldSize float64 // default 200 (square)
HueBarHeight float64 // default 14
AlphaBarHeight float64 // default 14
}
ColorPickerGroup defines the visual properties for ColorPicker components.
type ColorProperty ¶
type ColorProperty [core.StateCount]sg.Color
ColorProperty holds a color value for each component state.
func NewColorPropStates ¶
func NewColorPropStates(m map[core.ComponentState]sg.Color) ColorProperty
NewColorPropStates creates a ColorProperty from explicit state values. Unset states (zero Color) are filled via the fallback chain.
func NewColorPropUniform ¶
func NewColorPropUniform(c sg.Color) ColorProperty
NewColorPropUniform creates a ColorProperty where all states have the same color.
func (*ColorProperty) Resolve ¶
func (p *ColorProperty) Resolve(s core.ComponentState) sg.Color
Resolve returns the color for the given state.
type Config ¶
type Config[G any] struct { Primary G Variants [VariantCount - 1]*G }
Config is a generic component config with variant group support. Primary is required (stored by value). All other variants are optional (stored as pointers) and fall back to Primary if nil.
type DataTableConfig ¶
type DataTableConfig = Config[DataTableGroup]
type DataTableGroup ¶
type DataTableGroup struct {
Background BackgroundProperty
HeaderBackground BackgroundProperty
HeaderText ColorProperty
HeaderHoverColor ColorProperty
HeaderBorderColor ColorProperty
HeaderBorderWidth float64
RowBackground BackgroundProperty
RowBackgroundAlt BackgroundProperty
RowHoverColor ColorProperty
SelectionColor ColorProperty
CellText ColorProperty
CellPadding float64
DividerColor ColorProperty
DividerWidth float64
SortGlyphColor ColorProperty
SortGlyphInactive ColorProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
}
DataTableGroup defines the visual properties for DataTable components.
type DecodedThemeBinary ¶
DecodedThemeBinary holds the three sections extracted from a WUIT file.
func DecodeThemeBinary ¶
func DecodeThemeBinary(data []byte) (*DecodedThemeBinary, error)
DecodeThemeBinary parses a WUIT binary blob and returns the three sections. Returns an error on invalid magic, unsupported version, or truncated data.
type DragHandleConfig ¶
type DragHandleConfig = Config[DragHandleGroup]
type DragHandleGroup ¶
type DragHandleGroup struct {
Background BackgroundProperty
GripColor ColorProperty
GripHoverColor ColorProperty
GripActiveColor ColorProperty
GripDotSize float64
GripSpacing float64
GripCount int
}
DragHandleGroup defines the visual properties for DragHandle components.
type FloatProperty ¶
type FloatProperty [core.StateCount]float64
FloatProperty holds a float64 value for each component state.
func CompileFloatProperty ¶
func CompileFloatProperty(path string, data any) (FloatProperty, []error)
CompileFloatProperty is exported for testing from the root package.
func NewFloatPropStates ¶
func NewFloatPropStates(m map[core.ComponentState]float64) FloatProperty
NewFloatPropStates creates a FloatProperty from explicit state values. Unset states (NaN) are filled via the fallback chain; remaining NaN → 0.
func NewFloatPropUniform ¶
func NewFloatPropUniform(v float64) FloatProperty
NewFloatPropUniform creates a FloatProperty where all states have the same value.
func (*FloatProperty) Resolve ¶
func (p *FloatProperty) Resolve(s core.ComponentState) float64
Resolve returns the float for the given state.
type GradientEditorConfig ¶
type GradientEditorConfig = Config[GradientEditorGroup]
type GradientEditorGroup ¶
type GradientEditorGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
PreviewHeight float64 // height of the preview bar in H/V mode, default 40
PreviewSize float64 // side length of the preview square in 4-corner mode, default 140
}
GradientEditorGroup defines the visual properties for GradientEditor components.
type IconButtonConfig ¶
type IconButtonConfig = Config[IconButtonGroup]
type IconButtonGroup ¶
type IconButtonGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
IconColor ColorProperty // tints the icon sprite per state
ActiveColor BackgroundProperty // background when Active == true
LabelColor ColorProperty
IconSize float64 // default icon width = height
Padding render.Insets
LabelGap float64 // gap between icon and label, default 4
FocusColor ColorProperty
FocusRingWidth float64
}
IconButtonGroup defines the visual properties for IconButton components.
type ImageConfig ¶
type ImageConfig = Config[ImageGroup]
type ImageCropperConfig ¶
type ImageCropperConfig = Config[ImageCropperGroup]
type ImageCropperGroup ¶
type ImageCropperGroup struct {
Background BackgroundProperty
CornerRadius float64
CropBorderColor ColorProperty
CropBorderWidth float64
HandleBackground BackgroundProperty
HandleSize float64
HandleCornerRadius float64
DimColor ColorProperty
GridColor ColorProperty
GridLineWidth float64
}
ImageCropperGroup defines the visual properties for ImageCropper components.
type ImageGroup ¶
type ImageGroup struct {
Background BackgroundProperty
CornerRadius float64
}
ImageGroup defines the visual properties for Image components.
type InputFieldConfig ¶
type InputFieldConfig = Config[InputFieldGroup]
type InputFieldGroup ¶
type InputFieldGroup struct {
LabelColor ColorProperty
RequiredColor ColorProperty
ErrorColor ColorProperty
WarningColor ColorProperty
SuccessColor ColorProperty
LabelGap float64 // space between label and input, default 4
MessageGap float64 // space between input and message, default 3
LabelLeftGap float64 // gap between label and input in left-label mode, default 8
}
InputFieldGroup defines the visual properties for InputField components.
type KeybindInputConfig ¶
type KeybindInputConfig = Config[KeybindInputGroup]
type KeybindInputGroup ¶
type KeybindInputGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
KeyCapBackground BackgroundProperty
KeyCapTextColor ColorProperty
KeyCapBorderColor ColorProperty
KeyCapBorderWidth float64
KeyCapCornerRadius float64
KeyCapPadding render.Insets
ListeningBackground BackgroundProperty
ListeningTextColor ColorProperty
ListeningBorderColor ColorProperty
ClearButtonColor ColorProperty
ClearButtonSize float64
UnsetTextColor ColorProperty
UnsetText string // default "---"
ListeningText string // default "Press any key..."
}
KeybindInputGroup defines the visual properties for KeybindInput components.
type LabelConfig ¶
type LabelConfig = Config[LabelGroup]
type LabelGroup ¶
type LabelGroup struct {
TextColor ColorProperty
}
LabelGroup defines the visual properties for Label components.
type ListConfig ¶
type ListGroup ¶
type ListGroup struct {
Background BackgroundProperty
ItemBackground BackgroundProperty
Border ColorProperty
ItemPadding render.Insets // padding applied around each rendered item (left keeps text off the edge)
FocusColor ColorProperty
FocusRingWidth float64
}
ListGroup defines the visual properties for List components.
type MaskedInputConfig ¶
type MaskedInputConfig = Config[MaskedInputGroup]
type MaskedInputGroup ¶
type MaskedInputGroup struct {
Background BackgroundProperty
TextColor ColorProperty
CursorColor ColorProperty
SelectionColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
PlaceholderAlpha float64
Padding render.Insets
// LiteralColor is used to render fixed separator characters in the mask.
LiteralColor ColorProperty
// MaskPlaceholderColor is used to render the placeholder character in empty slots.
MaskPlaceholderColor ColorProperty
// SlotPadding is the horizontal padding added to each side of a slot cell,
// creating visual spacing between adjacent characters. Default 3.
SlotPadding float64
FocusColor ColorProperty
FocusRingWidth float64
}
MaskedInputGroup defines the visual properties for MaskedInput components.
type MenuBarConfig ¶
type MenuBarConfig = Config[MenuBarGroup]
type MenuBarGroup ¶
type MenuBarGroup struct {
Background BackgroundProperty // bar background
EntryTextColor ColorProperty // entry label color (default, hover, active, disabled)
EntryBackground BackgroundProperty // entry background on hover/active
EntryPadding render.Insets // padding inside each entry label
Spacing float64 // gap between entries
Height float64 // bar height
BorderColor ColorProperty // bottom border of the bar
BorderWidth float64 // bottom border width
}
MenuBarGroup defines the visual properties for MenuBar components.
type MenuPopupConfig ¶
type MenuPopupConfig = Config[MenuPopupGroup]
type MenuPopupGroup ¶
type MenuPopupGroup struct {
Background BackgroundProperty
ItemBackground BackgroundProperty // hover/highlighted item background
TextColor ColorProperty
DisabledColor ColorProperty
SeparatorColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
ItemPadding render.Insets
ItemHeight float64
MaxHeight float64 // max visible height before scroll; 0 = default (280)
SelectedColor BackgroundProperty // background of the currently-selected item
}
MenuPopupGroup defines the visual properties for MenuPopup components.
type MeterBarConfig ¶
type MeterBarConfig = Config[MeterBarGroup]
type MeterBarGroup ¶
type MeterBarGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
FillBackground BackgroundProperty
FillBorder ColorProperty
FillBorderWidth float64
FillCornerRadius float64
TextColor ColorProperty
}
MeterBarGroup defines the visual properties for MeterBar components.
type NavDrawerConfig ¶
type NavDrawerConfig = Config[NavDrawerGroup]
type NavDrawerGroup ¶
type NavDrawerGroup struct {
}
NavDrawerGroup defines the visual properties for NavDrawer components.
type OptionRotatorChevronGroup ¶
type OptionRotatorChevronGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Width float64 // fixed pixel width of each chevron hit area
IconColor ColorProperty
IconSize float64 // scale multiplier for the procedural glyph
}
OptionRotatorChevronGroup defines the visual properties for the chevron buttons inside an OptionRotator.
type OptionRotatorConfig ¶
type OptionRotatorConfig = Config[OptionRotatorGroup]
type OptionRotatorGroup ¶
type OptionRotatorGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
TextColor ColorProperty
Chevron OptionRotatorChevronGroup
ChevronLeftIcon SpriteRef // theme icon for left chevron
ChevronRightIcon SpriteRef // theme icon for right chevron
FocusColor ColorProperty
FocusRingWidth float64
}
OptionRotatorGroup defines the visual properties for OptionRotator components.
type PanelConfig ¶
type PanelConfig = Config[PanelGroup]
type PanelGroup ¶
type PanelGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets // default content padding for VBox/HBox child layout
}
PanelGroup defines the visual properties for Panel components.
type PopoverConfig ¶
type PopoverConfig = Config[PopoverGroup]
type PopoverGroup ¶
type PopoverGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
TitleColor ColorProperty
}
PopoverGroup defines the visual properties for Popover components.
type PropertyInspectorConfig ¶
type PropertyInspectorConfig = Config[PropertyInspectorGroup]
type PropertyInspectorGroup ¶
type PropertyInspectorGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
SearchBarHeight float64
SearchBarGap float64
GroupHeaderBackground BackgroundProperty
GroupHeaderTextColor ColorProperty
GroupHeaderHeight float64
RowBackground BackgroundProperty
RowAltBackground BackgroundProperty
RowHoverBackground BackgroundProperty
RowHeight float64
LabelColor ColorProperty
LabelWidth float64
DividerColor ColorProperty
}
PropertyInspectorGroup defines the visual properties for PropertyInspector.
type RadioConfig ¶
type RadioConfig = Config[RadioGroup]
type RadioGroup ¶
type RadioGroup struct {
CircleColor ColorProperty
DotColor ColorProperty
CornerRadius float64 // -1 = auto (50% of size = circle)
DotIcon SpriteRef // theme icon for the radio dot
FocusColor ColorProperty
FocusRingWidth float64
}
RadioGroup defines the visual properties for RadioButton components.
type RichTextConfig ¶
type RichTextConfig = Config[RichTextGroup]
type RichTextEditorConfig ¶
type RichTextEditorConfig = Config[RichTextEditorGroup]
type RichTextEditorGroup ¶
type RichTextEditorGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
ToolbarBackground BackgroundProperty
ToolbarHeight float64
ToolbarPadding render.Insets
ToolbarButtonSize float64
ToolbarButtonGap float64
ToolbarActiveColor ColorProperty
ContentBackground BackgroundProperty
ContentPadding render.Insets
CursorColor ColorProperty
SelectionColor ColorProperty
}
RichTextEditorGroup defines the visual properties for RichTextEditor components.
type RichTextGroup ¶
type RichTextGroup struct {
TextColor ColorProperty
}
RichTextGroup defines the visual properties for RichText components.
type ScrollBarConfig ¶
type ScrollBarConfig = Config[ScrollBarGroup]
type ScrollBarGroup ¶
type ScrollBarGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
ThumbBackground BackgroundProperty
ThumbBorder ColorProperty
ThumbBorderWidth float64
ThumbCornerRadius float64
ArrowUpIcon SpriteRef // theme icon for scroll-up arrow
ArrowDownIcon SpriteRef // theme icon for scroll-down arrow
}
ScrollBarGroup defines the visual properties for ScrollBar components.
type SearchBoxConfig ¶
type SearchBoxConfig = Config[SearchBoxGroup]
type SearchBoxGroup ¶
type SearchBoxGroup struct {
Background BackgroundProperty
TextColor ColorProperty
CursorColor ColorProperty
SelectionColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
PlaceholderAlpha float64
Padding render.Insets
IconColor ColorProperty
ClearButtonColor ColorProperty
ClearHoverColor ColorProperty
ClearActiveColor ColorProperty
IconGap float64
FocusColor ColorProperty
FocusRingWidth float64
}
SearchBoxGroup defines the visual properties for SearchBox components. Defaults fall back to TextInput values when not set.
type SelectConfig ¶
type SelectConfig = Config[SelectGroup]
type SelectGroup ¶
type SelectGroup struct {
Background BackgroundProperty
TextColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
ChevronColor ColorProperty
FocusColor ColorProperty
FocusRingWidth float64
}
SelectGroup defines the visual properties for Select components.
type ShadowConfig ¶
ShadowConfig describes a drop shadow for tooltip components.
type SliderConfig ¶
type SliderConfig = Config[SliderGroup]
type SliderGroup ¶
type SliderGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
ThumbBackground BackgroundProperty
ThumbBorder ColorProperty
ThumbBorderWidth float64
ThumbCornerRadius float64
// ThumbSize overrides the cross-axis thumb dimension (height for horizontal
// sliders, width for vertical). When > 0 the thumb is centered on the track
// and can overflow it. Combine with ThumbCornerRadius -1 for a circle.
ThumbSize float64
// ThumbLength overrides the along-track thumb dimension (width for horizontal,
// height for vertical). When 0, ThumbSize is used for both axes (square/circle).
// Set ThumbLength < ThumbSize for a tall thin pill thumb (macOS style).
ThumbLength float64
FocusColor ColorProperty
FocusRingWidth float64
}
SliderGroup defines the visual properties for Slider components.
type SortableListConfig ¶
type SortableListConfig = Config[SortableListGroup]
type SortableListGroup ¶
type SortableListGroup struct {
Background BackgroundProperty
ItemBackground BackgroundProperty
ItemBorderColor ColorProperty
ItemBorderWidth float64
ItemCornerRadius float64
ItemPadding render.Insets
SelectionColor ColorProperty
BorderColor ColorProperty
BorderWidth float64
HandleColor ColorProperty
HandleHoverColor ColorProperty
HandleActiveColor ColorProperty
HandleWidth float64
HandleGap float64
InsertIndicatorColor ColorProperty
InsertIndicatorWidth float64
FocusColor ColorProperty
FocusRingWidth float64
}
SortableListGroup defines the visual properties for SortableList components.
type SortableTreeListConfig ¶
type SortableTreeListConfig = Config[SortableTreeListGroup]
type SortableTreeListGroup ¶
type SortableTreeListGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
RowBackground BackgroundProperty
RowHoverBg BackgroundProperty
RowSelectedBg BackgroundProperty
RowHeight float64
RowPadding render.Insets
IndentWidth float64
LabelColor ColorProperty
IconSize float64
IconGap float64
ChevronColor ColorProperty
ChevronSize float64
DropLineColor ColorProperty
DropLineWidth float64
DropTargetBg BackgroundProperty
DropTargetBorderColor ColorProperty
FocusColor ColorProperty
FocusRingWidth float64
}
SortableTreeListGroup defines the visual properties for SortableTreeList components.
type SpriteRef ¶
SpriteRef holds a resolved sprite image from the theme. Set is false when the slot was not specified in the theme JSON — the widget falls back to its built-in procedural glyph.
type StatWebConfig ¶
type StatWebConfig = Config[StatWebGroup]
type StatWebGroup ¶
type StatWebGroup struct {
Background BackgroundProperty
PolygonFill ColorProperty // inner area color (semi-transparent)
PolygonStroke ColorProperty // outline color
PolygonStrokeWidth float64
SpokeColor ColorProperty
SpokeWidth float64
GridColor ColorProperty // concentric polygon grid lines
GridLevels int // number of concentric rings, default 4
HandleColor ColorProperty
HandleHoverColor ColorProperty
HandleRadius float64
LabelColor ColorProperty
LabelFontSize float64
LabelOffset float64 // distance from spoke tip to label center
}
StatWebGroup defines the visual properties for StatWeb (spider/radar chart) components.
type TabsConfig ¶
type TabsGroup ¶
type TabsGroup struct {
BarBackground BackgroundProperty
SelectedTabColor ColorProperty
UnselectedTabColor ColorProperty
SelectedTabBackground BackgroundProperty
UnselectedTabBackground BackgroundProperty
ScrollArrowBackground BackgroundProperty
ScrollArrowColor ColorProperty
ScrollArrowWidth float64
}
TabsGroup defines the visual properties for TabBar components.
type TagBarConfig ¶
type TagBarConfig = Config[TagBarGroup]
type TagBarGroup ¶
type TagBarGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
Spacing float64 // gap between tags and between tags and input
FocusColor ColorProperty
FocusRingWidth float64
}
TagBarGroup defines the visual properties for TagBar components.
type TagGroup ¶
type TagGroup struct {
Background BackgroundProperty
SelectedBackground BackgroundProperty
TextColor ColorProperty
SelectedTextColor ColorProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64 // -1 = pill
Padding render.Insets
RemoveButtonSize float64 // diameter of the × click area
RemoveButtonColor ColorProperty
Gap float64 // space between text and × button
}
TagGroup defines the visual properties for Tag components.
type TextAreaConfig ¶
type TextAreaConfig = Config[TextAreaGroup]
type TextAreaGroup ¶
type TextAreaGroup struct {
Background BackgroundProperty
TextColor ColorProperty
CursorColor ColorProperty
SelectionColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
PlaceholderAlpha float64
Padding render.Insets
FocusColor ColorProperty
FocusRingWidth float64
}
TextAreaGroup defines the visual properties for TextArea components.
type TextInputConfig ¶
type TextInputConfig = Config[TextInputGroup]
type TextInputGroup ¶
type TextInputGroup struct {
Background BackgroundProperty
TextColor ColorProperty
CursorColor ColorProperty
SelectionColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
PlaceholderAlpha float64
Padding render.Insets
FocusColor ColorProperty
FocusRingWidth float64
PasswordDotColor ColorProperty
}
TextInputGroup defines the visual properties for TextInput components.
type Theme ¶
type Theme struct {
// Per-component configs.
Button ButtonConfig
Label LabelConfig
Badge BadgeConfig
Toggle ToggleConfig
Checkbox CheckboxConfig
Radio RadioConfig
TextInput TextInputConfig
MaskedInput MaskedInputConfig
InputField InputFieldConfig
SearchBox SearchBoxConfig
TextArea TextAreaConfig
Slider SliderConfig
ScrollBar ScrollBarConfig
MeterBar MeterBarConfig
Panel PanelConfig
Window WindowConfig
Tabs TabsConfig
List ListConfig
TreeList TreeListConfig
TileList TileListConfig
RichText RichTextConfig
OptionRotator OptionRotatorConfig
ToggleButtonBar ToggleButtonBarConfig
Tooltip TooltipConfig
MenuBar MenuBarConfig
MenuPopup MenuPopupConfig
Select SelectConfig
DragHandle DragHandleConfig
Image ImageConfig
AnimatedImage AnimatedImageConfig
ColorPicker ColorPickerConfig
GradientEditor GradientEditorConfig
Toast ToastConfig
SortableList SortableListConfig
SortableTreeList SortableTreeListConfig
IconButton IconButtonConfig
StatWeb StatWebConfig
Accordion AccordionConfig
Tag TagConfig
TagBar TagBarConfig
Popover PopoverConfig
TreeTable TreeTableConfig
DataTable DataTableConfig
KeybindInput KeybindInputConfig
TimePicker TimePickerConfig
ImageCropper ImageCropperConfig
ToolBar ToolBarConfig
CalendarSelector CalendarSelectorConfig
RichTextEditor RichTextEditorConfig
PropertyInspector PropertyInspectorConfig
// Atlas holds the packed texture atlas for nine-slice images.
// nil if no nine-slice images are used.
Atlas *sg.Atlas
// Sprites maps sprite key names (from the theme JSON "sprites" section)
// to their resolved SpriteRef values. Use GetSprite to look up by key.
// Nil if no sprites were declared.
Sprites map[string]SpriteRef
// CustomVariants maps user-defined variant names (declared in the JSON
// "variants" array) to their assigned Variant slot (Custom1..Custom56).
// Nil if no custom names were declared.
CustomVariants map[string]Variant
// UserComponents holds configurations for user-defined component types.
// Keys are the component names as they appear in the JSON "components" map.
// Nil if no user-defined components were declared.
UserComponents map[string]*UserConfig
// Fonts maps theme font role names (e.g. "body", "heading") to registered
// font family names. These are string-only references resolved at runtime
// via RegisterFontFamily — no font data is stored in the theme.
// Nil if no fonts were declared.
Fonts map[string]string
}
Theme holds the complete visual configuration for all WillowUI components.
func LoadTheme ¶
LoadTheme parses JSON theme data and produces a *Theme. Returns an error if validation fails (bad colors, missing required groups, etc.). Errors are collected so the author sees all problems at once. Nine-slice images are rejected — use LoadThemeFromFile or LoadThemeFromFS.
func LoadThemeBinary ¶
LoadThemeBinary decodes a WUIT binary and compiles the theme. The atlas (if present) is decoded from the embedded PNG + JSON sections.
func LoadThemeFromFS ¶
LoadThemeFromFS reads a JSON file from an fs.FS and compiles the theme. Nine-slice image paths are resolved within the FS.
func LoadThemeFromFile ¶
LoadThemeFromFile reads a JSON file and compiles the theme. Nine-slice image paths are resolved relative to the JSON file's directory.
func LoadThemeRelative ¶
LoadThemeRelative loads a theme JSON file resolved relative to the caller's source file. This is convenient for examples and tests where the JSON file sits next to the Go source.
func (*Theme) FontName ¶
FontName returns the registered font family name for the given role, or empty string if the role is not defined.
func (*Theme) GetSprite ¶
GetSprite returns the SpriteRef for the given key name, or an empty SpriteRef with Set=false if the key is not found.
func (*Theme) UserComponent ¶
func (t *Theme) UserComponent(name string) *UserConfig
UserComponent returns the Config for a user-defined component type, or an empty Config (all variants fall back to zero) if the name is not found.
type ThemeAtlasInput ¶
type ThemeAtlasInput struct {
// DefaultGlyphsPNG is the raw PNG bytes of the default icon spritesheet.
// If nil, default icons are not included.
DefaultGlyphsPNG []byte
// NineGridImages maps nine-grid names to their source images.
NineGridImages map[string]image.Image
// SpriteImages maps sprite names to their source images.
// Names matching default glyph names override the defaults.
SpriteImages map[string]image.Image
}
ThemeAtlasInput holds the images to pack into a theme atlas.
type ThemeAtlasOutput ¶
ThemeAtlasOutput holds the result of atlas compilation.
func CompileThemeAtlas ¶
func CompileThemeAtlas(input *ThemeAtlasInput) (*ThemeAtlasOutput, error)
CompileThemeAtlas packs all theme images into a single atlas and returns the atlas JSON and PNG bytes. Returns nil output if there are no images.
type TileListConfig ¶
type TileListConfig = Config[TileListGroup]
type TileListGroup ¶
type TileListGroup struct {
Background BackgroundProperty
ItemBackground BackgroundProperty
FocusColor ColorProperty
FocusRingWidth float64
}
TileListGroup defines the visual properties for TileList components.
type TimePickerConfig ¶
type TimePickerConfig = Config[TimePickerGroup]
type TimePickerGroup ¶
type TimePickerGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
ColumnBackground BackgroundProperty
ColumnWidth float64
ColumnHeight float64
ValueTextColor ColorProperty
ValueFontSize float64
ArrowColor ColorProperty
ArrowHoverColor ColorProperty
ArrowSize float64
SeparatorColor ColorProperty
SeparatorWidth float64
AmPmBackground BackgroundProperty
AmPmActiveColor ColorProperty
AmPmTextColor ColorProperty
AmPmCornerRadius float64
}
TimePickerGroup defines the visual properties for TimePicker components.
type ToastConfig ¶
type ToastConfig = Config[ToastGroup]
type ToastGroup ¶
type ToastGroup struct {
Background BackgroundProperty
TextColor ColorProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
IconColor ColorProperty
ProgressBarColor ColorProperty
MinWidth float64 // default 200
MaxWidth float64 // default 360
ItemSpacing float64 // gap between stacked toasts, default 6
AnimDuration float64 // tween duration in seconds, default 0.2
}
ToastGroup defines the visual properties for Toast notification components.
type ToggleButtonBarConfig ¶
type ToggleButtonBarConfig = Config[ToggleButtonBarGroup]
type ToggleButtonBarGroup ¶
type ToggleButtonBarGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
Spacing float64
SelectedBackground BackgroundProperty
SelectedTextColor ColorProperty
SelectedBorder ColorProperty
SelectedBorderWidth float64
SelectedCornerRadius float64
UnselectedBackground BackgroundProperty
UnselectedTextColor ColorProperty
UnselectedBorder ColorProperty
UnselectedBorderWidth float64
UnselectedCornerRadius float64
FocusColor ColorProperty
FocusRingWidth float64
}
ToggleButtonBarGroup defines the visual properties for ToggleButtonBar components.
type ToggleConfig ¶
type ToggleConfig = Config[ToggleGroup]
type ToggleGroup ¶
type ToggleGroup struct {
TrackColor ColorProperty
ThumbColor ColorProperty
CornerRadius float64
FocusColor ColorProperty
FocusRingWidth float64
}
ToggleGroup defines the visual properties for Toggle components.
type ToolBarConfig ¶
type ToolBarConfig = Config[ToolBarGroup]
type ToolBarGroup ¶
type ToolBarGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
Spacing float64 // gap between items, default 4
SeparatorColor ColorProperty // divider line color
SeparatorThickness float64 // divider line width, default 1
SeparatorHeight float64 // fraction of toolbar height, default 0.6
}
ToolBarGroup defines the visual properties for ToolBar components.
type TooltipConfig ¶
type TooltipConfig = Config[TooltipGroup]
type TooltipGroup ¶
type TooltipGroup struct {
Background BackgroundProperty
BorderColor ColorProperty
BorderWidth float64
CornerRadius float64
Padding render.Insets
MaxWidth float64
Shadow ShadowConfig
}
TooltipGroup defines the visual properties for Tooltip components.
type TreeListConfig ¶
type TreeListConfig = Config[TreeListGroup]
type TreeListGroup ¶
type TreeListGroup struct {
Background BackgroundProperty
ItemBackground BackgroundProperty
ExpandIcon SpriteRef // theme icon for collapsed tree node toggle
CollapseIcon SpriteRef // theme icon for expanded tree node toggle
FocusColor ColorProperty
FocusRingWidth float64
}
TreeListGroup defines the visual properties for TreeList components.
type TreeTableConfig ¶
type TreeTableConfig = Config[TreeTableGroup]
type TreeTableGroup ¶
type TreeTableGroup struct {
Background BackgroundProperty
Border ColorProperty
BorderWidth float64
HeaderBg BackgroundProperty
HeaderText ColorProperty
RowBg BackgroundProperty
RowAltBg BackgroundProperty
RowSelectedBg ColorProperty
CellText ColorProperty
ChevronColor ColorProperty
DividerColor ColorProperty
SortIndicator ColorProperty
CornerRadius float64
}
TreeTableGroup defines the visual properties for TreeTable components.
type UserConfig ¶
UserConfig holds a user-defined component configuration with variant support.
type UserGroup ¶
type UserGroup struct {
// contains filtered or unexported fields
}
UserGroup holds the parsed visual properties for a user-defined component variant. Property types are inferred from JSON values during compilation.
func (*UserGroup) Background ¶
func (g *UserGroup) Background(key string) BackgroundProperty
Background returns the BackgroundProperty for the given key, or a zero value if not found.
func (*UserGroup) Color ¶
func (g *UserGroup) Color(key string) ColorProperty
Color returns the ColorProperty for the given key, or a zero value if not found.
func (*UserGroup) Padding ¶
Padding returns the Insets for the given key, or a zero value if not found.
func (*UserGroup) StateFloat ¶
func (g *UserGroup) StateFloat(key string) FloatProperty
StateFloat returns the per-state FloatProperty for the given key, or a zero value if not found.
type Variant ¶
type Variant uint8
Variant selects a color group for a component (e.g. Primary, Danger).
const ( Primary Variant = iota // default for all components Secondary Accent Neutral Danger Success Warning Info Custom1 Custom2 Custom3 Custom4 Custom5 Custom6 Custom7 Custom8 Custom9 Custom10 Custom11 Custom12 Custom13 Custom14 Custom15 Custom16 Custom17 Custom18 Custom19 Custom20 Custom21 Custom22 Custom23 Custom24 Custom25 Custom26 Custom27 Custom28 Custom29 Custom30 Custom31 Custom32 Custom33 Custom34 Custom35 Custom36 Custom37 Custom38 Custom39 Custom40 Custom41 Custom42 Custom43 Custom44 Custom45 Custom46 Custom47 Custom48 Custom49 Custom50 Custom51 Custom52 Custom53 Custom54 Custom55 Custom56 VariantCount = 64 )
type WindowConfig ¶
type WindowConfig = Config[WindowGroup]
type WindowGroup ¶
type WindowGroup struct {
Background BackgroundProperty
TitleBackground BackgroundProperty
TitleTextColor ColorProperty
ResizeHandleColor ColorProperty
Border ColorProperty
BorderWidth float64
CornerRadius float64
ContentPaneUnderTitleBar bool // body background extends behind the title bar
CloseIcon SpriteRef // theme icon for the close button
ResizeIcon SpriteRef // theme icon for the resize handle
}
WindowGroup defines the visual properties for Window components.