diff --git a/new_editor/CMakeLists.txt b/new_editor/CMakeLists.txt index c9662396..9c284a82 100644 --- a/new_editor/CMakeLists.txt +++ b/new_editor/CMakeLists.txt @@ -277,6 +277,7 @@ if(XCENGINE_BUILD_XCUI_EDITOR_APP) app/Platform/Win32/EditorWindowBorderlessResize.cpp app/Platform/Win32/EditorWindowFrame.cpp app/Platform/Win32/EditorWindowFrameSupport.cpp + app/Platform/Win32/EditorWindowFrameRuntime.cpp app/Platform/Win32/EditorWindowTitleBar.cpp app/Platform/Win32/EditorWindowTitleBarDragRestore.cpp app/Platform/Win32/EditorWindowTitleBarInteraction.cpp diff --git a/new_editor/app/Platform/Win32/EditorWindow.h b/new_editor/app/Platform/Win32/EditorWindow.h index 3d2c7fb6..caad3d31 100644 --- a/new_editor/app/Platform/Win32/EditorWindow.h +++ b/new_editor/app/Platform/Win32/EditorWindow.h @@ -7,6 +7,8 @@ #include "State/EditorContext.h" #include "Platform/Win32/EditorWindowState.h" +#include + #include #include @@ -143,6 +145,22 @@ private: ::XCEngine::UI::UIRect ResolveWorkspaceBounds( float clientWidthDips, float clientHeightDips) const; + void RenderRuntimeFrame( + EditorContext& editorContext, + bool globalTabDragActive, + const ::XCEngine::UI::UIRect& workspaceBounds, + ::XCEngine::UI::UIDrawList& drawList); + void RenderInvalidFrame( + EditorContext& editorContext, + ::XCEngine::UI::UIDrawList& drawList) const; + void LogFrameInteractionTrace( + EditorContext& editorContext, + const std::vector<::XCEngine::UI::UIInputEvent>& frameEvents, + const UIEditorShellInteractionFrame& shellFrame) const; + void QueueShellTransferRequests( + bool globalTabDragActive, + const UIEditorDockHostInteractionState& dockHostInteractionState, + const UIEditorShellInteractionFrame& shellFrame); bool IsPointerInsideClientArea() const; LPCWSTR ResolveCurrentCursorResource() const; float GetDpiScale() const; diff --git a/new_editor/app/Platform/Win32/EditorWindowFrame.cpp b/new_editor/app/Platform/Win32/EditorWindowFrame.cpp index 1606d6f3..45d9b709 100644 --- a/new_editor/app/Platform/Win32/EditorWindowFrame.cpp +++ b/new_editor/app/Platform/Win32/EditorWindowFrame.cpp @@ -7,7 +7,6 @@ #include #include -#include namespace XCEngine::UI::Editor::App { @@ -42,95 +41,9 @@ void EditorWindow::RenderFrame( kShellSurfaceColor); if (editorContext.IsValid()) { - std::vector frameEvents = std::move(m_input.pendingEvents); - m_input.pendingEvents.clear(); - if (!frameEvents.empty() && IsVerboseRuntimeTraceEnabled()) { - LogRuntimeTrace( - "input", - DescribeInputEvents(frameEvents) + " | " + - editorContext.DescribeWorkspaceState( - m_composition.workspaceController, - m_composition.shellRuntime.GetShellInteractionState())); - } - - const Host::D3D12WindowRenderLoopFrameContext frameContext = - m_render.windowRenderLoop.BeginFrame(); - if (!frameContext.warning.empty()) { - LogRuntimeTrace("viewport", frameContext.warning); - } - - editorContext.AttachTextMeasurer(m_render.renderer); - m_composition.shellRuntime.Update( - editorContext, - m_composition.workspaceController, - workspaceBounds, - frameEvents, - BuildCaptureStatusText(), - m_window.primary - ? EditorShellVariant::Primary - : EditorShellVariant::DetachedWindow); - const UIEditorShellInteractionFrame& shellFrame = - m_composition.shellRuntime.GetShellFrame(); - const UIEditorDockHostInteractionState& dockHostInteractionState = - m_composition.shellRuntime - .GetShellInteractionState() - .workspaceInteractionState - .dockHostInteractionState; - if (IsVerboseRuntimeTraceEnabled() && - (!frameEvents.empty() || - shellFrame.result.workspaceResult.dockHostResult.layoutChanged || - shellFrame.result.workspaceResult.dockHostResult.commandExecuted)) { - std::ostringstream frameTrace = {}; - frameTrace << "result consumed=" - << (shellFrame.result.consumed ? "true" : "false") - << " layoutChanged=" - << (shellFrame.result.workspaceResult.dockHostResult.layoutChanged ? "true" : "false") - << " commandExecuted=" - << (shellFrame.result.workspaceResult.dockHostResult.commandExecuted ? "true" : "false") - << " active=" - << m_composition.workspaceController.GetWorkspace().activePanelId - << " message=" - << shellFrame.result.workspaceResult.dockHostResult.layoutResult.message; - LogRuntimeTrace("frame", frameTrace.str()); - } - - if (!globalTabDragActive && - !dockHostInteractionState.activeTabDragNodeId.empty() && - !dockHostInteractionState.activeTabDragPanelId.empty()) { - QueuePendingTabDragStart( - dockHostInteractionState.activeTabDragNodeId, - dockHostInteractionState.activeTabDragPanelId); - } - - if (shellFrame.result.workspaceResult.dockHostResult.detachRequested) { - QueuePendingDetachRequest( - shellFrame.result.workspaceResult.dockHostResult.detachedNodeId, - shellFrame.result.workspaceResult.dockHostResult.detachedPanelId); - } - - ApplyHostCaptureRequests(shellFrame.result); - for (const WorkspaceTraceEntry& entry : m_composition.shellRuntime.GetTraceEntries()) { - LogRuntimeTrace(entry.channel, entry.message); - } - ApplyHostedContentCaptureRequests(); - ApplyCurrentCursor(); - m_composition.shellRuntime.Append(drawList); - if (frameContext.canRenderViewports) { - m_composition.shellRuntime.RenderRequestedViewports(frameContext.renderContext); - } + RenderRuntimeFrame(editorContext, globalTabDragActive, workspaceBounds, drawList); } else { - drawList.AddText( - UIPoint(28.0f, 28.0f), - "Editor shell asset invalid.", - kShellTextColor, - 16.0f); - drawList.AddText( - UIPoint(28.0f, 54.0f), - editorContext.GetValidationMessage().empty() - ? std::string("Unknown validation error.") - : editorContext.GetValidationMessage(), - kShellMutedTextColor, - 12.0f); + RenderInvalidFrame(editorContext, drawList); } AppendBorderlessWindowChrome(drawList, width); diff --git a/new_editor/app/Platform/Win32/EditorWindowFrameRuntime.cpp b/new_editor/app/Platform/Win32/EditorWindowFrameRuntime.cpp new file mode 100644 index 00000000..08f4a473 --- /dev/null +++ b/new_editor/app/Platform/Win32/EditorWindowFrameRuntime.cpp @@ -0,0 +1,134 @@ +#include "Platform/Win32/EditorWindow.h" +#include "Platform/Win32/EditorWindowConstants.h" +#include "Platform/Win32/EditorWindowInputSupport.h" +#include "Platform/Win32/EditorWindowRuntimeSupport.h" +#include "Platform/Win32/EditorWindowStyle.h" + +#include +#include + +namespace XCEngine::UI::Editor::App { + +using namespace EditorWindowSupport; +using ::XCEngine::UI::UIDrawList; +using ::XCEngine::UI::UIInputEvent; +using ::XCEngine::UI::UIPoint; +using ::XCEngine::UI::UIRect; + +void EditorWindow::RenderRuntimeFrame( + EditorContext& editorContext, + bool globalTabDragActive, + const UIRect& workspaceBounds, + UIDrawList& drawList) { + std::vector frameEvents = std::move(m_input.pendingEvents); + m_input.pendingEvents.clear(); + if (!frameEvents.empty() && IsVerboseRuntimeTraceEnabled()) { + LogRuntimeTrace( + "input", + DescribeInputEvents(frameEvents) + " | " + + editorContext.DescribeWorkspaceState( + m_composition.workspaceController, + m_composition.shellRuntime.GetShellInteractionState())); + } + + const Host::D3D12WindowRenderLoopFrameContext frameContext = + m_render.windowRenderLoop.BeginFrame(); + if (!frameContext.warning.empty()) { + LogRuntimeTrace("viewport", frameContext.warning); + } + + editorContext.AttachTextMeasurer(m_render.renderer); + m_composition.shellRuntime.Update( + editorContext, + m_composition.workspaceController, + workspaceBounds, + frameEvents, + BuildCaptureStatusText(), + m_window.primary + ? EditorShellVariant::Primary + : EditorShellVariant::DetachedWindow); + const UIEditorShellInteractionFrame& shellFrame = + m_composition.shellRuntime.GetShellFrame(); + const UIEditorDockHostInteractionState& dockHostInteractionState = + m_composition.shellRuntime + .GetShellInteractionState() + .workspaceInteractionState + .dockHostInteractionState; + + LogFrameInteractionTrace(editorContext, frameEvents, shellFrame); + QueueShellTransferRequests(globalTabDragActive, dockHostInteractionState, shellFrame); + + ApplyHostCaptureRequests(shellFrame.result); + for (const WorkspaceTraceEntry& entry : m_composition.shellRuntime.GetTraceEntries()) { + LogRuntimeTrace(entry.channel, entry.message); + } + ApplyHostedContentCaptureRequests(); + ApplyCurrentCursor(); + m_composition.shellRuntime.Append(drawList); + if (frameContext.canRenderViewports) { + m_composition.shellRuntime.RenderRequestedViewports(frameContext.renderContext); + } +} + +void EditorWindow::RenderInvalidFrame( + EditorContext& editorContext, + UIDrawList& drawList) const { + drawList.AddText( + UIPoint(28.0f, 28.0f), + "Editor shell asset invalid.", + EditorWindowSupport::kShellTextColor, + 16.0f); + drawList.AddText( + UIPoint(28.0f, 54.0f), + editorContext.GetValidationMessage().empty() + ? std::string("Unknown validation error.") + : editorContext.GetValidationMessage(), + EditorWindowSupport::kShellMutedTextColor, + 12.0f); +} + +void EditorWindow::LogFrameInteractionTrace( + EditorContext& editorContext, + const std::vector& frameEvents, + const UIEditorShellInteractionFrame& shellFrame) const { + if (!IsVerboseRuntimeTraceEnabled() || + (frameEvents.empty() && + !shellFrame.result.workspaceResult.dockHostResult.layoutChanged && + !shellFrame.result.workspaceResult.dockHostResult.commandExecuted)) { + return; + } + + std::ostringstream frameTrace = {}; + frameTrace << "result consumed=" + << (shellFrame.result.consumed ? "true" : "false") + << " layoutChanged=" + << (shellFrame.result.workspaceResult.dockHostResult.layoutChanged ? "true" : "false") + << " commandExecuted=" + << (shellFrame.result.workspaceResult.dockHostResult.commandExecuted ? "true" : "false") + << " active=" + << m_composition.workspaceController.GetWorkspace().activePanelId + << " message=" + << shellFrame.result.workspaceResult.dockHostResult.layoutResult.message; + LogRuntimeTrace("frame", frameTrace.str()); +} + +void EditorWindow::QueueShellTransferRequests( + bool globalTabDragActive, + const UIEditorDockHostInteractionState& dockHostInteractionState, + const UIEditorShellInteractionFrame& shellFrame) { + if (!globalTabDragActive && + !dockHostInteractionState.activeTabDragNodeId.empty() && + !dockHostInteractionState.activeTabDragPanelId.empty()) { + QueuePendingTabDragStart( + dockHostInteractionState.activeTabDragNodeId, + dockHostInteractionState.activeTabDragPanelId); + } + + if (shellFrame.result.workspaceResult.dockHostResult.detachRequested) { + QueuePendingDetachRequest( + shellFrame.result.workspaceResult.dockHostResult.detachedNodeId, + shellFrame.result.workspaceResult.dockHostResult.detachedPanelId); + } +} + +} // namespace XCEngine::UI::Editor::App