abstract class Tessell::Kit::Component

Direct Known Subclasses

Defined in:

tessell/kit/component.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(key : UI::UiKey, enabled : Bool = true, visible : Bool = true) #

[View source]

Instance Method Detail

def a11y_active_cell : Bool | Nil #

[View source]
def a11y_children_count : Int32 | Nil #

虚拟列表等需要报告逻辑子节点总数的组件覆盖此值。


[View source]
def a11y_col : Int32 | Nil #

[View source]
def a11y_col_count : Int32 | Nil #

[View source]
def a11y_col_index_text : String | Nil #

[View source]
def a11y_enabled : Bool #

[View source]
def a11y_first_visible_index : Int32 | Nil #

可视窗口在逻辑总量中的起点(虚拟化网格用)。


[View source]
def a11y_name : String #

[View source]
def a11y_role : A11y::Role #

[View source]
def a11y_row : Int32 | Nil #

---- 二维网格语义(issue #31)---- 虚拟化大控件的 a11y 契约:坐标/选区/表头语义经结构化字段声明, 不再把坐标拼进 a11y_value 字符串。全部默认 nil/false——既有组件 零改动;表格类组件按需覆盖。


[View source]
def a11y_row_count : Int32 | Nil #

[View source]
def a11y_row_index_text : String | Nil #

行列表头的朗读文本(如 "A"/"1");nil = 非表头。


[View source]
def a11y_scroll_offset : Int32 #

[View source]
def a11y_selected : Bool | Nil #

[View source]
def a11y_value : String #

[View source]
def arrange(ctx : Context, bounds : Rect) : Nil #

[View source]
def attach(child : Component) : Component #

[View source]
def bounds : Rect #

[View source]
def bounds=(bounds : Rect) #

[View source]
def clip_bounds : Rect | Nil #

子组件可返回绝对坐标的裁切矩形;Root 会同步到 Node#clip。


[View source]
def collect_components(sink : Array(Component)) : Nil #

Root 用它遍历整棵树建立 Node ↔ Component 映射。 用显式 sink 而不是递归 block:Crystal 对 yield 转发块会内联展开。


[View source]
def dispose : Nil #

组件销毁:停掉其响应式作用域(幂等)。Root 在组件移出树时调用; 重新挂回树的组件需重建 watch(与 Node 生命周期同口径)。


[View source]
abstract def emit(b : UI::Builder, ctx : Context) : Nil #

[View source]
def enabled : Bool #

[View source]
def enabled=(enabled : Bool) #

[View source]
def focusable? : Bool #

[View source]
def focused : Bool #

[View source]
def focused=(focused : Bool) #

[View source]
def handle(event : Event, ctx : Context) : Bool #

[View source]
def hit?(point : Point) : Bool #

[View source]
def key : UI::UiKey #

[View source]
def mark_structure_dirty : Nil #

[View source]
abstract def measure(ctx : Context, constraints : Constraints) : Size #

[View source]
def on_focus_changed(focused : Bool) : Nil #

[View source]
def paint(p : Painter, ctx : Context) : Nil #

[View source]
def paint_token : UInt32 #

声明里的 paint token:状态变化时改变,UI.apply 只把该节点标 Paint。


[View source]
def parent : Component | Nil #

[View source]
def parent=(value : Component | Nil) : Nil #

[View source]
def signal_owner : Tessell::Signal::Owner #

懒创建的响应式作用域。首次 watch 时才分配(不用响应式的组件零开销)。


[View source]
def signal_owner? : Tessell::Signal::Owner | Nil #

非创建读取(For 行复用把组件 owner 收编到行 owner 时用)。


[View source]
def structure_dirty : Bool #

结构变更标记(issue #51):Container#add/remove 等结构修改后沿父链打到 树根,Root#build 消费一次并补一次 arrange——运行期增删子组件的宿主不必 再手动 root.layout。只向上标记,不扩散到兄弟子树。


[View source]
def structure_dirty=(structure_dirty : Bool) #

结构变更标记(issue #51):Container#add/remove 等结构修改后沿父链打到 树根,Root#build 消费一次并补一次 arrange——运行期增删子组件的宿主不必 再手动 root.layout。只向上标记,不扩散到兄弟子树。


[View source]
def take_structure_dirty : Bool #

取走并清空本节点的结构脏标记(Root 消费;只取根节点,子节点残留标记无害)。


[View source]
def tick(now_ms : Int64, ctx : Context) : Nil #

[View source]
def tooltip_delay_ms : Int32 #

[View source]
def tooltip_delay_ms=(tooltip_delay_ms : Int32) #

[View source]
def tooltip_text : String | Nil #

[View source]
def tooltip_text=(tooltip_text : String | Nil) #

[View source]
def visible : Bool #

[View source]
def visible=(visible : Bool) #

[View source]
def wants_tab? : Bool #

Tab 键语义(issue #16):默认 false——Tab 由 Root 走焦点环。 内部自带 Tab 导航的组件(表格、代码编辑器、树控件)覆盖为 true, Root 会先把 Tab/Shift+Tab 投递给当前焦点组件,组件返回 true 即消费。 Ctrl/Meta+Tab 恒定保留给焦点环,是键盘用户离开该组件的出口。


[View source]
def watch(&handler : -> Nil) : Tessell::Signal::Effect #

在组件作用域注册 effect(Solid 语义:创建即首跑)。handler 更新组件 状态 → 下一帧 Root#build 的 decl diff 自动产出失效(Layout/Paint), 与 #42 重入守卫安全组合(effect 内直接调 root.build 也只延迟为二段 提交)。组件销毁时 effect 自动停止。


[View source]