ui

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ui provides layouts, constraints, reusable controls and composition. Shared scene geometry and rendering belong to scene; retained HTML belongs to ui/html; component storage and queries belong to ecs.

Index

Constants

View Source
const MaxFileBrowserEntries = 2000
View Source
const WindowTitleBarButtonWidth float32 = 46

Variables

This section is empty.

Functions

func BindControl

func BindControl[T any](world *ecs.World, entity ecs.Entity, opts ControlOptions, component T) error

BindControl installs reusable control behavior on an existing static entity.

func BindControlComposition

func BindControlComposition(world *ecs.World, composition ControlComposition, owner ecs.Entity, bindButton func(ecs.Entity) error) error

BindControlComposition assigns static descendants to the behavior components already installed on owner. bindButton binds nested button roots when needed.

func BindList

func BindList[T any](world *ecs.World, entity ecs.Entity, opts ListOptions[T]) bool

BindList turns an existing scroll area into a virtual list. It is useful for scroll areas authored in a scene, whose transform and visual parts should be preserved.

func BindPart

func BindPart[T any](world *ecs.World, entity ecs.Entity) error

func BindRelation

func BindRelation[T any](world *ecs.World, entity, owner ecs.Entity) error

func BindSelector

func BindSelector(world *ecs.World, entity ecs.Entity, opts SelectorOptions) error

BindSelector builds a data-driven selector on an existing UI entity. Its list and option entities are runtime-owned and hidden until opened.

func BindVariant

func BindVariant[T comparable](world *ecs.World, owner ecs.Entity, variant Variant[T]) error

func BindVirtualJoystick

func BindVirtualJoystick(world *ecs.World, entity ecs.Entity, opts ControlOptions, joystick VirtualJoystick) error

BindVirtualJoystick adds joystick behavior to an authored UI control root. It intentionally does not generate visual parts, letting a scene provide its own art while preserving the same value and event behavior.

func BlurHTMLControl

func BlurHTMLControl(world *ecs.World, entity ecs.Entity)

BlurHTMLControl removes focus from a native HTML control, including its text input and IME state, like HTMLElement.blur().

func CaretBlinkDelay

func CaretBlinkDelay(world *ecs.World) (time.Duration, bool)

CaretBlinkDelay is the next visual deadline for a focused text field. An on-demand host can sleep between phases instead of polling every frame.

func ControlBounds

func ControlBounds(world *ecs.World, entity ecs.Entity) (float32, float32, bool)

func FindPart

func FindPart[P, T any](world *ecs.World, owner ecs.Entity) (ecs.Entity, bool)

func FocusControl

func FocusControl(world *ecs.World, entity ecs.Entity) bool

FocusControl moves native keyboard focus to a control. Passing zero clears focus. Applications can use it after opening a search bar or switching tabs.

func FocusedInputSystem

func FocusedInputSystem(name string) ecs.SystemConfig

func GetScrollAreaOffset

func GetScrollAreaOffset(world *ecs.World, entity ecs.Entity) (mgl32.Vec2, bool)

GetScrollAreaOffset exposes positive content offsets while UIScroll retains Clay's non-positive child-offset convention internally.

func ImageGridCellSize

func ImageGridCellSize(width float32, columns int, gap float32) float32

ImageGridCellSize returns the square card size for a grid width.

func ImageGridHeight

func ImageGridHeight(width float32, itemCount, columns int, gap float32) float32

ImageGridHeight returns the rendered height of an image grid.

func LayoutPending

func LayoutPending(world *ecs.World) bool

LayoutPending reports whether nested constraints need another settling pass.

func ListItemEntities

func ListItemEntities[T any](world *ecs.World, entity ecs.Entity) []ecs.Entity

ListItemEntities returns a copy of the pooled item entity handles.

func NormalizeNumberInputValue

func NormalizeNumberInputValue(value string, input NumberInput) (string, bool)

func RegisterRuntimeExtension

func RegisterRuntimeExtension(world *ecs.World, extension RuntimeExtension)

func RegisterRuntimeFeature

func RegisterRuntimeFeature[T RuntimeFeature](world *ecs.World)

func ResetHTMLForm

func ResetHTMLForm(world *ecs.World, owner ecs.Entity, formID string) bool

func ResetVirtualJoystick

func ResetVirtualJoystick(world *ecs.World, entity ecs.Entity) bool

ResetVirtualJoystick releases a joystick and publishes state changes.

func SetControlBounds

func SetControlBounds(world *ecs.World, entity ecs.Entity, width, height float32)

func SetControlDisabled

func SetControlDisabled(world *ecs.World, entity ecs.Entity, disabled bool)

func SetControlInputFilter

func SetControlInputFilter(world *ecs.World, entity ecs.Entity, filter scene.InputFilter)

func SetControlPassThrough

func SetControlPassThrough(world *ecs.World, entity ecs.Entity, passThrough bool)

func SetControlSelected

func SetControlSelected(world *ecs.World, entity ecs.Entity, selected bool)

func SetHTMLControlChecked

func SetHTMLControlChecked(world *ecs.World, control ecs.Entity, checked bool) bool

func SetHTMLControlOptionSelected

func SetHTMLControlOptionSelected(world *ecs.World, control ecs.Entity, option int, selected bool) bool

func SetHTMLControlSelected

func SetHTMLControlSelected(world *ecs.World, control ecs.Entity, selected int) bool

func SetHTMLControlSelectionRange

func SetHTMLControlSelectionRange(world *ecs.World, control ecs.Entity, anchor, focus int) bool

func SetHTMLControlValue

func SetHTMLControlValue(world *ecs.World, control ecs.Entity, value string) bool

func SetHTMLEditableSelection

func SetHTMLEditableSelection(world *ecs.World, editable ecs.Entity, anchor, focus int) bool

func SetHTMLEditableValue

func SetHTMLEditableValue(world *ecs.World, editable ecs.Entity, value string) bool

func SetListItems

func SetListItems[T any](world *ecs.World, entity ecs.Entity, items []T) bool

SetListItems replaces a list's data with an owned copy.

func SetPosition

func SetPosition(world *ecs.World, entity ecs.Entity, position scene.Val2) bool

SetPosition changes only a UI node's translation, preserving its other transforms.

func SetScrollAreaOffset

func SetScrollAreaOffset(world *ecs.World, entity ecs.Entity, offset mgl32.Vec2) bool

SetScrollAreaOffset updates the single UIScroll state and clamps it to the area's current range.

func SetSelectorScrollOffset

func SetSelectorScrollOffset(world *ecs.World, selector ecs.Entity, offset float32) bool

SetSelectorScrollOffset updates the selector list's single UIScroll state using a positive content offset.

func SetSize

func SetSize(world *ecs.World, entity ecs.Entity, width, height float32) bool

SetSize changes the node's measured Size2D. Use SetControlBounds when input target bounds must also change.

func SetText

func SetText(world *ecs.World, entity ecs.Entity, value string) bool

SetText changes an existing text visual without replacing its layout caches. Equal values and missing components return false and do not mark Changed.

func SetVirtualJoystickRawValue

func SetVirtualJoystickRawValue(world *ecs.World, entity ecs.Entity, value mgl32.Vec2) bool

