Integrate XCUI runtime context into SceneRuntime

This commit is contained in:
2026-04-05 06:52:17 +08:00
parent edf434aa03
commit d46dcbfa9e
7 changed files with 323 additions and 2 deletions

View File

@@ -1,12 +1,37 @@
#pragma once
#include <XCEngine/Scene/Scene.h>
#include <XCEngine/UI/Types.h>
#include <memory>
namespace XCEngine {
namespace UI {
namespace Runtime {
class UISceneRuntimeContext;
class UISystem;
class UIScreenStackController;
struct UISystemFrameResult;
} // namespace Runtime
} // namespace UI
} // namespace XCEngine
namespace XCEngine {
namespace Components {
class SceneRuntime {
public:
SceneRuntime();
~SceneRuntime();
SceneRuntime(SceneRuntime&& other) noexcept;
SceneRuntime& operator=(SceneRuntime&& other) noexcept;
SceneRuntime(const SceneRuntime&) = delete;
SceneRuntime& operator=(const SceneRuntime&) = delete;
void Start(Scene* scene);
void Stop();
@@ -14,10 +39,19 @@ public:
void Update(float deltaTime);
void LateUpdate(float deltaTime);
UI::Runtime::UISystem& GetUISystem();
UI::Runtime::UIScreenStackController& GetUIScreenStackController();
const UI::Runtime::UISystemFrameResult& GetLastUIFrame() const;
void SetUIViewportRect(const UI::UIRect& viewportRect);
void SetUIFocused(bool focused);
void QueueUIInputEvent(const UI::UIInputEvent& event);
void ClearQueuedUIInputEvents();
bool IsRunning() const { return m_running; }
Scene* GetScene() const { return m_scene; }
private:
std::unique_ptr<UI::Runtime::UISceneRuntimeContext> m_uiRuntime;
Scene* m_scene = nullptr;
bool m_running = false;
};

View File

@@ -0,0 +1,40 @@
#pragma once
#include <XCEngine/UI/Runtime/UIScreenDocumentHost.h>
#include <XCEngine/UI/Runtime/UIScreenStackController.h>
#include <XCEngine/UI/Runtime/UISystem.h>
namespace XCEngine {
namespace UI {
namespace Runtime {
class UISceneRuntimeContext {
public:
UISceneRuntimeContext();
UISystem& GetSystem();
const UISystem& GetSystem() const;
UIScreenStackController& GetStackController();
const UIScreenStackController& GetStackController() const;
const UISystemFrameResult& GetLastFrame() const;
void Reset();
void SetViewportRect(const UIRect& viewportRect);
void SetFocused(bool focused);
void QueueInputEvent(const UIInputEvent& event);
void ClearQueuedInputEvents();
void Update(double deltaTimeSeconds);
private:
UIDocumentScreenHost m_documentHost = {};
UISystem m_system;
UIScreenStackController m_stackController;
UIScreenFrameInput m_pendingFrameInput = {};
std::uint64_t m_nextFrameIndex = 1u;
};
} // namespace Runtime
} // namespace UI
} // namespace XCEngine