Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorAnimation::AnimatedValue< T, Space > Class Template Reference

Unified motion primitive: one value of type T transitioning from start to target over time, driven by a curve and a clock. More...

#include <PhosphorAnimation/AnimatedValue.h>

Public Member Functions

 AnimatedValue ()=default
 ~AnimatedValue ()=default
 AnimatedValue (const AnimatedValue &)=delete
AnimatedValue & operator= (const AnimatedValue &)=delete
 AnimatedValue (AnimatedValue &&) noexcept=default
AnimatedValue & operator= (AnimatedValue &&) noexcept=default
bool start (T from, T to, MotionSpec< T > spec)
 Begin an animation. Returns false if degenerate (from == to) or invalid.
bool retarget (T newTo, RetargetPolicy policy)
 Redirect in-flight animation to a new target.
bool retarget (T newTo)
 Convenience overload using m_spec.retargetPolicy.
void rebindClock (IMotionClock *newClock)
 Swap the driving clock without touching target/state/interpolation.
void cancel ()
 Stop animating; leave value() at its current position.
template<ColorSpace OtherSpace>
void seedFrom (const AnimatedValue< T, OtherSpace > &other)
 Cross-Space idle-state copy for color-space wrapper dispatch.
template<ColorSpace OtherSpace>
void seedSpecFrom (const AnimatedValue< T, OtherSpace > &other)
 Companion to seedFrom — copies clock + callbacks, leaves profile alone.
void finish ()
 Snap to target immediately, fire onValueChanged + onComplete.
void advance ()
 Advance animation by one paint tick.
T value () const
qreal velocity () const
const CurveState & state () const
bool isAnimating () const
bool isComplete () const
const MotionSpec< T > & spec () const
T from () const
T to () const
QRectF bounds () const
 Bounding rectangle of the swept path including curve overshoot.
QRectF boundsAt (QPointF anchor) const
 Damage rect anchored at anchor — QSizeF specialisation only.
std::pair< QSizeF, QSizeF > sweptSize () const
 (minSize, maxSize) the animation sweeps through, including overshoot.
bool hasSizeChange (qreal epsilonPx=kRectSizeEpsilonPx) const
 True when current size diverges from target by > epsilonPx on either axis.
std::pair< T, T > sweptRange () const
 (lo, hi) of a scalar animation's swept range, with overshoot.

Static Public Member Functions

static constexpr std::chrono::seconds safetyCap () noexcept

Detailed Description

template<typename T, ColorSpace Space = ColorSpace::Linear>
class PhosphorAnimation::AnimatedValue< T, Space >

Unified motion primitive: one value of type T transitioning from start to target over time, driven by a curve and a clock.

