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