refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
68
new_editor/app/Platform/Win32/EditorWindowManagerDetach.cpp
Normal file
68
new_editor/app/Platform/Win32/EditorWindowManagerDetach.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "EditorWindowManager.h"
|
||||
|
||||
#include "State/EditorContext.h"
|
||||
#include "EditorWindow.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
void EditorWindowManager::ProcessPendingDetachRequests() {
|
||||
if (m_globalTabDragSession.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<EditorWindow*> windowsToProcess = {};
|
||||
for (const std::unique_ptr<EditorWindow>& window : m_windows) {
|
||||
if (window != nullptr && window->GetHwnd() != nullptr) {
|
||||
windowsToProcess.push_back(window.get());
|
||||
}
|
||||
}
|
||||
|
||||
for (EditorWindow* window : windowsToProcess) {
|
||||
if (window != nullptr) {
|
||||
TryProcessDetachRequest(*window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorWindowManager::TryProcessDetachRequest(EditorWindow& sourceWindow) {
|
||||
const std::optional<EditorWindowPendingDetachRequest> pending =
|
||||
sourceWindow.ConsumeDetachRequest();
|
||||
if (!pending.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string sourceWindowId(sourceWindow.GetWindowId());
|
||||
UIEditorWindowWorkspaceController windowWorkspaceController =
|
||||
BuildLiveWindowWorkspaceController(sourceWindowId);
|
||||
const UIEditorWindowWorkspaceOperationResult result =
|
||||
windowWorkspaceController.DetachPanelToNewWindow(
|
||||
sourceWindowId,
|
||||
pending->nodeId,
|
||||
pending->panelId);
|
||||
if (result.status != UIEditorWindowWorkspaceOperationStatus::Changed) {
|
||||
LogRuntimeTrace("detach", "detach request rejected: " + result.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SynchronizeWindowsFromController(
|
||||
windowWorkspaceController,
|
||||
result.targetWindowId,
|
||||
pending->screenPoint)) {
|
||||
LogRuntimeTrace("detach", "failed to synchronize detached window state");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (EditorWindow* detachedWindow = FindWindow(result.targetWindowId);
|
||||
detachedWindow != nullptr &&
|
||||
detachedWindow->GetHwnd() != nullptr) {
|
||||
SetForegroundWindow(detachedWindow->GetHwnd());
|
||||
}
|
||||
|
||||
LogRuntimeTrace(
|
||||
"detach",
|
||||
"detached panel '" + pending->panelId + "' from window '" + sourceWindowId +
|
||||
"' to window '" + result.targetWindowId + "'");
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user