From 43a71bd09c5c68d3f0d79ecdc22778bcdca1d347 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 28 Apr 2026 00:05:10 +0800 Subject: [PATCH] Cut workspace panel factory out of windowing --- docs/plan/editor-core-refactor-plan.md | 9 +++++++++ editor/AGENTS.md | 18 +++++++++++++++--- editor/app/Bootstrap/Application.cpp | 7 +++++-- editor/app/Composition/EditorShellRuntime.cpp | 10 ++++++++-- editor/app/Composition/EditorShellRuntime.h | 2 +- .../Windowing/EditorWorkspaceShellRuntime.h | 11 ++++++++--- .../Content/EditorWindowContentFactory.cpp | 11 +---------- .../Content/EditorWindowContentFactory.h | 2 -- .../EditorWorkspaceWindowContentController.cpp | 6 +++--- editor/app/Windowing/EditorWindowManager.cpp | 2 -- editor/app/Windowing/EditorWindowManager.h | 2 -- 11 files changed, 50 insertions(+), 30 deletions(-) diff --git a/docs/plan/editor-core-refactor-plan.md b/docs/plan/editor-core-refactor-plan.md index 55e92965..952cdc72 100644 --- a/docs/plan/editor-core-refactor-plan.md +++ b/docs/plan/editor-core-refactor-plan.md @@ -272,6 +272,11 @@ Completed follow-up: owns the command-focus sync point between main panels and after-focus panels. - Concrete workspace and utility panels use `EditorPanelServices` and no longer include `Composition/EditorContext.h`. +- `app/Windowing/**` no longer accepts or calls + `EditorWorkspacePanelRuntimeSetFactory`. `Application` composes + `CreateEditorWorkspacePanelRuntimeSet()` with + `CreateEditorWorkspaceShellRuntime(...)`, then injects a zero-argument + `EditorWorkspaceShellRuntimeFactory` into windowing. ## Phase 2: Introduce XCEditorCore @@ -476,6 +481,10 @@ Completed cuts: `Core/Windowing/EditorWorkspaceShellRuntime.h`. `Application` injects the concrete `EditorShellRuntime` factory, and `EditorContext` remains the concrete `EditorFrameServices` implementation. +- The shell-runtime construction hook visible to `app/Windowing/**` is now a + zero-argument `EditorWorkspaceShellRuntimeFactory`. Workspace panel runtime + set construction stays in `Application`, so windowing no longer sees + `EditorWorkspacePanelRuntimeSetFactory`. ## Phase 6: Documentation Update diff --git a/editor/AGENTS.md b/editor/AGENTS.md index fe30da4a..6ec55f83 100644 --- a/editor/AGENTS.md +++ b/editor/AGENTS.md @@ -160,6 +160,10 @@ change. `EditorShellRuntime` is the current concrete implementation, and `Application` injects it through the content factory instead of letting `app/Windowing/**` construct or name the concrete type directly. +- The workspace shell runtime factory passed into windowing is intentionally + zero-argument. `Application` composes the concrete workspace-panel runtime + set with `EditorShellRuntime`; `app/Windowing/**` must not accept or call + `EditorWorkspacePanelRuntimeSetFactory`. - `EditorWindowRuntimeController` owns the content controller, render runtime, screenshot controller, title-bar logo texture, text measurer access, DPI scale, and frame-rate display. @@ -340,7 +344,10 @@ inside pure shell/widget code. `app/Core/Windowing/EditorWorkspaceShellRuntime.h` are the current composition-to-windowing contract boundary. `EditorContext` and `EditorShellRuntime` remain concrete composition types; `app/Windowing/**` - uses the contracts instead of those concrete headers. + uses the contracts instead of those concrete headers. The shell-runtime + factory is the only workspace-shell construction hook visible to windowing; + workspace panel runtime construction stays in the application composition + root. - Legacy fine-grained app-split CMake targets are retired architecture history. Current production editor targets are `XCUIEditor`, `XCEditorCore`, and `XCEditor`. @@ -439,6 +446,11 @@ ownership rule. implements the frame-services contract, `EditorShellRuntime` implements the shell-runtime contract, and `Application` injects the concrete shell runtime factory so `app/Windowing/**` no longer includes composition concrete types. +- `app/Windowing/**` no longer receives + `EditorWorkspacePanelRuntimeSetFactory` or constructs workspace panel runtime + sets. `Application` composes `CreateEditorWorkspacePanelRuntimeSet()` with + `CreateEditorWorkspaceShellRuntime(...)` before handing windowing a + zero-argument `EditorWorkspaceShellRuntimeFactory`. - Viewport rendering is routed through `ViewportHostService` and the per-window render runtime rather than directly from shell composition. - The old fine-grained app-split target residue was removed from CMake and @@ -450,8 +462,8 @@ ownership rule. panel classes. - Shared app panel contracts started moving into `app/Core`: panel IDs now live under `app/Core/Panels`, and the workspace-panel runtime interface lives - under `app/Core/WorkspacePanels`. `Application` is the current composition - root for the concrete workspace panel factory. + under `app/Core/WorkspacePanels`. `Application` is the composition root for + the concrete workspace panel factory. - Panel-facing app services now live behind `app/Core/Panels/EditorPanelServices.h`. Workspace-panel and utility-window runtime contracts no longer expose `EditorContext`, and concrete feature diff --git a/editor/app/Bootstrap/Application.cpp b/editor/app/Bootstrap/Application.cpp index 14f74908..23044e12 100644 --- a/editor/app/Bootstrap/Application.cpp +++ b/editor/app/Bootstrap/Application.cpp @@ -150,14 +150,17 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) { m_editorContext->GetShellAsset().captureRootPath); m_renderRuntimeFactory = std::make_unique(); + App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory = []() { + return App::CreateEditorWorkspaceShellRuntime( + App::CreateEditorWorkspacePanelRuntimeSet()); + }; m_windowManager = std::make_unique( *m_editorContext, *m_windowSystem, *m_renderRuntimeFactory, *m_resourceService, *m_windowHostRuntime, - App::CreateEditorWorkspacePanelRuntimeSet, - App::CreateEditorWorkspaceShellRuntime, + std::move(workspaceShellRuntimeFactory), App::CreateEditorUtilityWindowPanel); m_editorContext->SetExitRequestHandler([this]() { diff --git a/editor/app/Composition/EditorShellRuntime.cpp b/editor/app/Composition/EditorShellRuntime.cpp index bd2fd271..0857c2e1 100644 --- a/editor/app/Composition/EditorShellRuntime.cpp +++ b/editor/app/Composition/EditorShellRuntime.cpp @@ -96,8 +96,14 @@ void EditorShellRuntime::ClearExternalDockHostDropPreview() { .dockHostState.dropPreview = {}; } -EditorWorkspacePanelCursorKind EditorShellRuntime::GetHostedContentCursorKind() const { - return m_workspacePanels.GetHostedContentCursorKind(); +EditorWorkspaceShellCursorKind EditorShellRuntime::GetHostedContentCursorKind() const { + switch (m_workspacePanels.GetHostedContentCursorKind()) { + case EditorWorkspacePanelCursorKind::ResizeEW: + return EditorWorkspaceShellCursorKind::ResizeEW; + case EditorWorkspacePanelCursorKind::Arrow: + default: + return EditorWorkspaceShellCursorKind::Arrow; + } } Widgets::UIEditorDockHostCursorKind EditorShellRuntime::GetDockCursorKind() const { diff --git a/editor/app/Composition/EditorShellRuntime.h b/editor/app/Composition/EditorShellRuntime.h index efb487ce..3a177fb3 100644 --- a/editor/app/Composition/EditorShellRuntime.h +++ b/editor/app/Composition/EditorShellRuntime.h @@ -81,7 +81,7 @@ public: const Widgets::UIEditorDockHostDropPreviewState& preview) override; void ClearExternalDockHostDropPreview() override; - EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const override; + EditorWorkspaceShellCursorKind GetHostedContentCursorKind() const override; Widgets::UIEditorDockHostCursorKind GetDockCursorKind() const override; bool TryResolveDockTabDragHotspot( std::string_view nodeId, diff --git a/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h b/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h index e2d86507..4cf6a923 100644 --- a/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h +++ b/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h @@ -1,12 +1,12 @@ #pragma once #include "Windowing/EditorFrameServices.h" -#include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include #include #include +#include #include #include #include @@ -42,6 +42,11 @@ class EditorHostResourceService; namespace XCEngine::UI::Editor::App { +enum class EditorWorkspaceShellCursorKind : std::uint8_t { + Arrow = 0, + ResizeEW +}; + class EditorWorkspaceShellRuntime { public: virtual ~EditorWorkspaceShellRuntime() = default; @@ -78,7 +83,7 @@ public: const Widgets::UIEditorDockHostDropPreviewState& preview) = 0; virtual void ClearExternalDockHostDropPreview() = 0; - virtual EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const = 0; + virtual EditorWorkspaceShellCursorKind GetHostedContentCursorKind() const = 0; virtual Widgets::UIEditorDockHostCursorKind GetDockCursorKind() const = 0; virtual bool TryResolveDockTabDragHotspot( std::string_view nodeId, @@ -93,6 +98,6 @@ public: }; using EditorWorkspaceShellRuntimeFactory = - std::function(EditorWorkspacePanelRuntimeSet)>; + std::function()>; } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Content/EditorWindowContentFactory.cpp b/editor/app/Windowing/Content/EditorWindowContentFactory.cpp index ea8f15e9..133cb764 100644 --- a/editor/app/Windowing/Content/EditorWindowContentFactory.cpp +++ b/editor/app/Windowing/Content/EditorWindowContentFactory.cpp @@ -15,23 +15,17 @@ class DefaultEditorWindowContentFactory final : public EditorWindowContentFactor public: DefaultEditorWindowContentFactory( EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory) : m_windowSystem(windowSystem) - , m_workspacePanelFactory(std::move(workspacePanelFactory)) , m_workspaceShellRuntimeFactory(std::move(workspaceShellRuntimeFactory)) , m_utilityPanelFactory(std::move(utilityPanelFactory)) {} std::unique_ptr CreateWorkspaceContentController( const UIEditorWindowWorkspaceState& windowState) const override { - EditorWorkspacePanelRuntimeSet workspacePanels = - m_workspacePanelFactory - ? m_workspacePanelFactory() - : EditorWorkspacePanelRuntimeSet{}; std::unique_ptr shellRuntime = m_workspaceShellRuntimeFactory - ? m_workspaceShellRuntimeFactory(std::move(workspacePanels)) + ? m_workspaceShellRuntimeFactory() : nullptr; return CreateEditorWorkspaceWindowContentController( windowState, @@ -52,7 +46,6 @@ public: private: EditorWindowSystem& m_windowSystem; - EditorWorkspacePanelRuntimeSetFactory m_workspacePanelFactory = {}; EditorWorkspaceShellRuntimeFactory m_workspaceShellRuntimeFactory = {}; EditorUtilityWindowPanelFactory m_utilityPanelFactory = {}; }; @@ -61,12 +54,10 @@ private: std::unique_ptr CreateDefaultEditorWindowContentFactory( EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory) { return std::make_unique( windowSystem, - std::move(workspacePanelFactory), std::move(workspaceShellRuntimeFactory), std::move(utilityPanelFactory)); } diff --git a/editor/app/Windowing/Content/EditorWindowContentFactory.h b/editor/app/Windowing/Content/EditorWindowContentFactory.h index ae4e2ac2..8c453cb0 100644 --- a/editor/app/Windowing/Content/EditorWindowContentFactory.h +++ b/editor/app/Windowing/Content/EditorWindowContentFactory.h @@ -2,7 +2,6 @@ #include "UtilityWindows/EditorUtilityWindowRuntime.h" #include "Windowing/EditorWorkspaceShellRuntime.h" -#include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include #include @@ -31,7 +30,6 @@ public: std::unique_ptr CreateDefaultEditorWindowContentFactory( EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory); diff --git a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp index eb84217c..55b85260 100644 --- a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp +++ b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp @@ -12,11 +12,11 @@ namespace XCEngine::UI::Editor::App { namespace { EditorWindowContentCursorKind ToContentCursorKind( - EditorWorkspacePanelCursorKind cursorKind) { + EditorWorkspaceShellCursorKind cursorKind) { switch (cursorKind) { - case EditorWorkspacePanelCursorKind::ResizeEW: + case EditorWorkspaceShellCursorKind::ResizeEW: return EditorWindowContentCursorKind::ResizeEW; - case EditorWorkspacePanelCursorKind::Arrow: + case EditorWorkspaceShellCursorKind::Arrow: default: return EditorWindowContentCursorKind::Arrow; } diff --git a/editor/app/Windowing/EditorWindowManager.cpp b/editor/app/Windowing/EditorWindowManager.cpp index 63412700..23bfc910 100644 --- a/editor/app/Windowing/EditorWindowManager.cpp +++ b/editor/app/Windowing/EditorWindowManager.cpp @@ -25,7 +25,6 @@ EditorWindowManager::EditorWindowManager( Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, Host::EditorHostResourceService& resourceService, EditorWindowHostRuntimeServices& hostRuntime, - EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory) : m_frameServices(frameServices) @@ -34,7 +33,6 @@ EditorWindowManager::EditorWindowManager( , m_hostRuntime(hostRuntime) { m_contentFactory = CreateDefaultEditorWindowContentFactory( windowSystem, - std::move(workspacePanelFactory), std::move(workspaceShellRuntimeFactory), std::move(utilityPanelFactory)); m_workspaceCoordinator = diff --git a/editor/app/Windowing/EditorWindowManager.h b/editor/app/Windowing/EditorWindowManager.h index 030d2d75..8c17d864 100644 --- a/editor/app/Windowing/EditorWindowManager.h +++ b/editor/app/Windowing/EditorWindowManager.h @@ -11,7 +11,6 @@ #include "EditorWindowHostInterfaces.h" #include "EditorWindowHostTypes.h" #include "EditorWindowInstance.h" -#include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include #include #include @@ -51,7 +50,6 @@ public: Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, Host::EditorHostResourceService& resourceService, EditorWindowHostRuntimeServices& hostRuntime, - EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory); ~EditorWindowManager();