#include #include #include #include #include #include #include namespace { using namespace XCEngine::UI::Editor; bool Require(bool condition, std::string_view message) { if (!condition) { std::cerr << message << '\n'; return false; } return true; } UIEditorPanelRegistry BuildPanelRegistry() { UIEditorPanelRegistry registry = {}; registry.panels.push_back(UIEditorPanelDescriptor{ "scene", "Scene", UIEditorPanelPresentationKind::Placeholder, true, true, true, {}, {}, }); registry.panels.push_back(UIEditorPanelDescriptor{ "game", "Game", UIEditorPanelPresentationKind::Placeholder, true, true, true, {}, {}, }); return registry; } UIEditorWorkspaceModel BuildWorkspace() { UIEditorWorkspaceModel workspace = {}; workspace.root = BuildUIEditorWorkspaceTabStack( "root", std::vector{ BuildUIEditorWorkspacePanel("scene-panel", "scene", "Scene"), BuildUIEditorWorkspacePanel("game-panel", "game", "Game"), }, 0u); workspace.activePanelId = "scene"; return workspace; } } // namespace int main() { UIEditorWindowWorkspaceController controller = BuildDefaultUIEditorWindowWorkspaceController( BuildPanelRegistry(), BuildWorkspace(), "main"); const UIEditorWindowWorkspaceValidationResult validation = controller.ValidateState(); if (!Require(validation.IsValid(), validation.message)) { return 1; } const UIEditorWindowWorkspaceOperationResult detachResult = controller.DetachPanelToNewWindow("main", "root", "game", "game-window"); if (!Require( detachResult.status == UIEditorWindowWorkspaceOperationStatus::Changed, detachResult.message)) { return 1; } const UIEditorWindowWorkspaceSet& windowSet = controller.GetWindowSet(); if (!Require(windowSet.windows.size() == 2u, "expected two windows after detach")) { return 1; } if (!Require(windowSet.primaryWindowId == "main", "primary window id changed unexpectedly")) { return 1; } if (!Require(windowSet.activeWindowId == "game-window", "detached window was not activated")) { return 1; } const UIEditorWindowWorkspaceState* const mainWindow = FindUIEditorWindowWorkspaceState(windowSet, "main"); const UIEditorWindowWorkspaceState* const detachedWindow = FindUIEditorWindowWorkspaceState(windowSet, "game-window"); if (!Require(mainWindow != nullptr, "main window state missing")) { return 1; } if (!Require(detachedWindow != nullptr, "detached window state missing")) { return 1; } if (!Require( detachedWindow->workspace.activePanelId == "game", "detached workspace active panel mismatch")) { return 1; } return 0; }