refactor(new_editor/app): reorganize host structure and add smoke test
This commit is contained in:
173
new_editor/app/Platform/Win32/EditorWindowLifecycle.cpp
Normal file
173
new_editor/app/Platform/Win32/EditorWindowLifecycle.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
#include "Platform/Win32/EditorWindow.h"
|
||||
#include "Platform/Win32/EditorWindowRuntimeSupport.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
using namespace EditorWindowSupport;
|
||||
|
||||
EditorWindow::EditorWindow(
|
||||
std::string windowId,
|
||||
std::wstring title,
|
||||
bool primary,
|
||||
UIEditorWorkspaceController workspaceController)
|
||||
: m_window{
|
||||
nullptr,
|
||||
std::move(windowId),
|
||||
std::move(title),
|
||||
{},
|
||||
primary }
|
||||
, m_composition{ std::move(workspaceController), {} } {
|
||||
UpdateCachedTitleText();
|
||||
}
|
||||
|
||||
std::string_view EditorWindow::GetWindowId() const {
|
||||
return m_window.windowId;
|
||||
}
|
||||
|
||||
HWND EditorWindow::GetHwnd() const {
|
||||
return m_window.hwnd;
|
||||
}
|
||||
|
||||
bool EditorWindow::HasHwnd() const {
|
||||
return m_window.hwnd != nullptr;
|
||||
}
|
||||
|
||||
bool EditorWindow::IsPrimary() const {
|
||||
return m_window.primary;
|
||||
}
|
||||
|
||||
bool EditorWindow::IsRenderReady() const {
|
||||
return m_render.ready;
|
||||
}
|
||||
|
||||
bool EditorWindow::IsTrackingMouseLeave() const {
|
||||
return m_input.trackingMouseLeave;
|
||||
}
|
||||
|
||||
bool EditorWindow::HasHoveredBorderlessResizeEdge() const {
|
||||
return m_chrome.runtime.GetHoveredBorderlessResizeEdge() !=
|
||||
Host::BorderlessWindowResizeEdge::None;
|
||||
}
|
||||
|
||||
const std::wstring& EditorWindow::GetTitle() const {
|
||||
return m_window.title;
|
||||
}
|
||||
|
||||
const UIEditorWorkspaceController& EditorWindow::GetWorkspaceController() const {
|
||||
return m_composition.workspaceController;
|
||||
}
|
||||
|
||||
UIEditorWorkspaceController& EditorWindow::GetWorkspaceController() {
|
||||
return m_composition.workspaceController;
|
||||
}
|
||||
|
||||
const EditorShellRuntime& EditorWindow::GetShellRuntime() const {
|
||||
return m_composition.shellRuntime;
|
||||
}
|
||||
|
||||
EditorShellRuntime& EditorWindow::GetShellRuntime() {
|
||||
return m_composition.shellRuntime;
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionFrame& EditorWindow::GetShellFrame() const {
|
||||
return m_composition.shellRuntime.GetShellFrame();
|
||||
}
|
||||
|
||||
const UIEditorShellInteractionState& EditorWindow::GetShellInteractionState() const {
|
||||
return m_composition.shellRuntime.GetShellInteractionState();
|
||||
}
|
||||
|
||||
void EditorWindow::AttachHwnd(HWND hwnd) {
|
||||
m_window.hwnd = hwnd;
|
||||
}
|
||||
|
||||
void EditorWindow::MarkDestroyed() {
|
||||
m_window.hwnd = nullptr;
|
||||
m_input.trackingMouseLeave = false;
|
||||
}
|
||||
|
||||
void EditorWindow::SetTrackingMouseLeave(bool trackingMouseLeave) {
|
||||
m_input.trackingMouseLeave = trackingMouseLeave;
|
||||
}
|
||||
|
||||
void EditorWindow::SetTitle(std::wstring title) {
|
||||
m_window.title = std::move(title);
|
||||
UpdateCachedTitleText();
|
||||
}
|
||||
|
||||
void EditorWindow::ReplaceWorkspaceController(UIEditorWorkspaceController workspaceController) {
|
||||
m_composition.workspaceController = std::move(workspaceController);
|
||||
}
|
||||
|
||||
std::optional<EditorWindowPendingTabDragStart> EditorWindow::ConsumePendingTabDragStart() {
|
||||
if (!m_pendingTabDragStart.pending ||
|
||||
m_pendingTabDragStart.nodeId.empty() ||
|
||||
m_pendingTabDragStart.panelId.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
EditorWindowPendingTabDragStart pending = {};
|
||||
pending.nodeId = std::move(m_pendingTabDragStart.nodeId);
|
||||
pending.panelId = std::move(m_pendingTabDragStart.panelId);
|
||||
pending.screenPoint = m_pendingTabDragStart.screenPoint;
|
||||
|
||||
m_pendingTabDragStart = {};
|
||||
return pending;
|
||||
}
|
||||
|
||||
std::optional<EditorWindowPendingDetachRequest> EditorWindow::ConsumeDetachRequest() {
|
||||
if (!m_pendingDetachRequest.pending ||
|
||||
m_pendingDetachRequest.nodeId.empty() ||
|
||||
m_pendingDetachRequest.panelId.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
EditorWindowPendingDetachRequest pending = {};
|
||||
pending.nodeId = std::move(m_pendingDetachRequest.nodeId);
|
||||
pending.panelId = std::move(m_pendingDetachRequest.panelId);
|
||||
pending.screenPoint = m_pendingDetachRequest.screenPoint;
|
||||
|
||||
m_pendingDetachRequest = {};
|
||||
return pending;
|
||||
}
|
||||
|
||||
void EditorWindow::QueuePendingTabDragStart(std::string_view nodeId, std::string_view panelId) {
|
||||
POINT screenPoint = {};
|
||||
if (!GetCursorPos(&screenPoint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pendingTabDragStart.pending = true;
|
||||
m_pendingTabDragStart.nodeId = std::string(nodeId);
|
||||
m_pendingTabDragStart.panelId = std::string(panelId);
|
||||
m_pendingTabDragStart.screenPoint = screenPoint;
|
||||
}
|
||||
|
||||
void EditorWindow::QueuePendingDetachRequest(std::string_view nodeId, std::string_view panelId) {
|
||||
POINT screenPoint = {};
|
||||
if (!GetCursorPos(&screenPoint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pendingDetachRequest.pending = true;
|
||||
m_pendingDetachRequest.nodeId = std::string(nodeId);
|
||||
m_pendingDetachRequest.panelId = std::string(panelId);
|
||||
m_pendingDetachRequest.screenPoint = screenPoint;
|
||||
}
|
||||
|
||||
void EditorWindow::InvalidateHostWindow() const {
|
||||
if (m_window.hwnd != nullptr && IsWindow(m_window.hwnd)) {
|
||||
InvalidateRect(m_window.hwnd, nullptr, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorWindow::IsVerboseRuntimeTraceEnabled() {
|
||||
static const bool s_enabled = ResolveVerboseRuntimeTraceEnabled();
|
||||
return s_enabled;
|
||||
}
|
||||
|
||||
void EditorWindow::UpdateCachedTitleText() {
|
||||
m_window.titleText = WideToUtf8(m_window.title);
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user