Expand description
简化版 Element 树 — 阶段 3
设计文档 § 3.3 扩展(阶段 3-A):
- 同 type 同 key 的 Element 节点原地复用,只更新 widget 引用 + 重建 RO
- 不同 type 或不同 key 的 Element 替换(旧 element 暂存到 Inactive 池,新挂载)
subscriber_id跨 update 保留,Signal 订阅关系自然延续- children 列表按 index 对齐(3-C 引入 ListView 后支持 key 配对)
设计文档 § 3.3 扩展(阶段 3-B):
Inactive 池:卸载的 Element 按(type_id, key)暂存,后续 mount 优先复用
阶段 3 重构:State 上提到 Element 层
- Element 持有
Option<Box<dyn State>>字段 - StatefulWidget mount 时,Element 调
widget.create_state()+set_widget+init_state - 同 type widget 复用时,Element 调
set_widget(new)+did_update_widget - Element 卸载时调
dispose() - 渲染、子节点、事件都优先走 state,fallback 到 widget
Re-exports§
Modules§
Structs§
- Element
- Element — 树上的一个节点
- Element
Tree - Element 树
- Frame
Paint - 一帧的渲染输出:多个 layer 的 paint list,按 z_order 升序(后画的在上)
- Layer
- Layer — 一个独立的“重绘单元“
- Layer
Paint - 单个 layer 的 paint 输出
- Layer
Tree - Layer 树
- Overlay
Handle - 阶段 3-13:Overlay 句柄(由
show_overlay返回,hide_overlay关闭)
Functions§
- locate_
element_ in_ ro_ tree - 阶段 2-E:在 RO 树里 DFS 找到持有
id的 RO, 返回 (累计全局原点, 该 RO 的 content_size) —— 二者取自同一个克隆 RO, 避免“本体未被 layout 导致 content_size=ZERO“的问题。 - locate_
element_ via_ tree_ pair - bugfix(layer offset 同步):element 树与 RO 树平行下降定位 element 的布局位置。
- paint_
frame - 渲染整帧(阶段 4-A dirty 感知版):
- request_
full_ repaint - 请求下一帧全量重绘(运行时资源不连续变化时调用)
Type Aliases§
- Text
Measurer - 文字测量回调:(文本, 字号, 最大宽度) → (宽度, 高度)