core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultButtonPadding    = render.Insets{Top: 8, Right: 16, Bottom: 8, Left: 16}
	DefaultTextInputPadding = render.Insets{Top: 8, Right: 8, Bottom: 8, Left: 8}
	DefaultTextAreaPadding  = render.Insets{Top: 8, Right: 8, Bottom: 8, Left: 8}
	DefaultBarPadding       = render.Insets{Top: 4, Right: 4, Bottom: 4, Left: 4}
)

Default auto-padding values per component type.

View Source
var ActiveScene *sg.Scene

ActiveScene holds the current scene for input injection support. Set via SetScene; used by TextInput/TextArea to read injected chars/keys.

View Source
var AutoPadding = render.Insets{Top: -1, Right: -1, Bottom: -1, Left: -1}

AutoPadding is the sentinel Insets value meaning "use the component's built-in default padding". All four fields are -1.

View Source
var FallbackScene *sg.Scene

FallbackScene keeps the last non-nil scene registered with SetScene. It lets injected-key lookups continue to work when ActiveScene is nil.

StateFallbacks defines the fallback chain for each state. Each entry is tried left-to-right; the first non-zero value is used. StateDefault has no fallbacks (it is the terminal).

Functions

func ClampDim

func ClampDim(v, min, max float64) float64

ClampDim clamps v between min and max. A zero max means no upper bound.

func ClipboardRead

func ClipboardRead() (string, error)

ClipboardRead reads the current clipboard contents.

func ClipboardWrite

func ClipboardWrite(s string)

ClipboardWrite writes s to the clipboard.

func IsKeyJustPressed

func IsKeyJustPressed(key engine.Key) bool

IsKeyJustPressed returns true if the key was just pressed via real input or was present in the injected keys queue.

func ResolveAutoInsets

func ResolveAutoInsets(i, fallback render.Insets) render.Insets

ResolveAutoInsets returns fallback if i is auto, otherwise returns i unchanged.

func SetScene

func SetScene(s *sg.Scene)

SetScene registers the active scene so UI components can read injected keyboard input from test runners. The most recently registered non-nil scene is retained as a fallback when active scene is nil.

Types

type Alignment

type Alignment int

Alignment controls child positioning. Used for both cross-axis (Align) and main-axis (Justify) in VBox/HBox layouts.

const (
	AlignStart        Alignment = iota // left for VBox, top for HBox (default)
	AlignCenter                        // center on cross-axis
	AlignEnd                           // right for VBox, bottom for HBox
	AlignSpaceBetween                  // distribute children evenly across main axis
)

type Anchor

type Anchor int

Anchor identifies a position within a parent container. Used by AnchorLayout to pin children to edges or corners.

const (
	AnchorTopLeft Anchor = iota
	AnchorTopCenter
	AnchorTopRight
	AnchorMiddleLeft
	AnchorCenter
	AnchorMiddleRight
	AnchorBottomLeft
	AnchorBottomCenter
	AnchorBottomRight
)

type Background

type Background struct {
	Type     BackgroundType
	Color    sg.Color
	Slice    *render.NineSlice
	Gradient *render.GradientColors
}

Background describes how to render a component's background.

func GradientBackground

func GradientBackground(g *render.GradientColors) Background

GradientBackground creates a gradient background.

func SliceBackground

func SliceBackground(s *render.NineSlice) Background

SliceBackground creates a nine-slice background.

func SolidBackground

func SolidBackground(c sg.Color) Background

SolidBackground creates a solid-color background.

type BackgroundType

type BackgroundType uint8

BackgroundType tags the kind of background rendering.

const (
	BgNone BackgroundType = iota
	BgSolid
	BgNineSlice
	BgGradient
)

type ComponentState

type ComponentState uint8

ComponentState represents the visual state of a component.

const (
	StateDefault ComponentState = iota
	StateHover
	StateActive
	StateDisabled
	StateFocus
	StateFocusHover
	StateFocusActive
	StateFocusDisabled
	StateCount // exported sentinel for array sizing
)

func ComputeState

func ComputeState(enabled, focused, hovered, active bool) ComponentState

ComputeState maps component boolean flags to a ComponentState.

type LayoutMode

type LayoutMode int

LayoutMode controls how a Component arranges its children.

const (
	// LayoutNone uses manual positioning; children keep their own X/Y.
	LayoutNone LayoutMode = iota
	// LayoutVBox stacks children vertically with spacing between them.
	LayoutVBox
	// LayoutHBox stacks children horizontally with spacing between them.
	LayoutHBox
	// LayoutGrid arranges children in a fixed-column grid.
	LayoutGrid
	// LayoutFlow arranges children left-to-right, wrapping to new rows when
	// the available width is exceeded.
	LayoutFlow
	// LayoutAnchor pins each child to a corner, edge, or center of the parent
	// using per-child anchor metadata. Use Component.AddAnchoredChild to add
	// children with explicit anchor positions.
	LayoutAnchor
)

type Orientation

type Orientation int

Orientation represents horizontal or vertical direction.

const (
	Horizontal Orientation = iota
	Vertical
)

Jump to

Keyboard shortcuts

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