149 lines
5.1 KiB
C++
149 lines
5.1 KiB
C++
#pragma once
|
|
|
|
#include "Platform/Win32/EditorWindowManager.h"
|
|
|
|
namespace XCEngine::UI::Editor::App::Internal {
|
|
|
|
class EditorWindowHostRuntime final {
|
|
public:
|
|
using CreateParams = EditorWindowManager::CreateParams;
|
|
|
|
EditorWindowHostRuntime(
|
|
EditorWindowHostConfig hostConfig,
|
|
std::filesystem::path repoRoot,
|
|
EditorContext& editorContext);
|
|
~EditorWindowHostRuntime();
|
|
|
|
EditorWindow* CreateEditorWindow(
|
|
UIEditorWorkspaceController workspaceController,
|
|
const CreateParams& params);
|
|
void HandlePendingNativeWindowCreated(HWND hwnd);
|
|
void Shutdown();
|
|
|
|
EditorWindow* FindWindow(HWND hwnd);
|
|
const EditorWindow* FindWindow(HWND hwnd) const;
|
|
EditorWindow* FindWindow(std::string_view windowId);
|
|
const EditorWindow* FindWindow(std::string_view windowId) const;
|
|
EditorWindow* FindPrimaryWindow();
|
|
const EditorWindow* FindPrimaryWindow() const;
|
|
|
|
bool HasWindows() const;
|
|
void DestroyClosedWindows();
|
|
void RenderAllWindows(
|
|
bool globalTabDragActive,
|
|
EditorWindowWorkspaceCoordinator& workspaceCoordinator);
|
|
void HandleDestroyedWindow(HWND hwnd);
|
|
|
|
EditorContext& GetEditorContext() {
|
|
return m_editorContext;
|
|
}
|
|
|
|
const EditorContext& GetEditorContext() const {
|
|
return m_editorContext;
|
|
}
|
|
|
|
const EditorWindowHostConfig& GetHostConfig() const {
|
|
return m_hostConfig;
|
|
}
|
|
|
|
const std::filesystem::path& GetRepoRoot() const {
|
|
return m_repoRoot;
|
|
}
|
|
|
|
std::vector<std::unique_ptr<EditorWindow>>& GetWindows() {
|
|
return m_windows;
|
|
}
|
|
|
|
const std::vector<std::unique_ptr<EditorWindow>>& GetWindows() const {
|
|
return m_windows;
|
|
}
|
|
|
|
void LogRuntimeTrace(std::string_view channel, std::string_view message) const;
|
|
|
|
private:
|
|
void DestroyEditorWindow(EditorWindow& window);
|
|
|
|
EditorWindowHostConfig m_hostConfig = {};
|
|
std::filesystem::path m_repoRoot = {};
|
|
EditorContext& m_editorContext;
|
|
std::vector<std::unique_ptr<EditorWindow>> m_windows = {};
|
|
EditorWindow* m_pendingCreateWindow = nullptr;
|
|
};
|
|
|
|
class EditorWindowWorkspaceCoordinator final {
|
|
public:
|
|
explicit EditorWindowWorkspaceCoordinator(EditorWindowHostRuntime& hostRuntime);
|
|
~EditorWindowWorkspaceCoordinator();
|
|
|
|
bool IsGlobalTabDragActive() const;
|
|
bool OwnsActiveGlobalTabDrag(std::string_view windowId) const;
|
|
void EndGlobalTabDragSession();
|
|
bool HandleGlobalTabDragPointerMove(HWND hwnd);
|
|
bool HandleGlobalTabDragPointerButtonUp(HWND hwnd);
|
|
void HandleWindowFrameTransferRequests(
|
|
EditorWindow& sourceWindow,
|
|
EditorWindowFrameTransferRequests&& transferRequests);
|
|
|
|
private:
|
|
struct GlobalTabDragSession {
|
|
bool active = false;
|
|
std::string panelWindowId = {};
|
|
std::string sourceNodeId = {};
|
|
std::string panelId = {};
|
|
std::string previewWindowId = {};
|
|
POINT screenPoint = {};
|
|
POINT dragHotspot = {};
|
|
};
|
|
|
|
UIEditorWindowWorkspaceSet BuildWindowWorkspaceSet(
|
|
std::string_view activeWindowId = {}) const;
|
|
UIEditorWindowWorkspaceController BuildLiveWindowWorkspaceController(
|
|
std::string_view activeWindowId) const;
|
|
bool SynchronizeWindowsFromWindowSet(
|
|
const UIEditorWindowWorkspaceSet& windowSet,
|
|
std::string_view preferredNewWindowId,
|
|
const POINT& preferredScreenPoint);
|
|
bool SynchronizeWindowsFromController(
|
|
const UIEditorWindowWorkspaceController& windowWorkspaceController,
|
|
std::string_view preferredNewWindowId,
|
|
const POINT& preferredScreenPoint);
|
|
UIEditorWorkspaceController BuildWorkspaceControllerForWindow(
|
|
const UIEditorWindowWorkspaceState& windowState) const;
|
|
std::wstring BuildWindowTitle(
|
|
const UIEditorWorkspaceController& workspaceController) const;
|
|
RECT BuildDetachedWindowRect(const POINT& screenPoint) const;
|
|
void BeginGlobalTabDragSession(
|
|
std::string_view panelWindowId,
|
|
std::string_view sourceNodeId,
|
|
std::string_view panelId,
|
|
const POINT& screenPoint,
|
|
const POINT& dragHotspot);
|
|
bool TryResolveGlobalTabDragHotspot(
|
|
const EditorWindow& sourceWindow,
|
|
std::string_view nodeId,
|
|
std::string_view panelId,
|
|
const POINT& screenPoint,
|
|
POINT& outDragHotspot) const;
|
|
void ClearGlobalTabDragDropPreview();
|
|
void UpdateGlobalTabDragDropPreview();
|
|
void UpdateGlobalTabDragOwnerWindowPosition();
|
|
EditorWindow* FindTopmostWindowAtScreenPoint(
|
|
const POINT& screenPoint,
|
|
std::string_view excludedWindowId = {});
|
|
const EditorWindow* FindTopmostWindowAtScreenPoint(
|
|
const POINT& screenPoint,
|
|
std::string_view excludedWindowId = {}) const;
|
|
bool TryStartGlobalTabDrag(
|
|
EditorWindow& sourceWindow,
|
|
const EditorWindowPanelTransferRequest& request);
|
|
bool TryProcessDetachRequest(
|
|
EditorWindow& sourceWindow,
|
|
const EditorWindowPanelTransferRequest& request);
|
|
void LogRuntimeTrace(std::string_view channel, std::string_view message) const;
|
|
|
|
EditorWindowHostRuntime& m_hostRuntime;
|
|
GlobalTabDragSession m_globalTabDragSession = {};
|
|
};
|
|
|
|
} // namespace XCEngine::UI::Editor::App::Internal
|