SetVirtualJoystickRawValue sets a joystick's physical normalized deflection. The value is clamped to the unit circle before Axis and DeadZone are applied.

func SpawnButton

func SpawnButton(world *ecs.World, opts ButtonOptions) ecs.Entity

func SpawnButtonGroup

func SpawnButtonGroup[T any](world *ecs.World, opts ButtonGroupOptions[T]) ecs.Entity

func SpawnCheckbox

func SpawnCheckbox(world *ecs.World, opts CheckboxOptions) ecs.Entity

func SpawnContextMenu

func SpawnContextMenu(world *ecs.World, opts ContextMenuOptions) ecs.Entity

func SpawnControl

func SpawnControl[T any](world *ecs.World, opts ControlOptions, component T) ecs.Entity

SpawnControl creates a behavior-only control root. Parts are ordinary child entities linked by the behavior that owns them.

func SpawnDialog

func SpawnDialog(world *ecs.World, opts DialogOptions) ecs.Entity

func SpawnImageGrid

func SpawnImageGrid(world *ecs.World, opts ImageGridOptions) ecs.Entity

SpawnImageGrid creates a thumbnail grid. The grid emits ImageGridEvent and EventImageGridRemove when a removable card's close control is activated.

func SpawnInput

func SpawnInput(world *ecs.World, opts TextOptions) ecs.Entity

func SpawnLabel

func SpawnLabel(world *ecs.World, opts LabelOptions) ecs.Entity

func SpawnList

func SpawnList[T any](world *ecs.World, opts ListOptions[T]) ecs.Entity

SpawnList creates a virtual list. Its entity count is based on the viewport and overscan, not on the number of items.

func SpawnMenu

func SpawnMenu(world *ecs.World, opts MenuOptions) ecs.Entity

func SpawnNode

func SpawnNode[T any](world *ecs.World, options NodeOptions, value T) ecs.Entity

SpawnNode reuses a factory owned by world. Retain a NewNodeSpawner result when a hot loop should avoid even the factory's type-key lookup.

func SpawnNode2

func SpawnNode2[A, B any](world *ecs.World, options NodeOptions, a A, b B) ecs.Entity

func SpawnNumberInput

func SpawnNumberInput(world *ecs.World, opts NumberInputOptions) ecs.Entity

func SpawnPanel

func SpawnPanel(world *ecs.World, opts PanelOptions) ecs.Entity

func SpawnProgress

func SpawnProgress(world *ecs.World, opts ProgressOptions) ecs.Entity

func SpawnScrollArea

func SpawnScrollArea(world *ecs.World, opts ScrollAreaOptions) ecs.Entity

func SpawnScrollContent

func SpawnScrollContent(world *ecs.World, area ecs.Entity, x, y float32) ecs.Entity

func SpawnSelector

func SpawnSelector(world *ecs.World, opts SelectorOptions) ecs.Entity

func SpawnTab

func SpawnTab(world *ecs.World, opts TabOptions) ecs.Entity

func SpawnTabPanel

func SpawnTabPanel(world *ecs.World, tabs ecs.Entity, opts TabPanelOptions) ecs.Entity

func SpawnTextarea

func SpawnTextarea(world *ecs.World, opts TextOptions) ecs.Entity

func SpawnTree

func SpawnTree[T comparable](world *ecs.World, opts TreeOptions[T]) ecs.Entity

SpawnTree creates typed nodes whose clicks are dispatched by the Widgets UpdateSystem. SyncTreeSystem[T] handles their layout and visual state.

func SpawnVirtualJoystick

func SpawnVirtualJoystick(world *ecs.World, opts VirtualJoystickOptions) ecs.Entity

SpawnVirtualJoystick creates a complete virtual joystick. Set Floating to show its visual parts at the press position instead of keeping them visible. Read VirtualJoystick.Value from the returned entity, or subscribe to ChangedEvent[mgl32.Vec2] and VirtualJoystickActiveEvent.

func SpawnWindowTitleBar

func SpawnWindowTitleBar(world *ecs.World, opts WindowTitleBarOptions) ecs.Entity

SpawnWindowTitleBar creates a reusable custom-window title-bar control group. The returned entity is an invisible layout root; its children are the interactive buttons and carry WindowTitleBarButton actions.

func StepNumberInputValue

func StepNumberInputValue(value string, input NumberInput, direction int) (string, bool)

func Sync

func Sync(world *ecs.World) error

Sync runs the registered UI synchronization stages for a world.

func SyncAfterLayout

func SyncAfterLayout(world *ecs.World) error

SyncAfterLayout runs registered UI synchronization after layout.

func SyncAfterLayoutSystem

func SyncAfterLayoutSystem(name string) ecs.SystemConfig

func SyncAfterLayoutWith

func SyncAfterLayoutWith[F RuntimeFeature](world *ecs.World) error

SyncAfterLayoutWith runs the selected tool profile after UI layout.

func SyncHTML

func SyncHTML(world *ecs.World) error

func SyncHTMLSystem

func SyncHTMLSystem(name string) ecs.SystemConfig

func SyncLayoutSystem

func SyncLayoutSystem(name string) ecs.SystemConfig

SyncLayoutSystem applies Layout and Widget components before UI global transforms are propagated. It is intentionally independent of the higher level ui widget runtime so scenes can use these components on their own.

func SyncListSystem

func SyncListSystem[T any](name string) ecs.SystemConfig

SyncListSystem updates the pooled item entities after scrolling or replacing items. Add one system for every item type used by a world.

func SyncSystem

func SyncSystem(name string) ecs.SystemConfig

func SyncTextInputSystem

func SyncTextInputSystem(name string) ecs.SystemConfig

func SyncTreeSystem

func SyncTreeSystem[T comparable](name string) ecs.SystemConfig

func SyncWith

func SyncWith[F RuntimeFeature](world *ecs.World) error

SyncWith synchronizes a statically selected tool profile without changing the features installed in the world's scheduled UI runtime.

func TextCaretIndex

func TextCaretIndex[V piecetree.Value](text *scene.Text2D, value V, x, y float32) int

func TextareaScrollBarAt

func TextareaScrollBarAt(world *ecs.World, screenX, screenY float32) bool

TextareaScrollBarAt reports whether a screen point is inside a visible textarea scrollbar.

func UnbindControl

func UnbindControl(world *ecs.World, entity ecs.Entity)

UnbindControl removes the behavior installed by BindControl from an existing entity. Authored transform, layout, and visual components are intentionally left to the caller; this function only tears down UI control state and the relations used by static control compositions.

func UnbindControlCompositionPart

func UnbindControlCompositionPart(world *ecs.World, entity ecs.Entity)

UnbindControlCompositionPart removes composition state from one static node.

func UnbindVariant

func UnbindVariant[T comparable](world *ecs.World, owner, entity ecs.Entity)

func UpdateLayout

func UpdateLayout(world *ecs.World) error

UpdateLayout immediately applies all Layout and Widget components in world. It is the programmatic equivalent of waiting for the next UI sync frame.

func UpdateSystem

func UpdateSystem(name string) ecs.SystemConfig

