Files
XCEngine/editor/app/Platform/Win32/Runtime/EditorWindowRuntimeController.h

106 lines
3.8 KiB
C++

#pragma once
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include "Windowing/Content/EditorWindowContentController.h"
#include "Platform/Win32/Runtime/EditorWindowScreenshotController.h"
#include <Rendering/D3D12/D3D12UiRenderer.h>
#include <Rendering/D3D12/D3D12UiTextSystem.h>
#include <Rendering/D3D12/D3D12UiTextureHost.h>
#include <Rendering/D3D12/D3D12WindowRenderLoop.h>
#include <Rendering/D3D12/D3D12WindowRenderer.h>
#include <XCEngine/UI/DrawData.h>
#include <windows.h>
#include <chrono>
#include <filesystem>
#include <memory>
#include <string>
namespace XCEngine::UI::Editor::App {
class EditorContext;
class EditorWindowRuntimeController final {
public:
explicit EditorWindowRuntimeController(
std::unique_ptr<EditorWindowContentController> contentController);
~EditorWindowRuntimeController();
EditorWindowRuntimeController(const EditorWindowRuntimeController&) = delete;
EditorWindowRuntimeController& operator=(const EditorWindowRuntimeController&) = delete;
EditorWindowRuntimeController(EditorWindowRuntimeController&&) = delete;
EditorWindowRuntimeController& operator=(EditorWindowRuntimeController&&) = delete;
bool IsReady() const;
EditorWindowWorkspaceBinding* TryGetWorkspaceBinding();
const EditorWindowWorkspaceBinding* TryGetWorkspaceBinding() const;
EditorWindowDockHostBinding* TryGetDockHostBinding();
const EditorWindowDockHostBinding* TryGetDockHostBinding() const;
const EditorWindowInputFeedbackBinding* TryGetInputFeedbackBinding() const;
const EditorWindowTitleBarBinding* TryGetTitleBarBinding() const;
const UIEditorShellInteractionFrame& GetShellFrame() const;
const UIEditorShellInteractionState& GetShellInteractionState() const;
::XCEngine::UI::UISize ResolveMinimumOuterSize() const;
void SetDpiScale(float dpiScale);
::XCEngine::UI::Editor::UIEditorTextMeasurer& GetTextMeasurer();
const ::XCEngine::UI::Editor::UIEditorTextMeasurer& GetTextMeasurer() const;
const ::XCEngine::UI::UITextureHandle& GetTitleBarLogoIcon() const;
bool Initialize(
HWND hwnd,
const std::filesystem::path& repoRoot,
EditorContext& editorContext,
const std::filesystem::path& captureRoot,
bool autoCaptureOnStartup);
void Shutdown();
void ResetInteractionState();
bool ApplyResize(UINT width, UINT height);
Host::D3D12WindowRenderLoopFrameContext BeginFrame();
Host::D3D12WindowRenderLoopPresentResult Present(
const ::XCEngine::UI::UIDrawData& drawData);
EditorWindowFrameTransferRequests UpdateAndAppend(
const EditorWindowContentFrameContext& context,
::XCEngine::UI::UIDrawData& drawData);
void RenderRequestedViewports(
const ::XCEngine::Rendering::RenderContext& renderContext);
void RequestManualScreenshot(std::string reason);
std::string BuildCaptureStatusText() const;
std::string BuildFrameRateText() const;
private:
void ResetFrameTiming();
void UpdateFrameTiming();
void RefreshDisplayedFrameStats();
Host::D3D12WindowRenderer m_windowRenderer = {};
Host::D3D12UiTextureHost m_textureHost = {};
Host::D3D12UiTextSystem m_textSystem = {};
Host::D3D12UiRenderer m_uiRenderer = {};
Host::D3D12WindowRenderLoop m_windowRenderLoop = {};
EditorWindowScreenshotController m_screenshotController = {};
::XCEngine::UI::UITextureHandle m_titleBarLogoIcon = {};
std::unique_ptr<EditorWindowContentController> m_contentController = {};
std::chrono::steady_clock::time_point m_lastFrameTime = {};
bool m_hasLastFrameTime = false;
float m_smoothedDeltaTimeSeconds = 0.0f;
float m_frameStatsDisplayAccumulatorSeconds = 0.0f;
float m_displayFps = 0.0f;
float m_displayFrameTimeMs = 0.0f;
float m_dpiScale = 1.0f;
std::string m_frameRateText = {};
bool m_ready = false;
};
} // namespace XCEngine::UI::Editor::App