#include "Content/EditorWorkspaceWindowContentController.h" #include #include #include #include #include namespace XCEngine::UI::Editor::App { namespace { EditorWindowContentCursorKind ToContentCursorKind( EditorWorkspaceShellCursorKind cursorKind) { switch (cursorKind) { case EditorWorkspaceShellCursorKind::ResizeEW: return EditorWindowContentCursorKind::ResizeEW; case EditorWorkspaceShellCursorKind::Arrow: default: return EditorWindowContentCursorKind::Arrow; } } EditorWindowContentCursorKind ToContentCursorKind( Widgets::UIEditorDockHostCursorKind cursorKind) { switch (cursorKind) { case Widgets::UIEditorDockHostCursorKind::ResizeEW: return EditorWindowContentCursorKind::ResizeEW; case Widgets::UIEditorDockHostCursorKind::ResizeNS: return EditorWindowContentCursorKind::ResizeNS; case Widgets::UIEditorDockHostCursorKind::Arrow: default: return EditorWindowContentCursorKind::Arrow; } } } // namespace EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, std::unique_ptr shellRuntime) : m_windowId(windowState.windowId) , m_windowSystem(windowSystem) , m_projection(BuildEditorWorkspaceWindowProjection( std::wstring_view{}, windowSystem.GetPanelRegistry(), windowState, false)) , m_shellRuntime(std::move(shellRuntime)) {} EditorWorkspaceWindowContentController::~EditorWorkspaceWindowContentController() = default; EditorWindowContentCapabilities EditorWorkspaceWindowContentController::GetCapabilities() const { return EditorWindowContentCapabilities{ .workspace = true, .dockHost = true, .inputFeedback = true, .titleBar = true, .viewportRendering = true, .utilityPanel = false, }; } EditorWindowWorkspaceBinding* EditorWorkspaceWindowContentController::TryGetWorkspaceBinding() { return this; } const EditorWindowWorkspaceBinding* EditorWorkspaceWindowContentController::TryGetWorkspaceBinding() const { return this; } EditorWindowDockHostBinding* EditorWorkspaceWindowContentController::TryGetDockHostBinding() { return this; } const EditorWindowDockHostBinding* EditorWorkspaceWindowContentController::TryGetDockHostBinding() const { return this; } const EditorWindowInputFeedbackBinding* EditorWorkspaceWindowContentController::TryGetInputFeedbackBinding() const { return this; } const EditorWindowTitleBarBinding* EditorWorkspaceWindowContentController::TryGetTitleBarBinding() const { return this; } const EditorWorkspaceWindowProjection* EditorWorkspaceWindowContentController::TryGetWorkspaceProjection() const { return &m_projection; } void EditorWorkspaceWindowContentController::RefreshWorkspaceProjection( EditorWorkspaceWindowProjection projection) { m_projection = std::move(projection); } bool EditorWorkspaceWindowContentController::TryBuildAuthoritativeWorkspaceController( UIEditorWorkspaceController& outController) { return m_windowSystem.TryBuildLiveWindowWorkspaceController( m_windowId, outController); } void EditorWorkspaceWindowContentController::Initialize( const EditorWindowContentInitializationContext& context) { if (m_shellRuntime == nullptr) { return; } m_shellRuntime->Initialize( context.repoRoot, context.textureHost, context.resourceService, context.textMeasurer); m_shellRuntime->AttachViewportWindowRenderer(context.viewportRenderer); } void EditorWorkspaceWindowContentController::Shutdown() { if (m_shellRuntime != nullptr) { m_shellRuntime->Shutdown(); } } void EditorWorkspaceWindowContentController::ResetInteractionState() { if (m_shellRuntime != nullptr) { m_shellRuntime->ResetInteractionState(); } } void EditorWorkspaceWindowContentController::SetViewportSurfacePresentationEnabled(bool enabled) { if (m_shellRuntime != nullptr) { m_shellRuntime->SetViewportSurfacePresentationEnabled(enabled); } } EditorWindowFrameTransferRequests EditorWorkspaceWindowContentController::UpdateAndAppend( const EditorWindowContentFrameContext& context, ::XCEngine::UI::UIDrawData& drawData) { UIEditorWorkspaceController workspaceController = {}; if (!TryBuildAuthoritativeWorkspaceController(workspaceController)) { AppendUIEditorRuntimeTrace( "window", "workspace frame skipped: authoritative state missing for window '" + m_windowId + "'"); return {}; } if (m_shellRuntime == nullptr) { return {}; } return m_frameOrchestrator.UpdateAndAppend( context.frameServices, workspaceController, *m_shellRuntime, context.bounds, context.inputEvents, context.cursorScreenPoint, context.captureStatusText, context.primary, context.globalTabDragActive, context.useDetachedTitleBarTabStrip, drawData); } void EditorWorkspaceWindowContentController::RenderRequestedViewports( const ::XCEngine::Rendering::RenderContext& renderContext) { if (m_shellRuntime != nullptr) { m_shellRuntime->RenderRequestedViewports(renderContext); } } const UIEditorShellInteractionFrame& EditorWorkspaceWindowContentController::GetShellFrame() const { return m_shellRuntime->GetShellFrame(); } const UIEditorShellInteractionState& EditorWorkspaceWindowContentController::GetShellInteractionState() const { return m_shellRuntime->GetShellInteractionState(); } void EditorWorkspaceWindowContentController::SetExternalDockHostDropPreview( const Widgets::UIEditorDockHostDropPreviewState& preview) { if (m_shellRuntime != nullptr) { m_shellRuntime->SetExternalDockHostDropPreview(preview); } } void EditorWorkspaceWindowContentController::ClearExternalDockHostDropPreview() { if (m_shellRuntime != nullptr) { m_shellRuntime->ClearExternalDockHostDropPreview(); } } bool EditorWorkspaceWindowContentController::TryResolveDockTabDragHotspot( std::string_view nodeId, std::string_view panelId, const ::XCEngine::UI::UIPoint& point, ::XCEngine::UI::UIPoint& outHotspot) const { return m_shellRuntime != nullptr && m_shellRuntime->TryResolveDockTabDragHotspot( nodeId, panelId, point, outHotspot); } UIEditorDockHostTabDropTarget EditorWorkspaceWindowContentController::ResolveDockTabDropTarget( const ::XCEngine::UI::UIPoint& point) const { return m_shellRuntime != nullptr ? m_shellRuntime->ResolveDockTabDropTarget(point) : UIEditorDockHostTabDropTarget{}; } bool EditorWorkspaceWindowContentController::HasHostedContentCapture() const { return m_shellRuntime != nullptr && m_shellRuntime->HasHostedContentCapture(); } bool EditorWorkspaceWindowContentController::HasShellInteractiveCapture() const { return m_shellRuntime != nullptr && m_shellRuntime->HasShellInteractiveCapture(); } bool EditorWorkspaceWindowContentController::HasInteractiveCapture() const { return m_shellRuntime != nullptr && m_shellRuntime->HasInteractiveCapture(); } EditorWindowContentCursorKind EditorWorkspaceWindowContentController::GetHostedContentCursorKind() const { return m_shellRuntime != nullptr ? ToContentCursorKind(m_shellRuntime->GetHostedContentCursorKind()) : EditorWindowContentCursorKind::Arrow; } EditorWindowContentCursorKind EditorWorkspaceWindowContentController::GetDockCursorKind() const { return m_shellRuntime != nullptr ? ToContentCursorKind(m_shellRuntime->GetDockCursorKind()) : EditorWindowContentCursorKind::Arrow; } ::XCEngine::UI::UISize EditorWorkspaceWindowContentController::ResolveMinimumOuterSize() const { return m_projection.minimumOuterSize; } bool EditorWorkspaceWindowContentController::ShouldUseDetachedTitleBarTabStrip() const { return m_projection.useDetachedTitleBarTabStrip; } std::string EditorWorkspaceWindowContentController::ResolveTabStripTitleText( std::string_view fallbackTitle) const { return m_projection.tabStripTitleText.empty() ? std::string(fallbackTitle) : m_projection.tabStripTitleText; } std::string EditorWorkspaceWindowContentController::ResolveDetachedWindowTitleText( std::string_view fallbackWindowTitle) const { return m_projection.detachedWindowTitleText.empty() ? std::string(fallbackWindowTitle) : m_projection.detachedWindowTitleText; } std::unique_ptr CreateEditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, std::unique_ptr shellRuntime) { return std::make_unique( windowState, windowSystem, std::move(shellRuntime)); } } // namespace XCEngine::UI::Editor::App