func UpdateWindowTitleBar

func UpdateWindowTitleBar(world *ecs.World, entity ecs.Entity, opts WindowTitleBarOptions) bool

UpdateWindowTitleBar changes the root bounds and keeps its controls aligned to the right edge of the title bar.

Types

type Action

type Action[T any] struct {
	Value T
}

type AuthoredControls

type AuthoredControls struct{}

AuthoredControls enables pointer-state variants for controls whose visuals are authored directly in a scene.

type BodyPart

type BodyPart struct{}

type Button

type Button struct{}

Button marks controls whose reusable behavior is button styling. Activation remains the original scene.InputEventTap and is handled by bound game logic.

type ButtonContentAlignment

type ButtonContentAlignment uint8

ButtonContentAlignment controls how a button arranges its icon and label.

const (
	ButtonContentStart ButtonContentAlignment = iota
	ButtonContentCenter
)

type ButtonGroup

type ButtonGroup struct {
	Buttons    []ecs.Entity
	Width      float32
	Height     float32
	StackIndex int
}

type ButtonGroupDividerOptions

type ButtonGroupDividerOptions struct {
	Width float32
	Inset float32
	Color graphics.ColorRGBA
}

type ButtonGroupItem

type ButtonGroupItem[T any] struct {
	Value    T
	Label    string
	Icon     IconStyle
	Width    float32
	Disabled bool
}

type ButtonGroupOptions

type ButtonGroupOptions[T any] struct {
	Divider     *ButtonGroupDividerOptions
	Style       *ButtonGroupStyle
	Items       []ButtonGroupItem[T]
	Theme       Theme
	FontSize    float64
	DPI         float64
	X, Y        float32
	Height      float32
	Radius      CornerRadius
	PassThrough bool
}

type ButtonGroupStyle

type ButtonGroupStyle struct {
	Button  ButtonStyle
	Frame   SurfaceStyle
	Divider SurfaceStyle
}

type ButtonGroupValue

type ButtonGroupValue[T any] struct {
	Value T
	Group ecs.Entity
	Index int
}

type ButtonOptions

type ButtonOptions struct {
	Style        *ButtonStyle
	Label        string
	Icon         IconStyle
	Theme        Theme
	FontSize     float64
	DPI          float64
	Radius       CornerRadius
	X            float32
	Height       float32
	Width        float32
	Y            float32
	Variant      ButtonVariant
	JoinLeft     bool
	JoinRight    bool
	Disabled     bool
	PassThrough  bool
	ContentAlign ButtonContentAlignment
}

type ButtonStyle

type ButtonStyle struct {
	Body       StateStyle[SurfaceStyle]
	JoinedEdge StateStyle[SurfaceStyle]
}

type ButtonStyles

type ButtonStyles struct {
	Primary ButtonStyle
	Surface ButtonStyle
	Danger  ButtonStyle
}

type ButtonVariant

type ButtonVariant uint8
const (
	ButtonPrimary ButtonVariant = iota
	ButtonSurface
)

type CaretPart

type CaretPart struct{}

type ChangedEvent

type ChangedEvent[T any] struct {
	Value  T
	Entity ecs.Entity
}

type CheckboxOptions

type CheckboxOptions struct {
	Style       *CheckboxStyle
	Label       string
	Theme       Theme
	FontSize    float64
	DPI         float64
	Height      float32
	Radius      CornerRadius
	X           float32
	Width       float32
	Y           float32
	Disabled    bool
	PassThrough bool
	Checked     bool
}

type CheckboxStyle

type CheckboxStyle struct {
	Track ToggleStyle[SurfaceStyle]
	Mark  StateStyle[SurfaceStyle]
}

type CodeToken

type CodeToken struct {
	Start, End, Offset int
	RuneStart, RuneEnd int
	Quoted             bool
}

CodeToken describes a code token in byte and rune offsets. Offset is the byte position of the requested character; Quoted identifies string contents.

func CodeTokenAt

func CodeTokenAt[V piecetree.Value](inputValue V, index int) (token CodeToken)

CodeTokenAt finds the token at a rune index in one allocation-free scan. Words include Unicode letters, digits and combining marks. Quoted contents stay together, excluding their delimiters; other delimiters stay separate.

type CompositionNode

type CompositionNode struct {
	Text          string
	X, Y          float32
	Width, Height float32
	Kind          CompositionNodeKind
	Visible       bool
}

CompositionNode describes one static, visual node available to a control. Behavior is selected exclusively by components installed on the control root.

type CompositionNodeKind

type CompositionNodeKind uint8
const (
	CompositionGroup CompositionNodeKind = iota
	CompositionSprite
	CompositionText
)

type Content

type Content[T any] struct {
	Value T
}

type ContextMenu

type ContextMenu struct {
	Selected   int
	StackIndex int
	Width      float32
	ItemHeight float32
	Padding    float32
	Open       bool
}

type ContextMenuItem

type ContextMenuItem = Item[ContextMenu]

type ContextMenuOptions

type ContextMenuOptions struct {
	Style       *MenuStyle
	Items       []string
	Theme       Theme
	X, Y        float32
	Width       float32
	ItemHeight  float32
	Padding     float32
	Radius      CornerRadius
	Open        bool
	PassThrough bool
}

type ContextMenuPanelPart

type ContextMenuPanelPart struct{}

type Control

type Control struct {
	Selected bool
}

Control marks an input target as a styled UI control. Geometry, disabled state, ordering and input state remain in generic ECS components.

type ControlComposition

type ControlComposition map[ecs.Entity]CompositionNode

ControlComposition contains the static nodes that may form control visuals.

type ControlOptions

type ControlOptions struct {
	X, Y          float32
	Width, Height float32
	StackIndex    int
	Disabled      bool
	PassThrough   bool
}

type ControlState

type ControlState struct {
	Hovered  bool
	Pressed  bool
	Selected bool
	Focused  bool
	Disabled bool
}

ControlState is the visual input state shared by interactive widgets.

type ControlVariant

type ControlVariant uint8
const (
	VariantAlways ControlVariant = iota
	VariantInputNormal
	VariantUnfocusedNormal
	VariantClosedNormal
	VariantHovered
	VariantUnfocusedHovered
	VariantClosedHovered
	VariantPressed
	VariantFocused
	VariantChecked
	VariantOpen
	VariantOpenEnabled
)

type CornerRadius

type CornerRadius float32
const Circle CornerRadius = -1

Circle uses the largest radius allowed by the surface dimensions.

type Danger

type Danger struct{}

type DecrementPart

type DecrementPart struct{}

type Dialog

type Dialog struct{}

Dialog marks a panel as a transient dialog surface.

type DialogOptions

type DialogOptions = PanelOptions

type FileBrowser

type FileBrowser struct {
	CurrentDir   string
	SelectedPath string

	Extensions []string

	Truncated bool
	// contains filtered or unexported fields
}

func NewFileBrowser

func NewFileBrowser(start string, extensions ...string) (FileBrowser, error)

func (*FileBrowser) Entries

func (browser *FileBrowser) Entries() ([]FileBrowserEntry, error)

func (*FileBrowser) OpenDirectory

func (browser *FileBrowser) OpenDirectory(path string) error

