Refine editor shell asset contract

This commit is contained in:
2026-04-07 13:01:48 +08:00
parent e7669dc8c3
commit 6bf61ad8e2
4 changed files with 130 additions and 54 deletions

View File

@@ -19,6 +19,19 @@ Widgets::UIEditorStatusBarSegment BuildDefaultShellModeSegment() {
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) {
@@ -124,9 +137,13 @@ UIEditorWorkspacePanelPresentationModel BuildShellPresentation(
}
UIEditorShellInteractionDefinition BuildDefaultShellDefinition(
const UIEditorPanelRegistry& panelRegistry) {
const UIEditorPanelRegistry& panelRegistry,
const UIEditorWorkspaceModel& workspace) {
UIEditorShellInteractionDefinition definition = {};
definition.statusSegments = { BuildDefaultShellModeSegment() };
definition.statusSegments = {
BuildDefaultShellModeSegment(),
BuildDefaultActivePanelSegment(workspace)
};
definition.workspacePresentations.reserve(panelRegistry.panels.size());
for (const UIEditorPanelDescriptor& descriptor : panelRegistry.panels) {
definition.workspacePresentations.push_back(BuildShellPresentation(descriptor));
@@ -144,7 +161,7 @@ EditorShellAsset BuildDefaultEditorShellAsset(const std::filesystem::path& repoR
asset.panelRegistry = BuildDefaultEditorShellPanelRegistry();
asset.workspace = BuildDefaultEditorShellWorkspaceModel();
asset.workspaceSession = BuildDefaultUIEditorWorkspaceSession(asset.panelRegistry, asset.workspace);
asset.shellDefinition = BuildDefaultShellDefinition(asset.panelRegistry);
asset.shellDefinition = BuildDefaultShellDefinition(asset.panelRegistry, asset.workspace);
return asset;
}