docs: add Editor API documentation
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# HierarchyActionRouter
|
||||
|
||||
**命名空间**: `XCEngine::Editor::Actions`
|
||||
|
||||
**类型**: `header-helper`
|
||||
|
||||
**源文件**: `editor/src/Actions/HierarchyActionRouter.h`
|
||||
|
||||
**描述**: 封装 Hierarchy 面板中的选中、重命名、拖拽重挂接、排序和上下文菜单动作。
|
||||
|
||||
## 概述
|
||||
|
||||
`HierarchyActionRouter` 是当前实体层级树交互的主要承载者。它把 `HierarchyPanel.cpp` 中最容易膨胀的逻辑拆成了几类可复用动作:
|
||||
|
||||
- 选择与背景点击清空选择
|
||||
- 实体重命名请求与提交
|
||||
- 拖拽实体到其他父节点或根节点
|
||||
- 创建 / 删除 / 复制 / 粘贴 / 重复实体
|
||||
- 排序选项弹窗
|
||||
|
||||
## 当前实现
|
||||
|
||||
- 拖拽载荷类型固定为字符串 `"ENTITY_PTR"`
|
||||
- `HandleHierarchySelectionClick` 只实现了单选和 Ctrl 增选
|
||||
- `CommitEntityRename` 会先验证实体存在且名字非空,再调用 [`RenameEntity`](../../Commands/EntityCommands/EntityCommands.md)
|
||||
- 拖拽重挂接时会调用 `Commands::CanReparentEntity` 和 `ReparentEntityPreserveWorldTransform`
|
||||
- 背景右键菜单可以直接创建空物体、Camera、Light,以及命名为 `Cube` / `Sphere` / `Plane` 的空实体
|
||||
|
||||
## 设计说明
|
||||
|
||||
这类层级树交互通常非常碎,如果全写在面板类里,后续一加多选、拖放规则或菜单项就会迅速失控。
|
||||
把交互逻辑集中在 router 里有三个好处:
|
||||
|
||||
- 面板类仍然只负责树结构遍历和 UI 布局
|
||||
- 所有入口都能复用同一套实体命令
|
||||
- 可以明确把“层级树交互规则”与“SceneManager 真正修改场景”的职责隔开
|
||||
|
||||
这和 Unity Hierarchy 的设计也比较接近:Hierarchy 面板只是入口,真正的数据修改要落到场景编辑命令层。
|
||||
|
||||
## 当前限制
|
||||
|
||||
- 暂不支持多实体批量拖拽
|
||||
- 只有 `Ctrl` 增选,没有框选、Shift 范围选中等高级交互
|
||||
- `Cube` / `Sphere` / `Plane` 当前只是命名约定,不会自动附加网格或渲染组件
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Actions](../Actions.md)
|
||||
- [HierarchyPanel](../../panels/HierarchyPanel/HierarchyPanel.md)
|
||||
- [EntityCommands](../../Commands/EntityCommands/EntityCommands.md)
|
||||
- [EditorEvents](../../Core/EditorEvents/EditorEvents.md)
|
||||
Reference in New Issue
Block a user