#include "Platform/Win32/EditorWindow.h" #include "Platform/Win32/EditorWindowConstants.h" #include "Platform/Win32/EditorWindowInputSupport.h" #include "Platform/Win32/EditorWindowRuntimeSupport.h" #include "Platform/Win32/EditorWindowStyle.h" #include #include namespace XCEngine::UI::Editor::App { using namespace EditorWindowSupport; using ::XCEngine::UI::UIDrawData; using ::XCEngine::UI::UIDrawList; using ::XCEngine::UI::UIInputEvent; using ::XCEngine::UI::UIPoint; using ::XCEngine::UI::UIRect; void EditorWindow::RenderFrame( EditorContext& editorContext, bool globalTabDragActive) { if (!m_render.ready || m_window.hwnd == nullptr) { return; } UINT pixelWidth = 0u; UINT pixelHeight = 0u; if (!ResolveRenderClientPixelSize(pixelWidth, pixelHeight)) { return; } const float width = PixelsToDips(static_cast(pixelWidth)); const float height = PixelsToDips(static_cast(pixelHeight)); const UIRect workspaceBounds = ResolveWorkspaceBounds(width, height); UIDrawData drawData = {}; UIDrawList& drawList = drawData.EmplaceDrawList("XCEditorShell"); drawList.AddFilledRect( UIRect(0.0f, 0.0f, width, height), kShellSurfaceColor); if (editorContext.IsValid()) { RenderRuntimeFrame(editorContext, globalTabDragActive, workspaceBounds, drawList); } else { RenderInvalidFrame(editorContext, drawList); } AppendBorderlessWindowChrome(drawList, width); const Host::D3D12WindowRenderLoopPresentResult presentResult = m_render.windowRenderLoop.Present(drawData); if (!presentResult.warning.empty()) { LogRuntimeTrace("present", presentResult.warning); } m_render.autoScreenshot.CaptureIfRequested( m_render.renderer, drawData, pixelWidth, pixelHeight, presentResult.framePresented); } void EditorWindow::OnPaintMessage( EditorContext& editorContext, bool globalTabDragActive) { if (!m_render.ready || m_window.hwnd == nullptr) { return; } PAINTSTRUCT paintStruct = {}; BeginPaint(m_window.hwnd, &paintStruct); RenderFrame(editorContext, globalTabDragActive); EndPaint(m_window.hwnd, &paintStruct); } UIRect EditorWindow::ResolveWorkspaceBounds(float clientWidthDips, float clientHeightDips) const { if (!IsBorderlessWindowEnabled()) { return UIRect(0.0f, 0.0f, clientWidthDips, clientHeightDips); } if (ShouldUseDetachedTitleBarTabStrip()) { return UIRect(0.0f, 0.0f, clientWidthDips, clientHeightDips); } const float titleBarHeight = (std::min)(kBorderlessTitleBarHeightDips, clientHeightDips); return UIRect( 0.0f, titleBarHeight, clientWidthDips, (std::max)(0.0f, clientHeightDips - titleBarHeight)); } } // namespace XCEngine::UI::Editor::App