Refactor new editor scene runtime ownership

This commit is contained in:
2026-04-18 00:45:14 +08:00
parent 2fe1076218
commit b48760ca3d
12 changed files with 792 additions and 326 deletions

View File

@@ -5,6 +5,8 @@
#include "Features/Project/ProjectPanel.h"
#include "Composition/EditorShellRuntime.h"
#include <XCEditor/App/EditorPanelIds.h>
#include <sstream>
#include <utility>
@@ -114,15 +116,20 @@ void ApplyHierarchySelection(
return;
}
if (event.itemId.empty()) {
context.ClearSelection();
const EditorSceneRuntime& sceneRuntime = context.GetSceneRuntime();
if (!sceneRuntime.HasSceneSelection()) {
if (context.GetSession().selection.kind == EditorSelectionKind::HierarchyNode) {
context.ClearSelection();
}
return;
}
EditorSelectionState selection = {};
selection.kind = EditorSelectionKind::HierarchyNode;
selection.itemId = event.itemId;
selection.displayName = event.label.empty() ? event.itemId : event.label;
selection.itemId = sceneRuntime.GetSelectedItemId();
selection.displayName = sceneRuntime.GetSelectedDisplayName().empty()
? selection.itemId
: sceneRuntime.GetSelectedDisplayName();
context.SetSelection(std::move(selection));
}
@@ -166,14 +173,14 @@ std::vector<WorkspaceTraceEntry> SyncWorkspaceEvents(
ApplyHierarchySelection(context, event);
const std::string message = DescribeHierarchyPanelEvent(event);
context.SetStatus("Hierarchy", message);
entries.push_back(WorkspaceTraceEntry{ "hierarchy", std::move(message) });
entries.push_back(WorkspaceTraceEntry{ std::string(kHierarchyPanelId), std::move(message) });
}
for (const ProjectPanel::Event& event : runtime.GetProjectPanelEvents()) {
ApplyProjectSelection(context, event);
const std::string message = DescribeProjectPanelEvent(event);
context.SetStatus("Project", message);
entries.push_back(WorkspaceTraceEntry{ "project", std::move(message) });
entries.push_back(WorkspaceTraceEntry{ std::string(kProjectPanelId), std::move(message) });
}
return entries;