#include "Platform/Win32/Windowing/EditorWindowSession.h" #include "Platform/Win32/Windowing/EditorWindowSupport.h" #include namespace XCEngine::UI::Editor::App { using namespace EditorWindowSupport; EditorWindowSession::EditorWindowSession( std::string windowId, std::wstring title, EditorWindowCategory category, EditorWindowChromePolicy chromePolicy, bool primary) { m_state.window.windowId = std::move(windowId); m_state.window.title = std::move(title); m_state.window.category = category; m_state.window.chromePolicy = chromePolicy; m_state.window.primary = primary; UpdateCachedTitleText(); } std::string_view EditorWindowSession::GetWindowId() const { return m_state.window.windowId; } HWND EditorWindowSession::GetHwnd() const { return m_state.window.hwnd; } bool EditorWindowSession::HasHwnd() const { return m_state.window.hwnd != nullptr; } EditorWindowCategory EditorWindowSession::GetCategory() const { return m_state.window.category; } const EditorWindowChromePolicy& EditorWindowSession::GetChromePolicy() const { return m_state.window.chromePolicy; } EditorWindowLifecycleState EditorWindowSession::GetLifecycleState() const { return m_state.window.lifecycle; } bool EditorWindowSession::IsPrimary() const { return m_state.window.primary; } bool EditorWindowSession::IsWorkspaceWindow() const { return m_state.window.category == EditorWindowCategory::Workspace; } bool EditorWindowSession::IsUtilityWindow() const { return m_state.window.category == EditorWindowCategory::Utility; } bool EditorWindowSession::IsClosing() const { return m_state.window.lifecycle == EditorWindowLifecycleState::Closing; } bool EditorWindowSession::IsDestroyed() const { return m_state.window.lifecycle == EditorWindowLifecycleState::Destroyed; } const std::wstring& EditorWindowSession::GetTitle() const { return m_state.window.title; } std::string_view EditorWindowSession::GetCachedTitleText() const { return m_state.window.titleText; } void EditorWindowSession::AttachHwnd(HWND hwnd) { m_state.window.hwnd = hwnd; m_state.window.lifecycle = EditorWindowLifecycleState::NativeAttached; } void EditorWindowSession::MarkNativeAttached() { m_state.window.lifecycle = EditorWindowLifecycleState::NativeAttached; } void EditorWindowSession::MarkInitializing() { m_state.window.lifecycle = EditorWindowLifecycleState::Initializing; } void EditorWindowSession::MarkRunning() { m_state.window.lifecycle = EditorWindowLifecycleState::Running; } void EditorWindowSession::MarkDestroyed() { m_state.window.hwnd = nullptr; m_state.window.lifecycle = EditorWindowLifecycleState::Destroyed; } void EditorWindowSession::MarkClosing() { m_state.window.lifecycle = EditorWindowLifecycleState::Closing; } void EditorWindowSession::SetPrimary(bool primary) { m_state.window.primary = primary; } void EditorWindowSession::SetTitle(std::wstring title) { m_state.window.title = std::move(title); UpdateCachedTitleText(); } void EditorWindowSession::QueueCompletedImmediateFrame( EditorWindowFrameTransferRequests transferRequests) { m_hasQueuedCompletedImmediateFrame = true; if (transferRequests.workspace.workspaceMutation.has_value()) { m_queuedImmediateFrameTransferRequests.workspace.workspaceMutation = std::move(transferRequests.workspace.workspaceMutation); } if (transferRequests.workspace.beginGlobalTabDrag.has_value()) { m_queuedImmediateFrameTransferRequests.workspace.beginGlobalTabDrag = std::move(transferRequests.workspace.beginGlobalTabDrag); } if (transferRequests.workspace.detachPanel.has_value()) { m_queuedImmediateFrameTransferRequests.workspace.detachPanel = std::move(transferRequests.workspace.detachPanel); } if (transferRequests.utility.openUtilityWindow.has_value()) { m_queuedImmediateFrameTransferRequests.utility.openUtilityWindow = std::move(transferRequests.utility.openUtilityWindow); } } bool EditorWindowSession::HasQueuedCompletedImmediateFrame() const { return m_hasQueuedCompletedImmediateFrame; } EditorWindowFrameTransferRequests EditorWindowSession::ConsumeQueuedCompletedImmediateFrameTransferRequests() { m_hasQueuedCompletedImmediateFrame = false; EditorWindowFrameTransferRequests transferRequests = std::move(m_queuedImmediateFrameTransferRequests); m_queuedImmediateFrameTransferRequests = {}; return transferRequests; } void EditorWindowSession::UpdateCachedTitleText() { m_state.window.titleText = WideToUtf8(m_state.window.title); } } // namespace XCEngine::UI::Editor::App