docs: expand popup state API docs
This commit is contained in:
51
docs/api/XCEngine/Editor/UI/PopupState/DeferredPopupState.md
Normal file
51
docs/api/XCEngine/Editor/UI/PopupState/DeferredPopupState.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# DeferredPopupState
|
||||
|
||||
**命名空间**: `XCEngine::Editor::UI`
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**源文件**: `editor/src/UI/PopupState.h`
|
||||
|
||||
## 作用
|
||||
|
||||
表示“下一帧打开一个 ImGui popup”的最小延迟打开状态。
|
||||
|
||||
## 公开接口
|
||||
|
||||
```cpp
|
||||
void RequestOpen();
|
||||
void ConsumeOpenRequest(const char* popupId);
|
||||
bool HasPendingOpenRequest() const;
|
||||
void Clear();
|
||||
```
|
||||
|
||||
## 当前实现行为
|
||||
|
||||
- `RequestOpen()`
|
||||
- 只把内部 `m_openRequested` 设为 `true`
|
||||
- 当前帧不会立刻调用 `ImGui::OpenPopup(...)`
|
||||
- `ConsumeOpenRequest(popupId)`
|
||||
- 只有当存在待消费请求时才会调用 `ImGui::OpenPopup(popupId)`
|
||||
- 成功消费后会把待开标志清回 `false`
|
||||
- `HasPendingOpenRequest()`
|
||||
- 返回当前是否还保留未消费的打开请求
|
||||
- `Clear()`
|
||||
- 只清空待开标志
|
||||
|
||||
## 典型使用位置
|
||||
|
||||
- `MainMenuActionRouter` 用它驱动 `Help -> About`
|
||||
- `InspectorActionRouter` 用它驱动 `Add Component`
|
||||
- `HierarchyActionRouter` 用它驱动层级空白区域或选项 popup
|
||||
- `AboutEditorDialog` 会在真正绘制前调用 `ConsumeOpenRequest(...)`
|
||||
|
||||
## 设计含义
|
||||
|
||||
- 这类 helper 的核心价值是把“请求打开 popup”和“实际调用 `ImGui::OpenPopup()` 的帧时机”分开。
|
||||
- 这样调用方不需要自己维护散落的布尔标志。
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [PopupState](PopupState.md)
|
||||
- [TargetedPopupState](TargetedPopupState.md)
|
||||
- [AboutEditorDialog](../AboutEditorDialog/AboutEditorDialog.md)
|
||||
Reference in New Issue
Block a user