Files
XCEngine/new_editor/src/panels/XCUIDemoPanel.h

92 lines
4.0 KiB
C
Raw Normal View History

2026-04-05 04:55:25 +08:00
#pragma once
#include "Panel.h"
#include "XCUIBackend/XCUIHostedPreviewPresenter.h"
#include "XCUIBackend/XCUIInputBridge.h"
2026-04-05 12:30:03 +08:00
#include "XCUIBackend/XCUIPanelCanvasHost.h"
2026-04-05 04:55:25 +08:00
#include "XCUIBackend/XCUIDemoRuntime.h"
#include <cstdint>
2026-04-05 04:55:25 +08:00
#include <memory>
#include <string>
2026-04-05 04:55:25 +08:00
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 = {};
};
2026-04-05 04:55:25 +08:00
class XCUIDemoPanel : public Panel {
public:
explicit XCUIDemoPanel(
::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* inputSource = nullptr);
2026-04-05 04:55:25 +08:00
XCUIDemoPanel(
::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* inputSource,
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> previewPresenter,
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> canvasHost = nullptr);
2026-04-05 04:55:25 +08:00
~XCUIDemoPanel() override = default;
void Render() override;
const XCUIDemoPanelFrameComposition& ComposeFrame(
const XCUIDemoPanelFrameComposeOptions& options = XCUIDemoPanelFrameComposeOptions());
2026-04-05 04:55:25 +08:00
void SetHostedPreviewEnabled(bool enabled);
void SetHostedPreviewPresenter(
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> previewPresenter);
2026-04-05 12:30:03 +08:00
void SetCanvasHost(
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> canvasHost);
2026-04-05 04:55:25 +08:00
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; }
2026-04-05 04:55:25 +08:00
private:
bool m_lastReloadSucceeded = false;
bool m_hostedPreviewEnabled = true;
bool m_showCanvasHud = true;
bool m_showDebugRects = true;
::XCEngine::Editor::XCUIBackend::IXCUIInputSnapshotSource* m_inputSource = nullptr;
2026-04-05 04:55:25 +08:00
::XCEngine::Editor::XCUIBackend::XCUIInputBridge m_inputBridge;
::XCEngine::Editor::XCUIBackend::XCUIDemoRuntime m_runtime;
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIHostedPreviewPresenter> m_previewPresenter;
2026-04-05 12:30:03 +08:00
std::unique_ptr<::XCEngine::Editor::XCUIBackend::IXCUIPanelCanvasHost> m_canvasHost;
2026-04-05 04:55:25 +08:00
::XCEngine::Editor::XCUIBackend::XCUIHostedPreviewStats m_lastPreviewStats = {};
XCUIDemoPanelFrameComposition m_lastFrameComposition = {};
2026-04-05 04:55:25 +08:00
};
} // namespace NewEditor
} // namespace XCEngine