Cut workspace panel factory out of windowing

This commit is contained in:
2026-04-28 00:05:10 +08:00
parent 03967b152d
commit 43a71bd09c
11 changed files with 50 additions and 30 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -150,14 +150,17 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
m_editorContext->GetShellAsset().captureRootPath);
m_renderRuntimeFactory =
std::make_unique<Host::D3D12EditorWindowRenderRuntimeFactory>();
App::EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory = []() {
return App::CreateEditorWorkspaceShellRuntime(
App::CreateEditorWorkspacePanelRuntimeSet());
};
m_windowManager = std::make_unique<App::EditorWindowManager>(
*m_editorContext,
*m_windowSystem,
*m_renderRuntimeFactory,
*m_resourceService,
*m_windowHostRuntime,
App::CreateEditorWorkspacePanelRuntimeSet,
App::CreateEditorWorkspaceShellRuntime,
std::move(workspaceShellRuntimeFactory),
App::CreateEditorUtilityWindowPanel);
m_editorContext->SetExitRequestHandler([this]() {

View File

@@ -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 {

View File

@@ -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,

View File

@@ -1,12 +1,12 @@
#pragma once
#include "Windowing/EditorFrameServices.h"
#include "WorkspacePanels/EditorWorkspacePanelRuntime.h"
#include <XCEditor/Docking/UIEditorDockHostTransfer.h>
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
#include <XCEngine/UI/Types.h>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <memory>
@@ -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<std::unique_ptr<EditorWorkspaceShellRuntime>(EditorWorkspacePanelRuntimeSet)>;
std::function<std::unique_ptr<EditorWorkspaceShellRuntime>()>;
} // namespace XCEngine::UI::Editor::App

View File

@@ -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<EditorWindowContentController> CreateWorkspaceContentController(
const UIEditorWindowWorkspaceState& windowState) const override {
EditorWorkspacePanelRuntimeSet workspacePanels =
m_workspacePanelFactory
? m_workspacePanelFactory()
: EditorWorkspacePanelRuntimeSet{};
std::unique_ptr<EditorWorkspaceShellRuntime> 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<EditorWindowContentFactory> CreateDefaultEditorWindowContentFactory(
EditorWindowSystem& windowSystem,
EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory,
EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory,
EditorUtilityWindowPanelFactory utilityPanelFactory) {
return std::make_unique<DefaultEditorWindowContentFactory>(
windowSystem,
std::move(workspacePanelFactory),
std::move(workspaceShellRuntimeFactory),
std::move(utilityPanelFactory));
}

View File

@@ -2,7 +2,6 @@
#include "UtilityWindows/EditorUtilityWindowRuntime.h"
#include "Windowing/EditorWorkspaceShellRuntime.h"
#include "WorkspacePanels/EditorWorkspacePanelRuntime.h"
#include <memory>
#include <string_view>
@@ -31,7 +30,6 @@ public:
std::unique_ptr<EditorWindowContentFactory> CreateDefaultEditorWindowContentFactory(
EditorWindowSystem& windowSystem,
EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory,
EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory,
EditorUtilityWindowPanelFactory utilityPanelFactory);

View File

@@ -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;
}

View File

@@ -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 =

View File

@@ -11,7 +11,6 @@
#include "EditorWindowHostInterfaces.h"
#include "EditorWindowHostTypes.h"
#include "EditorWindowInstance.h"
#include "WorkspacePanels/EditorWorkspacePanelRuntime.h"
#include <memory>
#include <string_view>
#include <vector>
@@ -51,7 +50,6 @@ public:
Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory,
Host::EditorHostResourceService& resourceService,
EditorWindowHostRuntimeServices& hostRuntime,
EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory,
EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory,
EditorUtilityWindowPanelFactory utilityPanelFactory);
~EditorWindowManager();