refactor(editor): isolate windowing from composition runtime

This commit is contained in:
2026-04-27 23:45:24 +08:00
parent 603d003684
commit 6b488d5eac
34 changed files with 418 additions and 193 deletions

View File

@@ -40,7 +40,7 @@ EditorWindowContentCursorKind ToContentCursorKind(
EditorWorkspaceWindowContentController::EditorWorkspaceWindowContentController(
const UIEditorWindowWorkspaceState& windowState,
EditorWindowSystem& windowSystem,
EditorWorkspacePanelRuntimeSet workspacePanels)
std::unique_ptr<EditorWorkspaceShellRuntime> 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<EditorWindowContentController> CreateEditorWorkspaceWindowContentController(
const UIEditorWindowWorkspaceState& windowState,
EditorWindowSystem& windowSystem,
EditorWorkspacePanelRuntimeSet workspacePanels) {
std::unique_ptr<EditorWorkspaceShellRuntime> shellRuntime) {
return std::make_unique<EditorWorkspaceWindowContentController>(
windowState,
windowSystem,
std::move(workspacePanels));
std::move(shellRuntime));
}
} // namespace XCEngine::UI::Editor::App