Refactor editor windowing and update renderer regression

This commit is contained in:
2026-04-26 03:41:58 +08:00
parent 68993c46bb
commit 4fcaac81d6
39 changed files with 1181 additions and 872 deletions

View File

@@ -1,5 +1,9 @@
#include "Windowing/Content/EditorWorkspaceWindowContentController.h"
#include "Windowing/System/EditorWindowPresentationPolicy.h"
#include "Windowing/System/EditorWindowSystem.h"
#include <XCEditor/Foundation/UIEditorRuntimeTrace.h>
#include <XCEditor/Workspace/UIEditorDetachedWindowPolicy.h>
#include <XCEditor/Workspace/UIEditorWorkspaceLayoutPersistence.h>
@@ -49,10 +53,12 @@ EditorWorkspaceWindowProjection BuildWorkspaceProjectionFromController(
EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController(
std::string windowId,
UIEditorWorkspaceController workspaceController)
UIEditorWorkspaceController workspaceController,
EditorWindowSystem& windowSystem)
: m_windowId(std::move(windowId)),
m_workspaceController(std::move(workspaceController)) {
m_projection = BuildWorkspaceProjectionFromController(m_workspaceController, m_windowId);
m_workspaceController(std::move(workspaceController)),
m_windowSystem(windowSystem) {
RefreshProjectionFromWorkspaceController();
}
EditorWorkspaceWindowContentController::~EditorWorkspaceWindowContentController() = default;
@@ -125,6 +131,27 @@ void EditorWorkspaceWindowContentController::RefreshWorkspaceProjection(
m_projection = std::move(projection);
}
void EditorWorkspaceWindowContentController::RefreshProjectionFromWorkspaceController(bool primary) {
const std::wstring preservedWindowTitle = m_projection.windowTitle;
m_projection = BuildWorkspaceProjectionFromController(m_workspaceController, m_windowId);
if (!primary) {
m_projection.windowTitle = ResolveEditorWindowPresentationTitle(
std::wstring_view{},
m_workspaceController.GetPanelRegistry(),
m_projection.windowState,
false);
} else if (!preservedWindowTitle.empty()) {
m_projection.windowTitle = preservedWindowTitle;
}
}
void EditorWorkspaceWindowContentController::RestoreWorkspaceControllerFromProjection() {
m_workspaceController = UIEditorWorkspaceController(
m_workspaceController.GetPanelRegistry(),
m_projection.windowState.workspace,
m_projection.windowState.session);
}
void EditorWorkspaceWindowContentController::Initialize(
const EditorWindowContentInitializationContext& context) {
m_shellRuntime.Initialize(context.repoRoot, context.textureHost, context.textMeasurer);
@@ -165,14 +192,19 @@ EditorWindowFrameTransferRequests EditorWorkspaceWindowContentController::Update
m_workspaceController.GetWorkspace(),
m_workspaceController.GetSession());
if (!AreUIEditorWorkspaceLayoutSnapshotsEquivalent(beforeSnapshot, afterSnapshot)) {
transferRequests.workspace.workspaceMutation = EditorWindowWorkspaceMutationRequest{
.windowState =
UIEditorWindowWorkspaceState{
.windowId = m_windowId,
.workspace = m_workspaceController.GetWorkspace(),
.session = m_workspaceController.GetSession(),
},
};
std::string error = {};
if (!m_windowSystem.CommitLiveWindowMutation(
m_windowId,
m_workspaceController,
error)) {
AppendUIEditorRuntimeTrace(
"window",
"workspace direct commit rejected for window '" +
m_windowId + "': " + error);
RestoreWorkspaceControllerFromProjection();
} else {
RefreshProjectionFromWorkspaceController(context.primary);
}
}
return transferRequests;
}
@@ -263,10 +295,12 @@ std::string EditorWorkspaceWindowContentController::ResolveDetachedWindowTitleTe
std::unique_ptr<EditorWindowContentController> CreateEditorWorkspaceWindowContentController(
std::string_view windowId,
UIEditorWorkspaceController workspaceController) {
UIEditorWorkspaceController workspaceController,
EditorWindowSystem& windowSystem) {
return std::make_unique<EditorWorkspaceWindowContentController>(
std::string(windowId),
std::move(workspaceController));
std::move(workspaceController),
windowSystem);
}
} // namespace XCEngine::UI::Editor::App