diff --git a/docs/plan/editor-core-refactor-plan.md b/docs/plan/editor-core-refactor-plan.md index 222060e3..55e92965 100644 --- a/docs/plan/editor-core-refactor-plan.md +++ b/docs/plan/editor-core-refactor-plan.md @@ -50,6 +50,11 @@ incomplete: - Feature panels no longer use `Composition/EditorContext.h` directly. The app-core and app feature/viewport test targets now exercise `XCEditorCore` outside the executable host. +- Windowing now consumes composition through neutral contracts under + `editor/app/Core/Windowing`: `EditorFrameServices` for per-frame + composition/state access and `EditorWorkspaceShellRuntime` for per-window + shell runtime behavior. `EditorContext` and `EditorShellRuntime` remain the + concrete composition implementations, injected from `Application`. Completed boundary cuts: @@ -82,6 +87,10 @@ Completed boundary cuts: now live under `editor/app/Core/Windowing`, and `XCEditorCore` no longer exports the whole `editor/app` root as a public include directory. +- `app/Windowing/**` no longer includes concrete + `Composition/EditorContext.h` or `Composition/EditorShellRuntime.h`. + Instead it consumes `EditorFrameServices` and + `EditorWorkspaceShellRuntime` from `editor/app/Core/Windowing`. - The private `editor/app` compatibility include root is gone from `XCEditorCore` and `XCEditor`. App implementation files now include through explicit module roots such as `app/Composition`, `app/Features`, @@ -172,6 +181,9 @@ Within `XCEditorCore`: - `State` must not depend on `Composition`. - `Windowing` may depend on `Core`, `Composition` interfaces, and `XCUIEditor`, but must not include Win32 or D3D12 concrete host headers. +- The current composition interfaces for windowing are + `Core/Windowing/EditorFrameServices.h` and + `Core/Windowing/EditorWorkspaceShellRuntime.h`. - Host contracts may live in `Core` or `Host/Interfaces`. - Win32 and D3D12 concrete implementations live outside `XCEditorCore` unless they are purely abstract host contracts. @@ -459,6 +471,11 @@ Completed cuts: Win32 resource APIs, and the mapping from product resource IDs to built-in editor icon requests, so `XCEditorCore` no longer needs `app/Bootstrap` as a private include root for resource loading. +- Windowing now depends on composition through + `Core/Windowing/EditorFrameServices.h` and + `Core/Windowing/EditorWorkspaceShellRuntime.h`. `Application` injects the + concrete `EditorShellRuntime` factory, and `EditorContext` remains the + concrete `EditorFrameServices` implementation. ## Phase 6: Documentation Update @@ -502,6 +519,8 @@ The refactor is complete when: - `XCEditor` executable source is limited to host startup and concrete platform/render backend wiring. - `Composition` no longer includes concrete feature panel headers. +- `Windowing` no longer includes concrete composition runtime/state headers; + it depends on `Core/Windowing` composition interfaces instead. - `Services` no longer include `Features/**`. - Win32 and D3D12 communicate through neutral host/render contracts. - app-core and app feature/viewport tests are wired into CMake and build diff --git a/editor/AGENTS.md b/editor/AGENTS.md index 490a4d08..fe30da4a 100644 --- a/editor/AGENTS.md +++ b/editor/AGENTS.md @@ -58,7 +58,8 @@ change. that are not owned by a concrete feature or composition implementation. Current examples are panel IDs, shared window type contracts, host window geometry/metrics, frame transfer requests, the panel-facing service view, - workspace-panel runtime interface, and utility-window runtime/descriptors. + the windowing-facing frame-services/shell-runtime contracts, workspace-panel + runtime interface, and utility-window runtime/descriptors. - `app/Host/Interfaces/` contains neutral host-facing contracts used across editor core and executable host code: editor window host interfaces, render-runtime factories, UI texture hosts, viewport render hosts, host @@ -100,6 +101,10 @@ change. shared value contracts in `app/Core`. Do not add new public app contracts under concrete `app/Windowing`, `app/Rendering`, `app/Host/Win32`, `app/Host/D3D12`, or legacy `app/Platform` paths. +- `app/Windowing/**` may depend on `app/Core/Windowing` contracts such as + `EditorFrameServices` and `EditorWorkspaceShellRuntime`, but it must not + include concrete `app/Composition/EditorContext.h` or + `app/Composition/EditorShellRuntime.h`. - Keep shell composition and widget logic data-driven. The reusable layer should emit frames, layouts, draw data, command results, and transfer requests; the app decides how those requests affect native windows and engine services. @@ -138,7 +143,8 @@ change. - `EditorContext` owns the app-level shell asset, editor session, command routing, selection/focus services, project runtime, scene runtime, color - picker state, and pending utility-window requests. + picker state, pending utility-window requests, and the + `EditorFrameServices` implementation consumed by windowing. - `EditorWindowSystem` owns the authoritative `UIEditorWindowWorkspaceSet`. Workspace windows should derive their local projection from this state rather than storing independent layout truth. @@ -150,6 +156,10 @@ change. service, built-in icons, the workspace panel runtime set, shell interaction state/frame, splitter correction state, trace entries, draw composer, interaction engine, hosted panel coordinator, and session coordinator. +- `EditorWorkspaceShellRuntime` is the windowing-facing shell runtime contract. + `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. - `EditorWindowRuntimeController` owns the content controller, render runtime, screenshot controller, title-bar logo texture, text measurer access, DPI scale, and frame-rate display. @@ -326,6 +336,11 @@ inside pure shell/widget code. - `XCEditor` is the thin executable host that wires `XCEditorCore` to concrete Win32 and D3D12 implementations. Do not move concrete platform/render host code into `XCEditorCore` without first introducing neutral host contracts. +- `app/Core/Windowing/EditorFrameServices.h` and + `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. - Legacy fine-grained app-split CMake targets are retired architecture history. Current production editor targets are `XCUIEditor`, `XCEditorCore`, and `XCEditor`. @@ -418,6 +433,12 @@ ownership rule. - Shared window category, lifecycle, chrome-policy, native-host-policy, screen geometry, chrome metrics, and frame-transfer request contracts now live under `app/Core/Windowing`. +- Windowing now consumes composition through + `app/Core/Windowing/EditorFrameServices.h` and + `app/Core/Windowing/EditorWorkspaceShellRuntime.h`. `EditorContext` + 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. - 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 diff --git a/editor/app/Bootstrap/Application.cpp b/editor/app/Bootstrap/Application.cpp index 485c9928..14f74908 100644 --- a/editor/app/Bootstrap/Application.cpp +++ b/editor/app/Bootstrap/Application.cpp @@ -2,6 +2,7 @@ #include "EditorResources.h" #include "SystemInteractionService.h" #include "EditorContext.h" +#include "EditorShellRuntime.h" #include "EditorUtilityWindowRegistry.h" #include "EditorWorkspacePanelRegistry.h" #include "EditorWindowManager.h" @@ -156,6 +157,7 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) { *m_resourceService, *m_windowHostRuntime, App::CreateEditorWorkspacePanelRuntimeSet, + App::CreateEditorWorkspaceShellRuntime, App::CreateEditorUtilityWindowPanel); m_editorContext->SetExitRequestHandler([this]() { diff --git a/editor/app/Composition/EditorContext.cpp b/editor/app/Composition/EditorContext.cpp index 33ca3590..fba41cba 100644 --- a/editor/app/Composition/EditorContext.cpp +++ b/editor/app/Composition/EditorContext.cpp @@ -2,6 +2,7 @@ #include "EditorShellAssetBuilder.h" #include "EditorSceneRuntime.h" #include "Panels/EditorPanelIds.h" +#include "WorkspaceEventSync.h" #include #include #include @@ -293,6 +294,11 @@ std::string EditorContext::DescribeWorkspaceState( return stream.str(); } +std::vector EditorContext::SyncWorkspacePanelFrameEvents( + const std::vector& panelEvents) { + return SyncWorkspaceEvents(*this, panelEvents); +} + } // namespace XCEngine::UI::Editor::App namespace XCEngine::UI::Editor::App { diff --git a/editor/app/Composition/EditorContext.h b/editor/app/Composition/EditorContext.h index dae3448c..a64f3142 100644 --- a/editor/app/Composition/EditorContext.h +++ b/editor/app/Composition/EditorContext.h @@ -1,7 +1,7 @@ #pragma once -#include "EditorShellVariant.h" #include "Panels/EditorPanelServices.h" +#include "Windowing/EditorFrameServices.h" #include "EditorSceneRuntime.h" #include "Project/EditorProjectRuntime.h" #include "UtilityWindows/EditorUtilityWindowRuntime.h" @@ -31,21 +31,22 @@ namespace XCEngine::UI::Editor::App { class EditorEditCommandRoute; -class EditorContext { +class EditorContext : public EditorFrameServices { public: bool Initialize(const std::filesystem::path& repoRoot); - void AttachTextMeasurer(const UIEditorTextMeasurer& textMeasurer); + void AttachTextMeasurer(const UIEditorTextMeasurer& textMeasurer) override; void SetSystemInteractionHost(System::SystemInteractionService* systemInteractionHost); void BindEditCommandRoutes( EditorEditCommandRoute* hierarchyRoute, EditorEditCommandRoute* projectRoute, EditorEditCommandRoute* sceneRoute, - EditorEditCommandRoute* inspectorRoute = nullptr); + EditorEditCommandRoute* inspectorRoute = nullptr) override; void SetExitRequestHandler(std::function handler); - void SyncSessionFromWorkspace(const UIEditorWorkspaceController& workspaceController); + void SyncSessionFromWorkspace( + const UIEditorWorkspaceController& workspaceController) override; - bool IsValid() const; - const std::string& GetValidationMessage() const; + bool IsValid() const override; + const std::string& GetValidationMessage() const override; const EditorShellAsset& GetShellAsset() const; const EditorSession& GetSession() const; EditorCommandFocusService& GetCommandFocusService(); @@ -57,31 +58,33 @@ public: EditorColorPickerToolState& GetColorPickerToolState(); const EditorColorPickerToolState& GetColorPickerToolState() const; void RequestOpenUtilityWindow(EditorUtilityWindowKind kind); - std::optional ConsumeOpenUtilityWindowRequest(); + std::optional ConsumeOpenUtilityWindowRequest() override; void SetSelection(EditorSelectionState selection); void ClearSelection(); void SyncSessionFromSelectionService(); - void SyncSessionFromCommandFocusService(); + void SyncSessionFromCommandFocusService() override; System::SystemInteractionService* GetSystemInteractionHost(); const System::SystemInteractionService* GetSystemInteractionHost() const; UIEditorWorkspaceController BuildWorkspaceController() const; - const UIEditorShellInteractionServices& GetShellServices() const; - EditorPanelServices BuildPanelServices(); + const UIEditorShellInteractionServices& GetShellServices() const override; + EditorPanelServices BuildPanelServices() override; UIEditorShellInteractionDefinition BuildShellDefinition( const UIEditorWorkspaceController& workspaceController, std::string_view captureText, - EditorShellVariant variant = EditorShellVariant::Primary) const; + EditorShellVariant variant = EditorShellVariant::Primary) const override; void SetReadyStatus(); - void SetStatus(std::string status, std::string message); + void SetStatus(std::string status, std::string message) override; void UpdateStatusFromShellResult( const UIEditorWorkspaceController& workspaceController, - const UIEditorShellInteractionResult& result); + const UIEditorShellInteractionResult& result) override; std::string DescribeWorkspaceState( const UIEditorWorkspaceController& workspaceController, - const UIEditorShellInteractionState& interactionState) const; + const UIEditorShellInteractionState& interactionState) const override; + std::vector SyncWorkspacePanelFrameEvents( + const std::vector& panelEvents) override; private: void AppendConsoleEntry(std::string channel, std::string message); diff --git a/editor/app/Composition/EditorShellAssetBuilder.h b/editor/app/Composition/EditorShellAssetBuilder.h index 01ea0eb7..0a9bddb4 100644 --- a/editor/app/Composition/EditorShellAssetBuilder.h +++ b/editor/app/Composition/EditorShellAssetBuilder.h @@ -1,6 +1,6 @@ #pragma once -#include "EditorShellVariant.h" +#include "Windowing/EditorShellVariant.h" #include #include diff --git a/editor/app/Composition/EditorShellHostedPanelCoordinator.cpp b/editor/app/Composition/EditorShellHostedPanelCoordinator.cpp index 0baf4b70..c52c38da 100644 --- a/editor/app/Composition/EditorShellHostedPanelCoordinator.cpp +++ b/editor/app/Composition/EditorShellHostedPanelCoordinator.cpp @@ -1,6 +1,6 @@ #include "EditorShellHostedPanelCoordinator.h" -#include "EditorContext.h" +#include "Windowing/EditorFrameServices.h" #include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include @@ -20,7 +20,7 @@ void EditorShellHostedPanelCoordinator::Update( context.inputEvents, shellOwnsHostedContentPointerStream); - EditorPanelServices services = context.context.BuildPanelServices(); + EditorPanelServices services = context.frameServices.BuildPanelServices(); const EditorWorkspacePanelUpdateContext updateContext{ .services = services, .shellFrame = context.shellFrame, @@ -31,7 +31,7 @@ void EditorShellHostedPanelCoordinator::Update( context.workspacePanels.UpdatePhase( updateContext, EditorWorkspacePanelUpdatePhase::Main); - context.context.SyncSessionFromCommandFocusService(); + context.frameServices.SyncSessionFromCommandFocusService(); context.workspacePanels.UpdatePhase( updateContext, EditorWorkspacePanelUpdatePhase::AfterCommandFocusSync); diff --git a/editor/app/Composition/EditorShellHostedPanelCoordinator.h b/editor/app/Composition/EditorShellHostedPanelCoordinator.h index d5c48bb2..9edc32b1 100644 --- a/editor/app/Composition/EditorShellHostedPanelCoordinator.h +++ b/editor/app/Composition/EditorShellHostedPanelCoordinator.h @@ -17,11 +17,11 @@ struct UIEditorShellInteractionState; namespace XCEngine::UI::Editor::App { -class EditorContext; +class EditorFrameServices; class EditorWorkspacePanelRuntimeSet; struct EditorShellHostedPanelCoordinatorContext { - EditorContext& context; + EditorFrameServices& frameServices; UIEditorShellInteractionFrame& shellFrame; UIEditorShellInteractionState& shellInteractionState; const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents; diff --git a/editor/app/Composition/EditorShellRuntime.cpp b/editor/app/Composition/EditorShellRuntime.cpp index 035d2410..bd2fd271 100644 --- a/editor/app/Composition/EditorShellRuntime.cpp +++ b/editor/app/Composition/EditorShellRuntime.cpp @@ -1,7 +1,6 @@ #include "EditorShellRuntime.h" #include "UiTextureHost.h" #include "ViewportRenderHost.h" -#include "EditorContext.h" #include #include @@ -138,6 +137,11 @@ bool EditorShellRuntime::HasInteractiveCapture() const { return HasHostedContentCapture() || HasShellInteractiveCapture(); } +std::unique_ptr CreateEditorWorkspaceShellRuntime( + EditorWorkspacePanelRuntimeSet workspacePanels) { + return std::make_unique(std::move(workspacePanels)); +} + } // namespace XCEngine::UI::Editor::App namespace XCEngine::UI::Editor::App { @@ -163,7 +167,7 @@ void EditorShellRuntime::Append(::XCEngine::UI::UIDrawData& drawData) const { namespace XCEngine::UI::Editor::App { void EditorShellRuntime::Update( - EditorContext& context, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, const ::XCEngine::UI::UIRect& bounds, const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents, @@ -175,7 +179,7 @@ void EditorShellRuntime::Update( const auto buildDefinition = [&]() { return m_sessionCoordinator.PrepareShellDefinition( EditorShellSessionCoordinatorContext{ - .context = context, + .frameServices = frameServices, .workspaceController = workspaceController, .captureText = captureText, .shellVariant = shellVariant, @@ -190,7 +194,7 @@ void EditorShellRuntime::Update( .workspaceController = workspaceController, .bounds = bounds, .inputEvents = inputEvents, - .shellServices = context.GetShellServices(), + .shellServices = frameServices.GetShellServices(), .buildDefinition = buildDefinition, .hostedContentCaptureActive = HasHostedContentCapture(), .useDetachedTitleBarTabStrip = useDetachedTitleBarTabStrip, @@ -198,19 +202,18 @@ void EditorShellRuntime::Update( .detachedWindowChromeHeight = detachedWindowChromeHeight, .viewportHostService = m_viewportHostService, }); - m_sessionCoordinator.FinalizeFrame(context, workspaceController, m_shellFrame.result); + m_sessionCoordinator.FinalizeFrame(frameServices, workspaceController, m_shellFrame.result); m_hostedPanelCoordinator.Update( EditorShellHostedPanelCoordinatorContext{ - .context = context, + .frameServices = frameServices, .shellFrame = m_shellFrame, .shellInteractionState = m_shellInteractionState, .inputEvents = inputEvents, .shellInteractiveCaptureActive = HasShellInteractiveCapture(), .workspacePanels = m_workspacePanels, }); - m_traceEntries = SyncWorkspaceEvents( - context, + m_traceEntries = frameServices.SyncWorkspacePanelFrameEvents( m_workspacePanels.CollectFrameEvents()); } diff --git a/editor/app/Composition/EditorShellRuntime.h b/editor/app/Composition/EditorShellRuntime.h index ef841476..efb487ce 100644 --- a/editor/app/Composition/EditorShellRuntime.h +++ b/editor/app/Composition/EditorShellRuntime.h @@ -4,11 +4,10 @@ #include "EditorShellHostedPanelCoordinator.h" #include "EditorShellInteractionEngine.h" #include "EditorShellSessionCoordinator.h" -#include "EditorShellVariant.h" +#include "Windowing/EditorWorkspaceShellRuntime.h" #include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include "Assets/BuiltInIcons.h" #include "Viewport/ViewportHostService.h" -#include "WorkspaceEventSync.h" #include #include @@ -19,15 +18,10 @@ #include #include +#include #include #include -namespace XCEngine::UI::Editor::App { - -class EditorContext; - -} // namespace XCEngine::UI::Editor::App - namespace XCEngine::UI::Editor::Rendering::Host { class UiTextureHost; @@ -49,7 +43,7 @@ class RenderContext; namespace XCEngine::UI::Editor::App { -class EditorShellRuntime { +class EditorShellRuntime final : public EditorWorkspaceShellRuntime { public: EditorShellRuntime() = default; explicit EditorShellRuntime(EditorWorkspacePanelRuntimeSet workspacePanels); @@ -58,15 +52,15 @@ public: const std::filesystem::path& repoRoot, Rendering::Host::UiTextureHost& textureHost, Host::EditorHostResourceService& resourceService, - UIEditorTextMeasurer& textMeasurer); - void Shutdown(); - void ResetInteractionState(); - void AttachViewportWindowRenderer(Rendering::Host::ViewportRenderHost& renderer); - void DetachViewportWindowRenderer(); - void SetViewportSurfacePresentationEnabled(bool enabled); + UIEditorTextMeasurer& textMeasurer) override; + void Shutdown() override; + void ResetInteractionState() override; + void AttachViewportWindowRenderer(Rendering::Host::ViewportRenderHost& renderer) override; + void DetachViewportWindowRenderer() override; + void SetViewportSurfacePresentationEnabled(bool enabled) override; void Update( - EditorContext& context, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, const ::XCEngine::UI::UIRect& bounds, const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents, @@ -74,31 +68,31 @@ public: EditorShellVariant shellVariant = EditorShellVariant::Primary, bool useDetachedTitleBarTabStrip = false, float detachedTitleBarTabHeight = 0.0f, - float detachedWindowChromeHeight = 0.0f); + float detachedWindowChromeHeight = 0.0f) override; void RenderRequestedViewports( - const ::XCEngine::Rendering::RenderContext& renderContext); - void Append(::XCEngine::UI::UIDrawData& drawData) const; + const ::XCEngine::Rendering::RenderContext& renderContext) override; + void Append(::XCEngine::UI::UIDrawData& drawData) const override; - const UIEditorShellInteractionFrame& GetShellFrame() const; - const UIEditorShellInteractionState& GetShellInteractionState() const; - const std::vector& GetTraceEntries() const; + const UIEditorShellInteractionFrame& GetShellFrame() const override; + const UIEditorShellInteractionState& GetShellInteractionState() const override; + const std::vector& GetTraceEntries() const override; const std::string& GetBuiltInIconError() const; void SetExternalDockHostDropPreview( - const Widgets::UIEditorDockHostDropPreviewState& preview); - void ClearExternalDockHostDropPreview(); + const Widgets::UIEditorDockHostDropPreviewState& preview) override; + void ClearExternalDockHostDropPreview() override; - EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const; - Widgets::UIEditorDockHostCursorKind GetDockCursorKind() const; + EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const override; + Widgets::UIEditorDockHostCursorKind GetDockCursorKind() const override; bool TryResolveDockTabDragHotspot( std::string_view nodeId, std::string_view panelId, const ::XCEngine::UI::UIPoint& point, - ::XCEngine::UI::UIPoint& outHotspot) const; + ::XCEngine::UI::UIPoint& outHotspot) const override; UIEditorDockHostTabDropTarget ResolveDockTabDropTarget( - const ::XCEngine::UI::UIPoint& point) const; - bool HasHostedContentCapture() const; - bool HasShellInteractiveCapture() const; - bool HasInteractiveCapture() const; + const ::XCEngine::UI::UIPoint& point) const override; + bool HasHostedContentCapture() const override; + bool HasShellInteractiveCapture() const override; + bool HasInteractiveCapture() const override; private: ViewportHostService m_viewportHostService = {}; @@ -115,6 +109,9 @@ private: EditorShellSessionCoordinator m_sessionCoordinator = {}; }; +std::unique_ptr CreateEditorWorkspaceShellRuntime( + EditorWorkspacePanelRuntimeSet workspacePanels); + } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Composition/EditorShellSessionCoordinator.cpp b/editor/app/Composition/EditorShellSessionCoordinator.cpp index 35e498b8..b61adcb3 100644 --- a/editor/app/Composition/EditorShellSessionCoordinator.cpp +++ b/editor/app/Composition/EditorShellSessionCoordinator.cpp @@ -1,34 +1,33 @@ #include "EditorShellSessionCoordinator.h" -#include "EditorContext.h" #include "WorkspacePanels/EditorWorkspacePanelRuntime.h" namespace XCEngine::UI::Editor::App { UIEditorShellInteractionDefinition EditorShellSessionCoordinator::PrepareShellDefinition( const EditorShellSessionCoordinatorContext& context) const { - EditorPanelServices services = context.context.BuildPanelServices(); + EditorPanelServices services = context.frameServices.BuildPanelServices(); context.workspacePanels.PrepareForShellDefinition( services, context.workspaceController); - context.context.BindEditCommandRoutes( + context.frameServices.BindEditCommandRoutes( context.workspacePanels.FindCommandRoute(EditorActionRoute::Hierarchy), context.workspacePanels.FindCommandRoute(EditorActionRoute::Project), context.workspacePanels.FindCommandRoute(EditorActionRoute::Scene), context.workspacePanels.FindCommandRoute(EditorActionRoute::Inspector)); - context.context.SyncSessionFromWorkspace(context.workspaceController); - return context.context.BuildShellDefinition( + context.frameServices.SyncSessionFromWorkspace(context.workspaceController); + return context.frameServices.BuildShellDefinition( context.workspaceController, context.captureText, context.shellVariant); } void EditorShellSessionCoordinator::FinalizeFrame( - EditorContext& context, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, const UIEditorShellInteractionResult& shellResult) const { - context.SyncSessionFromWorkspace(workspaceController); - context.UpdateStatusFromShellResult(workspaceController, shellResult); + frameServices.SyncSessionFromWorkspace(workspaceController); + frameServices.UpdateStatusFromShellResult(workspaceController, shellResult); } } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Composition/EditorShellSessionCoordinator.h b/editor/app/Composition/EditorShellSessionCoordinator.h index e8b9180b..c550f612 100644 --- a/editor/app/Composition/EditorShellSessionCoordinator.h +++ b/editor/app/Composition/EditorShellSessionCoordinator.h @@ -1,6 +1,6 @@ #pragma once -#include "EditorShellVariant.h" +#include "Windowing/EditorFrameServices.h" #include #include @@ -9,11 +9,10 @@ namespace XCEngine::UI::Editor::App { -class EditorContext; class EditorWorkspacePanelRuntimeSet; struct EditorShellSessionCoordinatorContext { - EditorContext& context; + EditorFrameServices& frameServices; UIEditorWorkspaceController& workspaceController; std::string_view captureText; EditorShellVariant shellVariant = EditorShellVariant::Primary; @@ -25,7 +24,7 @@ public: UIEditorShellInteractionDefinition PrepareShellDefinition( const EditorShellSessionCoordinatorContext& context) const; void FinalizeFrame( - EditorContext& context, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, const UIEditorShellInteractionResult& shellResult) const; }; diff --git a/editor/app/Composition/WorkspaceEventSync.h b/editor/app/Composition/WorkspaceEventSync.h index 88338070..15fe5ef3 100644 --- a/editor/app/Composition/WorkspaceEventSync.h +++ b/editor/app/Composition/WorkspaceEventSync.h @@ -1,19 +1,14 @@ #pragma once +#include "Windowing/EditorFrameServices.h" #include "WorkspacePanels/EditorWorkspacePanelRuntime.h" -#include #include namespace XCEngine::UI::Editor::App { class EditorContext; -struct WorkspaceTraceEntry { - std::string channel = {}; - std::string message = {}; -}; - std::vector SyncWorkspaceEvents( EditorContext& context, const std::vector& panelEvents); diff --git a/editor/app/Core/Windowing/EditorFrameServices.h b/editor/app/Core/Windowing/EditorFrameServices.h new file mode 100644 index 00000000..7fd209d1 --- /dev/null +++ b/editor/app/Core/Windowing/EditorFrameServices.h @@ -0,0 +1,62 @@ +#pragma once + +#include "Panels/EditorPanelServices.h" +#include "UtilityWindows/EditorUtilityWindowRuntime.h" +#include "Windowing/EditorShellVariant.h" +#include "WorkspacePanels/EditorWorkspacePanelRuntime.h" + +#include +#include +#include + +#include +#include +#include +#include + +namespace XCEngine::UI::Editor::App { + +class EditorEditCommandRoute; + +struct WorkspaceTraceEntry { + std::string channel = {}; + std::string message = {}; +}; + +class EditorFrameServices { +public: + virtual ~EditorFrameServices() = default; + + virtual void AttachTextMeasurer(const UIEditorTextMeasurer& textMeasurer) = 0; + virtual bool IsValid() const = 0; + virtual const std::string& GetValidationMessage() const = 0; + + virtual void BindEditCommandRoutes( + EditorEditCommandRoute* hierarchyRoute, + EditorEditCommandRoute* projectRoute, + EditorEditCommandRoute* sceneRoute, + EditorEditCommandRoute* inspectorRoute) = 0; + virtual void SyncSessionFromWorkspace( + const UIEditorWorkspaceController& workspaceController) = 0; + virtual void SyncSessionFromCommandFocusService() = 0; + + virtual const UIEditorShellInteractionServices& GetShellServices() const = 0; + virtual EditorPanelServices BuildPanelServices() = 0; + virtual UIEditorShellInteractionDefinition BuildShellDefinition( + const UIEditorWorkspaceController& workspaceController, + std::string_view captureText, + EditorShellVariant variant) const = 0; + + virtual std::optional ConsumeOpenUtilityWindowRequest() = 0; + virtual void SetStatus(std::string status, std::string message) = 0; + virtual void UpdateStatusFromShellResult( + const UIEditorWorkspaceController& workspaceController, + const UIEditorShellInteractionResult& result) = 0; + virtual std::string DescribeWorkspaceState( + const UIEditorWorkspaceController& workspaceController, + const UIEditorShellInteractionState& interactionState) const = 0; + virtual std::vector SyncWorkspacePanelFrameEvents( + const std::vector& panelEvents) = 0; +}; + +} // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Composition/EditorShellVariant.h b/editor/app/Core/Windowing/EditorShellVariant.h similarity index 100% rename from editor/app/Composition/EditorShellVariant.h rename to editor/app/Core/Windowing/EditorShellVariant.h diff --git a/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h b/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h new file mode 100644 index 00000000..e2d86507 --- /dev/null +++ b/editor/app/Core/Windowing/EditorWorkspaceShellRuntime.h @@ -0,0 +1,98 @@ +#pragma once + +#include "Windowing/EditorFrameServices.h" +#include "WorkspacePanels/EditorWorkspacePanelRuntime.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace XCEngine::Rendering { + +class RenderContext; + +} // namespace XCEngine::Rendering + +namespace XCEngine::UI { + +class UIDrawData; +struct UIInputEvent; + +} // namespace XCEngine::UI + +namespace XCEngine::UI::Editor::Rendering::Host { + +class UiTextureHost; +class ViewportRenderHost; + +} // namespace XCEngine::UI::Editor::Rendering::Host + +namespace XCEngine::UI::Editor::Host { + +class EditorHostResourceService; + +} // namespace XCEngine::UI::Editor::Host + +namespace XCEngine::UI::Editor::App { + +class EditorWorkspaceShellRuntime { +public: + virtual ~EditorWorkspaceShellRuntime() = default; + + virtual void Initialize( + const std::filesystem::path& repoRoot, + Rendering::Host::UiTextureHost& textureHost, + Host::EditorHostResourceService& resourceService, + UIEditorTextMeasurer& textMeasurer) = 0; + virtual void Shutdown() = 0; + virtual void ResetInteractionState() = 0; + virtual void AttachViewportWindowRenderer(Rendering::Host::ViewportRenderHost& renderer) = 0; + virtual void DetachViewportWindowRenderer() = 0; + virtual void SetViewportSurfacePresentationEnabled(bool enabled) = 0; + + virtual void Update( + EditorFrameServices& frameServices, + UIEditorWorkspaceController& workspaceController, + const ::XCEngine::UI::UIRect& bounds, + const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents, + std::string_view captureText, + EditorShellVariant shellVariant, + bool useDetachedTitleBarTabStrip, + float detachedTitleBarTabHeight, + float detachedWindowChromeHeight) = 0; + virtual void RenderRequestedViewports( + const ::XCEngine::Rendering::RenderContext& renderContext) = 0; + virtual void Append(::XCEngine::UI::UIDrawData& drawData) const = 0; + + virtual const UIEditorShellInteractionFrame& GetShellFrame() const = 0; + virtual const UIEditorShellInteractionState& GetShellInteractionState() const = 0; + virtual const std::vector& GetTraceEntries() const = 0; + virtual void SetExternalDockHostDropPreview( + const Widgets::UIEditorDockHostDropPreviewState& preview) = 0; + virtual void ClearExternalDockHostDropPreview() = 0; + + virtual EditorWorkspacePanelCursorKind GetHostedContentCursorKind() const = 0; + virtual Widgets::UIEditorDockHostCursorKind GetDockCursorKind() const = 0; + virtual bool TryResolveDockTabDragHotspot( + std::string_view nodeId, + std::string_view panelId, + const ::XCEngine::UI::UIPoint& point, + ::XCEngine::UI::UIPoint& outHotspot) const = 0; + virtual UIEditorDockHostTabDropTarget ResolveDockTabDropTarget( + const ::XCEngine::UI::UIPoint& point) const = 0; + virtual bool HasHostedContentCapture() const = 0; + virtual bool HasShellInteractiveCapture() const = 0; + virtual bool HasInteractiveCapture() const = 0; +}; + +using EditorWorkspaceShellRuntimeFactory = + std::function(EditorWorkspacePanelRuntimeSet)>; + +} // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Content/EditorUtilityWindowContentController.cpp b/editor/app/Windowing/Content/EditorUtilityWindowContentController.cpp index 1fa1de20..d1fe207c 100644 --- a/editor/app/Windowing/Content/EditorUtilityWindowContentController.cpp +++ b/editor/app/Windowing/Content/EditorUtilityWindowContentController.cpp @@ -1,6 +1,5 @@ #include "Content/EditorUtilityWindowContentController.h" -#include "EditorContext.h" #include "UtilityWindows/EditorUtilityWindowRuntime.h" #include @@ -68,7 +67,7 @@ EditorUtilityWindowContentController::UpdateAndAppend( return {}; } - EditorPanelServices services = context.editorContext.BuildPanelServices(); + EditorPanelServices services = context.frameServices.BuildPanelServices(); m_panel->Update( services, EditorUtilityWindowHostContext{ diff --git a/editor/app/Windowing/Content/EditorWindowContentController.cpp b/editor/app/Windowing/Content/EditorWindowContentController.cpp index cf20bd93..ae1f5f57 100644 --- a/editor/app/Windowing/Content/EditorWindowContentController.cpp +++ b/editor/app/Windowing/Content/EditorWindowContentController.cpp @@ -1,24 +1,24 @@ #include "Content/EditorWindowContentController.h" -#include "EditorContext.h" #include "EditorWindowVisuals.h" #include namespace XCEngine::UI::Editor::App { -void EditorWindowContentController::PrepareEditorContext( - EditorContext& context, +void EditorWindowContentController::PrepareFrameServices( + EditorFrameServices& frameServices, UIEditorTextMeasurer& textMeasurer) { - context.AttachTextMeasurer(textMeasurer); + frameServices.AttachTextMeasurer(textMeasurer); } -bool EditorWindowContentController::IsEditorContextValid(const EditorContext& context) const { - return context.IsValid(); +bool EditorWindowContentController::AreFrameServicesValid( + const EditorFrameServices& frameServices) const { + return frameServices.IsValid(); } void EditorWindowContentController::AppendInvalidFrame( - const EditorContext& context, + const EditorFrameServices& frameServices, ::XCEngine::UI::UIDrawList& drawList) const { drawList.AddText( ::XCEngine::UI::UIPoint(28.0f, 28.0f), @@ -27,15 +27,16 @@ void EditorWindowContentController::AppendInvalidFrame( 16.0f); drawList.AddText( ::XCEngine::UI::UIPoint(28.0f, 54.0f), - context.GetValidationMessage().empty() + frameServices.GetValidationMessage().empty() ? std::string("Unknown validation error.") - : context.GetValidationMessage(), + : frameServices.GetValidationMessage(), kShellMutedTextColor, 12.0f); } -void EditorWindowContentController::NotifyStartupCaptureRequested(EditorContext& context) { - context.SetStatus("Capture", "Startup capture requested."); +void EditorWindowContentController::NotifyStartupCaptureRequested( + EditorFrameServices& frameServices) { + frameServices.SetStatus("Capture", "Startup capture requested."); } } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Content/EditorWindowContentController.h b/editor/app/Windowing/Content/EditorWindowContentController.h index 63bed7df..7d77f889 100644 --- a/editor/app/Windowing/Content/EditorWindowContentController.h +++ b/editor/app/Windowing/Content/EditorWindowContentController.h @@ -1,6 +1,7 @@ #pragma once #include "Windowing/EditorWindowTransferRequests.h" +#include "Windowing/EditorFrameServices.h" #include "EditorWindowContentBindings.h" #include @@ -50,8 +51,6 @@ class EditorHostResourceService; namespace XCEngine::UI::Editor::App { -class EditorContext; - struct EditorWindowContentCapabilities { bool workspace = false; bool dockHost = false; @@ -63,7 +62,7 @@ struct EditorWindowContentCapabilities { struct EditorWindowContentInitializationContext { const std::filesystem::path& repoRoot; - EditorContext& editorContext; + EditorFrameServices& frameServices; Rendering::Host::UiTextureHost& textureHost; Host::EditorHostResourceService& resourceService; UIEditorTextMeasurer& textMeasurer; @@ -71,7 +70,7 @@ struct EditorWindowContentInitializationContext { }; struct EditorWindowContentFrameContext { - EditorContext& editorContext; + EditorFrameServices& frameServices; const ::XCEngine::UI::UIRect& bounds; const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents; std::optional cursorScreenPoint = {}; @@ -109,12 +108,14 @@ public: } virtual void Initialize(const EditorWindowContentInitializationContext&) {} - virtual void PrepareEditorContext(EditorContext& context, UIEditorTextMeasurer& textMeasurer); - virtual bool IsEditorContextValid(const EditorContext& context) const; + virtual void PrepareFrameServices( + EditorFrameServices& frameServices, + UIEditorTextMeasurer& textMeasurer); + virtual bool AreFrameServicesValid(const EditorFrameServices& frameServices) const; virtual void AppendInvalidFrame( - const EditorContext& context, + const EditorFrameServices& frameServices, ::XCEngine::UI::UIDrawList& drawList) const; - virtual void NotifyStartupCaptureRequested(EditorContext& context); + virtual void NotifyStartupCaptureRequested(EditorFrameServices& frameServices); virtual void Shutdown() {} virtual void ResetInteractionState() {} virtual void SetViewportSurfacePresentationEnabled(bool) {} diff --git a/editor/app/Windowing/Content/EditorWindowContentFactory.cpp b/editor/app/Windowing/Content/EditorWindowContentFactory.cpp index 6e8de2d8..ea8f15e9 100644 --- a/editor/app/Windowing/Content/EditorWindowContentFactory.cpp +++ b/editor/app/Windowing/Content/EditorWindowContentFactory.cpp @@ -16,9 +16,11 @@ 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( @@ -27,10 +29,14 @@ public: m_workspacePanelFactory ? m_workspacePanelFactory() : EditorWorkspacePanelRuntimeSet{}; + std::unique_ptr shellRuntime = + m_workspaceShellRuntimeFactory + ? m_workspaceShellRuntimeFactory(std::move(workspacePanels)) + : nullptr; return CreateEditorWorkspaceWindowContentController( windowState, m_windowSystem, - std::move(workspacePanels)); + std::move(shellRuntime)); } std::unique_ptr CreateUtilityContentController( @@ -47,6 +53,7 @@ public: private: EditorWindowSystem& m_windowSystem; EditorWorkspacePanelRuntimeSetFactory m_workspacePanelFactory = {}; + EditorWorkspaceShellRuntimeFactory m_workspaceShellRuntimeFactory = {}; EditorUtilityWindowPanelFactory m_utilityPanelFactory = {}; }; @@ -55,10 +62,12 @@ 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 5140c4a9..ae4e2ac2 100644 --- a/editor/app/Windowing/Content/EditorWindowContentFactory.h +++ b/editor/app/Windowing/Content/EditorWindowContentFactory.h @@ -1,6 +1,7 @@ #pragma once #include "UtilityWindows/EditorUtilityWindowRuntime.h" +#include "Windowing/EditorWorkspaceShellRuntime.h" #include "WorkspacePanels/EditorWorkspacePanelRuntime.h" #include @@ -31,6 +32,7 @@ public: std::unique_ptr CreateDefaultEditorWindowContentFactory( EditorWindowSystem& windowSystem, EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, + EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory); } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp index 01ce2c33..eb84217c 100644 --- a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp +++ b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.cpp @@ -40,7 +40,7 @@ EditorWindowContentCursorKind ToContentCursorKind( EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSet workspacePanels) + std::unique_ptr shellRuntime) : m_windowId(windowState.windowId) , m_windowSystem(windowSystem) , m_projection(BuildEditorWorkspaceWindowProjection( @@ -48,7 +48,7 @@ EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController( windowSystem.GetPanelRegistry(), windowState, false)) - , m_shellRuntime(std::move(workspacePanels)) {} + , m_shellRuntime(std::move(shellRuntime)) {} EditorWorkspaceWindowContentController::~EditorWorkspaceWindowContentController() = default; @@ -111,24 +111,33 @@ bool EditorWorkspaceWindowContentController::TryBuildAuthoritativeWorkspaceContr void EditorWorkspaceWindowContentController::Initialize( const EditorWindowContentInitializationContext& context) { - m_shellRuntime.Initialize( + if (m_shellRuntime == nullptr) { + return; + } + m_shellRuntime->Initialize( context.repoRoot, context.textureHost, context.resourceService, context.textMeasurer); - m_shellRuntime.AttachViewportWindowRenderer(context.viewportRenderer); + m_shellRuntime->AttachViewportWindowRenderer(context.viewportRenderer); } void EditorWorkspaceWindowContentController::Shutdown() { - m_shellRuntime.Shutdown(); + if (m_shellRuntime != nullptr) { + m_shellRuntime->Shutdown(); + } } void EditorWorkspaceWindowContentController::ResetInteractionState() { - m_shellRuntime.ResetInteractionState(); + if (m_shellRuntime != nullptr) { + m_shellRuntime->ResetInteractionState(); + } } void EditorWorkspaceWindowContentController::SetViewportSurfacePresentationEnabled(bool enabled) { - m_shellRuntime.SetViewportSurfacePresentationEnabled(enabled); + if (m_shellRuntime != nullptr) { + m_shellRuntime->SetViewportSurfacePresentationEnabled(enabled); + } } EditorWindowFrameTransferRequests EditorWorkspaceWindowContentController::UpdateAndAppend( @@ -143,10 +152,14 @@ EditorWindowFrameTransferRequests EditorWorkspaceWindowContentController::Update return {}; } + if (m_shellRuntime == nullptr) { + return {}; + } + return m_frameOrchestrator.UpdateAndAppend( - context.editorContext, + context.frameServices, workspaceController, - m_shellRuntime, + *m_shellRuntime, context.bounds, context.inputEvents, context.cursorScreenPoint, @@ -159,26 +172,32 @@ EditorWindowFrameTransferRequests EditorWorkspaceWindowContentController::Update void EditorWorkspaceWindowContentController::RenderRequestedViewports( const ::XCEngine::Rendering::RenderContext& renderContext) { - m_shellRuntime.RenderRequestedViewports(renderContext); + if (m_shellRuntime != nullptr) { + m_shellRuntime->RenderRequestedViewports(renderContext); + } } const UIEditorShellInteractionFrame& EditorWorkspaceWindowContentController::GetShellFrame() const { - return m_shellRuntime.GetShellFrame(); + return m_shellRuntime->GetShellFrame(); } const UIEditorShellInteractionState& EditorWorkspaceWindowContentController::GetShellInteractionState() const { - return m_shellRuntime.GetShellInteractionState(); + return m_shellRuntime->GetShellInteractionState(); } void EditorWorkspaceWindowContentController::SetExternalDockHostDropPreview( const Widgets::UIEditorDockHostDropPreviewState& preview) { - m_shellRuntime.SetExternalDockHostDropPreview(preview); + if (m_shellRuntime != nullptr) { + m_shellRuntime->SetExternalDockHostDropPreview(preview); + } } void EditorWorkspaceWindowContentController::ClearExternalDockHostDropPreview() { - m_shellRuntime.ClearExternalDockHostDropPreview(); + if (m_shellRuntime != nullptr) { + m_shellRuntime->ClearExternalDockHostDropPreview(); + } } bool EditorWorkspaceWindowContentController::TryResolveDockTabDragHotspot( @@ -186,7 +205,8 @@ bool EditorWorkspaceWindowContentController::TryResolveDockTabDragHotspot( std::string_view panelId, const ::XCEngine::UI::UIPoint& point, ::XCEngine::UI::UIPoint& outHotspot) const { - return m_shellRuntime.TryResolveDockTabDragHotspot( + return m_shellRuntime != nullptr && + m_shellRuntime->TryResolveDockTabDragHotspot( nodeId, panelId, point, @@ -195,28 +215,34 @@ bool EditorWorkspaceWindowContentController::TryResolveDockTabDragHotspot( UIEditorDockHostTabDropTarget EditorWorkspaceWindowContentController::ResolveDockTabDropTarget( const ::XCEngine::UI::UIPoint& point) const { - return m_shellRuntime.ResolveDockTabDropTarget(point); + return m_shellRuntime != nullptr + ? m_shellRuntime->ResolveDockTabDropTarget(point) + : UIEditorDockHostTabDropTarget{}; } bool EditorWorkspaceWindowContentController::HasHostedContentCapture() const { - return m_shellRuntime.HasHostedContentCapture(); + return m_shellRuntime != nullptr && m_shellRuntime->HasHostedContentCapture(); } bool EditorWorkspaceWindowContentController::HasShellInteractiveCapture() const { - return m_shellRuntime.HasShellInteractiveCapture(); + return m_shellRuntime != nullptr && m_shellRuntime->HasShellInteractiveCapture(); } bool EditorWorkspaceWindowContentController::HasInteractiveCapture() const { - return m_shellRuntime.HasInteractiveCapture(); + return m_shellRuntime != nullptr && m_shellRuntime->HasInteractiveCapture(); } EditorWindowContentCursorKind EditorWorkspaceWindowContentController::GetHostedContentCursorKind() const { - return ToContentCursorKind(m_shellRuntime.GetHostedContentCursorKind()); + return m_shellRuntime != nullptr + ? ToContentCursorKind(m_shellRuntime->GetHostedContentCursorKind()) + : EditorWindowContentCursorKind::Arrow; } EditorWindowContentCursorKind EditorWorkspaceWindowContentController::GetDockCursorKind() const { - return ToContentCursorKind(m_shellRuntime.GetDockCursorKind()); + return m_shellRuntime != nullptr + ? ToContentCursorKind(m_shellRuntime->GetDockCursorKind()) + : EditorWindowContentCursorKind::Arrow; } ::XCEngine::UI::UISize EditorWorkspaceWindowContentController::ResolveMinimumOuterSize() const { @@ -244,11 +270,11 @@ std::string EditorWorkspaceWindowContentController::ResolveDetachedWindowTitleTe std::unique_ptr CreateEditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSet workspacePanels) { + std::unique_ptr shellRuntime) { return std::make_unique( windowState, windowSystem, - std::move(workspacePanels)); + std::move(shellRuntime)); } } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.h b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.h index 2aa30324..99123045 100644 --- a/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.h +++ b/editor/app/Windowing/Content/EditorWorkspaceWindowContentController.h @@ -1,8 +1,8 @@ #pragma once -#include "EditorShellRuntime.h" #include "Content/EditorWindowContentController.h" #include "Frame/EditorWindowFrameOrchestrator.h" +#include "Windowing/EditorWorkspaceShellRuntime.h" #include @@ -25,7 +25,7 @@ public: EditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSet workspacePanels); + std::unique_ptr shellRuntime); ~EditorWorkspaceWindowContentController() override; EditorWindowContentCapabilities GetCapabilities() const override; @@ -82,13 +82,13 @@ private: std::string m_windowId = {}; EditorWindowSystem& m_windowSystem; EditorWorkspaceWindowProjection m_projection = {}; - EditorShellRuntime m_shellRuntime = {}; + std::unique_ptr m_shellRuntime = {}; EditorWindowFrameOrchestrator m_frameOrchestrator = {}; }; std::unique_ptr CreateEditorWorkspaceWindowContentController( const UIEditorWindowWorkspaceState& windowState, EditorWindowSystem& windowSystem, - EditorWorkspacePanelRuntimeSet workspacePanels); + std::unique_ptr shellRuntime); } // namespace XCEngine::UI::Editor::App diff --git a/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.cpp b/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.cpp index 2f794d7e..1f802e98 100644 --- a/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.cpp +++ b/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.cpp @@ -31,14 +31,12 @@ int ResolveOuterDimension(float value, int fallback) { } EditorUtilityWindowCoordinator::EditorUtilityWindowCoordinator( - EditorContext& editorContext, EditorWindowHost& hostRuntime, EditorWindowManager& windowManager, Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, EditorWindowContentFactory& contentFactory) : m_hostRuntime(hostRuntime), m_windowManager(windowManager), - m_editorContext(editorContext), m_renderRuntimeFactory(renderRuntimeFactory), m_contentFactory(contentFactory) {} diff --git a/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.h b/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.h index 90aaae03..ad934204 100644 --- a/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.h +++ b/editor/app/Windowing/Coordinator/EditorUtilityWindowCoordinator.h @@ -11,7 +11,6 @@ class EditorWindowRenderRuntimeFactory; namespace XCEngine::UI::Editor::App { -class EditorContext; class EditorWindowContentFactory; class EditorWindowLifecycleCoordinator; class EditorWindowManager; @@ -19,7 +18,6 @@ class EditorWindowManager; class EditorUtilityWindowCoordinator final { public: EditorUtilityWindowCoordinator( - EditorContext& editorContext, EditorWindowHost& hostRuntime, EditorWindowManager& windowManager, Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, @@ -39,7 +37,6 @@ private: EditorWindowHost& m_hostRuntime; EditorWindowManager& m_windowManager; - EditorContext& m_editorContext; Rendering::Host::EditorWindowRenderRuntimeFactory& m_renderRuntimeFactory; EditorWindowContentFactory& m_contentFactory; EditorWindowLifecycleCoordinator* m_lifecycleCoordinator = nullptr; diff --git a/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.cpp b/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.cpp index 0f0b1dcf..2e1379a4 100644 --- a/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.cpp +++ b/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.cpp @@ -93,7 +93,6 @@ std::string DescribeWindowSetState(const UIEditorWindowWorkspaceSet& windowSet) } // namespace EditorWindowWorkspaceCoordinator::EditorWindowWorkspaceCoordinator( - EditorContext& editorContext, EditorWindowHost& hostRuntime, EditorWindowManager& windowManager, EditorWindowSystem& windowSystem, @@ -101,7 +100,6 @@ EditorWindowWorkspaceCoordinator::EditorWindowWorkspaceCoordinator( EditorWindowContentFactory& contentFactory) : m_hostRuntime(hostRuntime), m_windowManager(windowManager), - m_editorContext(editorContext), m_windowSystem(windowSystem), m_renderRuntimeFactory(renderRuntimeFactory), m_contentFactory(contentFactory) {} diff --git a/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.h b/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.h index f2e60c77..d2a549eb 100644 --- a/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.h +++ b/editor/app/Windowing/Coordinator/EditorWindowWorkspaceCoordinator.h @@ -26,7 +26,6 @@ class EditorWindowRenderRuntimeFactory; namespace XCEngine::UI::Editor::App { -class EditorContext; class EditorWindowContentFactory; class EditorWindowLifecycleCoordinator; class EditorWindowManager; @@ -34,7 +33,6 @@ class EditorWindowManager; class EditorWindowWorkspaceCoordinator final { public: EditorWindowWorkspaceCoordinator( - EditorContext& editorContext, EditorWindowHost& hostRuntime, EditorWindowManager& windowManager, EditorWindowSystem& windowSystem, @@ -124,7 +122,6 @@ private: EditorWindowHost& m_hostRuntime; EditorWindowManager& m_windowManager; - EditorContext& m_editorContext; EditorWindowSystem& m_windowSystem; Rendering::Host::EditorWindowRenderRuntimeFactory& m_renderRuntimeFactory; EditorWindowContentFactory& m_contentFactory; diff --git a/editor/app/Windowing/EditorWindowInstance.cpp b/editor/app/Windowing/EditorWindowInstance.cpp index be8fd69e..e99e071c 100644 --- a/editor/app/Windowing/EditorWindowInstance.cpp +++ b/editor/app/Windowing/EditorWindowInstance.cpp @@ -346,7 +346,7 @@ EditorWindowFrameTransferRequests EditorWindowInstance::RenderHostFrame( kShellSurfaceColor); EditorWindowFrameTransferRequests transferRequests = {}; - if (m_runtime->IsEditorContextValid()) { + if (m_runtime->AreFrameServicesValid()) { transferRequests = RenderRuntimeFrame(globalTabDragActive, frameSnapshot, drawData); } else { @@ -446,7 +446,7 @@ EditorWindowFrameTransferRequests EditorWindowInstance::RenderRuntimeFrame( return {}; } - m_runtime->PrepareEditorContext(); + m_runtime->PrepareFrameServices(); const auto frameContext = m_runtime->BeginFrame(); if (!frameContext.warning.empty()) { AppendUIEditorRuntimeTrace("viewport", frameContext.warning); diff --git a/editor/app/Windowing/EditorWindowManager.cpp b/editor/app/Windowing/EditorWindowManager.cpp index 7ccee8a8..63412700 100644 --- a/editor/app/Windowing/EditorWindowManager.cpp +++ b/editor/app/Windowing/EditorWindowManager.cpp @@ -20,24 +20,25 @@ namespace XCEngine::UI::Editor::App { EditorWindowManager::EditorWindowManager( - EditorContext& editorContext, + EditorFrameServices& frameServices, EditorWindowSystem& windowSystem, Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, Host::EditorHostResourceService& resourceService, EditorWindowHostRuntimeServices& hostRuntime, EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, + EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory) - : m_editorContext(editorContext) + : m_frameServices(frameServices) , m_renderRuntimeFactory(renderRuntimeFactory) , m_resourceService(resourceService) , m_hostRuntime(hostRuntime) { m_contentFactory = CreateDefaultEditorWindowContentFactory( windowSystem, std::move(workspacePanelFactory), + std::move(workspaceShellRuntimeFactory), std::move(utilityPanelFactory)); m_workspaceCoordinator = std::make_unique( - m_editorContext, m_hostRuntime, *this, windowSystem, @@ -45,7 +46,6 @@ EditorWindowManager::EditorWindowManager( *m_contentFactory); m_utilityCoordinator = std::make_unique( - m_editorContext, m_hostRuntime, *this, m_renderRuntimeFactory, @@ -80,7 +80,7 @@ EditorHostWindow* EditorWindowManager::CreateWorkspaceWindow( params.chromePolicy, params.primary, std::make_unique( - m_editorContext, + m_frameServices, m_resourceService, m_contentFactory->CreateWorkspaceContentController(windowState), m_renderRuntimeFactory.CreateWindowRenderRuntime())); @@ -109,7 +109,7 @@ EditorHostWindow* EditorWindowManager::CreateUtilityWindow( params.chromePolicy, params.primary, std::make_unique( - m_editorContext, + m_frameServices, m_resourceService, m_contentFactory->CreateUtilityContentController(descriptor), m_renderRuntimeFactory.CreateWindowRenderRuntime())); diff --git a/editor/app/Windowing/EditorWindowManager.h b/editor/app/Windowing/EditorWindowManager.h index 16a24d7a..030d2d75 100644 --- a/editor/app/Windowing/EditorWindowManager.h +++ b/editor/app/Windowing/EditorWindowManager.h @@ -5,6 +5,8 @@ #endif #include "UtilityWindows/EditorUtilityWindowRuntime.h" +#include "Windowing/EditorFrameServices.h" +#include "Windowing/EditorWorkspaceShellRuntime.h" #include "EditorWindowHostCoordinator.h" #include "EditorWindowHostInterfaces.h" #include "EditorWindowHostTypes.h" @@ -33,7 +35,6 @@ class EditorHostResourceService; namespace XCEngine::UI::Editor::App { -class EditorContext; class EditorWindowContentFactory; class EditorWindowHostRuntimeServices; class EditorWindowLifecycleCoordinator; @@ -45,12 +46,13 @@ struct EditorWindowFrameTransferRequests; class EditorWindowManager final : public EditorWindowHostCoordinator { public: EditorWindowManager( - EditorContext& editorContext, + EditorFrameServices& frameServices, EditorWindowSystem& windowSystem, Rendering::Host::EditorWindowRenderRuntimeFactory& renderRuntimeFactory, Host::EditorHostResourceService& resourceService, EditorWindowHostRuntimeServices& hostRuntime, EditorWorkspacePanelRuntimeSetFactory workspacePanelFactory, + EditorWorkspaceShellRuntimeFactory workspaceShellRuntimeFactory, EditorUtilityWindowPanelFactory utilityPanelFactory); ~EditorWindowManager(); @@ -97,7 +99,7 @@ private: EditorHostWindow& window, bool requestSkipNextSteadyStateFrame); - EditorContext& m_editorContext; + EditorFrameServices& m_frameServices; Rendering::Host::EditorWindowRenderRuntimeFactory& m_renderRuntimeFactory; Host::EditorHostResourceService& m_resourceService; EditorWindowHostRuntimeServices& m_hostRuntime; diff --git a/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.cpp b/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.cpp index d61acf82..f066d972 100644 --- a/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.cpp +++ b/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.cpp @@ -1,8 +1,5 @@ #include "Frame/EditorWindowFrameOrchestrator.h" -#include "EditorContext.h" -#include "EditorShellRuntime.h" -#include "EditorShellVariant.h" #include "Windowing/EditorWindowMetrics.h" #include "EditorWindowDiagnostics.h" #include "EditorWindowVisuals.h" @@ -48,9 +45,9 @@ std::string DescribeInputEventType(const UIInputEvent& event) { } // namespace EditorWindowFrameTransferRequests EditorWindowFrameOrchestrator::UpdateAndAppend( - EditorContext& editorContext, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, - EditorShellRuntime& shellRuntime, + EditorWorkspaceShellRuntime& shellRuntime, const ::XCEngine::UI::UIRect& workspaceBounds, const std::vector& frameEvents, const std::optional& cursorScreenPoint, @@ -60,13 +57,13 @@ EditorWindowFrameTransferRequests EditorWindowFrameOrchestrator::UpdateAndAppend bool useDetachedTitleBarTabStrip, UIDrawData& drawData) const { LogInputTrace( - editorContext, + frameServices, workspaceController, shellRuntime.GetShellInteractionState(), frameEvents); shellRuntime.Update( - editorContext, + frameServices, workspaceController, workspaceBounds, frameEvents, @@ -87,7 +84,7 @@ EditorWindowFrameTransferRequests EditorWindowFrameOrchestrator::UpdateAndAppend dockHostInteractionState, shellFrame); if (const std::optional requestedKind = - editorContext.ConsumeOpenUtilityWindowRequest(); + frameServices.ConsumeOpenUtilityWindowRequest(); requestedKind.has_value()) { transferRequests.utility.openUtilityWindow = EditorWindowOpenUtilityWindowRequest{ .kind = *requestedKind, @@ -107,7 +104,7 @@ EditorWindowFrameTransferRequests EditorWindowFrameOrchestrator::UpdateAndAppend } void EditorWindowFrameOrchestrator::AppendInvalidFrame( - EditorContext& editorContext, + EditorFrameServices& frameServices, UIDrawList& drawList) const { drawList.AddText( UIPoint(28.0f, 28.0f), @@ -116,9 +113,9 @@ void EditorWindowFrameOrchestrator::AppendInvalidFrame( 16.0f); drawList.AddText( UIPoint(28.0f, 54.0f), - editorContext.GetValidationMessage().empty() + frameServices.GetValidationMessage().empty() ? std::string("Unknown validation error.") - : editorContext.GetValidationMessage(), + : frameServices.GetValidationMessage(), kShellMutedTextColor, 12.0f); } @@ -144,7 +141,7 @@ std::string EditorWindowFrameOrchestrator::DescribeInputEvents( } void EditorWindowFrameOrchestrator::LogInputTrace( - EditorContext& editorContext, + EditorFrameServices& frameServices, const UIEditorWorkspaceController& workspaceController, const UIEditorShellInteractionState& shellInteractionState, const std::vector& frameEvents) const { @@ -155,7 +152,7 @@ void EditorWindowFrameOrchestrator::LogInputTrace( AppendUIEditorRuntimeTrace( "input", DescribeInputEvents(frameEvents) + " | " + - editorContext.DescribeWorkspaceState( + frameServices.DescribeWorkspaceState( workspaceController, shellInteractionState)); } diff --git a/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.h b/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.h index 3d7c89c2..b8e9ce81 100644 --- a/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.h +++ b/editor/app/Windowing/Frame/EditorWindowFrameOrchestrator.h @@ -1,6 +1,8 @@ #pragma once #include "Windowing/EditorWindowTransferRequests.h" +#include "Windowing/EditorFrameServices.h" +#include "Windowing/EditorWorkspaceShellRuntime.h" #include @@ -31,9 +33,6 @@ struct UIEditorShellInteractionState; namespace XCEngine::UI::Editor::App { -class EditorContext; -class EditorShellRuntime; - class EditorWindowFrameOrchestrator final { public: EditorWindowFrameOrchestrator() = default; @@ -45,9 +44,9 @@ public: EditorWindowFrameOrchestrator& operator=(EditorWindowFrameOrchestrator&&) = delete; EditorWindowFrameTransferRequests UpdateAndAppend( - EditorContext& editorContext, + EditorFrameServices& frameServices, UIEditorWorkspaceController& workspaceController, - EditorShellRuntime& shellRuntime, + EditorWorkspaceShellRuntime& shellRuntime, const ::XCEngine::UI::UIRect& workspaceBounds, const std::vector<::XCEngine::UI::UIInputEvent>& frameEvents, const std::optional& cursorScreenPoint, @@ -57,14 +56,14 @@ public: bool useDetachedTitleBarTabStrip, ::XCEngine::UI::UIDrawData& drawData) const; void AppendInvalidFrame( - EditorContext& editorContext, + EditorFrameServices& frameServices, ::XCEngine::UI::UIDrawList& drawList) const; std::string DescribeInputEvents( const std::vector<::XCEngine::UI::UIInputEvent>& events) const; private: void LogInputTrace( - EditorContext& editorContext, + EditorFrameServices& frameServices, const UIEditorWorkspaceController& workspaceController, const UIEditorShellInteractionState& shellInteractionState, const std::vector<::XCEngine::UI::UIInputEvent>& frameEvents) const; diff --git a/editor/app/Windowing/Runtime/EditorWindowRuntimeController.cpp b/editor/app/Windowing/Runtime/EditorWindowRuntimeController.cpp index 5bc18212..e6a0d4d6 100644 --- a/editor/app/Windowing/Runtime/EditorWindowRuntimeController.cpp +++ b/editor/app/Windowing/Runtime/EditorWindowRuntimeController.cpp @@ -44,11 +44,11 @@ bool LoadHostPngTexture( } EditorWindowRuntimeController::EditorWindowRuntimeController( - EditorContext& editorContext, + EditorFrameServices& frameServices, Host::EditorHostResourceService& resourceService, std::unique_ptr contentController, std::unique_ptr renderRuntime) - : m_editorContext(editorContext) + : m_frameServices(frameServices) , m_resourceService(resourceService) , m_renderRuntime(std::move(renderRuntime)) , m_contentController(std::move(contentController)) {} @@ -163,12 +163,12 @@ bool EditorWindowRuntimeController::Initialize( } assert(m_contentController != nullptr); - m_contentController->PrepareEditorContext( - m_editorContext, + m_contentController->PrepareFrameServices( + m_frameServices, m_renderRuntime->GetTextMeasurer()); m_contentController->Initialize(EditorWindowContentInitializationContext{ .repoRoot = repoRoot, - .editorContext = m_editorContext, + .frameServices = m_frameServices, .textureHost = m_renderRuntime->GetTextureHost(), .resourceService = m_resourceService, .textMeasurer = m_renderRuntime->GetTextMeasurer(), @@ -204,7 +204,7 @@ bool EditorWindowRuntimeController::Initialize( m_resourceService.GetExecutableDirectory()); if (autoCaptureOnStartup) { m_screenshotController.RequestCapture("startup"); - m_contentController->NotifyStartupCaptureRequested(m_editorContext); + m_contentController->NotifyStartupCaptureRequested(m_frameServices); } return true; @@ -261,23 +261,23 @@ bool EditorWindowRuntimeController::ApplyResize(std::uint32_t width, std::uint32 return resizeResult.hasViewportSurfacePresentation; } -void EditorWindowRuntimeController::PrepareEditorContext() { +void EditorWindowRuntimeController::PrepareFrameServices() { if (m_contentController != nullptr && m_renderRuntime != nullptr) { - m_contentController->PrepareEditorContext( - m_editorContext, + m_contentController->PrepareFrameServices( + m_frameServices, m_renderRuntime->GetTextMeasurer()); } } -bool EditorWindowRuntimeController::IsEditorContextValid() const { +bool EditorWindowRuntimeController::AreFrameServicesValid() const { return m_contentController != nullptr && - m_contentController->IsEditorContextValid(m_editorContext); + m_contentController->AreFrameServicesValid(m_frameServices); } void EditorWindowRuntimeController::AppendInvalidFrame( ::XCEngine::UI::UIDrawList& drawList) const { if (m_contentController != nullptr) { - m_contentController->AppendInvalidFrame(m_editorContext, drawList); + m_contentController->AppendInvalidFrame(m_frameServices, drawList); } } @@ -337,7 +337,7 @@ EditorWindowFrameTransferRequests EditorWindowRuntimeController::UpdateAndAppend assert(m_contentController != nullptr); return m_contentController->UpdateAndAppend( EditorWindowContentFrameContext{ - .editorContext = m_editorContext, + .frameServices = m_frameServices, .bounds = bounds, .inputEvents = inputEvents, .cursorScreenPoint = cursorScreenPoint, diff --git a/editor/app/Windowing/Runtime/EditorWindowRuntimeController.h b/editor/app/Windowing/Runtime/EditorWindowRuntimeController.h index 9cfbdbb6..74e87082 100644 --- a/editor/app/Windowing/Runtime/EditorWindowRuntimeController.h +++ b/editor/app/Windowing/Runtime/EditorWindowRuntimeController.h @@ -6,6 +6,7 @@ #include "Content/EditorWindowContentController.h" #include "Runtime/EditorWindowScreenshotController.h" +#include "Windowing/EditorFrameServices.h" #include "EditorWindowRenderRuntime.h" @@ -25,12 +26,6 @@ class UIDrawList; } // namespace XCEngine::UI -namespace XCEngine::UI::Editor::App { - -class EditorContext; - -} // namespace XCEngine::UI::Editor::App - namespace XCEngine::UI::Editor::Host { class EditorHostResourceService; @@ -42,7 +37,7 @@ namespace XCEngine::UI::Editor::App { class EditorWindowRuntimeController final { public: EditorWindowRuntimeController( - EditorContext& editorContext, + EditorFrameServices& frameServices, Host::EditorHostResourceService& resourceService, std::unique_ptr contentController, std::unique_ptr renderRuntime); @@ -81,8 +76,8 @@ public: void ResetInteractionState(); bool ApplyResize(std::uint32_t width, std::uint32_t height); - void PrepareEditorContext(); - bool IsEditorContextValid() const; + void PrepareFrameServices(); + bool AreFrameServicesValid() const; void AppendInvalidFrame(::XCEngine::UI::UIDrawList& drawList) const; Rendering::Host::EditorWindowRenderRuntimeFrameContext BeginFrame(); Rendering::Host::EditorWindowRenderRuntimePresentResult Present( @@ -107,7 +102,7 @@ private: void UpdateFrameTiming(); void RefreshDisplayedFrameStats(); - EditorContext& m_editorContext; + EditorFrameServices& m_frameServices; Host::EditorHostResourceService& m_resourceService; std::unique_ptr m_renderRuntime = {}; EditorWindowScreenshotController m_screenshotController = {};