1.6 KiB
1.6 KiB
TargetedPopupState
命名空间: XCEngine::Editor::UI
类型: template class
源文件: editor/src/UI/PopupState.h
签名
template <typename Target>
class TargetedPopupState;
作用
在延迟打开 popup 的同时,把一个目标对象或目标句柄绑定到该 popup 状态上。
公开接口
void RequestOpen(Target target);
void ConsumeOpenRequest(const char* popupId);
bool HasPendingOpenRequest() const;
bool HasTarget() const;
Target& TargetValue();
const Target& TargetValue() const;
void Clear();
当前实现行为
RequestOpen(target)- 会把
target移入m_target - 把
m_hasTarget设为true - 再通过内部
DeferredPopupState记录一次待开请求
- 会把
ConsumeOpenRequest(...)- 直接转发给内部
DeferredPopupState
- 直接转发给内部
HasPendingOpenRequest()- 返回当前是否还存在未消费的 popup 打开请求
HasTarget()- 返回当前是否已绑定有效目标
TargetValue()- 返回当前绑定目标
Clear()- 清空内部 popup 请求
- 把目标重置为
Target{} - 把
m_hasTarget设回false
典型使用位置
HierarchyActionRouter用TargetedPopupState<GameObject*>维护实体右键菜单目标ProjectActionRouter用TargetedPopupState<AssetItemPtr>维护项目资源项上下文菜单目标
当前实现边界
- 目标对象的生命周期不由该类型管理。
- 它只保存一个值或句柄,不做失效检测。