refactor(new_editor): tighten app dependency boundaries

This commit is contained in:
2026-04-19 02:48:41 +08:00
parent 7429f22fb1
commit c59cd83c38
86 changed files with 1754 additions and 1077 deletions

View File

@@ -1,4 +1,4 @@
#include <XCEditor/App/EditorHostCommandBridge.h>
#include "Commands/EditorHostCommandBridge.h"
#include <string>
#include <utility>

View File

@@ -1,5 +1,6 @@
#include <XCEditor/App/EditorSession.h>
#include <XCEditor/App/EditorPanelIds.h>
#include "State/EditorSession.h"
#include "Composition/EditorPanelIds.h"
#include <XCEditor/Workspace/UIEditorWorkspaceController.h>

View File

@@ -18,21 +18,6 @@ UIEditorPanelRegistryValidationResult MakeValidationError(
} // namespace
UIEditorPanelRegistry BuildEditorFoundationPanelRegistry() {
UIEditorPanelRegistry registry = {};
registry.panels = {
{
"editor-foundation-root",
"Root Surface",
UIEditorPanelPresentationKind::Placeholder,
true,
false,
false
}
};
return registry;
}
const UIEditorPanelDescriptor* FindUIEditorPanelDescriptor(
const UIEditorPanelRegistry& registry,
std::string_view panelId) {

View File

@@ -8,31 +8,6 @@ namespace XCEngine::UI::Editor {
namespace {
Widgets::UIEditorStatusBarSegment BuildDefaultShellModeSegment() {
Widgets::UIEditorStatusBarSegment segment = {};
segment.segmentId = "mode";
segment.label = "Editor Shell";
segment.slot = Widgets::UIEditorStatusBarSlot::Leading;
segment.tone = Widgets::UIEditorStatusBarTextTone::Primary;
segment.interactive = false;
segment.showSeparator = true;
segment.desiredWidth = 112.0f;
return segment;
}
Widgets::UIEditorStatusBarSegment BuildDefaultActivePanelSegment(
const UIEditorWorkspaceModel& workspace) {
Widgets::UIEditorStatusBarSegment segment = {};
segment.segmentId = "active-panel";
segment.label = workspace.activePanelId.empty() ? std::string("(none)") : workspace.activePanelId;
segment.slot = Widgets::UIEditorStatusBarSlot::Trailing;
segment.tone = Widgets::UIEditorStatusBarTextTone::Muted;
segment.interactive = false;
segment.showSeparator = false;
segment.desiredWidth = 144.0f;
return segment;
}
EditorShellAssetValidationResult MakeValidationError(
EditorShellAssetValidationCode code,
std::string message) {
@@ -122,51 +97,8 @@ EditorShellAssetValidationResult ValidateShellDefinitionAgainstRegistry(
return {};
}
UIEditorWorkspacePanelPresentationModel BuildShellPresentation(
const UIEditorPanelDescriptor& descriptor) {
UIEditorWorkspacePanelPresentationModel presentation = {};
presentation.panelId = descriptor.panelId;
presentation.kind = descriptor.presentationKind;
if (descriptor.presentationKind == UIEditorPanelPresentationKind::ViewportShell) {
presentation.viewportShellModel.spec = descriptor.viewportShellSpec;
if (presentation.viewportShellModel.spec.chrome.title.empty()) {
presentation.viewportShellModel.spec.chrome.title = descriptor.defaultTitle;
}
if (presentation.viewportShellModel.spec.chrome.subtitle.empty()) {
presentation.viewportShellModel.spec.chrome.subtitle = "Editor Shell";
}
presentation.viewportShellModel.frame.statusText = descriptor.defaultTitle;
}
return presentation;
}
UIEditorShellInteractionDefinition BuildFoundationShellDefinition(
const UIEditorPanelRegistry& panelRegistry,
const UIEditorWorkspaceModel& workspace) {
UIEditorShellInteractionDefinition definition = {};
definition.statusSegments = {
BuildDefaultShellModeSegment(),
BuildDefaultActivePanelSegment(workspace)
};
definition.workspacePresentations.reserve(panelRegistry.panels.size());
for (const UIEditorPanelDescriptor& descriptor : panelRegistry.panels) {
definition.workspacePresentations.push_back(BuildShellPresentation(descriptor));
}
return definition;
}
} // namespace
EditorShellAsset BuildEditorFoundationShellAsset(const std::filesystem::path& repoRoot) {
EditorShellAsset asset = {};
asset.captureRootPath = (repoRoot / "new_editor/captures").lexically_normal();
asset.panelRegistry = BuildEditorFoundationPanelRegistry();
asset.workspace = BuildEditorFoundationWorkspaceModel();
asset.workspaceSession = BuildDefaultUIEditorWorkspaceSession(asset.panelRegistry, asset.workspace);
asset.shellDefinition = BuildFoundationShellDefinition(asset.panelRegistry, asset.workspace);
return asset;
}
UIEditorShortcutManager BuildEditorShellShortcutManager(const EditorShellAsset& asset) {
UIEditorShortcutManager manager(asset.shortcutAsset.commandRegistry);
for (const XCEngine::UI::UIShortcutBinding& binding : asset.shortcutAsset.bindings) {

View File

@@ -599,21 +599,6 @@ bool AreUIEditorWorkspaceModelsEquivalent(
AreUIEditorWorkspaceNodesEquivalent(lhs.root, rhs.root);
}
UIEditorWorkspaceModel BuildEditorFoundationWorkspaceModel() {
const UIEditorPanelRegistry registry = BuildEditorFoundationPanelRegistry();
const UIEditorPanelDescriptor& rootPanel =
Internal::RequirePanelDescriptor(registry, "editor-foundation-root");
UIEditorWorkspaceModel workspace = {};
workspace.root = BuildUIEditorWorkspaceSingleTabStack(
"editor-foundation-root-node",
rootPanel.panelId,
rootPanel.defaultTitle,
rootPanel.placeholder);
workspace.activePanelId = rootPanel.panelId;
return workspace;
}
UIEditorWorkspaceNode BuildUIEditorWorkspacePanel(
std::string nodeId,
std::string panelId,