1.8
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
PropertyAnimatorType< T > Class Template Reference

Animates a property of a widget. More...

Inheritance diagram for PropertyAnimatorType< T >:
Inheritance graph
[legend]

Public Types

using PropertyCallback = std::function< void(T v)>
 Property callback type. More...
 
using Value = T
 Alias for the value type of the animator. More...
 

Public Member Functions

 PropertyAnimatorType (std::chrono::milliseconds duration, const EasingFunc &func=easing_linear)
 
 PropertyAnimatorType (T start=T(), T end=T(), std::chrono::milliseconds duration=std::chrono::milliseconds(), const EasingFunc &func=easing_linear)
 
void clear_change_callbacks ()
 Clear all callbacks. More...
 
void on_change (PropertyCallback callback)
 Register a callback handler for when the value changes. More...
 
- Public Member Functions inherited from AutoAnimation
 AutoAnimation (EasingScalar start, EasingScalar end, std::chrono::milliseconds duration, const EasingFunc &func=easing_linear, const AnimationCallback &callback=nullptr)
 
 AutoAnimation (std::chrono::milliseconds duration, const EasingFunc &func=easing_linear, const AnimationCallback &callback=nullptr)
 
void interval (std::chrono::milliseconds duration)
 Change the interval of the internal timer. More...
 
void resume () override
 Resume the animation from its current value. More...
 
void start () override
 Start the animation from its start value. More...
 
void stop () override
 Stop the animation. More...
 
- Public Member Functions inherited from Animation
 Animation (EasingScalar start, EasingScalar end, const AnimationCallback &callback, std::chrono::milliseconds duration, EasingFunc func=easing_linear)
 
EGT_NODISCARD EasingScalar current () const
 Get the current value. More...
 
void duration (std::chrono::milliseconds dur)
 
void easing_func (EasingFunc func)
 
EGT_NODISCARD EasingScalar ending () const
 Get the ending value. More...
 
void ending (EasingScalar end)
 
bool next () override
 Periodic call to the animation. More...
 
void reverse (bool rev)
 
void rounding (bool enable)
 Should the value be rounded? More...
 
EGT_NODISCARD EasingScalar starting () const
 Get the starting value. More...
 
void starting (EasingScalar start)
 
- Public Member Functions inherited from AnimationBase
 AnimationBase ()=default
 
 AnimationBase (AnimationBase &&) noexcept=default
 
 AnimationBase (const AnimationBase &)=delete
 
virtual ~AnimationBase () noexcept=default
 
void add_callback (AnimationCallback callback)
 Register a callback for the animation. More...
 
void clear_callbacks ()
 Clear all callbacks. More...
 
AnimationBaseoperator= (AnimationBase &&) noexcept=default
 
AnimationBaseoperator= (const AnimationBase &)=delete
 
virtual EGT_NODISCARD bool running () const
 Returns true if the animation is currently running. More...
 

Protected Types

using CallbackArray = std::vector< PropertyCallback >
 Property callback array type. More...
 

Protected Member Functions

void invoke_handlers (T value)
 Invoke handlers with the specified value. More...
 

Protected Attributes

CallbackArray m_callbacks
 Registered callbacks for the animation. More...
 
- Protected Attributes inherited from AutoAnimation
PeriodicTimer m_timer
 Periodic timer used to run the animation. More...
 
- Protected Attributes inherited from Animation
EasingScalar m_current {0}
 Current value. More...
 
std::chrono::milliseconds m_duration {}
 Duration of the animation. More...
 
EasingFunc m_easing {easing_linear}
 Easing function. More...
 
EasingScalar m_elapsed {0}
 Keep track of the progress of the animation. More...
 
EasingScalar m_end {0}
 Ending value. More...
 
std::chrono::time_point< std::chrono::steady_clock > m_intermediate_time
 Absolute time used to track the animation time elapsed. More...
 
bool m_reverse {false}
 Is the animation running in reverse. More...
 
bool m_round {false}
 Should the dispatched value be rounded? More...
 
EasingScalar m_start {0}
 Starting value. More...
 
- Protected Attributes inherited from AnimationBase
std::vector< AnimationCallbackm_callbacks
 Registered callbacks for the animation. More...
 
bool m_running {false}
 The running state of the animation. More...
 

Detailed Description

template<class T>
class egt::v1::PropertyAnimatorType< T >

Animates a property of a widget.

This as a utility class that makes animating a specific property of a widget easier. Any property that matches PropertyAnimator::property_callback_t can be used.

Member Typedef Documentation

◆ CallbackArray

using CallbackArray = std::vector<PropertyCallback>
protected

Property callback array type.

◆ PropertyCallback

using PropertyCallback = std::function<void (T v)>

Property callback type.

◆ Value

using Value = T

Alias for the value type of the animator.

Constructor & Destructor Documentation

◆ PropertyAnimatorType() [1/2]

PropertyAnimatorType ( start = T(),
end = T(),
std::chrono::milliseconds  duration = std::chrono::milliseconds(),
const EasingFunc func = easing_linear 
)
inlineexplicit
Parameters
[in]startThe starting value of the animation.
[in]endThe ending value of the animation.
[in]durationThe duration of the animation.
[in]funcThe easing function to use.

◆ PropertyAnimatorType() [2/2]

PropertyAnimatorType ( std::chrono::milliseconds  duration,
const EasingFunc func = easing_linear 
)
inlineexplicit
Parameters
[in]durationThe duration of the animation.
[in]funcThe easing function to use.

Member Function Documentation

◆ clear_change_callbacks()

void clear_change_callbacks ( )
inline

Clear all callbacks.

◆ invoke_handlers()

void invoke_handlers ( value)
inlineprotected

Invoke handlers with the specified value.

◆ on_change()

void on_change ( PropertyCallback  callback)
inline

Register a callback handler for when the value changes.

Parameters
[in]callbackThe callback function to invoke.

Member Data Documentation

◆ m_callbacks

CallbackArray m_callbacks
protected

Registered callbacks for the animation.