51 ae::q20_12_t t = ae::q20_12_t{1};
62 static T
lerpValue(
const T& a,
const T& b, ae::q20_12_t t)
65 if constexpr (std::is_same_v<T, int>)
67 return math.
lerp(a, b, t);
69 else if constexpr (std::is_same_v<T, ae::q20_12_t>)
71 return math.
lerp(a, b, t);
73 else if constexpr (std::is_same_v<T, Point2D<int>>)
77 else if constexpr (std::is_same_v<T, Point2D<ae::q20_12_t>>)
83 static_assert(
sizeof(T) == 0,
"UIPropertyAnimation: unsupported type");
150 std::shared_ptr<UIAnimation>
build()
const
153 const ae::q20_12_t durationSec = math.
div(ae::q20_12_t{
durationMs}, ae::q20_12_t{1000});
155 auto anim = std::make_shared<UIPropertyAnimation<T>>(
ptr, f,
toVal, durationSec,
easeType);
Non-copyable wrapper around a value that UI tweens can target.
Weak handle used by callers to cancel/pause/query a running UI animation.
Base class for one UI animation step (property, delay, callback, sequence).
UIRepeatMode
How an animation behaves after reaching its end.
@ Loop
Restart from the beginning.
@ PingPong
Reverse direction each cycle.
@ Once
Play once, then complete.
Easing mode alias for UI property animations.
MathManager::EaseMode UIEase
Easing curves available to UI tweens.
ae::q20_12_t clamp(ae::q20_12_t v, ae::q20_12_t lo, ae::q20_12_t hi)
Clamps a Q20.12 value to [lo, hi].
ae::q20_12_t ease(EaseMode mode, ae::q20_12_t t)
Applies an easing curve to a normalized time value.
ae::q20_12_t div(ae::q20_12_t num, ae::q20_12_t den)
Divides two Q20.12 values.
ae::q20_12_t lerp(ae::q20_12_t a, ae::q20_12_t b, ae::q20_12_t t)
Linearly interpolates two Q20.12 values.
Non-owning control handle for a UIAnimation managed by UIAnimator.
virtual void reset()
Resets runtime state so the animation can play again (used by Loop).
UIAnimation(const UIAnimation &)=delete
Owns and ticks active UI animations. Safe against cancel-during-tick.
UIPropertyAnimationBuilder & repeat(UIRepeatMode mode, int count=-1)
UIPropertyAnimationBuilder & to(const T &v)
UIAnimationHandle start()
UIPropertyAnimationBuilder & ease(UIEase e)
UIPropertyAnimationBuilder(T &tgt, UIAnimator *animOwner=nullptr)
UIPropertyAnimationBuilder & pingPong(int count=-1)
UIPropertyAnimationBuilder & loop(int count=-1)
UIPropertyAnimationBuilder & duration(int ms)
Duration in milliseconds.
std::shared_ptr< UIAnimation > build() const
UIPropertyAnimationBuilder & from(const T &v)
void reset() override
Resets runtime state so the animation can play again (used by Loop).
bool onUpdate(ae::q20_12_t dt) override
Per-frame update.
static T lerpValue(const T &a, const T &b, ae::q20_12_t t)
UIPropertyAnimation(T *tgt, const T &fromVal, const T &toVal, ae::q20_12_t durationSec, UIEase easeMode)