refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
75
new_editor/app/Composition/EditorShellAssetDefinition.cpp
Normal file
75
new_editor/app/Composition/EditorShellAssetDefinition.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "EditorShellAssetBuilderSupport.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace XCEngine::UI::Editor::App::CompositionSupport {
|
||||
|
||||
namespace {
|
||||
|
||||
UIEditorShellToolbarButton BuildToolbarButton(
|
||||
std::string buttonId,
|
||||
UIEditorShellToolbarGlyph glyph) {
|
||||
UIEditorShellToolbarButton button = {};
|
||||
button.buttonId = std::move(buttonId);
|
||||
button.glyph = glyph;
|
||||
button.enabled = true;
|
||||
return button;
|
||||
}
|
||||
|
||||
UIEditorWorkspacePanelPresentationModel BuildHostedContentPresentation(
|
||||
std::string panelId) {
|
||||
UIEditorWorkspacePanelPresentationModel presentation = {};
|
||||
presentation.panelId = std::move(panelId);
|
||||
presentation.kind = UIEditorPanelPresentationKind::HostedContent;
|
||||
return presentation;
|
||||
}
|
||||
|
||||
UIEditorWorkspacePanelPresentationModel BuildViewportPresentation(
|
||||
std::string panelId,
|
||||
std::string title) {
|
||||
UIEditorWorkspacePanelPresentationModel presentation = {};
|
||||
presentation.panelId = std::move(panelId);
|
||||
presentation.kind = UIEditorPanelPresentationKind::ViewportShell;
|
||||
presentation.viewportShellModel.spec.chrome.title = std::move(title);
|
||||
presentation.viewportShellModel.spec.chrome.subtitle = {};
|
||||
presentation.viewportShellModel.spec.chrome.showTopBar = false;
|
||||
presentation.viewportShellModel.spec.chrome.showBottomBar = false;
|
||||
presentation.viewportShellModel.frame.statusText.clear();
|
||||
return presentation;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
UIEditorShellInteractionDefinition BuildBaseEditorShellDefinition() {
|
||||
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 = {
|
||||
BuildHostedContentPresentation("hierarchy"),
|
||||
BuildViewportPresentation("scene", "Scene"),
|
||||
BuildViewportPresentation("game", "Game"),
|
||||
BuildHostedContentPresentation("inspector"),
|
||||
BuildHostedContentPresentation("console"),
|
||||
BuildHostedContentPresentation("project")
|
||||
};
|
||||
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::CompositionSupport
|
||||
Reference in New Issue
Block a user