127 lines
3.7 KiB
C++
127 lines
3.7 KiB
C++
|
|
#include "Platform/Win32/Windowing/EditorWindowSession.h"
|
||
|
|
|
||
|
|
#include "Platform/Win32/Windowing/EditorWindowSupport.h"
|
||
|
|
|
||
|
|
#include <utility>
|
||
|
|
|
||
|
|
namespace XCEngine::UI::Editor::App {
|
||
|
|
|
||
|
|
using namespace EditorWindowSupport;
|
||
|
|
|
||
|
|
EditorWindowSession::EditorWindowSession(
|
||
|
|
std::string windowId,
|
||
|
|
std::wstring title,
|
||
|
|
bool primary) {
|
||
|
|
m_state.window.windowId = std::move(windowId);
|
||
|
|
m_state.window.title = std::move(title);
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
EditorWindowLifecycleState EditorWindowSession::GetLifecycleState() const {
|
||
|
|
return m_state.window.lifecycle;
|
||
|
|
}
|
||
|
|
|
||
|
|
bool EditorWindowSession::IsPrimary() const {
|
||
|
|
return m_state.window.primary;
|
||
|
|
}
|
||
|
|
|
||
|
|
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.beginGlobalTabDrag.has_value()) {
|
||
|
|
m_queuedImmediateFrameTransferRequests.beginGlobalTabDrag =
|
||
|
|
std::move(transferRequests.beginGlobalTabDrag);
|
||
|
|
}
|
||
|
|
if (transferRequests.detachPanel.has_value()) {
|
||
|
|
m_queuedImmediateFrameTransferRequests.detachPanel =
|
||
|
|
std::move(transferRequests.detachPanel);
|
||
|
|
}
|
||
|
|
if (transferRequests.openUtilityWindow.has_value()) {
|
||
|
|
m_queuedImmediateFrameTransferRequests.openUtilityWindow =
|
||
|
|
std::move(transferRequests.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
|