Files
XCEngine/new_editor/app/Platform/Win32/WindowManager/Detach.cpp

48 lines
1.7 KiB
C++

#include "Platform/Win32/WindowManager/Internal.h"
#include "State/EditorContext.h"
#include "Platform/Win32/EditorWindow.h"
#include <XCEditor/Workspace/UIEditorWindowWorkspaceController.h>
namespace XCEngine::UI::Editor::App::Internal {
bool EditorWindowWorkspaceCoordinator::TryProcessDetachRequest(
EditorWindow& sourceWindow,
const EditorWindowPanelTransferRequest& request) {
const std::string sourceWindowId(sourceWindow.GetWindowId());
UIEditorWindowWorkspaceController windowWorkspaceController =
BuildLiveWindowWorkspaceController(sourceWindowId);
const UIEditorWindowWorkspaceOperationResult result =
windowWorkspaceController.DetachPanelToNewWindow(
sourceWindowId,
request.nodeId,
request.panelId);
if (result.status != UIEditorWindowWorkspaceOperationStatus::Changed) {
LogRuntimeTrace("detach", "detach request rejected: " + result.message);
return false;
}
if (!SynchronizeWindowsFromController(
windowWorkspaceController,
result.targetWindowId,
request.screenPoint)) {
LogRuntimeTrace("detach", "failed to synchronize detached window state");
return false;
}
if (EditorWindow* detachedWindow = m_hostRuntime.FindWindow(result.targetWindowId);
detachedWindow != nullptr &&
detachedWindow->GetHwnd() != nullptr) {
SetForegroundWindow(detachedWindow->GetHwnd());
}
LogRuntimeTrace(
"detach",
"detached panel '" + request.panelId + "' from window '" + sourceWindowId +
"' to window '" + result.targetWindowId + "'");
return true;
}
} // namespace XCEngine::UI::Editor::App::Internal