2026-04-25 18:20:17 +08:00
|
|
|
#include "Windowing/Content/EditorUtilityWindowContentController.h"
|
2026-04-25 16:46:01 +08:00
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
2026-04-25 17:51:37 +08:00
|
|
|
EditorWindowContentCapabilities
|
|
|
|
|
EditorUtilityWindowContentController::GetCapabilities() const {
|
|
|
|
|
return EditorWindowContentCapabilities{
|
|
|
|
|
.workspace = false,
|
|
|
|
|
.dockHost = false,
|
|
|
|
|
.inputFeedback = false,
|
|
|
|
|
.titleBar = false,
|
|
|
|
|
.viewportRendering = false,
|
|
|
|
|
.utilityPanel = true,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 16:46:01 +08:00
|
|
|
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
|