func (*FileBrowser) OpenParent

func (browser *FileBrowser) OpenParent() error

func (*FileBrowser) OpenValue

func (browser *FileBrowser) OpenValue(value string) (string, error)

func (*FileBrowser) SaveValue

func (browser *FileBrowser) SaveValue(value string) (string, error)

func (*FileBrowser) Select

func (browser *FileBrowser) Select(path string) error

type FileBrowserEntry

type FileBrowserEntry struct {
	Name  string
	Path  string
	IsDir bool
}

type FillPart

type FillPart struct{}

type FocusChangedEvent

type FocusChangedEvent struct {
	Entity       ecs.Entity
	Focused      bool
	FocusVisible bool
}

type FrameBorderPart

type FrameBorderPart struct{}

type FullRuntime

type FullRuntime struct{}

FullRuntime selects HTML and widget systems for editor and tool worlds. Optional feature packages can add their own synchronizers with RegisterRuntimeExtension. Widgets also synchronize authored control compositions.

type HTMLRenderer

type HTMLRenderer struct{}

HTMLRenderer enables synchronization of html.Surface components into UI entities. It is kept separate so tools can opt into HTML without enabling Markdown parsing.

type HTMLSelectStyle

type HTMLSelectStyle struct {
	Item StateStyle[SurfaceStyle]
	Text StateStyle[graphics.ColorRGBA]
}

HTMLSelectStyle supplies native option interaction colors for an HTML surface. Normal option colors continue to come from the authored select control.

type IconContent

type IconContent struct {
	Value IconStyle
}

type IconPart

type IconPart struct{}

type IconStyle

type IconStyle struct {
	Texture  *graphics.Texture
	Fallback string
	Width    float32
	Height   float32
}

IconStyle renders Texture when present and otherwise renders Fallback text.

func TextIcon

func TextIcon(value string) IconStyle

func TextureIcon

func TextureIcon(texture *graphics.Texture, width, height float32) IconStyle

func (IconStyle) Empty

func (icon IconStyle) Empty() bool

type ImageGrid

type ImageGrid struct {
	DeleteIcon  IconStyle
	Items       []ImageGridItem
	Columns     int
	Width       float32
	Gap         float32
	Padding     float32
	LabelHeight float32
}

ImageGrid owns a fixed collection of image cards. Recreate it when the item list or layout changes; moving its entity updates the whole grid.

type ImageGridEvent

type ImageGridEvent struct {
	Grid  ecs.Entity
	Index int
}

ImageGridEvent reports a remove request for a card.

type ImageGridItem

type ImageGridItem struct {
	Texture   *graphics.Texture
	Label     string
	Removable bool
}

ImageGridItem describes one image card in an ImageGrid.

type ImageGridOptions

type ImageGridOptions struct {
	Style       *ImageGridStyle
	DeleteIcon  IconStyle
	Items       []ImageGridItem
	Theme       Theme
	Columns     int
	LabelHeight float32
	X           float32
	Padding     float32
	Gap         float32
	Radius      CornerRadius
	Width       float32
	Y           float32
	PassThrough bool
}

ImageGridOptions configures an ImageGrid.

type ImageGridStyle

type ImageGridStyle struct {
	Remove StateStyle[SurfaceStyle]
	Cell   SurfaceStyle
}

type IncrementPart

type IncrementPart struct{}

type Indexed

type Indexed[T any] struct {
	Value int
}

Indexed adds an ordinal only to part kinds that have multiple instances.

type Input

type Input struct{}

type InputEvent

type InputEvent[T any] struct {
	Value  T
	Entity ecs.Entity
}

type Item

type Item[Kind any] struct {
	Label    string
	Owner    ecs.Entity
	Index    int
	Disabled bool
}

type ItemPart

type ItemPart struct{}

type KnobPart

type KnobPart struct{}

type Label

type Label struct {
	Value    string
	Color    graphics.ColorRGBA
	FontSize float64
	DPI      float64
}

type LabelOptions

type LabelOptions struct {
	Value       string
	Theme       Theme
	FontSize    float64
	DPI         float64
	Color       graphics.ColorRGBA
	X, Y        float32
	PassThrough bool
}

type LabelPart

type LabelPart struct{}

type Layout

type Layout struct {
	ConstraintNum       int                       `json:"constraintNum,omitempty"`
	Padding             scene.UIRect              `json:"padding,omitzero"`
	CellSize            mgl32.Vec2                `json:"cellSize,omitzero"`
	SpacingY            float32                   `json:"spacingY,omitempty"`
	PaddingTop          float32                   `json:"paddingTop,omitempty"`
	PaddingBottom       float32                   `json:"paddingBottom,omitempty"`
	PaddingRight        float32                   `json:"paddingRight,omitempty"`
	SpacingX            float32                   `json:"spacingX,omitempty"`
	PaddingLeft         float32                   `json:"paddingLeft,omitempty"`
	VerticalDirection   LayoutVerticalDirection   `json:"verticalDirection,omitempty"`
	HorizontalDirection LayoutHorizontalDirection `json:"horizontalDirection,omitempty"`
	Type                LayoutType                `json:"type,omitempty"`
	StartAxis           LayoutStartAxis           `json:"startAxis,omitempty"`
	AffectedByScale     bool                      `json:"affectedByScale,omitempty"`
	AutoAlignment       bool                      `json:"autoAlignment,omitempty"`
	Constraint          LayoutConstraint          `json:"constraint,omitempty"`
	ResizeMode          LayoutResizeMode          `json:"resizeMode,omitempty"`
}

Layout is a UI container layout component. Children are the entities that carry Parent{Entity: owner}; authored SiblingOrder values preserve sibling order and Entity values provide a deterministic runtime fallback. PaddingLeft/Right/Top/Bottom are in logical pixels. Padding can be used when percentage or viewport-relative padding is desired.

func NewLayout

func NewLayout() Layout

type LayoutConstraint

type LayoutConstraint uint8
const (
	LayoutConstraintNone LayoutConstraint = iota
	LayoutConstraintFixedRow
	LayoutConstraintFixedColumn
)

type LayoutHorizontalDirection

type LayoutHorizontalDirection uint8
const (
	LayoutLeftToRight LayoutHorizontalDirection = iota
	LayoutRightToLeft
)

type LayoutResizeMode

type LayoutResizeMode uint8

LayoutResizeMode controls whether a layout changes its children or itself.

const (
	LayoutResizeNone LayoutResizeMode = iota
	LayoutResizeChildren
	LayoutResizeContainer
)

type LayoutStartAxis

type LayoutStartAxis uint8
const (
	LayoutStartHorizontal LayoutStartAxis = iota
	LayoutStartVertical
)

type LayoutType

type LayoutType uint8

LayoutType selects the arrangement performed by Layout.

const (
	LayoutNone LayoutType = iota
	LayoutHorizontal
	LayoutVertical
	LayoutGrid
)

type LayoutVerticalDirection

type LayoutVerticalDirection uint8
const (
	LayoutTopToBottom LayoutVerticalDirection = iota
	LayoutBottomToTop
)

type LinkActivatedEvent

