Documentation
¶
Overview ¶
Package luimygo renders LUI patch batches with MyGo native UI. Backend methods belong to the UI goroutine. Runtime serializes C ABI calls on a dedicated OS thread and delivers copied batches back to that goroutine.
Code generated by tooling/generate_mygo_schema.py; DO NOT EDIT.
Index ¶
- func ComputeThemeVariables(parent, declarations map[string]string) map[string]string
- func ResolveThemeValue(value string, variables map[string]string) (string, bool)
- func SupportedKinds() []string
- type Backend
- func (b *Backend) ApplyBatch(batch Batch) error
- func (b *Backend) ApplyJSON(data []byte, snapshot bool) error
- func (b *Backend) ApplySnapshot(batch Batch) error
- func (b *Backend) BindHostElement(id int64, element ui.Element) error
- func (b *Backend) Bounds(c *ui.Context, id int64) (ui.Rect, bool)
- func (b *Backend) Close()
- func (b *Backend) CommittedBounds(c *ui.Context, id int64) (ui.Rect, bool)
- func (b *Backend) CommittedScrollOffset(c *ui.Context, id int64) (x, y float32, known bool)
- func (b *Backend) Err() error
- func (b *Backend) Generation() int64
- func (b *Backend) InputNode(target ui.InputTarget) (InputNode, bool)
- func (b *Backend) InputTextSnapshot(c *ui.Context, id int64) (text string, anchor, caret int, ok bool)
- func (b *Backend) NaturalImageSize(id int64) (width, height float32, ready bool)
- func (b *Backend) Node(id int64) (Node, bool)
- func (b *Backend) OpenMenuOwners(c *ui.Context) []InputNode
- func (b *Backend) PresentMediaSurfaceFrame(id int64, pixels image.Image) error
- func (b *Backend) RegisterIcon(name string, svg []byte) error
- func (b *Backend) RegisterImage(id int64, pixels image.Image) error
- func (b *Backend) RequestFocus(id int64) error
- func (b *Backend) ResolveColor(c *ui.Context, s string) (ui.Color, error)
- func (b *Backend) Roots() []int64
- func (b *Backend) ScrollOffset(id int64) (x, y float32, err error)
- func (b *Backend) ScrollTo(id int64, x, y float32) error
- func (b *Backend) SetThemeDefaults(tokens map[string]string) error
- func (b *Backend) TextGeometry(c *ui.Context, id int64) (ui.CommittedText, bool)
- func (b *Backend) UnregisterIcon(name string)
- func (b *Backend) UnregisterImage(id int64)
- func (b *Backend) UnregisterMediaSurface(id int64)
- func (b *Backend) View(c *ui.Context)
- type Batch
- type Config
- type Event
- type Extension
- type FileDialogOptions
- type FileServices
- type InputNode
- type Node
- type Operation
- type Renderer
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeThemeVariables ¶
ComputeThemeVariables computes declarations before inheritance. Invalid or cyclic declarations remove an inherited value; an absent declaration keeps it. Parent values must already be computed, not raw declarations from an ancestor.
func ResolveThemeValue ¶
ResolveThemeValue substitutes variables from a computed, inherited variable map. Missing/invalid references use their fallback, including an empty one.
func SupportedKinds ¶
func SupportedKinds() []string
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) ApplyBatch ¶
func (*Backend) ApplySnapshot ¶
func (*Backend) BindHostElement ¶
BindHostElement gives an extension or custom renderer's primary control the retained node's host identity. Call during rendering, on the UI thread.
func (*Backend) Bounds ¶
Bounds reads a nonempty committed box in window DIPs, never a speculative layout. Missing, hidden, unmounted and closed nodes report false.
func (*Backend) Close ¶
func (b *Backend) Close()
Close releases node services and registered host resources. Call it on the UI goroutine after closing the OCaml session; repeated calls are harmless.
func (*Backend) CommittedBounds ¶
CommittedBounds returns the transformed window-space box of a committed node, rejecting model changes that have not reached layout yet.
func (*Backend) CommittedScrollOffset ¶
CommittedScrollOffset reads an actual committed scroll host's offset in DIPs, including ordinary overflow:auto containers. Unlike ScrollOffset it never reports unapplied commands. Non-scrollers, missing, hidden, stale or uncommitted nodes report known=false. Call after layout on the UI thread.
func (*Backend) Generation ¶
func (*Backend) InputNode ¶
func (b *Backend) InputNode(target ui.InputTarget) (InputNode, bool)
InputNode resolves the closest retained host binding on MyGo's actual focus or hit ancestry. Call only inside Context.CaptureInput, on the UI thread. Unbound internal control children resolve to their closest retained parent; missing, hidden, disabled, closed and expired targets do not resolve.
func (*Backend) InputTextSnapshot ¶
func (b *Backend) InputTextSnapshot(c *ui.Context, id int64) (text string, anchor, caret int, ok bool)
InputTextSnapshot reads the actual native TextInput/TextArea's consumed edit state, not the model text property or a frame cache. Offsets count runes and preserve anchor/caret direction. Call on the UI thread in CaptureInput before default handling, or OnChange after input. A window-stable Context is safe for this query outside a build. Missing, hidden, disabled, retired, unbound, non-input and closed controls report false, not an invented empty selection. Custom/raw renderers must BindHostElement to their actual input each build; standard text-field/input/textarea controls are already bound.
func (*Backend) NaturalImageSize ¶
NaturalImageSize reports cached decoded pixel dimensions for a retained image, file-image or avatar. Call on the UI goroutine. It does not start decoding or use layout, crop dimensions, avatar fallbacks or assets from retired nodes.
func (*Backend) OpenMenuOwners ¶
OpenMenuOwners returns detached snapshots of actual open menu/popover owners, including anchors outside a portal. Query after layout or between frames on the UI thread. Only committed presentations and live retained incarnations resolve; this does not change input, focus or presentation.
func (*Backend) PresentMediaSurfaceFrame ¶
PresentMediaSurfaceFrame copies an immutable frame into the named surface. Replacement keeps the existing toolkit texture allocation where possible.
func (*Backend) RegisterIcon ¶
RegisterIcon registers an application SVG under a canonical app:slug name. Parsing owns the document; later mutation of the supplied bytes is harmless.
func (*Backend) RegisterImage ¶
RegisterImage copies pixels into a host-owned resource. Call it on the UI goroutine; retained nodes reference the resource independently of their lives.
func (*Backend) RequestFocus ¶
RequestFocus waits for this node's next binding if it has not rendered yet. It does not acknowledge focus or change any model-controlled property.
func (*Backend) ResolveColor ¶
ResolveColor uses the same current scoped tokens as standard typed paint properties. Call from a renderer while building; do not retain Context. Unlike the internal legacy paint fallback, an unresolved value is an error.
func (*Backend) ScrollOffset ¶
ScrollOffset reads the retained offset, including an unapplied ScrollTo. The next committed layout clamps that offset to the content extent.
func (*Backend) ScrollTo ¶
ScrollTo sets an immediate offset in DIPs. Token-controlled scroll requests retain ownership until completion; use their standard protocol to replace one.
func (*Backend) SetThemeDefaults ¶
SetThemeDefaults replaces this window's host-owned tokens. It does not emit patches or modify application nodes. Nested theme props override these values only for their subtree. Call between frames on the UI goroutine; nil clears.
func (*Backend) TextGeometry ¶
TextGeometry reads the exact committed shaped text of a standard text node, including its range in a rich inline paragraph. Offsets are rune-relative to this node; coordinates are window DIPs. Query after layout or between frames on the UI thread. The returned value expires on the next MyGo build. Missing, hidden, detached, unmounted and closed nodes return false.
func (*Backend) UnregisterIcon ¶
func (*Backend) UnregisterImage ¶
func (*Backend) UnregisterMediaSurface ¶
type Batch ¶
func DecodeBatch ¶
DecodeBatch keeps integer IDs exact, including IDs beyond JavaScript's float64 integer range. Required fields must be present even when zero.
type Config ¶
type Config struct {
FileServices FileServices
// Dispatch synchronously delivers a model-owned interaction proposal.
// Apply accepted or normalized property updates before returning. If the
// controlled property is unchanged, the native proposal is rejected.
Dispatch func(Event) error
Extensions map[string]Extension
// Renderers deliberately overrides built-in standard component behavior.
Renderers map[string]Renderer
// InputValue applies host-owned text commands before a standard text editor
// is constructed. InputControl then binds its native focus and selection.
// Both run during live construction on the UI thread, never fitting probes.
// Do not retain the value pointer or Element; neither hook emits model events.
InputValue func(Node, *string)
InputControl func(Node, ui.Element, string)
}
type Event ¶
type Event struct {
Kind string `json:"kind"`
Node int64 `json:"node"`
Text string `json:"text,omitempty"`
Checked bool `json:"checked,omitempty"`
Value float64 `json:"value,omitempty"`
Modifiers int32 `json:"modifiers,omitempty"`
Identifier string `json:"identifier,omitempty"`
Name string `json:"name,omitempty"`
Values map[string]any `json:"values,omitempty"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
Button int32 `json:"button,omitempty"`
TargetClass string `json:"target-class,omitempty"`
Token int64 `json:"token,omitempty"`
Outcome string `json:"outcome,omitempty"`
Generation int64 `json:"generation,omitempty"`
Pins []int64 `json:"pins,omitempty"`
First int64 `json:"first"`
Last int64 `json:"last"`
AtStart bool `json:"at-start"`
AtEnd bool `json:"at-end"`
Key string `json:"key,omitempty"`
Shift bool `json:"shift,omitempty"`
Payload string `json:"payload,omitempty"`
// contains filtered or unexported fields
}
type FileDialogOptions ¶
FileDialogOptions describes portable desktop selection constraints.
type FileServices ¶
type FileServices interface {
OpenFiles(context.Context, FileDialogOptions) ([]string, error)
}
FileServices is the operating-system dialog boundary. The backend keeps request correlation, retained lifetimes and event delivery on its UI thread. OpenFiles may block; implementations should observe cancellation where their native dialog API permits it. Nil paths represent user cancellation.
type InputNode ¶
type InputNode struct {
Node Node
// contains filtered or unexported fields
}
InputNode is a snapshot of a retained node resolved from committed MyGo input. Current rejects removed or remounted node IDs, including reuse between a pointer press and release. Node is a copy and must not be changed.
type Node ¶
type Node struct {
ID int64
Kind, Identifier, Fingerprint string
Parent int64
Children []int64
Props map[string]any
}
Node is a detached read snapshot. Parent is zero for a root; wire IDs are positive.
type Operation ¶
type Operation struct {
Op string `json:"op"`
ID int64 `json:"id,omitempty"`
Parent int64 `json:"parent,omitempty"`
Child int64 `json:"child,omitempty"`
Index int `json:"index"`
Kind string `json:"kind,omitempty"`
Property string `json:"property,omitempty"`
Identifier string `json:"identifier,omitempty"`
Fingerprint string `json:"fingerprint"`
Value any `json:"value,omitempty"`
}
type Renderer ¶
Renderer builds a custom control, calling children within its container. emit queues an event for delivery after construction; never retain Context.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns a session in an OCaml shared library exporting lui_ocaml_*. OpenRuntime and all session methods are called on the backend's UI goroutine. A process can host one OCaml runtime library and one active session.
Source Files
¶
- backend.go
- collections.go
- colors.go
- composites.go
- contract.go
- controls.go
- events.go
- files.go
- host.go
- input.go
- layout.go
- menu_owners.go
- menus.go
- overlays.go
- pointer.go
- render.go
- resources.go
- runtime.go
- runtime_events.go
- runtime_unix.go
- schema_generated.go
- style.go
- text_geometry.go
- text_snapshot.go
- theme.go
- theme_variables.go
- wire.go