refactor(editor/windowing): promote core into XCUIEditorLib
This commit is contained in:
69
editor/src/Windowing/EditorWindowPresentationPolicy.cpp
Normal file
69
editor/src/Windowing/EditorWindowPresentationPolicy.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <XCEditor/Windowing/EditorWindowPresentationPolicy.h>
|
||||
|
||||
#include <XCEditor/Workspace/UIEditorDetachedWindowPolicy.h>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
namespace {
|
||||
|
||||
std::wstring ResolvePrimaryTitle(std::wstring_view primaryWindowTitle) {
|
||||
return primaryWindowTitle.empty()
|
||||
? std::wstring(L"XCEngine Editor")
|
||||
: std::wstring(primaryWindowTitle);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
UIEditorWorkspaceController BuildWorkspaceControllerForWindowState(
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWindowWorkspaceState& windowState) {
|
||||
return UIEditorWorkspaceController(
|
||||
panelRegistry,
|
||||
windowState.workspace,
|
||||
windowState.session);
|
||||
}
|
||||
|
||||
EditorWorkspaceWindowProjection BuildEditorWorkspaceWindowProjection(
|
||||
std::wstring_view primaryWindowTitle,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWindowWorkspaceState& windowState,
|
||||
bool primary) {
|
||||
const UIEditorWorkspaceController workspaceController =
|
||||
BuildWorkspaceControllerForWindowState(panelRegistry, windowState);
|
||||
|
||||
EditorWorkspaceWindowProjection projection = {};
|
||||
projection.minimumOuterSize = ResolveUIEditorDetachedWorkspaceMinimumOuterSize(
|
||||
workspaceController);
|
||||
projection.useDetachedTitleBarTabStrip = HasUIEditorSingleVisibleRootTab(workspaceController);
|
||||
projection.tabStripTitleText = ResolveUIEditorDetachedWorkspaceTitle(workspaceController);
|
||||
projection.detachedWindowTitleText = ResolveUIEditorDetachedWorkspaceTitle(workspaceController);
|
||||
projection.windowTitle = ResolveEditorWindowPresentationTitle(
|
||||
primaryWindowTitle,
|
||||
panelRegistry,
|
||||
windowState,
|
||||
primary);
|
||||
return projection;
|
||||
}
|
||||
|
||||
std::wstring ResolveEditorWindowPresentationTitle(
|
||||
std::wstring_view primaryWindowTitle,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWindowWorkspaceState& windowState,
|
||||
bool primary) {
|
||||
if (primary) {
|
||||
return ResolvePrimaryTitle(primaryWindowTitle);
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceController workspaceController =
|
||||
BuildWorkspaceControllerForWindowState(panelRegistry, windowState);
|
||||
const std::string detachedTitle =
|
||||
ResolveUIEditorDetachedWorkspaceTitle(workspaceController);
|
||||
if (detachedTitle.empty()) {
|
||||
return std::wstring(L"XCEngine Editor");
|
||||
}
|
||||
|
||||
const std::string decoratedTitle = detachedTitle + " - XCEngine Editor";
|
||||
return std::wstring(decoratedTitle.begin(), decoratedTitle.end());
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user