Documentation
¶
Overview ¶
Package ui binds a persistent Go node graph to GPUI protobuf snapshots. Reactive calculations run in Go; painting and native input stay in Rust.
Index ¶
- type Document
- func (d *Document) Attach(root *Node, sink func(*scene.Node) error) (func(), error)
- func (d *Document) BindCanvas(owner *reactive.Scope, read func() []*scene.DrawCommand) *Node
- func (d *Document) BindImage(owner *reactive.Scope, read func() *clientlib.Resource) *Node
- func (d *Document) BindText(owner *reactive.Scope, read func() string) *Node
- func (d *Document) Canvas(owner *reactive.Scope, commands ...*scene.DrawCommand) *Node
- func (d *Document) ColorScheme() scene.ColorScheme
- func (d *Document) Dispose()
- func (d *Document) Div(owner *reactive.Scope, children ...*Node) *Node
- func (d *Document) Element(name string) (uint64, bool)
- func (d *Document) Err() error
- func (d *Document) Fragment(owner *reactive.Scope, children ...*Node) *Node
- func (d *Document) Image(owner *reactive.Scope, resource *clientlib.Resource) *Node
- func (d *Document) Input(owner *reactive.Scope, value *reactive.Signal[string], options InputOptions) *Node
- func (d *Document) OpenWindow(ctx context.Context, options clientlib.WindowOptions, root *Node) (*Mount, error)
- func (d *Document) Scope() *reactive.Scope
- func (d *Document) Show(owner *reactive.Scope, condition func() bool, ...) *Node
- func (d *Document) Snapshot(root *Node) (*scene.Node, error)
- func (d *Document) Text(owner *reactive.Scope, value string) *Node
- func (d *Document) UniformList(owner *reactive.Scope, rowHeight float32, rows ...*Node) *Node
- func (d *Document) UseTheme(compiler *tw.Compiler)
- func (d *Document) WindowSize() clientlib.WindowSize
- type Handler
- type InputOptions
- type Mount
- type Node
- func (n *Node) Accessible(label string, metadata *scene.Accessibility) *Node
- func (n *Node) Append(children ...*Node) error
- func (n *Node) BindAccessibility(label string, read func() *scene.Accessibility) *Node
- func (n *Node) BindStyle(read func() *scene.Style) *Node
- func (n *Node) BindTWClass(read func() string) *Node
- func (n *Node) Dispose()
- func (n *Node) Focusable(index int32) *Node
- func (n *Node) Hover(style *scene.Style) *Node
- func (n *Node) ID() uint64
- func (n *Node) Name(name string) *Node
- func (n *Node) OnClick(handler Handler) *Node
- func (n *Node) Scope() *reactive.Scope
- func (n *Node) SetChildren(children ...*Node) error
- func (n *Node) Style(style *scene.Style) *Node
- func (n *Node) TWClass(classes string) *Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func (*Document) Attach ¶
Attach installs a generic snapshot sink. Bindings update selectively, while the current wire contract still sends one complete snapshot per settled batch.
func (*Document) BindCanvas ¶ added in v0.0.2
BindCanvas repaints with the commands the accessor returns when its dependencies change. The commands are copied; unchanged commands publish nothing.
func (*Document) BindImage ¶ added in v0.0.2
BindImage displays the resource the accessor returns, switching when its dependencies change. A nil resource fails the computation.
func (*Document) Canvas ¶ added in v0.0.2
Canvas paints drawing commands in local coordinates. Give it a size: it fills its box and has no children.
func (*Document) ColorScheme ¶ added in v0.0.2
func (d *Document) ColorScheme() scene.ColorScheme
ColorScheme returns whether the mounted window is drawn light or dark. It is tracked separately from WindowSize, so a binding that reads only the color scheme does not rerun on resizes. It is scene.ColorSchemeUnspecified before OpenWindow and on backends without the window-color-scheme capability.
func (*Document) Image ¶ added in v0.0.2
Image displays an uploaded image or SVG resource. The resource must stay uploaded while any mounted snapshot references it.
func (*Document) Input ¶
func (d *Document) Input(owner *reactive.Scope, value *reactive.Signal[string], options InputOptions) *Node
Input mirrors a signal through the bridge's epoch/edit-revision protocol. Native edits echo their acknowledgement; authoritative signal replacements advance the epoch. The persistent node/entity is never replaced per keystroke.
func (*Document) OpenWindow ¶
func (*Document) Show ¶
func (d *Document) Show(owner *reactive.Scope, condition func() bool, yes, no func(*reactive.Scope) *Node) *Node
Show constructs a branch only when the condition changes and disposes the previous branch's owned effects/handlers. The range itself is transparent.
func (*Document) UniformList ¶ added in v0.0.2
UniformList virtualizes its children as rows of one height, in logical pixels from 1 to 16384. Children are managed like a Div's, so For and Show ranges can supply rows; each serialized child is one row. Every row is still sent in every snapshot. Scroll with Mount.Window().ScrollTo and the list's ID.
func (*Document) UseTheme ¶ added in v0.0.2
UseTheme sets the compiler that Node.TWClass and BindTWClass use; the default is Tailwind's default theme. Set it before building nodes: classes already applied are not recompiled.
func (*Document) WindowSize ¶ added in v0.0.2
func (d *Document) WindowSize() clientlib.WindowSize
WindowSize returns the mounted window's drawable area. It is tracked like a signal read, so bindings and Show conditions follow resizes. It is zero before OpenWindow and on backends without the window-size capability.
type InputOptions ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node keeps its ID across updates. Fragments are transparent ranges and do not add native layout containers. Nodes have one parent and one document.
func For ¶
func For[T any, K comparable](d *Document, owner *reactive.Scope, items func() []T, key func(T) K, render func(*reactive.Scope, *reactive.Signal[T], *reactive.Signal[int]) *Node) *Node
For preserves rows by application key, including native input entities on reorder and immutable item replacement. Duplicate keys reject before mutation.
func (*Node) Accessible ¶
func (n *Node) Accessible(label string, metadata *scene.Accessibility) *Node
func (*Node) BindAccessibility ¶
func (n *Node) BindAccessibility(label string, read func() *scene.Accessibility) *Node
func (*Node) BindTWClass ¶ added in v0.0.2
BindTWClass recompiles the class list when the accessor's dependencies change. A class that cannot be compiled fails the computation.
func (*Node) Hover ¶ added in v0.0.2
Hover sets a partial style refinement GPUI applies while the pointer is over the element, without a Go event or another snapshot.