116 lines
4.2 KiB
C++
116 lines
4.2 KiB
C++
#pragma once
|
|
|
|
#ifndef NOMINMAX
|
|
#define NOMINMAX
|
|
#endif
|
|
|
|
#include "Windowing/Content/EditorWindowContentController.h"
|
|
#include "Windowing/Runtime/EditorWindowScreenshotController.h"
|
|
|
|
#include <Rendering/Host/EditorWindowRenderRuntime.h>
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace XCEngine::UI {
|
|
|
|
class UIDrawList;
|
|
|
|
} // namespace XCEngine::UI
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
class EditorContext;
|
|
|
|
class EditorWindowRuntimeController final {
|
|
public:
|
|
EditorWindowRuntimeController(
|
|
EditorContext& editorContext,
|
|
std::unique_ptr<EditorWindowContentController> contentController,
|
|
std::unique_ptr<Rendering::Host::EditorWindowRenderRuntime> renderRuntime);
|
|
~EditorWindowRuntimeController();
|
|
|
|
EditorWindowRuntimeController(const EditorWindowRuntimeController&) = delete;
|
|
EditorWindowRuntimeController& operator=(const EditorWindowRuntimeController&) = delete;
|
|
EditorWindowRuntimeController(EditorWindowRuntimeController&&) = delete;
|
|
EditorWindowRuntimeController& operator=(EditorWindowRuntimeController&&) = delete;
|
|
|
|
bool IsReady() const;
|
|
EditorWindowContentCapabilities GetCapabilities() 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(
|
|
const Rendering::Host::EditorWindowRenderRuntimeInitializeParams& renderParams,
|
|
const std::filesystem::path& repoRoot,
|
|
const std::filesystem::path& captureRoot,
|
|
bool autoCaptureOnStartup);
|
|
void Shutdown();
|
|
void ResetInteractionState();
|
|
bool ApplyResize(std::uint32_t width, std::uint32_t height);
|
|
|
|
void PrepareEditorContext();
|
|
bool IsEditorContextValid() const;
|
|
void AppendInvalidFrame(::XCEngine::UI::UIDrawList& drawList) const;
|
|
Rendering::Host::EditorWindowRenderRuntimeFrameContext BeginFrame();
|
|
Rendering::Host::EditorWindowRenderRuntimePresentResult Present(
|
|
const ::XCEngine::UI::UIDrawData& drawData);
|
|
EditorWindowFrameTransferRequests UpdateAndAppend(
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
|
std::optional<EditorWindowScreenPoint> cursorScreenPoint,
|
|
bool primary,
|
|
bool globalTabDragActive,
|
|
bool useDetachedTitleBarTabStrip,
|
|
::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();
|
|
|
|
EditorContext& m_editorContext;
|
|
std::unique_ptr<Rendering::Host::EditorWindowRenderRuntime> m_renderRuntime = {};
|
|
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
|