module
Tessell::UI
Defined in:
tessell/ui/apply.crtessell/ui/builder.cr
tessell/ui/key.cr
Class Method Summary
-
.a11y_emit(root : Node, a11y : A11y::Builder, sink : Array(A11y::Node), vlist : Widgets::VirtualList, container : Node, name_for : Proc(Int32, String) | Nil = nil, item_role : A11y::Role = A11y::Role::ListItem) : Int32
Virtual-list aware overload.
-
.a11y_emit(root : Node, a11y : A11y::Builder, sink : Array(A11y::Node)) : Int32
Emit the accessible tree (preorder DFS) into a caller-provided sink.
-
.apply(decls : Array(Decl), root : Node, pool : Pool, a11y : A11y::Builder | Nil = nil, during_apply : Proc(Nil) | Nil = nil) : Nil
Apply flat DFS-preorder declarations to an existing root Node.
-
.apply_auto_layout(decls : Array(Decl), pool : Pool, viewport : Rect, measurer : Text::Measurer | Nil = nil) : Int32
---- Auto layout(issue #5)---- 把 auto=true 的声明子树交给核心两遍内核求解,并把结果写回 Node.bounds——布局与命中树同源(Router/HitTest 直接读同一棵树)。
-
.build(root : UiKey, b : Builder, & : Builder -> ) : Nil
Build declarations into caller-provided reusable buffers.
-
.consume(nodes : Array(Node)) : Nil
Consume (clear) dirty flags on nodes whose dirty set has been handled (layout/paint/composite processed).
Class Method Detail
Virtual-list aware overload. When DFS reaches container, that node is
emitted with VirtualList semantics: children_count = logical row count,
scroll_offset = scroll_y, and only the visible window is emitted as item
children (Role::ListItem). The full 10k rows are never materialized.
Emit the accessible tree (preorder DFS) into a caller-provided sink. The sink is cleared and reused; no intermediate array is allocated and steady state (pre-sized sink, unchanged meta) performs no allocations. Must be called after UI.apply so that a11y meta is in sync.
Apply flat DFS-preorder declarations to an existing root Node.
- Reuse nodes by UiKey (stable id); removed subtrees stay pooled for reuse.
- Dirty only on changes: layout-affecting -> Layout, paint-only -> Paint.
- apply never clears dirty flags. Dirty flags must be consumed (cleared) by the caller after the dirty set is processed, via UI.consume.
- No-change steady state is zero-alloc when buffers are pre-sized.
- When
a11yis given, accessible meta is synced for new/changed nodes and removed for deleted nodes (keyed by node.object_id, the same id a11y uses).
---- Auto layout(issue #5)---- 把 auto=true 的声明子树交给核心两遍内核求解,并把结果写回 Node.bounds——布局与命中树同源(Router/HitTest 直接读同一棵树)。
调用顺序:先 UI.apply(建立 Node/映射),再 .apply_auto_layout。
measurer 注入后 auto_text 叶子按文本测量;不注入则按 0 尺寸。
显式 bounds 的声明混入 auto 子树时按 Fixed 尺寸参与排布。
返回值:bounds 被改写的节点数(稳态为 0)。
Build declarations into caller-provided reusable buffers. Usage: UI.build(root_key, builder) { |b| b.text(k, "hi") }
Consume (clear) dirty flags on nodes whose dirty set has been handled (layout/paint/composite processed). MUST be called after the dirty set is processed; calling before consumption causes missed drawing/updates. Only the provided nodes are cleaned; other dirty nodes remain dirty.