2026-04-15 22:47:42 +08:00
|
|
|
#include "EditorShellAssetBuilderInternal.h"
|
2026-04-15 08:24:06 +08:00
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
2026-04-15 22:47:42 +08:00
|
|
|
namespace XCEngine::UI::Editor::App::CompositionInternal {
|
2026-04-15 08:24:06 +08:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
UIEditorShellToolbarButton BuildToolbarButton(
|
|
|
|
|
std::string buttonId,
|
|
|
|
|
UIEditorShellToolbarGlyph glyph) {
|
|
|
|
|
UIEditorShellToolbarButton button = {};
|
|
|
|
|
button.buttonId = std::move(buttonId);
|
|
|
|
|
button.glyph = glyph;
|
|
|
|
|
button.enabled = true;
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-19 00:03:25 +08:00
|
|
|
UIEditorWorkspacePanelPresentationModel BuildViewportPresentation(
|
|
|
|
|
const UIEditorPanelDescriptor& descriptor) {
|
2026-04-15 08:24:06 +08:00
|
|
|
UIEditorWorkspacePanelPresentationModel presentation = {};
|
2026-04-19 00:03:25 +08:00
|
|
|
presentation.panelId = descriptor.panelId;
|
|
|
|
|
presentation.kind = descriptor.presentationKind;
|
|
|
|
|
presentation.viewportShellModel.spec = descriptor.viewportShellSpec;
|
|
|
|
|
if (presentation.viewportShellModel.spec.chrome.title.empty()) {
|
|
|
|
|
presentation.viewportShellModel.spec.chrome.title = descriptor.defaultTitle;
|
|
|
|
|
}
|
2026-04-15 08:24:06 +08:00
|
|
|
return presentation;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-19 00:03:25 +08:00
|
|
|
UIEditorWorkspacePanelPresentationModel BuildPanelPresentation(
|
|
|
|
|
const UIEditorPanelDescriptor& descriptor) {
|
|
|
|
|
if (descriptor.presentationKind == UIEditorPanelPresentationKind::ViewportShell) {
|
|
|
|
|
return BuildViewportPresentation(descriptor);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 08:24:06 +08:00
|
|
|
UIEditorWorkspacePanelPresentationModel presentation = {};
|
2026-04-19 00:03:25 +08:00
|
|
|
presentation.panelId = descriptor.panelId;
|
|
|
|
|
presentation.kind = descriptor.presentationKind;
|
2026-04-15 08:24:06 +08:00
|
|
|
return presentation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2026-04-19 00:03:25 +08:00
|
|
|
UIEditorShellInteractionDefinition BuildBaseEditorShellDefinition(
|
|
|
|
|
const UIEditorPanelRegistry& panelRegistry) {
|
2026-04-15 08:24:06 +08:00
|
|
|
UIEditorShellInteractionDefinition definition = {};
|
|
|
|
|
definition.menuModel = BuildEditorMenuModel();
|
|
|
|
|
definition.toolbarButtons = {
|
|
|
|
|
BuildToolbarButton("run.play", UIEditorShellToolbarGlyph::Play),
|
|
|
|
|
BuildToolbarButton("run.pause", UIEditorShellToolbarGlyph::Pause),
|
|
|
|
|
BuildToolbarButton("run.step", UIEditorShellToolbarGlyph::Step)
|
|
|
|
|
};
|
|
|
|
|
definition.statusSegments = {};
|
2026-04-19 00:03:25 +08:00
|
|
|
definition.workspacePresentations.reserve(panelRegistry.panels.size());
|
|
|
|
|
for (const UIEditorPanelDescriptor& descriptor : panelRegistry.panels) {
|
|
|
|
|
definition.workspacePresentations.push_back(BuildPanelPresentation(descriptor));
|
|
|
|
|
}
|
2026-04-15 08:24:06 +08:00
|
|
|
return definition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string ResolveEditorPanelTitle(
|
|
|
|
|
const UIEditorPanelRegistry& registry,
|
|
|
|
|
std::string_view panelId) {
|
|
|
|
|
if (const UIEditorPanelDescriptor* descriptor =
|
|
|
|
|
FindUIEditorPanelDescriptor(registry, panelId);
|
|
|
|
|
descriptor != nullptr) {
|
|
|
|
|
return descriptor->defaultTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return panelId.empty() ? std::string("(none)") : std::string(panelId);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 22:47:42 +08:00
|
|
|
} // namespace XCEngine::UI::Editor::App::CompositionInternal
|