type LinkActivatedEvent struct {
	Target string
	Entity ecs.Entity
}

type List

type List[T any] struct {
	BindItem   func(*ecs.World, ecs.Entity, int, T)
	UnbindItem func(*ecs.World, ecs.Entity)
	Items      []T

	Overscan int
	First    int
	Last     int
	ItemSize float32
	Axis     ListAxis
	// contains filtered or unexported fields
}

List is a virtual list backed by a fixed pool of item entities. Items may be replaced at runtime; changing the viewport or item size requires recreating the list so its item pool remains correctly sized.

type ListAxis

type ListAxis uint8

ListAxis controls the axis along which list items are laid out and scrolled.

const (
	ListVertical ListAxis = iota
	ListHorizontal
)

type ListItem

type ListItem[T any] struct {
	Value T
	List  ecs.Entity
	Index int
}

ListItem identifies the item currently represented by a pooled item entity. Index is -1 while the entity is not in use.

type ListOptions

type ListOptions[T any] struct {
	UnbindItem func(*ecs.World, ecs.Entity)
	BindItem   func(*ecs.World, ecs.Entity, int, T)

	// BuildItem initializes each pooled entity once. Add custom visuals as its
	// children; BindItem then updates them whenever it represents an item.
	// UnbindItem resets those visuals when a pooled entity stops representing an
	// item. It is also called once after BuildItem so empty lists start cleanly.
	BuildItem             func(*ecs.World, ecs.Entity)
	Style                 *ScrollStyle
	Items                 []T
	Theme                 Theme
	Overscan              int
	ScrollX               float32
	ThumbBarSize          float32
	X, Y                  float32
	ScrollY               float32
	BarSize               float32
	MinThumbSize          float32
	ItemSize              float32
	HoverBarSize          float32
	Radius                CornerRadius
	Width, Height         float32
	Axis                  ListAxis
	PassThrough           bool
	ReserveScrollbarSpace bool
	Controlled            bool
}
type Menu struct {
	Label      string
	Selected   int
	StackIndex int
	Width      float32
	ItemHeight float32
	Padding    float32
	Open       bool
}
type MenuItem = Item[Menu]
type MenuOptions struct {
	Style         *MenuStyle
	Label         string
	Items         []string
	Theme         Theme
	X, Y          float32
	Width, Height float32
	Padding       float32
	Radius        CornerRadius
	PassThrough   bool
}
type MenuPanelPart struct{}
type MenuStyle struct {
	Trigger   ButtonStyle
	Item      StateStyle[SurfaceStyle]
	Indicator IconStyle
	Popup     SurfaceStyle
}

type NodeOptions

type NodeOptions struct {
	Anchor     *scene.Anchor
	Parent     ecs.Entity
	StackIndex int
	X, Y       float32
	Hidden     bool
}

NodeOptions describes an unrotated UI node with unit scale. Zero options create a visible top-left node at the origin; Hidden explicitly hides it. A nil Anchor selects TopLeft; use &scene.AnchorCenter for a centered node.

type NodeSpawner

type NodeSpawner[T any] struct {
	// contains filtered or unexported fields
}

NodeSpawner binds the six common UI components plus T to one archetype. T must differ from the fixed components; duplicates panic at construction.

func NewNodeSpawner

func NewNodeSpawner[T any](world *ecs.World) NodeSpawner[T]

func (*NodeSpawner[T]) Reserve

func (s *NodeSpawner[T]) Reserve(capacity int)

func (*NodeSpawner[T]) Spawn

func (s *NodeSpawner[T]) Spawn(options NodeOptions, value T) ecs.Entity

type NodeSpawner2

type NodeSpawner2[A, B any] struct {
	// contains filtered or unexported fields
}

NodeSpawner2 creates nodes with two additional components in the same write. Use it for e.g. Size2D plus a visual, avoiding a follow-up Insert and migration.

func NewNodeSpawner2

func NewNodeSpawner2[A, B any](world *ecs.World) NodeSpawner2[A, B]

func (*NodeSpawner2[A, B]) Reserve

func (s *NodeSpawner2[A, B]) Reserve(capacity int)

func (*NodeSpawner2[A, B]) Spawn

func (s *NodeSpawner2[A, B]) Spawn(options NodeOptions, a A, b B) ecs.Entity

type NumberInput

type NumberInput struct {
	UpIcon          IconStyle
	DownIcon        IconStyle
	Step            float64
	StepButtonWidth float32
	Changed         bool
	Integer         bool
}

type NumberInputBorderPart

type NumberInputBorderPart struct{}

type NumberInputOptions

type NumberInputOptions struct {
	Style           *NumberInputStyle
	Value           string
	Placeholder     string
	UpIcon          IconStyle
	DownIcon        IconStyle
	Theme           Theme
	DPI             float64
	MaxRunes        int
	Step            float64
	FontSize        float64
	Width, Height   float32
	Y               float32
	StepButtonWidth float32
	X               float32
	Radius          CornerRadius
	Disabled        bool
	Integer         bool
	PassThrough     bool
}

type NumberInputStep

type NumberInputStep struct {
	Input     ecs.Entity
	Direction int
}

type NumberInputStyle

type NumberInputStyle struct {
	Step  StateStyle[SurfaceStyle]
	Field TextFieldStyle
}

type NumberStepIconPart

type NumberStepIconPart struct{}

type Panel

type Panel struct {
	Title string
}

type PanelOptions

type PanelOptions struct {
	Style         *PanelStyle
	Title         string
	Theme         Theme
	Border        graphics.ColorRGBA
	X, Y          float32
	Width, Height float32
	Radius        CornerRadius
	BorderWidth   float32
	PassThrough   bool
}

type PanelPart

type PanelPart struct{}

type PanelStyle

type PanelStyle struct {
	Body SurfaceStyle
}

type Part

type Part[T any] struct{}

Part is a zero-sized, strongly typed semantic marker.

type Progress

type Progress struct {
	Min           float32
	Max           float32
	Value         float32
	Indeterminate bool
	Slider        bool
	Changed       bool
	Fill          ecs.Entity
	Thumb         ecs.Entity
}

type ProgressOptions

type ProgressOptions struct {
	Style         *ProgressStyle
	Theme         Theme
	Value         float32
	Height        float32
	Min           float32
	Max           float32
	X             float32
	ThumbSize     float32
	Radius        CornerRadius
	Width         float32
	Y             float32
	Indeterminate bool
	Slider        bool
	PassThrough   bool
}

type ProgressStyle

type ProgressStyle struct {
	Track StateStyle[SurfaceStyle]
	Thumb StateStyle[SurfaceStyle]
	Fill  SurfaceStyle
}

type ProgressThumb

type ProgressThumb struct {
	Progress ecs.Entity
}

ProgressThumb links an authored thumb control to its progress source.

type Relation

type Relation[T any] struct {
	Owner ecs.Entity
}

Relation links a control part to its owner. T identifies the relation's domain, while semantic purpose is represented by a separate Part marker.

type RuntimeExtension

type RuntimeExtension struct {
	Sync ecs.System
}

RuntimeExtension adds an optional synchronizer to an existing UI runtime. Feature packages use this boundary so unused implementations stay out of the core UI binary.

