载入中...
搜索中...
未找到
UISystem.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6#include "ui/UIHost.h"
7
8#include <functional>
9#include <optional>
10#include <string>
11#include <vector>
12
13namespace eve::graphics {
14class Canvas;
15}
16
17namespace eve::ui {
18class UIBackend;
19}
20
21namespace eve::ui {
22
24struct UIEvent {
26 std::string hostName;
27 std::string nodeId;
28 int nodeIndex = -1;
29 std::string kind; // "click" | "toggle" | "value" | "text"
30 uint32_t handlerIndex = 0;
31 bool toggleValue = false;
32 float floatValue = 0.f;
33 std::string textValue;
34};
35
37struct UIClick {
38 std::string hostName;
39 std::string nodeId;
40};
41
43struct UIChange {
44 std::string hostName;
45 std::string nodeId;
46 std::string kind;
47};
48
50enum class DragDropOrigin : uint8_t { Internal = 0, OperatingSystemFile };
51
53enum class DragDropSupport : uint8_t { Supported = 0, UnsupportedPlatform };
54
56struct UIDrop {
58 std::string sourceHostName;
59 std::string sourceNodeId;
60 std::string targetHostName;
61 std::string targetNodeId;
62 std::string payloadType;
63 std::string payloadText;
64};
65
68struct UIStats {
69 int hostCount = 0;
70 int nodeCount = 0;
71 double measureMs = 0.0;
72 double walkMs = 0.0;
73};
74
82 std::string key; // "hostName/nodeId"
84 uint64_t textureId = 0; // registered via UIBackend::registerTexture
85 int width = 0;
86 int height = 0;
87 bool hovered = false;
88 bool active = false; // mouse button held inside the viewport
89 float mouseX = 0.f; // widget-local
90 float mouseY = 0.f;
91 float dragDX = 0.f;
92 float dragDY = 0.f;
93 float wheel = 0.f;
94};
95
98public:
100 static void setBackend(UIBackend &backend);
102 static void clearBackend() noexcept;
110 [[nodiscard]] static eve::OptionalRef<UIBackend> backend();
111 static const UIStats &stats();
119 [[nodiscard]] static eve::OptionalRef<ViewportState> viewportState(const std::string &hostName,
120 const std::string &nodeId);
128 [[nodiscard]] static eve::ResultRef<ViewportState> ensureViewport(const std::string &key, int w, int h);
129
131 static void render();
132
134 static std::vector<UIEvent> &pendingEvents();
136 static void dispatchEvents();
137
146 [[nodiscard]] static UIHostHandle findHost(const std::string &name);
155 [[nodiscard]] static UIHostHandle findHostByOwner(uint32_t ownerId);
156
157 static std::vector<UIClick> &clickQueue();
159 static std::vector<UIChange> &changeQueue();
161 [[nodiscard]] static DragDropSupport dragDropSupport() noexcept;
167 static void enqueuePlatformFileDrop(const std::string &path);
169 static std::vector<UIDrop> &dropQueue();
171 [[nodiscard]] static std::optional<UIDrop> consumeDrop();
173 static std::string consumeClick();
175 static std::string consumeClickFor(const std::string &hostName);
177 static std::string consumeChange();
178};
179
180} // namespace eve::ui
float w
Definition AnimClip.cpp:738
Vocabulary aliases for nullable and checked borrowed references.
std::string nodeId
#define EVENGINE_API_WORLD
Definition Export.h:109
std::uint32_t key
int h
std::string name
OnnxTransferStats stats
Definition OnnxGpgpu.cpp:56
std::string path
Definition PlayHost.cpp:110
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Canvas public API.
Definition Canvas.h:17
Platform / renderer backend for declarative UI. Concrete implementations live under ui/<backend>/ (e....
Definition UIBackend.h:20
EVENGINE_API_WORLD public API.
Definition UISystem.h:97
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
DragDropOrigin
Origin of an owning desktop drag-and-drop payload snapshot.
Definition UISystem.h:50
DragDropSupport
Build-target availability of retained drag-and-drop.
Definition UISystem.h:53
ecs::EntityHandle UIHostHandle
Definition UIHost.h:16
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
Value/text/toggle change for script: "hostName/nodeId".
Definition UISystem.h:43
std::string kind
Definition UISystem.h:46
std::string nodeId
Definition UISystem.h:45
std::string hostName
Definition UISystem.h:44
One script-facing click: "hostName/nodeId".
Definition UISystem.h:37
std::string hostName
Definition UISystem.h:38
std::string nodeId
Definition UISystem.h:39
One completed desktop drop with no borrowed node or platform pointers.
Definition UISystem.h:56
std::string targetHostName
Definition UISystem.h:60
std::string payloadType
Definition UISystem.h:62
DragDropOrigin origin
Definition UISystem.h:57
std::string payloadText
Definition UISystem.h:63
std::string sourceHostName
Definition UISystem.h:58
std::string targetNodeId
Definition UISystem.h:61
std::string sourceNodeId
Definition UISystem.h:59
UIEvent public API.
Definition UISystem.h:24
std::string textValue
Definition UISystem.h:33
UIHostHandle host
Definition UISystem.h:25
std::string kind
Definition UISystem.h:29
std::string nodeId
Definition UISystem.h:27
uint32_t handlerIndex
Definition UISystem.h:30
std::string hostName
Definition UISystem.h:26
UIStats public API.
Definition UISystem.h:68
double measureMs
Definition UISystem.h:71
ViewportState public API.
Definition UISystem.h:81
graphics::Canvas * canvas
Definition UISystem.h:83