Refactor editor panel services boundary

This commit is contained in:
2026-04-27 16:22:46 +08:00
parent 048ca7b362
commit 9f299ab6e3
17 changed files with 228 additions and 123 deletions

View File

@@ -9,7 +9,6 @@
#include "Features/Scene/SceneViewportFeature.h"
#include "Rendering/Assets/BuiltInIcons.h"
#include "Rendering/Viewport/ViewportHostService.h"
#include "Composition/EditorContext.h"
#include <XCEditor/Panels/UIEditorHostedPanelDispatch.h>
@@ -201,7 +200,7 @@ public:
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_panel.Update(
context.context.GetSession(),
context.services.session,
ResolveHostedPanelDispatchEntry(
context.shellFrame.hostedPanelDispatchFrame,
GetPanelId()));
@@ -244,10 +243,10 @@ public:
}
void PrepareForShellDefinition(
EditorContext& context,
EditorPanelServices& services,
UIEditorWorkspaceController&) override {
m_panel.SetSceneRuntime(&context.GetSceneRuntime());
m_panel.SetCommandFocusService(&context.GetCommandFocusService());
m_panel.SetSceneRuntime(&services.sceneRuntime);
m_panel.SetCommandFocusService(&services.commandFocusService);
}
void Update(const EditorWorkspacePanelUpdateContext& context) override {
@@ -305,9 +304,9 @@ public:
}
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_panel.SetCommandFocusService(&context.context.GetCommandFocusService());
m_panel.SetCommandFocusService(&context.services.commandFocusService);
m_panel.Update(
context.context,
context.services,
ResolveHostedPanelDispatchEntry(
context.shellFrame.hostedPanelDispatchFrame,
GetPanelId()),
@@ -354,9 +353,9 @@ public:
}
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_panel.SetProjectRuntime(&context.context.GetProjectRuntime());
m_panel.SetCommandFocusService(&context.context.GetCommandFocusService());
m_panel.SetSystemInteractionHost(context.context.GetSystemInteractionHost());
m_panel.SetProjectRuntime(&context.services.projectRuntime);
m_panel.SetCommandFocusService(&context.services.commandFocusService);
m_panel.SetSystemInteractionHost(context.services.systemInteractionHost);
m_panel.Update(
ResolveHostedPanelDispatchEntry(
context.shellFrame.hostedPanelDispatchFrame,
@@ -438,16 +437,16 @@ public:
}
void PrepareForShellDefinition(
EditorContext& context,
EditorPanelServices& services,
UIEditorWorkspaceController&) override {
m_commandRoute.BindSceneRuntime(&context.GetSceneRuntime());
m_feature.SetCommandFocusService(&context.GetCommandFocusService());
m_feature.SyncRenderRequest(context.GetSceneRuntime());
m_commandRoute.BindSceneRuntime(&services.sceneRuntime);
m_feature.SetCommandFocusService(&services.commandFocusService);
m_feature.SyncRenderRequest(services.sceneRuntime);
}
void Update(const EditorWorkspacePanelUpdateContext& context) override {
m_feature.Update(
context.context.GetSceneRuntime(),
context.services.sceneRuntime,
context.shellInteractionState.workspaceInteractionState.composeState,
context.shellFrame.workspaceInteractionFrame.composeFrame);
}
@@ -495,26 +494,19 @@ void EditorWorkspacePanelRuntimeSet::ResetInteractionState() {
}
void EditorWorkspacePanelRuntimeSet::PrepareForShellDefinition(
EditorContext& context,
EditorPanelServices& services,
UIEditorWorkspaceController& workspaceController) {
for (const std::unique_ptr<EditorWorkspacePanel>& panel : m_panels) {
panel->PrepareForShellDefinition(context, workspaceController);
panel->PrepareForShellDefinition(services, workspaceController);
}
}
void EditorWorkspacePanelRuntimeSet::Update(
const EditorWorkspacePanelUpdateContext& context) {
const std::vector<EditorWorkspacePanel*> mainPanels =
BuildUpdateOrder(EditorWorkspacePanelUpdatePhase::Main);
for (EditorWorkspacePanel* panel : mainPanels) {
panel->Update(context);
}
context.context.SyncSessionFromCommandFocusService();
const std::vector<EditorWorkspacePanel*> afterFocusSyncPanels =
BuildUpdateOrder(EditorWorkspacePanelUpdatePhase::AfterCommandFocusSync);
for (EditorWorkspacePanel* panel : afterFocusSyncPanels) {
void EditorWorkspacePanelRuntimeSet::UpdatePhase(
const EditorWorkspacePanelUpdateContext& context,
EditorWorkspacePanelUpdatePhase phase) {
const std::vector<EditorWorkspacePanel*> phasePanels =
BuildUpdateOrder(phase);
for (EditorWorkspacePanel* panel : phasePanels) {
panel->Update(context);
}
}