1.10
Public Member Functions | Protected Attributes | List of all members
AutoAnimation Class Reference

Animation object with built in timer. More...

#include <animation.h>

Inheritance diagram for AutoAnimation:
Inheritance graph
[legend]

Public Member Functions

 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.
 
void resume () override
 Resume the animation from its current value.
 
void start () override
 Start the animation from its start value.
 
void stop () override
 Stop the animation.
 
- 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.
 
void duration (std::chrono::milliseconds dur)
 
void easing_func (EasingFunc func)
 
EGT_NODISCARD EasingScalar ending () const
 Get the ending value.
 
void ending (EasingScalar end)
 
bool next () override
 Periodic call to the animation.
 
void reverse (bool rev)
 
void rounding (bool enable)
 Should the value be rounded?
 
EGT_NODISCARD EasingScalar starting () const
 Get the starting value.
 
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.
 
void clear_callbacks ()
 Clear all callbacks.
 
AnimationBaseoperator= (AnimationBase &&) noexcept=default
 
AnimationBaseoperator= (const AnimationBase &)=delete
 
virtual EGT_NODISCARD bool running () const
 Returns true if the animation is currently running.
 

Protected Attributes

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

Detailed Description

Animation object with built in timer.

An Animation usually involves setting up a timer to run the animation at a periodic interval. This wraps an animation around a built in timer to run the animation.

Constructor & Destructor Documentation

◆ AutoAnimation() [1/2]

AutoAnimation ( EasingScalar  start,
EasingScalar  end,
std::chrono::milliseconds  duration,
const EasingFunc func = easing_linear,
const AnimationCallback callback = nullptr 
)
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.
[in]callbackCalled whenever the animation value changes. May be nullptr.

◆ AutoAnimation() [2/2]

AutoAnimation ( std::chrono::milliseconds  duration,
const EasingFunc func = easing_linear,
const AnimationCallback callback = nullptr 
)
explicit
Parameters
[in]durationThe duration of the animation.
[in]funcThe easing function to use.
[in]callbackCalled whenever the animation value changes. May be nullptr.

Member Function Documentation

◆ interval()

void interval ( std::chrono::milliseconds  duration)

Change the interval of the internal timer.

The internal timer defaults to an interval of 30ms. See Timer::change_duration() for more information on the ramifications of making this change on a running timer.

◆ resume()

void resume ( )
overridevirtual

Resume the animation from its current value.

Reimplemented from Animation.

◆ start()

void start ( )
overridevirtual

Start the animation from its start value.

Reimplemented from Animation.

◆ stop()

void stop ( )
overridevirtual

Stop the animation.

Reimplemented from Animation.

Member Data Documentation

◆ m_timer

PeriodicTimer m_timer
protected

Periodic timer used to run the animation.