type RuntimeFeature

type RuntimeFeature interface {
	// contains filtered or unexported methods
}

RuntimeFeature is a statically selected UI subsystem. Only feature types passed to RegisterRuntimeFeature are retained by the linker.

type ScrollArea

type ScrollArea struct {
	// ReserveScrollbarSpace subtracts visible scrollbar gutters from the content viewport.
	ReserveScrollbarSpace bool
	Width                 float32
	Height                float32
	ContentWidth          float32
	ContentHeight         float32
	Controlled            bool
	DisableDrag           bool
	WheelStep             float32
	BarSize               float32
	MinThumbSize          float32
	ThumbBarSize          float32
	HoverBarSize          float32
	HoverHorizontal       bool
	HoverVertical         bool
	DraggingHorizontal    bool
	DraggingVertical      bool
	StackIndex            int
	// ScrollBarStackIndex overrides the visual layer of scrollbar parts; zero follows StackIndex.
	ScrollBarStackIndex int
}

func (ScrollArea) Measure

func (area ScrollArea) Measure() ScrollMetrics

Measure derives the viewport and scroll range without allocating.

type ScrollAreaOptions

type ScrollAreaOptions struct {
	Style                 *ScrollStyle
	Theme                 Theme
	ScrollBarStackIndex   int
	ScrollX               float32
	Width                 float32
	ContentWidth          float32
	ContentHeight         float32
	X, Y                  float32
	WheelStep             float32
	Radius                CornerRadius
	ScrollY               float32
	BarSize               float32
	MinThumbSize          float32
	ThumbBarSize          float32
	HoverBarSize          float32
	Height                float32
	ReserveScrollbarSpace bool
	PassThrough           bool
	DisableDrag           bool
	Controlled            bool
}

type ScrollContent

type ScrollContent struct {
	Area ecs.Entity
	X    float32
	Y    float32
}

type ScrollMetrics

type ScrollMetrics struct {
	ViewportWidth     float32
	ViewportHeight    float32
	MaxScrollX        float32
	MaxScrollY        float32
	HorizontalVisible bool
	VerticalVisible   bool
}

func GetScrollAreaMetrics

func GetScrollAreaMetrics(world *ecs.World, entity ecs.Entity) (ScrollMetrics, bool)

GetScrollAreaMetrics derives viewport and range data from the current area configuration.

func MeasureScrollArea

func MeasureScrollArea(width, height, contentWidth, contentHeight float32) ScrollMetrics

type ScrollStyle

type ScrollStyle struct {
	Thumb StateStyle[SurfaceStyle]
	Track SurfaceStyle
}

type ScrollThumbHorizontalPart

type ScrollThumbHorizontalPart struct{}

type ScrollThumbVerticalPart

type ScrollThumbVerticalPart struct{}

type ScrollTrackHorizontalPart

type ScrollTrackHorizontalPart struct{}

type ScrollTrackVerticalPart

type ScrollTrackVerticalPart struct{}

type SelectedEvent

type SelectedEvent[T any] struct {
	Value  T
	Entity ecs.Entity
	Index  int
}

type SelectionPart

type SelectionPart struct{}

type Selector

type Selector struct {
	Label      string
	Icon       IconStyle
	Selected   int
	StackIndex int
	ItemHeight float32
	ListHeight float32
	Open       bool
	Upward     bool
}

type SelectorIconPart

type SelectorIconPart struct{}

type SelectorItem

type SelectorItem = Item[Selector]

type SelectorList

type SelectorList struct {
	Selector ecs.Entity
}

type SelectorListPart

type SelectorListPart struct{}

type SelectorOptions

type SelectorOptions struct {
	Style       *SelectorStyle
	Label       string
	Icon        IconStyle
	Options     []string
	Theme       Theme
	Selected    int
	ScrollY     float32
	Height      float32
	ItemHeight  float32
	ListHeight  float32
	X           float32
	Radius      CornerRadius
	Width       float32
	Y           float32
	Disabled    bool
	PassThrough bool
	Upward      bool
	JoinLeft    bool
	JoinRight   bool
}

type SelectorPanelBorderPart

type SelectorPanelBorderPart struct{}

type SelectorPanelPart

type SelectorPanelPart struct{}

type SelectorScrollThumbPart

type SelectorScrollThumbPart struct{}

type SelectorScrollTrackPart

type SelectorScrollTrackPart struct{}

type SelectorStyle

type SelectorStyle struct {
	Body  StateStyle[SurfaceStyle]
	Item  StateStyle[SurfaceStyle]
	Popup SurfaceStyle
}

type Skin

type Skin struct {
	Button          ButtonStyles
	NumberInput     NumberInputStyle
	Checkbox        CheckboxStyle
	Selector        SelectorStyle
	Progress        ProgressStyle
	VirtualJoystick VirtualJoystickStyle
	ImageGrid       ImageGridStyle
	Scroll          ScrollStyle
	Menu            MenuStyle
	ContextMenu     MenuStyle
	Tree            TreeStyle
	Tab             TabStyle
	ButtonGroup     ButtonGroupStyle
	TextField       TextFieldStyle
	Panel           PanelStyle
}

Skin contains the visual styles used by all built-in widgets.

func DefaultSkin

func DefaultSkin(theme Theme) Skin

type StateStyle

type StateStyle[T any] struct {
	Normal   T
	Hovered  *T
	Pressed  *T
	Selected *T
	Focused  *T
	Disabled *T
}

StateStyle resolves a value for an input state. Missing overrides fall back to Normal.

func NewStateStyle

func NewStateStyle[T any](normal T) StateStyle[T]

func (StateStyle[T]) Resolve

func (style StateStyle[T]) Resolve(state ControlState) T

func (StateStyle[T]) WithDisabled

func (style StateStyle[T]) WithDisabled(value T) StateStyle[T]

func (StateStyle[T]) WithFocused

func (style StateStyle[T]) WithFocused(value T) StateStyle[T]

func (StateStyle[T]) WithHovered

func (style StateStyle[T]) WithHovered(value T) StateStyle[T]

func (StateStyle[T]) WithPressed

func (style StateStyle[T]) WithPressed(value T) StateStyle[T]

func (StateStyle[T]) WithSelected

func (style StateStyle[T]) WithSelected(value T) StateStyle[T]

type StyleOverride

type StyleOverride[T any] struct {
	Value T
}

StyleOverride stores a strongly typed per-entity style override.

type SubmittedEvent

type SubmittedEvent[T any] struct {
	Value  T
	Entity ecs.Entity
}

type SurfaceStyle

type SurfaceStyle struct {
	Image      scene.UIImage2D
	Background scene.Shape2D
	Border     scene.Shape2D
}

SurfaceStyle describes the independently rendered background, image and border layers.

func ColorSurface

func ColorSurface(color graphics.ColorRGBA) SurfaceStyle

func NineSliceSurface

func NineSliceSurface(texture *graphics.Texture, slice scene.NineSlice2D) SurfaceStyle

func TextureSurface

func TextureSurface(texture *graphics.Texture) SurfaceStyle

func (SurfaceStyle) WithBackground

