载入中...
搜索中...
未找到
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};
44
49 float fromX = 0.f;
50 float fromY = 0.f;
51 float toX = 0.f;
52 float toY = 0.f;
53 double startMs = 0.0;
54 double durationMs = 0.0;
55 double delayMs = 0.0;
56 std::string ease = "smoothstep";
57};
58
62 std::string nodeId;
64 float fromX = 0.f;
65 float fromY = 0.f;
66 float toX = 0.f;
67 float toY = 0.f;
68 double startMs = 0.0;
69 double durationMs = 0.0;
70 double delayMs = 0.0;
71 std::string ease = "smoothstep";
72};
73
79public:
90 void animateHostPos(UIHostHandle host, float x, float y, float durationMs, const std::string &ease, float delayMs,
91 double nowMs);
92
103 void animateHostSize(UIHostHandle host, float w, float h, float durationMs, const std::string &ease, float delayMs,
104 double nowMs);
105
115 void animateHostOverlayAlpha(UIHostHandle host, float alpha, float durationMs, const std::string &ease,
116 float delayMs, double nowMs);
117
129 [[nodiscard]] eve::Result<void> animateItemOpacity(UIHostHandle host, const std::string &id, float opacity,
130 float durationMs, const std::string &ease, float delayMs,
131 double nowMs);
132
146 [[nodiscard]] eve::Result<void> animateItemPos(UIHostHandle host, const std::string &id, float x, float y,
147 float durationMs, const std::string &ease, float delayMs,
148 double nowMs);
149
151 void cancelHost(UIHostHandle host);
152
154 void cancelItem(UIHostHandle host, const std::string &id = {});
155
157 void cancelAll(UIHostHandle host);
158
163 void tick(double nowMs);
164
166 [[nodiscard]] std::size_t hostTweenCount() const noexcept { return hostTweens_.size(); }
167
169 [[nodiscard]] std::size_t itemTweenCount() const noexcept { return itemTweens_.size(); }
170
171private:
172 void replaceHost(UIHostHandle host, UiHostTweenTarget target);
173 void replaceItem(UIHostHandle host, const std::string &id, UiItemTweenTarget target);
174 void applyHost(UiHostTween &t, float k);
175 void applyItem(UiItemTween &t, float k);
176 static bool sameHost(UIHostHandle a, UIHostHandle b) noexcept;
177
178 std::vector<UiHostTween> hostTweens_;
179 std::vector<UiItemTween> itemTweens_;
180};
181
183[[nodiscard]] EVENGINE_API_WORLD double uiTweenWallClockMs();
184
185} // namespace eve::ui
LogicalId target
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#define EVENGINE_API_WORLD
Definition Export.h:109
int h
TokenKind kind
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
float t
Move-only, checked operation results for the common layer.
SimulationTick tick
float opacity
UIHostHandle host
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Owns pending UI tweens and advances them against an injected clock. @ownership UI owns one driver; ha...
Definition UiTween.h:78
std::size_t hostTweenCount() const noexcept
Number of pending host tweens (tests / diagnostics).
Definition UiTween.h:166
std::size_t itemTweenCount() const noexcept
Number of pending item tweens (tests / diagnostics).
Definition UiTween.h:169
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:16
One host-level tween slot.
Definition UiTween.h:46
std::string ease
Definition UiTween.h:56
UIHostHandle host
Definition UiTween.h:47
UiHostTweenTarget target
Definition UiTween.h:48
One item-level tween slot scoped to a host + node id.
Definition UiTween.h:60
UiItemTweenTarget target
Definition UiTween.h:63
std::string ease
Definition UiTween.h:71
UIHostHandle host
Definition UiTween.h:61
std::string nodeId
Definition UiTween.h:62