载入中...
搜索中...
未找到
UiTween.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
13#include "common/Result.h"
14#include "ui/UIHost.h"
15
16#include <cstdint>
17#include <string>
18#include <vector>
19
20namespace eve::ui {
21
30[[nodiscard]] EVENGINE_API_WORLD float evaluateUiEase(float t, const char *kind);
31
33enum class UiHostTweenTarget : std::uint8_t {
34 Pos = 0,
35 Size = 1,
36 OverlayAlpha = 2,
37};
38
40enum class UiItemTweenTarget : std::uint8_t {
41 Opacity = 0,
42 Pos = 1,
43 Value = 2,
44};
45
50 float fromX = 0.f;
51 float fromY = 0.f;
52 float toX = 0.f;
53 float toY = 0.f;
54 double startMs = 0.0;
55 double durationMs = 0.0;
56 double delayMs = 0.0;
57 std::string ease = "smoothstep";
58};
59
63 std::string nodeId;
66 float fromX = 0.f;
67 float fromY = 0.f;
68 float toX = 0.f;
69 float toY = 0.f;
70 double startMs = 0.0;
71 double durationMs = 0.0;
72 double delayMs = 0.0;
73 std::string ease = "smoothstep";
74};
75
81public:
92 void animateHostPos(UIHostHandle host, float x, float y, float durationMs, const std::string &ease, float delayMs,
93 double nowMs);
94
105 void animateHostSize(UIHostHandle host, float w, float h, float durationMs, const std::string &ease, float delayMs,
106 double nowMs);
107
117 void animateHostOverlayAlpha(UIHostHandle host, float alpha, float durationMs, const std::string &ease,
118 float delayMs, double nowMs);
119
131 [[nodiscard]] eve::Result<void> animateItemOpacity(UIHostHandle host, const std::string &id, float opacity,
132 float durationMs, const std::string &ease, float delayMs,
133 double nowMs);
134
148 [[nodiscard]] eve::Result<void> animateItemPos(UIHostHandle host, const std::string &id, float x, float y,
149 float durationMs, const std::string &ease, float delayMs,
150 double nowMs);
151
157 [[nodiscard]] eve::Result<void> animateItemValue(UIHostHandle host, const std::string &id, float value,
158 float durationMs, const std::string &ease, float delayMs,
159 double nowMs);
160
162 void cancelHost(UIHostHandle host);
163
165 void cancelItem(UIHostHandle host, const std::string &id = {});
166
168 void cancelAll(UIHostHandle host);
169
174 void tick(double nowMs);
175
177 [[nodiscard]] std::size_t hostTweenCount() const noexcept { return hostTweens_.size(); }
178
180 [[nodiscard]] std::size_t itemTweenCount() const noexcept { return itemTweens_.size(); }
181
182private:
183 void replaceHost(UIHostHandle host, UiHostTweenTarget target);
184 void replaceItem(UIHostHandle host, const std::string &id, UiItemTweenTarget target);
185 void applyHost(UiHostTween &t, float k);
186 void applyItem(UiItemTween &t, float k);
187 static bool sameHost(UIHostHandle a, UIHostHandle b) noexcept;
188
189 std::vector<UiHostTween> hostTweens_;
190 std::vector<UiItemTween> itemTweens_;
191};
192
194[[nodiscard]] EVENGINE_API_WORLD double uiTweenWallClockMs();
195
196} // namespace eve::ui
double y
double x
LogicalId target
float w
Definition AnimClip.cpp:738
#define EVENGINE_API_WORLD
Definition Export.h:109
int h
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Object::Ptr value
float t
Move-only, checked operation results for the common layer.
std::string kind
SimulationTick tick
float opacity
UIHostHandle host
Move-only operation result carrying either a value or Status.
Definition Result.h:176
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Owns pending UI tweens and advances them against an injected clock. @ownership UI owns one driver; ha...
Definition UiTween.h:80
std::size_t hostTweenCount() const noexcept
Number of pending host tweens (tests / diagnostics).
Definition UiTween.h:177
std::size_t itemTweenCount() const noexcept
Number of pending item tweens (tests / diagnostics).
Definition UiTween.h:180
UiItemTweenTarget
Retained-node property driven by a float or vec2 tween.
Definition UiTween.h:40
@ Opacity
UINode.opacity (transient)
UiHostTweenTarget
Host window property driven by a vec2 or float tween.
Definition UiTween.h:33
@ OverlayAlpha
Meta.overlayBgAlpha
@ Size
Meta.sizeX / sizeY (px)
@ Pos
Meta.posX / posY (px)
float evaluateUiEase(float t, const char *kind)
Evaluate a UI tween ease curve in [0,1].
Definition UiTween.cpp:35
double uiTweenWallClockMs()
Wall-clock milliseconds from steady_clock (presentation clock).
Definition UiTween.cpp:115
ecs::EntityHandle UIHostHandle
Definition UIHost.h:20
Non-owning node token; valid across property reconciliation, invalid after tree replacement....
Definition UIHost.h:25
One host-level tween slot.
Definition UiTween.h:47
std::string ease
Definition UiTween.h:57
UIHostHandle host
Definition UiTween.h:48
UiHostTweenTarget target
Definition UiTween.h:49
One item-level tween slot scoped to a host + node id.
Definition UiTween.h:61
UiItemTweenTarget target
Definition UiTween.h:65
std::string ease
Definition UiTween.h:73
UIHostHandle host
Definition UiTween.h:62
std::string nodeId
Definition UiTween.h:63
UINodeHandle node
Definition UiTween.h:64