#include "Composition/EditorShellRuntime.h" #include "Host/TextureHost.h" #include "Host/ViewportRenderHost.h" #include "State/EditorContext.h" #include "Composition/EditorPanelIds.h" #include namespace XCEngine::UI::Editor::App { void EditorShellRuntime::Initialize( const std::filesystem::path& repoRoot, Host::TextureHost& textureHost, UIEditorTextMeasurer& textMeasurer) { m_textureHost = &textureHost; m_builtInIcons.Initialize(textureHost); m_sceneViewportController.Initialize(repoRoot, textureHost); m_hierarchyPanel.SetBuiltInIcons(&m_builtInIcons); m_projectPanel.SetBuiltInIcons(&m_builtInIcons); m_projectPanel.SetTextMeasurer(&textMeasurer); m_hierarchyPanel.Initialize(); m_projectPanel.Initialize(repoRoot); } void EditorShellRuntime::AttachViewportWindowRenderer(Host::ViewportRenderHost& 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_splitterDragCorrectionState = {}; m_traceEntries.clear(); m_sceneEditCommandRoute = {}; if (m_textureHost != nullptr) { m_sceneViewportController.Shutdown(*m_textureHost); m_builtInIcons.Shutdown(); m_textureHost = nullptr; } else { m_builtInIcons.Shutdown(); } m_viewportHostService.Shutdown(); } void EditorShellRuntime::ResetInteractionState() { m_shellFrame = {}; m_shellInteractionState = {}; m_splitterDragCorrectionState = {}; m_traceEntries.clear(); m_sceneViewportController.ResetInteractionState(); 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& EditorShellRuntime::GetTraceEntries() const { return m_traceEntries; } const std::vector& EditorShellRuntime::GetHierarchyPanelEvents() const { return m_hierarchyPanel.GetFrameEvents(); } const std::vector& EditorShellRuntime::GetProjectPanelEvents() const { return m_projectPanel.GetFrameEvents(); } const std::string& EditorShellRuntime::GetBuiltInIconError() const { return m_builtInIcons.GetLastError(); } void EditorShellRuntime::SetExternalDockHostDropPreview( const Widgets::UIEditorDockHostDropPreviewState& preview) { m_shellInteractionState.workspaceInteractionState.dockHostInteractionState .dockHostState.dropPreview = preview; } void EditorShellRuntime::ClearExternalDockHostDropPreview() { m_shellInteractionState.workspaceInteractionState.dockHostInteractionState .dockHostState.dropPreview = {}; } ProjectPanel::CursorKind EditorShellRuntime::GetHostedContentCursorKind() const { return m_projectPanel.GetCursorKind(); } Widgets::UIEditorDockHostCursorKind EditorShellRuntime::GetDockCursorKind() const { return Widgets::ResolveUIEditorDockHostCursorKind( m_shellFrame.workspaceInteractionFrame.dockHostFrame.layout); } EditorShellPointerOwner EditorShellRuntime::GetPointerOwner() const { const auto& dockHostInteractionState = m_shellInteractionState.workspaceInteractionState.dockHostInteractionState; if (dockHostInteractionState.splitterDragState.active || !dockHostInteractionState.activeTabDragNodeId.empty()) { return EditorShellPointerOwner::DockHost; } for (const auto& panelState : m_shellInteractionState.workspaceInteractionState.composeState.panelStates) { if (!panelState.viewportShellState.inputBridgeState.captured) { continue; } if (panelState.panelId == kGamePanelId) { return EditorShellPointerOwner::GameViewport; } return EditorShellPointerOwner::SceneViewport; } if (m_hierarchyPanel.HasActivePointerCapture()) { return EditorShellPointerOwner::HierarchyPanel; } if (m_projectPanel.HasActivePointerCapture()) { return EditorShellPointerOwner::ProjectPanel; } return EditorShellPointerOwner::None; } bool EditorShellRuntime::WantsHostPointerCapture() const { return IsHostedContentPointerOwner(GetPointerOwner()); } bool EditorShellRuntime::WantsHostPointerRelease() const { return !IsHostedContentPointerOwner(GetPointerOwner()); } bool EditorShellRuntime::HasHostedContentCapture() const { return IsHostedContentPointerOwner(GetPointerOwner()); } bool EditorShellRuntime::HasShellInteractiveCapture() const { return IsShellPointerOwner(GetPointerOwner()); } bool EditorShellRuntime::HasInteractiveCapture() const { return GetPointerOwner() != EditorShellPointerOwner::None; } } // namespace XCEngine::UI::Editor::App