class Tessell::UI::Builder

Overview

Chain builder that emits Decl records into preallocated buffers. No Node is created and the hot build path performs no allocations when buf and stack have sufficient pre-reserved capacity.

Defined in:

tessell/ui/builder.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(buf : Array(Decl), stack : Array(UiKey)) #

[View source]

Instance Method Detail

def auto_node(key : UiKey, dir : Layout::Direction = Layout::Direction::Vertical, padding : Insets = Insets.new, gap : Float32 = 0.0_f32, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

自动尺寸叶子/容器节点(非文本):宽高 Auto,可与 vstack/hstack 嵌套。


[View source]
def auto_text(key : UiKey, str : String, size : Float32, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

自动尺寸文本叶子:宽度/高度由注入的 Measurer 测量(Auto)。


[View source]
def buf : Array(Decl) #

[View source]
def column(key : UiKey, bounds : Rect = Rect.new, paint : UInt32 = 0_u32, dir : Layout::Direction = Layout::Direction::Vertical, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

[View source]
def column(key : UiKey, bounds : Rect = Rect.new, paint : UInt32 = 0_u32, dir : Layout::Direction = Layout::Direction::Vertical, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true, & : Builder -> ) : Nil #

[View source]
def current_parent : UiKey #

[View source]
def group(key : UiKey, bounds : Rect = Rect.new, dir : Layout::Direction = Layout::Direction::Vertical, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true, & : Builder -> ) : Nil #

Generic nested group.


[View source]
def hstack(key : UiKey, padding : Insets = Insets.new, gap : Float32 = 0.0_f32, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true, & : Builder -> ) : Nil #

[View source]
def node(key : UiKey, bounds : Rect = Rect.new, dir : Layout::Direction = Layout::Direction::Vertical, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

Leaf/group node with explicit geometry and optional direction.


[View source]
def reset(root : UiKey) : Nil #

[View source]
def row(key : UiKey, bounds : Rect = Rect.new, paint : UInt32 = 0_u32, dir : Layout::Direction = Layout::Direction::Horizontal, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

Directional container helpers. Optional direction argument; when a block is given the container is nested.


[View source]
def row(key : UiKey, bounds : Rect = Rect.new, paint : UInt32 = 0_u32, dir : Layout::Direction = Layout::Direction::Horizontal, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true, & : Builder -> ) : Nil #

[View source]
def stack : Array(UiKey) #

[View source]
def text(key : UiKey, str : String, bounds : Rect = Rect.new, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true) : Nil #

Text leaf. Text change is layout-affecting.


[View source]
def vstack(key : UiKey, padding : Insets = Insets.new, gap : Float32 = 0.0_f32, paint : UInt32 = 0_u32, a11y_role : A11y::Role = A11y::Role::Group, a11y_name : String = "", a11y_value : String = "", a11y_focusable : Bool = false, a11y_enabled : Bool = true, & : Builder -> ) : Nil #

---- Auto layout 声明(issue #5)---- vstack/hstack 容器不写 bounds,由 UI.apply_auto_layout 依内核求解; 子项可用 auto_text(测量定尺寸)或显式 bounds(Fixed)参与排布。


[View source]