func (surface SurfaceStyle) WithBackground(shape scene.Shape2D) SurfaceStyle

func (SurfaceStyle) WithBorder

func (surface SurfaceStyle) WithBorder(shape scene.Shape2D) SurfaceStyle

type Tab

type Tab struct {
	Selected     int
	Width        float32
	Height       float32
	HeaderHeight float32
	Highlight    graphics.ColorRGBA
	ItemBorders  bool
}

type TabItem

type TabItem struct {
	Label    string
	Icon     IconStyle
	Tabs     ecs.Entity
	Index    int
	Width    float32
	Disabled bool
}

type TabItemBorder

type TabItemBorder struct {
	Side TabItemBorderSide
}

type TabItemBorderPart

type TabItemBorderPart struct{}

type TabItemBorderSide

type TabItemBorderSide uint8
const (
	TabItemBorderTop TabItemBorderSide = iota
	TabItemBorderRight
	TabItemBorderBottom
	TabItemBorderLeft
)

type TabItemSpec

type TabItemSpec struct {
	Label    string
	Icon     IconStyle
	Disabled bool
}

type TabOptions

type TabOptions struct {
	Style        *TabStyle
	Items        []TabItemSpec
	Theme        Theme
	Selected     int
	Highlight    graphics.ColorRGBA
	Height       float32
	HeaderHeight float32
	X            float32
	Radius       CornerRadius
	Width        float32
	Y            float32
	PassThrough  bool
	ItemBorders  bool
}

type TabPanel

type TabPanel struct {
	Tabs  ecs.Entity
	Index int
}

type TabPanelOptions

type TabPanelOptions struct {
	Style       *TabStyle
	Theme       Theme
	Index       int
	Radius      CornerRadius
	PassThrough bool
}

type TabStyle

type TabStyle struct {
	Frame SurfaceStyle
	Item  ToggleStyle[SurfaceStyle]
	Panel SurfaceStyle
}

type TextControl

type TextControl[T TextControlMode] struct {
	Value       string
	Placeholder string
	Password    bool
	Wrap        bool
	Padding     float32
	MaxRunes    int
	FontSize    float64
	DPI         float64
}

TextControl configures explicit text-field behavior for an existing control root. T selects single-line Input or multiline Textarea behavior in code.

type TextControlMode

type TextControlMode interface {
	Input | Textarea
}

type TextField

type TextField struct {
	Source piecetree.Snapshot

	// Buffer optionally binds native input to a document-owned piece tree.
	Buffer *input.TextBuffer

	Composition string
	Placeholder string
	Value       string

	Caret    int
	MaxRunes int
	FontSize float64
	DPI      float64
	Anchor   int
	// ScrollX is the signed horizontal text offset. Positive values move the
	// text right; negative values reveal the caret in overflowing values.
	ScrollX float32

	Submitted bool
	Password  bool

	Selecting bool

	Focused bool
	// contains filtered or unexported fields
}

func (*TextField) RecordEdit

func (f *TextField) RecordEdit(previous TextField)

RecordEdit records a committed native edit. Document-backed editors own their history; ordinary controls retain immutable strings without copying.

func (TextField) Text

func (f TextField) Text() piecetree.Snapshot

type TextFieldKeyHandler

type TextFieldKeyHandler struct {
	Handle func(*input.State) bool
}

TextFieldKeyHandler intercepts keyboard editing before native text input and focus traversal. Returning true lets editor widgets own Enter, Tab, arrows and Escape without also inserting text or moving the document caret.

type TextFieldStyle

type TextFieldStyle struct {
	Body      StateStyle[SurfaceStyle]
	Caret     SurfaceStyle
	Selection SurfaceStyle
}

type TextOptions

type TextOptions struct {
	Style       *TextFieldStyle
	Value       string
	Placeholder string
	Theme       Theme
	MaxRunes    int
	FontSize    float64
	DPI         float64
	X           float32
	Height      float32
	Radius      CornerRadius
	Width       float32
	Y           float32
	JoinLeft    bool
	JoinRight   bool
	Disabled    bool
	PassThrough bool
	Wrap        bool
	Password    bool
}

type Textarea

type Textarea struct {

	// WrapWidthPercent scales the available content width; zero uses the full width.
	WrapWidthPercent float32

	// BarSize is the scrollbar width; zero uses the default and a negative value hides the bar while keeping scrolling.
	BarSize float32
	// WheelStep is the distance per wheel unit; zero uses the UI default.
	WheelStep float32
	Padding   float32
	ScrollX   float32
	ScrollY   float32

	// CaptureTab lets a code editor handle Tab without moving focus.
	CaptureTab bool
	// FollowTail reveals the end when the value or viewport changes, even without focus.
	FollowTail bool

	DisableHorizontalScroll bool
	Wrap                    bool

	// SelectTokens selects a code word, operator or quoted contents on a mouse double-click.
	SelectTokens bool
	// WrapTokens preserves words and identifiers, allowing long tokens to overflow.
	WrapTokens bool
	// contains filtered or unexported fields
}

Textarea stores multiline text behavior, content padding, and the current content offset. Scroll offsets use positive coordinates from the content's top-left corner.

func (*Textarea) ResetScroll

func (textarea *Textarea) ResetScroll()

ResetScroll returns the viewport to its origin and releases scrollbar dragging.

func (*Textarea) RestoreScroll

func (textarea *Textarea) RestoreScroll(x, y float32)

RestoreScroll restores a saved viewport without revealing the caret on the next layout pass. Layout still clamps the offset to the current content.

type Theme

type Theme struct {
	Font       *onixtext.Font
	FontSize   float64
	DPI        float64
	StackIndex int

	Background      graphics.ColorRGBA
	Surface         graphics.ColorRGBA
	SurfaceHover    graphics.ColorRGBA
	SurfaceActive   graphics.ColorRGBA
	SurfaceDisabled graphics.ColorRGBA
	Primary         graphics.ColorRGBA
	PrimaryHover    graphics.ColorRGBA
	PrimaryActive   graphics.ColorRGBA
	Text            graphics.ColorRGBA
	Muted           graphics.ColorRGBA
	Accent          graphics.ColorRGBA
	Danger          graphics.ColorRGBA
	Selection       graphics.ColorRGBA
}

func DefaultTheme

func DefaultTheme() Theme

func ThemeForWorld

func ThemeForWorld(world *ecs.World, theme Theme) Theme

ThemeForWorld resolves a theme against the world's configured theme.

func ThemeWithDefaults

func ThemeWithDefaults(theme Theme) Theme

ThemeWithDefaults fills omitted values with the standard UI theme.

type ThumbPart

type ThumbPart struct{}

type TitlePart

type TitlePart struct{}

type Toggle

type Toggle[T comparable] struct {
	Value   T
	Off     T
	On      T
	Changed bool
}

type ToggleStyle

type ToggleStyle[T any] struct {
	Off StateStyle[T]
	On  StateStyle[T]
}

ToggleStyle contains input styles for off/on or unselected/selected states.

func (ToggleStyle[T]) Resolve

func (style ToggleStyle[T]) Resolve(on bool, state ControlState) T

type TrackPart

type TrackPart struct{}

type Tree

