Documentation
¶
Overview ¶
Package html provides retained HTML surfaces and typed components on the scene runtime. It owns DOM, CSS, layout, reconciliation, painting, animation, and form state. The parent ui package adapts these controls to native widgets.
Index ¶
- Constants
- func Animating(world *ecs.World) bool
- func CommitTextEdit(world *ecs.World, target ecs.Entity)
- func ControlByID(world *ecs.World, owner ecs.Entity, id string) (ecs.Entity, bool)
- func ControlTextColor(world *ecs.World, control ecs.Entity) (graphics.ColorRGBA, bool)
- func ControlTextStyle(world *ecs.World, control ecs.Entity) (scene.Text2D, bool)
- func ControlTextTabWidth(world *ecs.World, control ecs.Entity, text *scene.Text2D) (float32, bool)
- func ControlValue(world *ecs.World, entity ecs.Entity) string
- func ControlValueDirty(world *ecs.World, entity ecs.Entity) bool
- func Dispose(world *ecs.World)
- func HasControlForm(world *ecs.World, control ecs.Entity) bool
- func HasForm(world *ecs.World, owner ecs.Entity, formID string) bool
- func NeedsFrame(world *ecs.World) bool
- func Release(world *ecs.World, owner ecs.Entity)
- func ResetControlForm(world *ecs.World, control ecs.Entity) bool
- func ResetForm(world *ecs.World, owner ecs.Entity, formID string) bool
- func Serialize(world *ecs.World, page ecs.Entity) (string, error)
- func Set(world *ecs.World, entity ecs.Entity, value string) bool
- func SetBaseCSS(world *ecs.World, page ecs.Entity, cssText string) bool
- func SetControlActive(world *ecs.World, control ecs.Entity, active bool) bool
- func SetControlChecked(world *ecs.World, control ecs.Entity, checked bool) bool
- func SetControlFocus(world *ecs.World, control ecs.Entity, focused bool) bool
- func SetControlFocusVisible(world *ecs.World, control ecs.Entity, focused, focusVisible bool) bool
- func SetControlHover(world *ecs.World, control ecs.Entity, hovered bool) bool
- func SetControlOptionSelected(world *ecs.World, control ecs.Entity, option int, selected bool) bool
- func SetControlSelected(world *ecs.World, control ecs.Entity, selected int) bool
- func SetControlSelectionFocus(world *ecs.World, control ecs.Entity, anchor, focus int) bool
- func SetControlSelectionRange(world *ecs.World, control ecs.Entity, anchor, focus int) bool
- func SetControlValue(world *ecs.World, control ecs.Entity, value string) bool
- func SetEditableSelection(world *ecs.World, editable ecs.Entity, anchor, focus int) bool
- func SetEditableValue(world *ecs.World, editable ecs.Entity, value string) bool
- func SetFocusableFocusVisible(world *ecs.World, target ecs.Entity, focused, focusVisible bool) bool
- func SetNodeOffset(world *ecs.World, owner ecs.Entity, id string, x, y float32) bool
- func SetNodeScroll(world *ecs.World, owner ecs.Entity, id string, area ecs.Entity, ...) bool
- func SetVisualActive(world *ecs.World, visual ecs.Entity, active bool) bool
- func SetVisualHover(world *ecs.World, visual ecs.Entity, hovered bool) bool
- func Sync(world *ecs.World) error
- func SyncComponentsSystem(name string) ecs.SystemConfig
- func SyncScrollContent(world *ecs.World)
- func SyncScrollbars(world *ecs.World)
- func SyncSystem(name string) ecs.SystemConfig
- func UnmountComponent(world *ecs.World, entity ecs.Entity) bool
- func UpdateComponentProps[P, S any](world *ecs.World, entity ecs.Entity, props P) bool
- func UpdateComponentState[P, S any](world *ecs.World, entity ecs.Entity, update func(*S)) bool
- type ActionContext
- type ActionHandler
- type Behavior
- type ClickHandler
- type Component
- type ComponentContext
- type ComponentEventContext
- type ComponentVNode
- type Control
- type ControlText
- type ControlTextFont
- type ControlVisual
- type ControlVisualKind
- type Definition
- func (definition *Definition[P, S]) ComponentChild(key uint64, props P, state S) ComponentVNode
- func (parent *Definition[P, S]) DefineScopedChild[CP, CS any](template Template, behavior Behavior[CP, CS]) (*Definition[CP, CS], error)
- func (definition *Definition[P, S]) HydrateComponent(world *ecs.World, page ecs.Entity, props P, state S, key uint64) (ecs.Entity, error)
- func (definition *Definition[P, S]) HydrateComponentInto(world *ecs.World, parent ecs.Entity, slot string, props P, state S, key uint64) (ecs.Entity, error)
- func (definition *Definition[P, S]) MountComponent(world *ecs.World, page ecs.Entity, props P, state S, key uint64) (ecs.Entity, error)
- func (definition *Definition[P, S]) MountComponentInto(world *ecs.World, parent ecs.Entity, slot string, props P, state S, key uint64) (ecs.Entity, error)
- type Editable
- type EditableText
- type EditableVisual
- type Event
- type EventKind
- type FallbackReason
- type FocusOwner
- type Focusable
- type HTMLMetrics
- type HTMLSliceCapacities
- type ImageProvider
- type Images
- type Layout
- type Node
- func (n Node) Append(child Node) bool
- func (n Node) Attribute(name string) (string, bool)
- func (n Node) Bounds() (Rect, bool)
- func (n Node) Clear() bool
- func (n Node) Clone() Node
- func (n Node) FindByID(id string) (Node, bool)
- func (n Node) OnClick(handler ClickHandler) bool
- func (n Node) OnPointer(handler PointerHandler) bool
- func (n Node) Remove() bool
- func (n Node) RemoveAttribute(name string) bool
- func (n Node) ScrollContainer() (ecs.Entity, bool)
- func (n Node) Serialize() (string, error)
- func (n Node) SetAttribute(name, value string) bool
- func (n Node) SetHidden(hidden bool) bool
- func (n Node) SetSelectedIndex(selected int) bool
- func (n Node) SetText(value string) bool
- type Option
- type PointerEvent
- type PointerHandler
- type Rect
- type RenderContext
- type ScrollContent
- type ScrollStyle
- type ScrollbarPart
- type SelectOption
- type Surface
- type SyncDiagnostics
- type SyncPath
- type Template
- type VNode
- type VNodeAttribute
- type View
- func (v *View) AppendComponentChild[P, S any](slot string, key uint64, definition *Definition[P, S], props P, state S) bool
- func (v *View) Attr(ref, name, value string) bool
- func (v *View) Components(slot string, nodes []ComponentVNode) bool
- func (v *View) Event(ref string, kind EventKind) bool
- func (v *View) Keyed(ref string, nodes []VNode) bool
- func (v *View) PatchBindings()
- func (v *View) RemoveAttr(ref, name string) bool
- func (v *View) Text(ref, value string) bool
Constants ¶
const ( ScrollbarHorizontal uint8 = iota ScrollbarVertical )
const ( ScrollbarTrack uint8 = iota ScrollbarThumb ScrollbarArrowStart ScrollbarArrowEnd )
Variables ¶
This section is empty.
Functions ¶
func CommitTextEdit ¶ added in v0.1.8
CommitTextEdit applies the document effects of an already committed native edit.
func ControlByID ¶
ControlByID returns the rendered form control for the first matching DOM id in this surface. It reuses the document and render indexes. Before a node is rendered, after replacing the source, or for a non-control match it returns false. Dirty document indexes are refreshed before resolving the id.
func ControlTextColor ¶
ControlTextColor returns the computed CSS foreground of a generated control.
func ControlTextStyle ¶
ControlTextStyle returns the computed font and foreground for native control text.
func ControlTextTabWidth ¶
ControlTextTabWidth resolves CSS tab-size against the control's current font.
func ControlValue ¶ added in v0.1.8
ControlValue reads the live value of a rendered HTML form control.
func ControlValueDirty ¶ added in v0.1.8
func HasControlForm ¶
HasControlForm reports whether a generated control has a form owner. It also handles unnamed ancestor forms, which have an empty FormID.
func NeedsFrame ¶
NeedsFrame includes changes made after HTML synchronization. An app must flush them before suspending, even if it already consumed its render request.
func Release ¶
Release removes retained children before their owner is despawned. Call outside ECS queries and removal hooks, which forbid structural changes.
func ResetControlForm ¶
ResetControlForm executes the reset default action for a generated control's form owner without event dispatch.
func ResetForm ¶
ResetForm executes the named form's reset default action without event dispatch. UI callers should use ui.ResetForm for a cancelable reset event.
func Serialize ¶
Serialize returns the current retained HTML document for page.
The returned string is HTML markup, rather than the diagnostic tree emitted by uinode.Node.String. The retained DOM is serialized after all mutations that have already been applied to the page, so callers should run Sync after changing component state when the serialized output must include that change.
func Set ¶
Set updates the HTML source on an existing entity. The visual tree is rebuilt by SyncSystem on the next synchronization pass.
func SetBaseCSS ¶
SetBaseCSS replaces the page stylesheet while preserving mounted component styles. Unchanged values reuse the retained stylesheet without allocation.
func SetControlActive ¶
SetControlActive updates CSS :active for the duration of a pointer activation. The active target's element ancestors match as they do in HTML.
func SetControlChecked ¶
SetControlChecked updates the live checkedness of a checkbox or radio without changing its authored checked content attribute.
func SetControlFocus ¶
SetControlFocus updates CSS :focus styles for a generated control in place. Focus changes are routed through the UI runtime, so the retained DOM and generated control entities remain stable while their styles update.
func SetControlFocusVisible ¶
SetControlFocusVisible updates :focus and records whether the current input modality should also match :focus-visible.
func SetControlHover ¶
SetControlHover updates CSS :hover styles for a generated control in place. It intentionally avoids changing the retained DOM or render revision, so pointer movement cannot rebuild the HTML control tree.
func SetControlOptionSelected ¶
SetControlOptionSelected updates one option's live selectedness. Unlike selectedIndex, this preserves other selected options on a multiple select.
func SetControlSelected ¶
SetControlSelected updates a select option without rebuilding its HTML tree. It returns false for an invalid or disabled option.
func SetControlSelectionFocus ¶
SetControlSelectionFocus updates the multiple-select navigation focus without changing selectedness. A negative anchor clears the range anchor.
func SetControlSelectionRange ¶
SetControlSelectionRange replaces a multiple select's live selectedness with the inclusive range between anchor and focus. Disabled options retain their prior state, matching Chromium user input.
func SetControlValue ¶
SetControlValue updates an editable control's live value without changing its authored value attribute or textarea child text.
func SetEditableSelection ¶
SetEditableSelection updates Selection anchor/focus rune offsets without rebuilding.
func SetEditableValue ¶
SetEditableValue replaces an editing host's live textContent. The DOM is retained and the next HTML synchronization pass recomputes layout.
func SetFocusableFocusVisible ¶
SetFocusableFocusVisible updates :focus for a generated HTML focus target.
func SetNodeOffset ¶
SetNodeOffset moves all retained visuals generated for the element with the supplied id. The offset is applied to each visual's local transform, so updating an animation does not rebuild the HTML document or its layout. For overlapping bindings, the last registered matching offset wins; updating an existing binding preserves its registration order.
func SetNodeScroll ¶
func SetNodeScroll(world *ecs.World, owner ecs.Entity, id string, area ecs.Entity, originX, originY float32) bool
SetNodeScroll attaches the generated visuals for an HTML element to an existing UIScroll viewport. The element's children are reparented to the viewport and clipped by its ClipRect2D; the binding is reapplied whenever the HTML visual tree is rebuilt. The first registered matching scroll binding owns each top-level visual; control and CSS clip descendants inherit it.
func SetVisualActive ¶
SetVisualActive updates :active for a retained non-control HTML visual.
func SetVisualHover ¶
SetVisualHover updates :hover for a retained non-control HTML visual.
func SyncComponentsSystem ¶
func SyncComponentsSystem(name string) ecs.SystemConfig
SyncComponentsSystem renders dirty components before the HTML layout system runs. SyncSystem calls it internally, so applications normally only need to register the existing HTML system.
func SyncScrollContent ¶
SyncScrollContent applies HTML scroll and sticky offsets after scroll input, before global transforms and hit-test bounds are synchronized.
func SyncScrollbars ¶
SyncScrollbars updates only retained thumb geometry after UIScroll input changes. The caller runs it after UIScrollSystem and before transforms sync.
func SyncSystem ¶
func SyncSystem(name string) ecs.SystemConfig
SyncSystem synchronizes every HTML component into ordinary ECS UI children. Register it before SyncUIGlobalTransformSystem so generated children receive their global transforms in the same frame.
func UnmountComponent ¶
UnmountComponent removes the component roots, bindings, and ECS entity.
func UpdateComponentProps ¶
UpdateComponentProps replaces typed props and schedules a render.
Types ¶
type ActionContext ¶
ActionContext is delivered synchronously before an HTML default action. PreventDefault only affects cancelable events.
func (*ActionContext) PreventDefault ¶
func (c *ActionContext) PreventDefault()
type ActionHandler ¶
type ActionHandler struct {
Handle func(*ActionContext)
}
ActionHandler observes cancelable HTML events before their default action. Handlers may be installed on the generated target or HTML surface.
type Behavior ¶
type Behavior[P, S any] struct { Render func(RenderContext[P, S], *View) Mount func(*ComponentContext[P, S]) Update func(*ComponentContext[P, S]) Unmount func(*ComponentContext[P, S]) HandleEvent func(*ComponentEventContext[P, S]) }
Behavior describes the render and event logic of a component.
type ClickHandler ¶
type ClickHandler func(*PointerEvent)
ClickHandler observes click (tap) events for one HTML node.
type Component ¶
type Component[P, S any] struct { Definition *Definition[P, S] Props P State S Page ecs.Entity Parent ecs.Entity Key uint64 }
Component is the typed state and props of one HTML component instance. Instances must be created with MountComponent so the page runtime can attach the type-erased render record used by the HTML component system.
type ComponentContext ¶
ComponentContext is passed to component lifecycle callbacks.
type ComponentEventContext ¶
type ComponentEventContext[P, S any] struct { World *ecs.World Pointer *PointerEvent Props *P State *S Ref string Event Event Component ecs.Entity // contains filtered or unexported fields }
ComponentEventContext is passed to a typed component event handler.
func (*ComponentEventContext[P, S]) DefaultPrevented ¶
func (c *ComponentEventContext[P, S]) DefaultPrevented() bool
DefaultPrevented reports whether PreventDefault was called.
func (*ComponentEventContext[P, S]) PreventDefault ¶
func (c *ComponentEventContext[P, S]) PreventDefault()
PreventDefault cancels the component event's default action.
func (*ComponentEventContext[P, S]) StopPropagation ¶
func (c *ComponentEventContext[P, S]) StopPropagation()
StopPropagation consumes the pointer event so it does not reach an HTML ancestor callback.
func (*ComponentEventContext[P, S]) UpdateState ¶
func (c *ComponentEventContext[P, S]) UpdateState(update func(*S)) bool
UpdateState mutates state and schedules one component render for the current synchronization pass. Mutating State directly is also supported; this method is useful when the update should be explicit at the call site.
type ComponentVNode ¶
type ComponentVNode struct {
Key uint64
// contains filtered or unexported fields
}
ComponentVNode describes one typed child component in a component VDOM. Values are snapshots; mount/update operations are shared by the definition.
type Control ¶
type Control struct {
Placeholder string
ID string
FormID string
Name string
Tag string
Type string
// DefaultValue reflects the authored value attribute or textarea text.
DefaultValue string
// Options contains the authored options of a select in document order.
Options []SelectOption
// DefaultSelected is the option selected by the authored attributes.
DefaultSelected int
// Selected is the live option index of a select, or -1 when no option is selected.
Selected int
MaxLength int
Owner ecs.Entity
// SelectionFocus is the option currently navigated by keyboard or pointer.
SelectionFocus int
// SelectionAnchor is the fixed option used for an extended user selection.
SelectionAnchor int
// RenderRevision changes when authored control data or geometry is synchronized.
RenderRevision uint64
// SelectedCount is the number of live selected options.
SelectedCount int
// PaddingBox is the area inside CSS borders, in control-local coordinates.
// Native scrollbars run along its edges independently of text padding.
PaddingBox scene.TextRangeRect2D
// DefaultChecked reflects the authored checked content attribute.
DefaultChecked bool
// DirtySelected reports whether any option has dirty live selectedness.
DirtySelected bool
// Multiple reflects the select multiple content attribute.
Multiple bool
// Wrap reports whether the textarea's computed white-space permits soft wrapping.
Wrap bool
ReadOnly bool
Disabled bool
// Open reports whether a select popup is currently open.
Open bool
// contains filtered or unexported fields
}
Control identifies a form control generated by an HTML surface. The generated entity remains stable while its DOM node and control type survive.
func (Control) DirtyChecked ¶
type ControlText ¶
type ControlText struct {
Control ecs.Entity
// Content is the CSS content box in the control's local coordinates.
Content scene.TextRangeRect2D
}
ControlText links a generated text visual to its form control.
type ControlTextFont ¶
ControlTextFont selects a native control's text face independently of its surface font. Attach it to the control so HTML reconciliation uses the same face for text, line height and CSS tab-size as the native widget.
type ControlVisual ¶
type ControlVisual struct {
Control ecs.Entity
Kind ControlVisualKind
Selection bool
Index int
}
ControlVisual links a generated caret, selection, or scrollbar visual to its form control. Selection remains separate because textareas reserve several indexed selection surfaces.
type ControlVisualKind ¶
type ControlVisualKind uint8
ControlVisualKind identifies generated form-control visuals whose geometry and style are supplied by the UI runtime.
const ( ControlVisualCaret ControlVisualKind = iota ControlVisualScrollTrackHorizontal ControlVisualScrollTrackVertical ControlVisualScrollThumbHorizontal ControlVisualScrollThumbVertical )
type Definition ¶
type Definition[P, S any] struct { Behavior Behavior[P, S] Template Template CSS string // ScopedCSS isolates this definition's selectors and template elements. ScopedCSS bool // contains filtered or unexported fields }
Definition is a compiled, reusable component definition.
func Define ¶
func Define[P, S any](template Template, cssText string, behavior Behavior[P, S]) (*Definition[P, S], error)
Define parses and compiles an HTML component definition.
func DefineScoped ¶
func DefineScoped[P, S any](template Template, cssText string, behavior Behavior[P, S]) (*Definition[P, S], error)
DefineScoped creates a component whose template elements and stylesheet are isolated by a stable, definition-level scope class.
func (*Definition[P, S]) ComponentChild ¶
func (definition *Definition[P, S]) ComponentChild(key uint64, props P, state S) ComponentVNode
ComponentChild creates a keyed child component VNode for a slot.
func (*Definition[P, S]) DefineScopedChild ¶
func (parent *Definition[P, S]) DefineScopedChild[CP, CS any](template Template, behavior Behavior[CP, CS]) (*Definition[CP, CS], error)
DefineScopedChild compiles content in its parent's CSS scope. The parent retains the stylesheet, so replacing child templates does not republish CSS.
func (*Definition[P, S]) HydrateComponent ¶
func (definition *Definition[P, S]) HydrateComponent(world *ecs.World, page ecs.Entity, props P, state S, key uint64) (ecs.Entity, error)
HydrateComponent adopts one matching component root sequence already retained by the page DOM. The sequence must be unique among the page's direct children; dynamic values are reconciled on the first Sync pass.
func (*Definition[P, S]) HydrateComponentInto ¶
func (definition *Definition[P, S]) HydrateComponentInto(world *ecs.World, parent ecs.Entity, slot string, props P, state S, key uint64) (ecs.Entity, error)
HydrateComponentInto adopts one matching child root sequence already present in a component slot. It preserves the existing DOM node identity.
func (*Definition[P, S]) MountComponent ¶
func (definition *Definition[P, S]) MountComponent(world *ecs.World, page ecs.Entity, props P, state S, key uint64) (ecs.Entity, error)
MountComponent appends a component's template roots to a page HTML document and creates the typed ECS component instance.
func (*Definition[P, S]) MountComponentInto ¶
func (definition *Definition[P, S]) MountComponentInto(world *ecs.World, parent ecs.Entity, slot string, props P, state S, key uint64) (ecs.Entity, error)
MountComponentInto mounts a child component into a data-ref element of an existing component. The child remains an independent ECS entity while its roots participate in the parent's DOM subtree.
type EditableText ¶
EditableText links the flattened live text visual of an editing host.
type EditableVisual ¶
EditableVisual links caret and selection visuals to an editing host.
type Event ¶
type Event struct {
Snapshot piecetree.Snapshot
Value string
// InputType identifies the beforeinput/input editing operation.
InputType string
Data string
ID string
FormID string
Name string
Kind EventKind
// SelectedCount allows allocation-free multiple-select event inspection.
SelectedCount int
Entity ecs.Entity
Selected int
Target ecs.Entity
Anchor int
Focus int
Checked bool
Document bool
Bubbles bool
Cancelable bool
DefaultPrevented bool
}
Event is emitted for generated interactive HTML elements. Entity is the HTML surface, while Target is the generated input entity when present.
func PublishEvent ¶ added in v0.1.8
DispatchAction synchronously dispatches an event to its generated target and then its HTML surface. It performs no allocation after ECS warmup. PublishEvent dispatches cancelable actions before publishing the result.
type EventKind ¶
type EventKind string
EventKind identifies a browser-style event emitted by an HTML control.
type FallbackReason ¶
type FallbackReason string
FallbackReason identifies why retained paint could not be updated locally.
const ( FallbackNone FallbackReason = "" FallbackInitial FallbackReason = "initial-document" FallbackDocument FallbackReason = "document-replaced" FallbackEnvironment FallbackReason = "render-environment" FallbackImages FallbackReason = "image-provider" FallbackLayout FallbackReason = "layout-requested" FallbackVisual FallbackReason = "visual-requested" FallbackRetained FallbackReason = "retained-paint-invalid" FallbackVisibility FallbackReason = "visibility-changed" FallbackContract FallbackReason = "control-or-event-contract" FallbackStructure FallbackReason = "structure-ownership" FallbackBox FallbackReason = "box-ownership" FallbackContext FallbackReason = "context-ownership" FallbackStack FallbackReason = "stacking-ownership" )
type FocusOwner ¶
FocusOwner links a rendered descendant to the HTML element that should receive pointer focus without changing the descendant's event target.
type Focusable ¶
type Focusable struct {
ID string
Tag string
Type string
Owner ecs.Entity
TabIndex int
Order uint32
Sequential bool
Pointer bool
AutoFocus bool
FocusVisible bool
}
Focusable describes an HTML element's focus behavior independently from whether the element is a form control.
type HTMLMetrics ¶ added in v0.1.8
type HTMLMetrics struct {
DOMNodes int
Boxes int
Fragments int
ECSChildren int
RenderItems int
PaintBoxes int
TexturePixels uint64
Slices HTMLSliceCapacities
}
HTMLMetrics is a retained-memory and extraction snapshot for one HTML surface. RenderItems is the number of 2D items in the latest extraction whose source entity belongs to this surface. TexturePixels counts unique surface-owned textures at physical resolution. Shared images and font atlases are accounted for by their providers.
func Metrics ¶ added in v0.1.8
func Metrics(world *ecs.World, owner ecs.Entity) HTMLMetrics
Metrics returns the current retained HTML metrics for owner. It performs no allocations and returns zero values when owner has no HTML render state. It scans the current document, layout, and last extracted scene on demand.
type HTMLSliceCapacities ¶ added in v0.1.8
type HTMLSliceCapacities struct {
DOMChildren int
BoxChildren int
TextFragments int
TextGlyphs int
ImageFragments int
ControlFragments int
LayoutChanged int
LayoutRemoved int
LayoutReordered int
PaintChildren int
PaintQueue int
PaintCullRoots int
PaintCullGroups int
PaintCullNodes int
RenderEntities int
EntityBindings int
TextureUnused int
InlineBackgrounds int
BoxEntities int
BoxGroups int
ScrollPaintRows int
PaintShapeFragments int
PaintListBoxes int
PaintListFree int
PaintListGlyphs int
FocusTargets int
StyleChanges int
MutationRoots int
LayoutNodes int
LayoutOrderNodes int
RemovedBoxes int
}
HTMLSliceCapacities reports the retained slice capacities owned by one HTML surface. The values describe backing storage, so they remain useful after a partial update has reduced the current lengths.
type ImageProvider ¶
type ImageProvider interface {
ResolveHTMLImage(source string, width, height float32) (*graphics.Texture, bool)
}
ImageProvider resolves an img src into an engine texture. Applications can install one as a resource when HTML pages reference project assets. Width and height are the laid-out CSS size before surface transforms and DPI.
type Images ¶
type Images struct{ Provider ImageProvider }
Images binds an immutable image provider to one surface. Its owner resolves relative URLs without exposing a global asset namespace.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a mutable node owned by an HTML surface. Mutations are rendered by the next HTML synchronization pass.
func (Node) Attribute ¶
Attribute returns an element's current authored attribute without serializing it.
func (Node) Bounds ¶
Bounds returns the last synchronized layout border box. Hidden or detached nodes have no box. Native window hit testing can use this without duplicating CSS layout. Surface transforms and runtime scroll/animation offsets are not included.
func (Node) OnClick ¶
func (n Node) OnClick(handler ClickHandler) bool
OnClick binds a native click callback to this HTML node. It runs for tap events after the pointer callback, when one is installed. Passing nil removes the click callback.
func (Node) OnPointer ¶
func (n Node) OnPointer(handler PointerHandler) bool
OnPointer binds a native pointer callback to this HTML node. The callback receives enter/leave/press/move/release/wheel/cancel and tap events. Passing nil removes the pointer callback.
func (Node) RemoveAttribute ¶
RemoveAttribute removes an element attribute.
func (Node) ScrollContainer ¶
ScrollContainer returns the node's synchronized overflow scroll entity, including when its content is outside the visible paint area.
func (Node) Serialize ¶
Serialize serializes this retained node and all of its descendants as HTML markup. Root is the usual entry point when the whole page is needed.
func (Node) SetAttribute ¶
SetAttribute sets an element attribute.
func (Node) SetSelectedIndex ¶
SetSelectedIndex writes the live selection, preserving authored defaults. It also works before the first render or while option text is being updated.
type Option ¶
type Option = SelectOption
Option is kept as a concise name for callers that inspect select options.
type PointerEvent ¶
type PointerEvent struct {
Target Node
// OriginalTarget is the logical node that received the scene input.
OriginalTarget Node
Kind scene.InputEventKind
X float32
Y float32
DeltaX float32
DeltaY float32
WheelX float32
WheelY float32
Handled bool
}
PointerEvent is delivered to a callback bound directly to an HTML node. Kind contains the pointer lifecycle event; a click callback receives the same event with Kind set to InputEventTap.
func (*PointerEvent) Consume ¶
func (e *PointerEvent) Consume()
Consume prevents the input event from bubbling to an ancestor.
type PointerHandler ¶
type PointerHandler func(*PointerEvent)
PointerHandler observes pointer lifecycle events for one HTML node.
type Rect ¶
type Rect struct{ X, Y, Width, Height float32 }
Rect is an element's CSS border box in its HTML surface's coordinates.
type RenderContext ¶
RenderContext is passed by value to Render. Props and State point to the component instance; copying the context does not copy its props or state.
type ScrollContent ¶
type ScrollContent struct {
Area ecs.Entity
X float32
Y float32
// contains filtered or unexported fields
}
ScrollContent links a generated HTML subtree to a UIScroll viewport. X and Y preserve the subtree's unscrolled local origin while the UI runtime applies the current UIScroll offset after input handling. Sticky content can use Area == 0 when only its sticky offset is needed.
type ScrollStyle ¶
type ScrollStyle struct {
BarSize float32
DisableHorizontalScroll bool
Hidden bool
HasTrackColor bool
HasThumbColor bool
HasThumbHoverColor bool
TrackColor graphics.ColorRGBA
ThumbColor graphics.ColorRGBA
ThumbHoverColor graphics.ColorRGBA
}
ScrollStyle contains the scrollbar values computed for an HTML node. Has*Color distinguishes authored colors (including transparent) from auto. BarSize matches CSS overflow scrollbars. Hidden records scrollbar-width:none, which suppresses painting while scrolling remains available.
func ControlScrollStyle ¶
ControlScrollStyle returns the scrollbar style computed for a generated form control. Unlike NodeScrollStyle, it also supports controls without an id attribute.
func NodeScrollStyle ¶
NodeScrollStyle returns scrollbar styling computed for an element. It supports the standard scrollbar-width and scrollbar-color declarations plus the track/thumb overrides used by native UI widgets.
type ScrollbarPart ¶
ScrollbarPart is one retained visual of a CSS overflow scrollbar. Axis is 0 for horizontal and 1 for vertical; Kind is track or thumb. The part is kept separate from UIScroll so input and painting can evolve independently while the entity identity remains stable across HTML syncs.
type SelectOption ¶
type SelectOption struct {
Value string
Label string
Disabled bool
DefaultSelected bool
// contains filtered or unexported fields
}
SelectOption is one authored option of an HTML select control.
func (SelectOption) Selected ¶
func (o SelectOption) Selected() bool
Selected reads the option's live selectedness from its logical node.
type Surface ¶
type Surface struct {
Font *onixtext.Font
// BoldFont is used for text whose computed font weight is 600 or heavier.
BoldFont *onixtext.Font
// Document transfers an independently owned scene node tree to the surface. Replacing
// the pointer replaces the document; mutate retained nodes through Root.
Document *uinode.Node
Images *Images
CSS string
Value string
FontSize float64
DPI float64
StackIndex int
Height float32
Width float32
// ReserveScrollbarSpace selects classic scrollbars, reducing the content viewport.
ReserveScrollbarSpace bool
PassThrough bool
// Source documents borrow strings by default. Enable CompactDOM for long-lived
// pages when discarded markup accounts for much of the source. Loading then
// copies the live strings and clears Value. Use Set to replace the source.
CompactDOM bool
}
Surface is a retained HTML surface. Value may contain regular HTML and inline <style> elements. CSS contains an optional stylesheet applied to the value. Width and Height use UI pixels; zero resolves to the current viewport size.
type SyncDiagnostics ¶
type SyncDiagnostics struct {
Path SyncPath
Fallback FallbackReason
}
SyncDiagnostics describes the last sync, including a stable full-update reason. Reading diagnostics does not invalidate the surface or allocate.
func Diagnostics ¶
func Diagnostics(world *ecs.World, owner ecs.Entity) SyncDiagnostics
type Template ¶
type Template struct {
Source string
// contains filtered or unexported fields
}
Template is the immutable source of a component view. Its compiled DOM is reused by every component instance; mounting clones it before applying changes.
func NewDocumentTemplate ¶ added in v0.1.4
NewDocumentTemplate takes ownership of a parsed document without serializing or parsing it again. The caller may retain read-only node references but must not mutate the document after this call. Embedded styles are extracted just as they are for source templates.
func NewTemplate ¶
NewTemplate creates a component template from an HTML fragment.
type VNode ¶
type VNode struct {
Tag string
Text string
Attributes []VNodeAttribute
Children []VNode
Key uint64
}
VNode describes one keyed element child. Children may contain nested keyed elements and are reconciled in place with the same DOM identity rules.
func VNodeElement ¶
func VNodeElement(key uint64, tag string, attributes []VNodeAttribute, children []VNode) VNode
VNodeElement creates a keyed element with nested VNode children.
type VNodeAttribute ¶
VNodeAttribute is one attribute on a keyed VNode child.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View writes dynamic values into the component's next VDOM buffer. References come from data-ref attributes in the compiled template.
func (*View) AppendComponentChild ¶
func (v *View) AppendComponentChild[P, S any](slot string, key uint64, definition *Definition[P, S], props P, state S) bool
AppendComponentChild appends a typed child directly to a View slot for this render. The slot owns its parameter buffers and reuses them on later renders. Call order determines child order; omitting a child on a render unmounts it.
func (*View) Components ¶
func (v *View) Components(slot string, nodes []ComponentVNode) bool
Components declares keyed child component instances rendered into a slot. Omitting a slot on a later render unmounts its previous children.
func (*View) Event ¶
Event enables a browser-style event binding identified by data-ref. Pointer clicks are delivered during input dispatch; native control events are delivered from the retained HTML event stream before the next render pass.
func (*View) Keyed ¶
Keyed reconciles element children under a data-ref container. Existing DOM nodes are matched by Key and moved in place, preserving their DOM identity.
func (*View) PatchBindings ¶
func (v *View) PatchBindings()
PatchBindings updates only the Text, Attr, RemoveAttr and Keyed bindings written by this render. Omitted bindings retain their ownership. Events and component lists require an ordinary render.
func (*View) RemoveAttr ¶
RemoveAttr removes an element attribute from a dynamic binding.
Source Files
¶
- ancestor_cache.go
- animation.go
- animation_composition.go
- animation_paint.go
- component.go
- doc.go
- document.go
- filter_raster.go
- gpu_blur.go
- icons.go
- idle.go
- incremental.go
- inline_background.go
- metrics.go
- node.go
- owner_spans.go
- paint_cull.go
- paint_list.go
- paint_raster.go
- partial.go
- raster_scratch.go
- reconcile.go
- scroll_sync.go
- serialize.go
- shadow_blur.go
- state.go
- sticky.go
- structure.go
- surface.go
- text_raster.go
- texture_cache.go
- visibility.go