Files
XCEngine/new_editor/app/Composition/EditorShellAssetDefinition.cpp

75 lines
2.6 KiB
C++

#include "EditorShellAssetBuilderInternal.h"
#include <utility>
namespace XCEngine::UI::Editor::App::CompositionInternal {
namespace {
UIEditorShellToolbarButton BuildToolbarButton(
std::string buttonId,
UIEditorShellToolbarGlyph glyph) {
UIEditorShellToolbarButton button = {};
button.buttonId = std::move(buttonId);
button.glyph = glyph;
button.enabled = true;
return button;
}
UIEditorWorkspacePanelPresentationModel BuildViewportPresentation(
const UIEditorPanelDescriptor& descriptor) {
UIEditorWorkspacePanelPresentationModel presentation = {};
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;
}
return presentation;
}
UIEditorWorkspacePanelPresentationModel BuildPanelPresentation(
const UIEditorPanelDescriptor& descriptor) {
if (descriptor.presentationKind == UIEditorPanelPresentationKind::ViewportShell) {
return BuildViewportPresentation(descriptor);
}
UIEditorWorkspacePanelPresentationModel presentation = {};
presentation.panelId = descriptor.panelId;
presentation.kind = descriptor.presentationKind;
return presentation;
}
} // namespace
UIEditorShellInteractionDefinition BuildBaseEditorShellDefinition(
const UIEditorPanelRegistry& panelRegistry) {
UIEditorShellInteractionDefinition definition = {};
definition.menuModel = BuildEditorMenuModel();
definition.toolbarButtons = {
BuildToolbarButton("run.play", UIEditorShellToolbarGlyph::Play),
BuildToolbarButton("run.pause", UIEditorShellToolbarGlyph::Pause),
BuildToolbarButton("run.step", UIEditorShellToolbarGlyph::Step)
};
definition.statusSegments = {};
definition.workspacePresentations.reserve(panelRegistry.panels.size());
for (const UIEditorPanelDescriptor& descriptor : panelRegistry.panels) {
definition.workspacePresentations.push_back(BuildPanelPresentation(descriptor));
}
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);
}
} // namespace XCEngine::UI::Editor::App::CompositionInternal