docs: clarify application demo state and page factory lifecycles
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// The page, cards and actions belong to Endor. The host only owns its sidebar.
|
||||
// 默认页由真实 Endor 对象组成:宿主负责窗口和侧栏,卡片布局、绘制和按钮回调在源代码中定义。
|
||||
// developer_pages::install_start_page 在每个 VM 安装此模块;OpenTool 的 New tab 动作调用下面的 newTab。
|
||||
// developer_pages::install_start_page 在每个 VM 的私有 globals 中安装类/函数,再将工厂挂到 ui.newTab;不写用户同名全局。
|
||||
// 安装模块不主动打开页面;OpenTool 的 New tab、源码 ui.newTab() 和下方 canvas 回调才实际调用工厂。
|
||||
// 渲染器通过视觉协议调用 measure/paint,按钮事件通过 VM 分派到 StartActions 的绑定方法。
|
||||
// Note 复用 Column 的内容测量,但固定卡片宽度;paint 只提供背景,孩子仍沿正常树绘制。
|
||||
class Note: Column {
|
||||
@@ -8,7 +9,7 @@ class Note: Column {
|
||||
tint: String
|
||||
// source_layout 调用这个覆盖方法;显式借用 Column 的测量结果,只替换卡片宽度,保留内容自然高度。
|
||||
function measure(self: Note, mount: Mount, constraints: Constraints): MeasureResult {
|
||||
// 沿用 Column 内容测量得到高度,但卡片宽固定为 224;不把背景圆角绘制误当布局尺寸。
|
||||
// 沿用 Column 内容测量得到高度,并请求宽 224;结果仍按当前 Constraints 钳制,不保证窄父容器中最终宽度也是 224。
|
||||
measured = Column.measure(self, mount, constraints)
|
||||
return MeasureResult(224, measured.height)
|
||||
}
|
||||
@@ -125,7 +126,7 @@ function newTab(): Page {
|
||||
actions = StartActions(page)
|
||||
// 每个按钮只保存动作入口,点击前不提前创建示例 Page。
|
||||
fixed = Button("窗口页面")
|
||||
// 绑定 vertical 回调后才会创建纵向滚动内容。
|
||||
// 这里只构造入口按钮;下面注册 actions.vertical 后仍要等点击才创建纵向滚动页,不在注册时执行回调。
|
||||
vertical = Button("纵向延伸")
|
||||
// 横向示例和纵向示例各有独立 Page/ScrollBlock,互不共享滚动偏移。
|
||||
horizontal = Button("横向延伸")
|
||||
|
||||
Reference in New Issue
Block a user