refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
115
new_editor/app/Composition/EditorShellRuntime.cpp
Normal file
115
new_editor/app/Composition/EditorShellRuntime.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "Composition/EditorShellRuntime.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
void EditorShellRuntime::Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Host::NativeRenderer& renderer) {
|
||||
m_builtInIcons.Initialize(renderer);
|
||||
m_hierarchyPanel.SetBuiltInIcons(&m_builtInIcons);
|
||||
m_projectPanel.SetBuiltInIcons(&m_builtInIcons);
|
||||
m_projectPanel.SetTextMeasurer(&renderer);
|
||||
m_hierarchyPanel.Initialize();
|
||||
m_projectPanel.Initialize(repoRoot);
|
||||
}
|
||||
|
||||
void EditorShellRuntime::AttachViewportWindowRenderer(Host::D3D12WindowRenderer& renderer) {
|
||||
m_viewportHostService.AttachWindowRenderer(renderer);
|
||||
}
|
||||
|
||||
void EditorShellRuntime::DetachViewportWindowRenderer() {
|
||||
m_viewportHostService.DetachWindowRenderer();
|
||||
}
|
||||
|
||||
void EditorShellRuntime::SetViewportSurfacePresentationEnabled(bool enabled) {
|
||||
m_viewportHostService.SetSurfacePresentationEnabled(enabled);
|
||||
}
|
||||
|
||||
void EditorShellRuntime::Shutdown() {
|
||||
m_shellFrame = {};
|
||||
m_shellInteractionState = {};
|
||||
m_traceEntries.clear();
|
||||
m_viewportHostService.Shutdown();
|
||||
m_builtInIcons.Shutdown();
|
||||
}
|
||||
|
||||
void EditorShellRuntime::ResetInteractionState() {
|
||||
m_shellFrame = {};
|
||||
m_shellInteractionState = {};
|
||||
m_traceEntries.clear();
|
||||
m_hierarchyPanel.ResetInteractionState();
|
||||
m_projectPanel.ResetInteractionState();
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionFrame& EditorShellRuntime::GetShellFrame() const {
|
||||
return m_shellFrame;
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionState& EditorShellRuntime::GetShellInteractionState() const {
|
||||
return m_shellInteractionState;
|
||||
}
|
||||
|
||||
const std::vector<WorkspaceTraceEntry>& EditorShellRuntime::GetTraceEntries() const {
|
||||
return m_traceEntries;
|
||||
}
|
||||
|
||||
const std::vector<HierarchyPanel::Event>& EditorShellRuntime::GetHierarchyPanelEvents() const {
|
||||
return m_hierarchyPanel.GetFrameEvents();
|
||||
}
|
||||
|
||||
const std::vector<ProjectPanel::Event>& EditorShellRuntime::GetProjectPanelEvents() const {
|
||||
return m_projectPanel.GetFrameEvents();
|
||||
}
|
||||
|
||||
const std::string& EditorShellRuntime::GetBuiltInIconError() const {
|
||||
return m_builtInIcons.GetLastError();
|
||||
}
|
||||
|
||||
ProjectPanel::CursorKind EditorShellRuntime::GetHostedContentCursorKind() const {
|
||||
return m_projectPanel.GetCursorKind();
|
||||
}
|
||||
|
||||
Widgets::UIEditorDockHostCursorKind EditorShellRuntime::GetDockCursorKind() const {
|
||||
return Widgets::ResolveUIEditorDockHostCursorKind(
|
||||
m_shellFrame.workspaceInteractionFrame.dockHostFrame.layout);
|
||||
}
|
||||
|
||||
bool EditorShellRuntime::WantsHostPointerCapture() const {
|
||||
return m_hierarchyPanel.WantsHostPointerCapture() ||
|
||||
m_projectPanel.WantsHostPointerCapture();
|
||||
}
|
||||
|
||||
bool EditorShellRuntime::WantsHostPointerRelease() const {
|
||||
return (m_hierarchyPanel.WantsHostPointerRelease() ||
|
||||
m_projectPanel.WantsHostPointerRelease()) &&
|
||||
!HasHostedContentCapture();
|
||||
}
|
||||
|
||||
bool EditorShellRuntime::HasHostedContentCapture() const {
|
||||
return m_hierarchyPanel.HasActivePointerCapture() ||
|
||||
m_projectPanel.HasActivePointerCapture();
|
||||
}
|
||||
|
||||
bool EditorShellRuntime::HasShellInteractiveCapture() const {
|
||||
if (m_shellInteractionState.workspaceInteractionState.dockHostInteractionState.splitterDragState.active) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!m_shellInteractionState.workspaceInteractionState.dockHostInteractionState.activeTabDragNodeId.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto& panelState : m_shellInteractionState.workspaceInteractionState.composeState.panelStates) {
|
||||
if (panelState.viewportShellState.inputBridgeState.captured) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorShellRuntime::HasInteractiveCapture() const {
|
||||
return HasShellInteractiveCapture() || HasHostedContentCapture();
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user