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

56 lines
2.2 KiB
C++

#include "EditorShellAssetBuilder.h"
#include "Composition/EditorShellAssetBuilderSupport.h"
namespace XCEngine::UI::Editor::App {
using namespace CompositionSupport;
EditorShellAsset BuildEditorShellAsset(const std::filesystem::path& repoRoot) {
EditorShellAsset asset = {};
asset.screenId = "editor.shell";
asset.captureRootPath = (repoRoot / "new_editor/captures").lexically_normal();
asset.panelRegistry = BuildEditorPanelRegistry();
asset.workspace = BuildEditorWorkspaceModel();
asset.workspaceSession =
BuildDefaultUIEditorWorkspaceSession(asset.panelRegistry, asset.workspace);
asset.shellDefinition = BuildBaseEditorShellDefinition();
asset.shortcutAsset.commandRegistry = BuildEditorCommandRegistry();
asset.shortcutAsset.bindings = BuildEditorShortcutBindings();
return asset;
}
UIEditorShellInteractionDefinition BuildEditorShellInteractionDefinition(
const EditorShellAsset& asset,
const UIEditorWorkspaceController& controller,
std::string_view statusText,
std::string_view captureText,
EditorShellVariant variant) {
UIEditorShellInteractionDefinition definition = asset.shellDefinition;
if (variant == EditorShellVariant::DetachedWindow) {
definition.menuModel = {};
definition.toolbarButtons.clear();
definition.statusSegments.clear();
}
const std::string activeTitle =
ResolveEditorPanelTitle(asset.panelRegistry, controller.GetWorkspace().activePanelId);
const std::string resolvedStatus =
statusText.empty() ? std::string("Shell ready") : std::string(statusText);
const std::string resolvedCapture =
captureText.empty() ? std::string("F12 -> Screenshot") : std::string(captureText);
for (Widgets::UIEditorStatusBarSegment& segment : definition.statusSegments) {
if (segment.segmentId == "editor-status") {
segment.label = resolvedStatus;
} else if (segment.segmentId == "capture") {
segment.label = resolvedCapture;
} else if (segment.segmentId == "active-panel") {
segment.label = activeTitle;
}
}
return definition;
}
} // namespace XCEngine::UI::Editor::App