53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
|
|
#include "EditorWindowManager.h"
|
||
|
|
|
||
|
|
#include "State/EditorContext.h"
|
||
|
|
#include "EditorWindow.h"
|
||
|
|
|
||
|
|
namespace XCEngine::UI::Editor::App {
|
||
|
|
|
||
|
|
UIEditorWindowWorkspaceSet EditorWindowManager::BuildWindowWorkspaceSet(
|
||
|
|
std::string_view activeWindowId) const {
|
||
|
|
UIEditorWindowWorkspaceSet windowSet = {};
|
||
|
|
if (const EditorWindow* primaryWindow = FindPrimaryWindow();
|
||
|
|
primaryWindow != nullptr) {
|
||
|
|
windowSet.primaryWindowId = std::string(primaryWindow->GetWindowId());
|
||
|
|
}
|
||
|
|
|
||
|
|
for (const std::unique_ptr<EditorWindow>& window : m_windows) {
|
||
|
|
if (window == nullptr || window->GetHwnd() == nullptr) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
UIEditorWindowWorkspaceState entry = {};
|
||
|
|
entry.windowId = std::string(window->GetWindowId());
|
||
|
|
entry.workspace = window->GetWorkspaceController().GetWorkspace();
|
||
|
|
entry.session = window->GetWorkspaceController().GetSession();
|
||
|
|
windowSet.windows.push_back(std::move(entry));
|
||
|
|
}
|
||
|
|
|
||
|
|
windowSet.activeWindowId =
|
||
|
|
!activeWindowId.empty() && FindWindow(activeWindowId) != nullptr
|
||
|
|
? std::string(activeWindowId)
|
||
|
|
: windowSet.primaryWindowId;
|
||
|
|
|
||
|
|
return windowSet;
|
||
|
|
}
|
||
|
|
|
||
|
|
UIEditorWindowWorkspaceController
|
||
|
|
EditorWindowManager::BuildLiveWindowWorkspaceController(
|
||
|
|
std::string_view activeWindowId) const {
|
||
|
|
return UIEditorWindowWorkspaceController(
|
||
|
|
m_editorContext.GetShellAsset().panelRegistry,
|
||
|
|
BuildWindowWorkspaceSet(activeWindowId));
|
||
|
|
}
|
||
|
|
|
||
|
|
UIEditorWorkspaceController EditorWindowManager::BuildWorkspaceControllerForWindow(
|
||
|
|
const UIEditorWindowWorkspaceState& windowState) const {
|
||
|
|
return UIEditorWorkspaceController(
|
||
|
|
m_editorContext.GetShellAsset().panelRegistry,
|
||
|
|
windowState.workspace,
|
||
|
|
windowState.session);
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace XCEngine::UI::Editor::App
|