Move-only. GUI-thread only (matches IMotionClock's contract).

Constructor & Destructor Documentation

◆ AnimatedValue() [1/3]

template<typename T, ColorSpace Space = ColorSpace::Linear>
PhosphorAnimation::AnimatedValue< T, Space >::AnimatedValue ( )
default

◆ ~AnimatedValue()

template<typename T, ColorSpace Space = ColorSpace::Linear>
PhosphorAnimation::AnimatedValue< T, Space >::~AnimatedValue ( )
default

◆ AnimatedValue() [2/3]

template<typename T, ColorSpace Space = ColorSpace::Linear>
PhosphorAnimation::AnimatedValue< T, Space >::AnimatedValue ( const AnimatedValue< T, Space > & )
delete

◆ AnimatedValue() [3/3]

template<typename T, ColorSpace Space = ColorSpace::Linear>
PhosphorAnimation::AnimatedValue< T, Space >::AnimatedValue ( AnimatedValue< T, Space > && )
defaultnoexcept

Member Function Documentation

◆ advance()

template<typename T, ColorSpace Space = ColorSpace::Linear>
void PhosphorAnimation::AnimatedValue< T, Space >::advance ( )
inline

Advance animation by one paint tick.

No-op when not animating. Spec callbacks must NOT destroy *this while running (see header).

◆ bounds()

template<typename T, ColorSpace Space>
requires detail::PositionalGeometric<T>
QRectF PhosphorAnimation::AnimatedValue< T, Space >::bounds ( ) const

Bounding rectangle of the swept path including curve overshoot.

◆ boundsAt()

template<typename T, ColorSpace Space>
requires detail::SizeGeometric<T>
QRectF PhosphorAnimation::AnimatedValue< T, Space >::boundsAt ( QPointF anchor) const

Damage rect anchored at anchor — QSizeF specialisation only.

◆ cancel()

template<typename T, ColorSpace Space = ColorSpace::Linear>
void PhosphorAnimation::AnimatedValue< T, Space >::cancel ( )
inline

Stop animating; leave value() at its current position.

Does not fire onComplete — cancellation is non-completion. Leaves isAnimating() AND isComplete() both false.

◆ finish()

template<typename T, ColorSpace Space = ColorSpace::Linear>
void PhosphorAnimation::AnimatedValue< T, Space >::finish ( )
inline

Snap to target immediately, fire onValueChanged + onComplete.

◆ from()

template<typename T, ColorSpace Space = ColorSpace::Linear>
T PhosphorAnimation::AnimatedValue< T, Space >::from ( ) const
inline

◆ hasSizeChange()

template<typename T, ColorSpace Space>
requires std::same_as<T, QRectF>
bool PhosphorAnimation::AnimatedValue< T, Space >::hasSizeChange ( qreal epsilonPx = kRectSizeEpsilonPx) const

True when current size diverges from target by > epsilonPx on either axis.

◆ isAnimating()

template<typename T, ColorSpace Space = ColorSpace::Linear>
bool PhosphorAnimation::AnimatedValue< T, Space >::isAnimating ( ) const
inline

◆ isComplete()

template<typename T, ColorSpace Space = ColorSpace::Linear>
bool PhosphorAnimation::AnimatedValue< T, Space >::isComplete ( ) const
inline

◆ operator=() [1/2]

template<typename T, ColorSpace Space = ColorSpace::Linear>
AnimatedValue & PhosphorAnimation::AnimatedValue< T, Space >::operator= ( AnimatedValue< T, Space > && )
defaultnoexcept

◆ operator=() [2/2]

template<typename T, ColorSpace Space = ColorSpace::Linear>
AnimatedValue & PhosphorAnimation::AnimatedValue< T, Space >::operator= ( const AnimatedValue< T, Space > & )
delete

◆ rebindClock()

template<typename T, ColorSpace Space>
void PhosphorAnimation::AnimatedValue< T, Space >::rebindClock ( IMotionClock * newClock)

Swap the driving clock without touching target/state/interpolation.

Swap the driving clock without touching target, state, or interpolation.

Rebases latched timestamps so elapsed/dt survive unchanged across the swap. Both clocks must share an epoch (epochCompatible); incompatible pairs are refused. Passing nullptr cancels the animation.

◆ retarget() [1/2]

template<typename T, ColorSpace Space = ColorSpace::Linear>
bool PhosphorAnimation::AnimatedValue< T, Space >::retarget ( T newTo)
inline

Convenience overload using m_spec.retargetPolicy.

◆ retarget() [2/2]

template<typename T, ColorSpace Space = ColorSpace::Linear>
bool PhosphorAnimation::AnimatedValue< T, Space >::retarget ( T newTo,
RetargetPolicy policy )
inline

Redirect in-flight animation to a new target.

Returns false on rejection (no stored spec) or degenerate target (complete-in-place).

◆ safetyCap()

template<typename T, ColorSpace Space = ColorSpace::Linear>
constexpr std::chrono::seconds PhosphorAnimation::AnimatedValue< T, Space >::safetyCap ( )
inlinestaticconstexprnoexcept

◆ seedFrom()

template<typename T, ColorSpace Space>
template<ColorSpace OtherSpace>
void PhosphorAnimation::AnimatedValue< T, Space >::seedFrom ( const AnimatedValue< T, OtherSpace > & other)

Cross-Space idle-state copy for color-space wrapper dispatch.

Copy idle state (from, to, current, isComplete) from a sibling that differs only in ColorSpace.

No-op if either side is animating.

◆ seedSpecFrom()

template<typename T, ColorSpace Space>
template<ColorSpace OtherSpace>
void PhosphorAnimation::AnimatedValue< T, Space >::seedSpecFrom ( const AnimatedValue< T, OtherSpace > & other)

Companion to seedFrom — copies clock + callbacks, leaves profile alone.

Copy clock + callbacks from a sibling's MotionSpec, leaving profile alone.

Keeps the target instance retarget-able after a space flip. Idle-only.

◆ spec()

template<typename T, ColorSpace Space = ColorSpace::Linear>
const MotionSpec< T > & PhosphorAnimation::AnimatedValue< T, Space >::spec ( ) const
inline

◆ start()

template<typename T, ColorSpace Space = ColorSpace::Linear>
bool PhosphorAnimation::AnimatedValue< T, Space >::start ( T from,
T to,
MotionSpec< T > spec )
inline

Begin an animation. Returns false if degenerate (from == to) or invalid.

◆ state()

template<typename T, ColorSpace Space = ColorSpace::Linear>
const CurveState & PhosphorAnimation::AnimatedValue< T, Space >::state ( ) const
inline

◆ sweptRange()

template<typename T, ColorSpace Space>
requires detail::ScalarValue<T>
std::pair< T, T > PhosphorAnimation::AnimatedValue< T, Space >::sweptRange ( ) const

(lo, hi) of a scalar animation's swept range, with overshoot.

◆ sweptSize()

template<typename T, ColorSpace Space>
requires detail::SizeGeometric<T>
std::pair< QSizeF, QSizeF > PhosphorAnimation::AnimatedValue< T, Space >::sweptSize ( ) const

(minSize, maxSize) the animation sweeps through, including overshoot.

◆ to()

template<typename T, ColorSpace Space = ColorSpace::Linear>
T PhosphorAnimation::AnimatedValue< T, Space >::to ( ) const
inline

◆ value()

template<typename T, ColorSpace Space = ColorSpace::Linear>
T PhosphorAnimation::AnimatedValue< T, Space >::value ( ) const
inline

◆ velocity()

template<typename T, ColorSpace Space = ColorSpace::Linear>
qreal PhosphorAnimation::AnimatedValue< T, Space >::velocity ( ) const
inline

The documentation for this class was generated from the following files: