#pragma once #include "Panel.h" #include "XCUIBackend/XCUIHostedPreviewPresenter.h" #include "XCUIBackend/XCUIInputBridge.h" #include "XCUIBackend/XCUIPanelCanvasHost.h" #include "XCUIBackend/XCUIDemoRuntime.h" #include #include #include namespace XCEngine { namespace NewEditor { struct XCUIDemoPanelFrameComposeOptions { float canvasHeight = 0.0f; float canvasTopInset = 0.0f; bool hostedPreviewEnabled = true; bool showCanvasHud = true; bool showDebugRects = true; std::uint64_t timestampNanoseconds = 0; const char* canvasChildId = "XCUIDemoCanvasHost"; const ::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameSnapshot* inputSnapshot = nullptr; bool useDefaultPlaceholder = true; const char* placeholderTitle = nullptr; const char* placeholderSubtitle = nullptr; bool drawPreviewFrame = true; const char* badgeTitle = nullptr; const char* badgeSubtitle = nullptr; }; struct XCUIDemoPanelFrameComposition { ::XCEngine::Editor::XCUIBackend::XCUIPanelCanvasSession canvasSession = {}; ::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameSnapshot inputSnapshot = {}; ::XCEngine::Editor::XCUIBackend::XCUIInputBridgeFrameDelta inputDelta = {}; ::XCEngine::Editor::XCUIBackend::XCUIDemoInputState input = {}; const ::XCEngine::Editor::XCUIBackend::XCUIDemoFrameResult* frame = nullptr; ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats previewStats = {}; ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewSurfaceDescriptor hostedSurfaceDescriptor = {}; ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewSurfaceImage hostedSurfaceImage = {}; bool hostedPreviewEnabled = false; bool nativeHostedPreview = false; bool hasHostedSurfaceDescriptor = false; bool showHostedSurfaceImage = false; std::string previewPathLabel = {}; std::string previewStateLabel = {}; }; class XCUIDemoPanel : public Panel { public: explicit XCUIDemoPanel( ::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* inputSource = nullptr); XCUIDemoPanel( ::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* inputSource, std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> previewPresenter, std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> canvasHost = nullptr); ~XCUIDemoPanel() override = default; void Render() override; const XCUIDemoPanelFrameComposition& ComposeFrame( const XCUIDemoPanelFrameComposeOptions& options = XCUIDemoPanelFrameComposeOptions()); void SetHostedPreviewEnabled(bool enabled); void SetHostedPreviewPresenter( std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> previewPresenter); void SetCanvasHost( std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> canvasHost); bool IsHostedPreviewEnabled() const { return m_hostedPreviewEnabled; } bool IsUsingNativeHostedPreview() const; const ::XCEngine::Editor::XCUIBackend::XCUIDemoFrameResult& GetFrameResult() const; const ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats& GetLastPreviewStats() const; const XCUIDemoPanelFrameComposition& GetLastFrameComposition() const; bool GetLastReloadSucceeded() const { return m_lastReloadSucceeded; } private: bool m_lastReloadSucceeded = false; bool m_hostedPreviewEnabled = true; bool m_showCanvasHud = true; bool m_showDebugRects = true; ::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* m_inputSource = nullptr; ::XCEngine::Editor::XCUIBackend::XCUIInputBridge m_inputBridge; ::XCEngine::Editor::XCUIBackend::XCUIDemoRuntime m_runtime; std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> m_previewPresenter; std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> m_canvasHost; ::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats m_lastPreviewStats = {}; XCUIDemoPanelFrameComposition m_lastFrameComposition = {}; }; } // namespace NewEditor } // namespace XCEngine