type Tree[T comparable] struct {
	Selected     T
	HasSelection bool
	Width        float32
	RowHeight    float32
}

type TreeEvent

type TreeEvent[T comparable] struct {
	ID    T
	Label string
	Tree  ecs.Entity
	Node  ecs.Entity
}

type TreeIndicatorImagePart

type TreeIndicatorImagePart struct{}

type TreeIndicatorTextPart

type TreeIndicatorTextPart struct{}

type TreeNode

type TreeNode[T comparable] struct {
	ID        T
	Parent    T
	Label     string
	Tree      ecs.Entity
	Order     int
	Depth     int
	HasParent bool
	Expanded  bool
	Leaf      bool
	Disabled  bool
	Selected  bool
}

type TreeNodeSpec

type TreeNodeSpec[T comparable] struct {
	ID        T
	Parent    T
	Label     string
	HasParent bool
	Expanded  bool
	Leaf      bool
}

type TreeOptions

type TreeOptions[T comparable] struct {
	Style       *TreeStyle
	Nodes       []TreeNodeSpec[T]
	Theme       Theme
	X, Y        float32
	Width       float32
	RowHeight   float32
	Radius      CornerRadius
	PassThrough bool
}

type TreeStyle

type TreeStyle struct {
	Row        ToggleStyle[SurfaceStyle]
	Collapsed  IconStyle
	Expanded   IconStyle
	Leaf       IconStyle
	Background SurfaceStyle
}

type TreeTextPart

type TreeTextPart struct{}

type Typography

type Typography struct {
	FontSize float64
	DPI      float64
	Color    graphics.ColorRGBA
}

type ValuePart

type ValuePart struct{}

type Variant

type Variant[T comparable] struct {
	State   T
	Entity  ecs.Entity
	Enabled bool
}

Variant associates an entity with one strongly typed owner state.

type Variants

type Variants[T comparable] struct {
	Items []Variant[T]
}

Variants stores the authored entities controlled by one state domain.

type VirtualJoystick

type VirtualJoystick struct {
	Value    mgl32.Vec2
	RawValue mgl32.Vec2
	DeadZone float32
	Axis     VirtualJoystickAxis
	Active   bool
	Floating bool
	Track    ecs.Entity
	Knob     ecs.Entity
	// contains filtered or unexported fields
}

VirtualJoystick stores the normalized output of a virtual joystick. RawValue retains the clamped physical deflection, while Value applies Axis and DeadZone. Track and Knob are optional visual part entities. Floating joysticks show those parts at the initial press position until release.

type VirtualJoystickActiveEvent

type VirtualJoystickActiveEvent struct {
	Entity ecs.Entity
	Active bool
}

VirtualJoystickActiveEvent is emitted when a joystick is engaged or reset.

type VirtualJoystickAxis

type VirtualJoystickAxis uint8

VirtualJoystickAxis limits a virtual joystick to one or both axes.

const (
	VirtualJoystickBoth VirtualJoystickAxis = iota
	VirtualJoystickHorizontal
	VirtualJoystickVertical
)

type VirtualJoystickKnobPart

type VirtualJoystickKnobPart struct{}

type VirtualJoystickOptions

type VirtualJoystickOptions struct {
	Style       *VirtualJoystickStyle
	Theme       Theme
	X, Y        float32
	Size        float32
	KnobSize    float32
	DeadZone    float32
	Axis        VirtualJoystickAxis
	Floating    bool
	Disabled    bool
	PassThrough bool
}

VirtualJoystickOptions configures a generated virtual joystick. Size is the diameter of its touch area and visual track. A non-positive size uses 120.

type VirtualJoystickStyle

type VirtualJoystickStyle struct {
	Track StateStyle[SurfaceStyle]
	Knob  StateStyle[SurfaceStyle]
}

VirtualJoystickStyle controls the track and thumb of a virtual joystick. Both parts resolve against the root control's pointer state.

type VirtualJoystickTrackPart

type VirtualJoystickTrackPart struct{}

type Widget

type Widget struct {
	TargetID    string          `json:"target,omitempty"`
	Target      ecs.Entity      `json:"-"`
	Left        scene.Val       `json:"left,omitzero"`
	Right       scene.Val       `json:"right,omitzero"`
	Top         scene.Val       `json:"top,omitzero"`
	Bottom      scene.Val       `json:"bottom,omitzero"`
	AlignLeft   bool            `json:"alignLeft,omitempty"`
	AlignRight  bool            `json:"alignRight,omitempty"`
	AlignTop    bool            `json:"alignTop,omitempty"`
	AlignBottom bool            `json:"alignBottom,omitempty"`
	AlignMode   WidgetAlignMode `json:"alignMode,omitempty"`
	Enabled     bool            `json:"enabled,omitempty"`
}

Widget pins a UI node to its parent's constraint box. A zero Target uses the entity's Parent; an explicit Target supports pinning to another UI node. TargetID is the stable scene-facing form of Target. Margins use Val, so Px, Percent and viewport units can be mixed.

func NewWidget

func NewWidget() Widget

func (*Widget) UnmarshalJSON

func (w *Widget) UnmarshalJSON(data []byte) error

type WidgetAlignMode

type WidgetAlignMode uint8

WidgetAlignMode determines how often a Widget recomputes its constraints.

const (
	WidgetAlignAlways WidgetAlignMode = iota
	WidgetAlignOnce
	WidgetAlignOnWindowResize
)

type Widgets

type Widgets struct{}

Widgets enables the reusable control input and visual systems, except Markdown rendering and focused text-input dispatch.

type WindowTitleBar

type WindowTitleBar struct {
	Buttons    []ecs.Entity
	Width      float32
	Height     float32
	StackIndex int
}

WindowTitleBar describes a reusable custom window title bar and its controls.

type WindowTitleBarAction

type WindowTitleBarAction uint8

WindowTitleBarAction identifies a standard custom-window control.

const (
	WindowTitleBarMinimize WindowTitleBarAction = iota
	WindowTitleBarMaximize
	WindowTitleBarClose
	WindowTitleBarFullscreen
)

type WindowTitleBarButton

type WindowTitleBarButton struct {
	Bar    ecs.Entity
	Action WindowTitleBarAction
}

WindowTitleBarButton binds a standard window action to a button entity.

type WindowTitleBarEvent

type WindowTitleBarEvent struct {
	Bar    ecs.Entity
	Button ecs.Entity
	Action WindowTitleBarAction
}

WindowTitleBarEvent is emitted when a title-bar button is activated.

type WindowTitleBarItem

type WindowTitleBarItem struct {
	Style  *ButtonStyle
	Icon   IconStyle
	Width  float32
	Action WindowTitleBarAction
}

WindowTitleBarItem configures one standard title-bar control.

type WindowTitleBarOptions

type WindowTitleBarOptions struct {
	Items       []WindowTitleBarItem
	Theme       Theme
	StackIndex  int
	X, Y        float32
	Width       float32
	Height      float32
	Radius      CornerRadius
	PassThrough bool
}

Directories

Path Synopsis
Package html provides retained HTML surfaces and typed components on the scene runtime.
Package html provides retained HTML surfaces and typed components on the scene runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL