Refactor new editor boundaries and test ownership

This commit is contained in:
2026-04-19 15:52:28 +08:00
parent dc13b56cf3
commit 93f06e84ed
279 changed files with 6349 additions and 3238 deletions

View File

@@ -1,6 +1,7 @@
#include "Composition/EditorShellRuntimeInternal.h"
#include "State/EditorContext.h"
#include "Features/PanelInputContext.h"
#include "Composition/EditorContext.h"
#include "Composition/EditorPanelIds.h"
#include <XCEditor/Foundation/UIEditorTheme.h>
@@ -27,6 +28,23 @@ bool IsPointerInputEventType(UIInputEventType type) {
}
}
PanelInputContext BuildHostedPanelInputContext(
const UIEditorWorkspaceInteractionFrame& workspaceFrame,
bool allowInteraction,
std::string_view panelId) {
PanelInputContext inputContext = {};
inputContext.allowInteraction = allowInteraction;
inputContext.hasInputFocus =
IsUIEditorWorkspaceHostedPanelInputOwner(workspaceFrame.inputOwner, panelId);
inputContext.focusGained =
!IsUIEditorWorkspaceHostedPanelInputOwner(workspaceFrame.previousInputOwner, panelId) &&
inputContext.hasInputFocus;
inputContext.focusLost =
IsUIEditorWorkspaceHostedPanelInputOwner(workspaceFrame.previousInputOwner, panelId) &&
!inputContext.hasInputFocus;
return inputContext;
}
} // namespace
std::vector<UIInputEvent> FilterShellInputEventsForHostedContentCapture(
@@ -125,11 +143,10 @@ void EditorShellRuntime::Update(
m_hierarchyPanel.SetSceneRuntime(&context.GetSceneRuntime());
m_hierarchyPanel.SetCommandFocusService(&context.GetCommandFocusService());
m_sceneEditCommandRoute.BindSceneRuntime(&context.GetSceneRuntime());
m_sceneViewportController.SetCommandFocusService(&context.GetCommandFocusService());
m_sceneViewportFeature.SetCommandFocusService(&context.GetCommandFocusService());
// Keep the previous render request available for readback-based picking during
// this update, then refresh it again after camera/navigation state changes.
m_viewportHostService.SetSceneViewportRenderRequest(
context.GetSceneRuntime().BuildSceneViewportRenderRequest());
m_sceneViewportFeature.SyncRenderRequest(context.GetSceneRuntime());
context.BindEditCommandRoutes(
&m_hierarchyPanel,
&m_projectPanel,
@@ -179,39 +196,46 @@ void EditorShellRuntime::Update(
FilterHostedContentInputEventsForShellOwnership(
inputEvents,
shellOwnsHostedContentPointerStream);
m_sceneViewportController.Update(
m_sceneViewportFeature.Update(
context.GetSceneRuntime(),
m_viewportHostService,
m_shellInteractionState.workspaceInteractionState.composeState,
m_shellFrame.workspaceInteractionFrame.composeFrame);
m_viewportHostService.SetSceneViewportRenderRequest(
context.GetSceneRuntime().BuildSceneViewportRenderRequest());
ApplyViewportFramesToShellFrame(m_shellFrame, m_viewportHostService);
context.SyncSessionFromWorkspace(workspaceController);
context.UpdateStatusFromShellResult(workspaceController, m_shellFrame.result);
const std::string& activePanelId = workspaceController.GetWorkspace().activePanelId;
const bool allowHostedInteraction = !m_shellFrame.result.workspaceInputSuppressed;
const PanelInputContext hierarchyInputContext = BuildHostedPanelInputContext(
m_shellFrame.workspaceInteractionFrame,
allowHostedInteraction,
kHierarchyPanelId);
const PanelInputContext projectInputContext = BuildHostedPanelInputContext(
m_shellFrame.workspaceInteractionFrame,
allowHostedInteraction,
kProjectPanelId);
const PanelInputContext inspectorInputContext = BuildHostedPanelInputContext(
m_shellFrame.workspaceInteractionFrame,
allowHostedInteraction,
kInspectorPanelId);
m_projectPanel.SetProjectRuntime(&context.GetProjectRuntime());
m_projectPanel.SetCommandFocusService(&context.GetCommandFocusService());
m_projectPanel.SetSystemInteractionHost(context.GetSystemInteractionHost());
m_inspectorPanel.SetCommandFocusService(&context.GetCommandFocusService());
m_hierarchyPanel.Update(
m_shellFrame.workspaceInteractionFrame.composeFrame.contentHostFrame,
hostedContentEvents,
!m_shellFrame.result.workspaceInputSuppressed,
activePanelId == kHierarchyPanelId);
hierarchyInputContext);
m_projectPanel.Update(
m_shellFrame.workspaceInteractionFrame.composeFrame.contentHostFrame,
hostedContentEvents,
!m_shellFrame.result.workspaceInputSuppressed,
activePanelId == kProjectPanelId);
projectInputContext);
m_traceEntries = SyncWorkspaceEvents(context, *this);
m_inspectorPanel.Update(
context.GetSession(),
context.GetSceneRuntime(),
m_shellFrame.workspaceInteractionFrame.composeFrame.contentHostFrame,
hostedContentEvents,
!m_shellFrame.result.workspaceInputSuppressed,
activePanelId == kInspectorPanelId);
inspectorInputContext);
context.SyncSessionFromCommandFocusService();
m_consolePanel.Update(
context.GetSession(),