关键节点
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#include "Platform/Win32/Content/EditorUtilityWindowContentController.h"
|
||||
|
||||
#include "UtilityWindows/EditorUtilityWindowPanel.h"
|
||||
#include "UtilityWindows/EditorUtilityWindowRegistry.h"
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
using ::XCEngine::UI::UIInputEvent;
|
||||
using ::XCEngine::UI::UIInputEventType;
|
||||
|
||||
EditorUtilityWindowContentController::EditorUtilityWindowContentController(
|
||||
std::unique_ptr<EditorUtilityWindowPanel> panel,
|
||||
const ::XCEngine::UI::UISize& minimumOuterSize)
|
||||
: m_panel(std::move(panel)),
|
||||
m_minimumOuterSize(minimumOuterSize) {}
|
||||
|
||||
EditorUtilityWindowContentController::~EditorUtilityWindowContentController() = default;
|
||||
|
||||
void EditorUtilityWindowContentController::Shutdown() {
|
||||
if (m_panel != nullptr) {
|
||||
m_panel->ResetInteractionState();
|
||||
}
|
||||
m_shellInteractionState = {};
|
||||
m_shellFrame = {};
|
||||
m_windowFocused = false;
|
||||
}
|
||||
|
||||
void EditorUtilityWindowContentController::ResetInteractionState() {
|
||||
if (m_panel != nullptr) {
|
||||
m_panel->ResetInteractionState();
|
||||
}
|
||||
}
|
||||
|
||||
EditorWindowFrameTransferRequests
|
||||
EditorUtilityWindowContentController::UpdateAndAppend(
|
||||
const EditorWindowContentFrameContext& context,
|
||||
::XCEngine::UI::UIDrawData& drawData) {
|
||||
bool focusGained = false;
|
||||
bool focusLost = false;
|
||||
for (const UIInputEvent& event : context.inputEvents) {
|
||||
if (event.type == UIInputEventType::FocusGained) {
|
||||
m_windowFocused = true;
|
||||
focusGained = true;
|
||||
} else if (event.type == UIInputEventType::FocusLost) {
|
||||
m_windowFocused = false;
|
||||
focusLost = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_shellInteractionState.focused = m_windowFocused;
|
||||
m_shellFrame.focused = m_windowFocused;
|
||||
|
||||
if (m_panel == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
m_panel->Update(
|
||||
context.editorContext,
|
||||
EditorUtilityWindowHostContext{
|
||||
.mounted = true,
|
||||
.bounds = context.bounds,
|
||||
.allowInteraction = true,
|
||||
.focused = m_windowFocused,
|
||||
.focusGained = focusGained,
|
||||
.focusLost = focusLost,
|
||||
},
|
||||
context.inputEvents);
|
||||
|
||||
::XCEngine::UI::UIDrawList& drawList =
|
||||
drawData.EmplaceDrawList(std::string(m_panel->GetDrawListId()));
|
||||
m_panel->Append(drawList);
|
||||
return {};
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionFrame& EditorUtilityWindowContentController::GetShellFrame() const {
|
||||
return m_shellFrame;
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionState&
|
||||
EditorUtilityWindowContentController::GetShellInteractionState() const {
|
||||
return m_shellInteractionState;
|
||||
}
|
||||
|
||||
::XCEngine::UI::UISize EditorUtilityWindowContentController::ResolveMinimumOuterSize() const {
|
||||
return m_minimumOuterSize;
|
||||
}
|
||||
|
||||
std::unique_ptr<EditorWindowContentController> CreateEditorUtilityWindowContentController(
|
||||
const EditorUtilityWindowDescriptor& descriptor) {
|
||||
std::unique_ptr<EditorUtilityWindowPanel> panel =
|
||||
CreateEditorUtilityWindowPanel(descriptor.kind);
|
||||
if (panel == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_unique<EditorUtilityWindowContentController>(
|
||||
std::move(panel),
|
||||
descriptor.minimumOuterSize);
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user