Files
XCEngine/new_editor/app/Platform/Win32/EditorWindowLifecycle.cpp

127 lines
3.3 KiB
C++
Raw Normal View History

#include "Platform/Win32/EditorWindow.h"
#include "Platform/Win32/EditorWindowRuntimeInternal.h"
namespace XCEngine::UI::Editor::App {
using namespace EditorWindowInternal;
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::SetExternalDockHostDropPreview(
const Widgets::UIEditorDockHostDropPreviewState& preview) {
m_composition.shellRuntime.SetExternalDockHostDropPreview(preview);
}
void EditorWindow::ClearExternalDockHostDropPreview() {
m_composition.shellRuntime.ClearExternalDockHostDropPreview();
}
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);
}
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