Align SRP boundaries and editor windowing

This commit is contained in:
2026-04-26 17:14:32 +08:00
parent a8256b05cd
commit b8599a8aff
38 changed files with 696 additions and 650 deletions

View File

@@ -1,12 +1,10 @@
#include "Platform/Win32/Windowing/EditorWindow.h"
#include "Bootstrap/EditorResources.h"
#include "Platform/Win32/Chrome/EditorWindowChromeController.h"
#include "Windowing/Content/EditorWindowContentController.h"
#include "Platform/Win32/Runtime/EditorWindowFrameDriver.h"
#include "Platform/Win32/Windowing/EditorWindowSession.h"
#include "Platform/Win32/Windowing/EditorWindowSupport.h"
#include "Platform/Win32/Runtime/EditorWindowInputController.h"
#include "Platform/Win32/Runtime/EditorWindowRuntimeController.h"
#include "Windowing/Runtime/EditorWindowRuntimeController.h"
#include <XCEditor/Docking/UIEditorDockHostTransfer.h>
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
#include <XCEditor/Shell/UIEditorShellInteraction.h>
@@ -88,7 +86,7 @@ EditorWindow::EditorWindow(
EditorWindowCategory category,
EditorWindowChromePolicy chromePolicy,
bool primary,
std::unique_ptr<EditorWindowContentController> contentController)
std::unique_ptr<EditorWindowRuntimeController> runtimeController)
: m_session(std::make_unique<EditorWindowSession>(
std::move(windowId),
std::move(title),
@@ -97,8 +95,7 @@ EditorWindow::EditorWindow(
primary))
, m_chromeController(std::make_unique<EditorWindowChromeController>())
, m_inputController(std::make_unique<EditorWindowInputController>())
, m_runtime(std::make_unique<EditorWindowRuntimeController>(
std::move(contentController))) {}
, m_runtime(std::move(runtimeController)) {}
EditorWindow::~EditorWindow() = default;
@@ -226,11 +223,8 @@ void EditorWindow::InvalidateHostWindow() const {
}
}
bool EditorWindow::Initialize(
const std::filesystem::path& repoRoot,
EditorContext& editorContext,
const std::filesystem::path& captureRoot,
bool autoCaptureOnStartup) {
bool EditorWindow::InitializeRuntime(
const EditorHostWindowRuntimeInitializationParams& params) {
if (m_session->GetHwnd() == nullptr) {
LogRuntimeTrace("app", "window initialize skipped: hwnd is null");
return false;
@@ -250,10 +244,9 @@ bool EditorWindow::Initialize(
MarkInitializing();
const bool initialized = m_runtime->Initialize(
m_session->GetHwnd(),
repoRoot,
editorContext,
captureRoot,
autoCaptureOnStartup);
params.repoRoot,
params.captureRoot,
params.autoCaptureOnStartup);
if (initialized) {
MarkRunning();
} else {
@@ -614,8 +607,7 @@ std::uint8_t ResolveExpectedShellCaptureButtons(
} // namespace
EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
EditorContext& editorContext,
EditorWindowFrameTransferRequests EditorWindow::RenderHostFrame(
bool globalTabDragActive) {
if (!m_runtime->IsReady() || m_session->GetHwnd() == nullptr) {
return {};
@@ -638,12 +630,12 @@ EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
kShellSurfaceColor);
EditorWindowFrameTransferRequests transferRequests = {};
if (m_runtime->IsEditorContextValid(editorContext)) {
if (m_runtime->IsEditorContextValid()) {
transferRequests =
RenderRuntimeFrame(editorContext, globalTabDragActive, workspaceBounds, drawData);
RenderRuntimeFrame(globalTabDragActive, workspaceBounds, drawData);
} else {
UIDrawList& invalidDrawList = drawData.EmplaceDrawList("XCEditorWindow.Invalid");
m_runtime->AppendInvalidFrame(editorContext, invalidDrawList);
m_runtime->AppendInvalidFrame(invalidDrawList);
}
UIDrawList& windowChromeDrawList = drawData.EmplaceDrawList("XCEditorWindow.Chrome");
@@ -656,22 +648,11 @@ EditorWindowFrameTransferRequests EditorWindow::RenderFrame(
return transferRequests;
}
EditorWindowFrameTransferRequests EditorWindow::OnPaintMessage(
EditorContext& editorContext,
bool globalTabDragActive) {
if (!m_runtime->IsReady() || m_session->GetHwnd() == nullptr) {
return {};
void EditorWindow::ValidateHostFrame() const {
if (const HWND hwnd = m_session->GetHwnd();
hwnd != nullptr && IsWindow(hwnd)) {
ValidateRect(hwnd, nullptr);
}
PAINTSTRUCT paintStruct = {};
BeginPaint(m_session->GetHwnd(), &paintStruct);
const EditorWindowFrameTransferRequests transferRequests =
EditorWindowFrameDriver::DriveImmediateFrame(
*this,
editorContext,
globalTabDragActive);
EndPaint(m_session->GetHwnd(), &paintStruct);
return transferRequests;
}
void EditorWindow::QueueCompletedImmediateFrame(
@@ -710,7 +691,6 @@ UIRect EditorWindow::ResolveWorkspaceBounds(float clientWidthDips, float clientH
}
EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
EditorContext& editorContext,
bool globalTabDragActive,
const UIRect& workspaceBounds,
UIDrawData& drawData) {
@@ -718,7 +698,7 @@ EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
std::vector<UIInputEvent> frameEvents = m_inputController->TakePendingEvents();
const bool useDetachedTitleBarTabStrip =
m_chromeController->ShouldUseDetachedTitleBarTabStrip(*this);
m_runtime->PrepareEditorContext(editorContext);
m_runtime->PrepareEditorContext();
const Host::D3D12WindowRenderLoopFrameContext frameContext = m_runtime->BeginFrame();
if (!frameContext.warning.empty()) {
LogRuntimeTrace("viewport", frameContext.warning);
@@ -726,16 +706,12 @@ EditorWindowFrameTransferRequests EditorWindow::RenderRuntimeFrame(
const EditorWindowFrameTransferRequests transferRequests =
m_runtime->UpdateAndAppend(
EditorWindowContentFrameContext{
.editorContext = editorContext,
.bounds = workspaceBounds,
.inputEvents = frameEvents,
.cursorScreenPoint = QueryCursorScreenPoint(),
.captureStatusText = m_runtime->BuildCaptureStatusText(),
.primary = m_session->IsPrimary(),
.globalTabDragActive = globalTabDragActive,
.useDetachedTitleBarTabStrip = useDetachedTitleBarTabStrip,
},
workspaceBounds,
frameEvents,
QueryCursorScreenPoint(),
m_session->IsPrimary(),
globalTabDragActive,
useDetachedTitleBarTabStrip,
drawData);
if (frameContext.canRenderViewports) {
m_runtime->RenderRequestedViewports(frameContext.renderContext);