30 #ifndef TWEENY_TWEEN_H
31 #define TWEENY_TWEEN_H
37 #include "tweentraits.h"
38 #include "tweenpoint.h"
47 template<
typename T,
typename... Ts>
109 template<
typename... Fs>
tween<T, Ts...> &
via(Fs... fs);
147 template<
typename... Fs>
tween<T, Ts...> &
via(
const std::string &
easing, Fs... fs);
164 template<
typename... Fs>
tween<T, Ts...> &
via(
const char *
easing, Fs... fs);
178 template<
typename... Fs>
tween<T, Ts...> &
via(
int index, Fs... fs);
219 const typename detail::tweentraits<T, Ts...>::valuesType &
step(int32_t dt,
bool suppressCallbacks =
false);
231 const typename detail::tweentraits<T, Ts...>::valuesType &
step(uint32_t dt,
bool suppressCallbacks =
false);
252 const typename detail::tweentraits<T, Ts...>::valuesType &
step(
float dp,
bool suppressCallbacks =
false);
263 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(
float p,
bool suppressCallbacks =
false);
275 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(int32_t d,
bool suppressCallbacks =
false);
287 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(uint32_t d,
bool suppressCallbacks =
false);
320 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::callbackType callback);
352 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::noValuesCallbackType callback);
384 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::noTweenCallbackType callback);
413 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::callbackType callback);
442 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::noTweenCallbackType callback);
471 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::noValuesCallbackType callback);
487 const typename detail::tweentraits<T, Ts...>::valuesType &
peek()
const;
496 const typename detail::tweentraits<T, Ts...>::valuesType
peek(
float progress)
const;
506 const typename detail::tweentraits<T, Ts...>::valuesType
peek(uint32_t time)
const;
551 const typename detail::tweentraits<T, Ts...>::valuesType &
jump(
size_t point,
bool suppressCallbacks =
false);
561 using traits = detail::tweentraits<T, Ts...>;
565 uint16_t currentPoint = 0;
566 float currentProgress = 0;
567 std::vector<detail::tweenpoint<T, Ts...>> points;
568 typename traits::valuesType current;
569 std::vector<typename traits::callbackType> onStepCallbacks;
570 std::vector<typename traits::callbackType> onSeekCallbacks;
571 int8_t currentDirection = 1;
575 tween(T t, Ts... vs);
576 template<
size_t I>
void interpolate(
float prog,
unsigned point,
typename traits::valuesType & values, detail::int2type<I>)
const;
577 void interpolate(
float prog,
unsigned point,
typename traits::valuesType & values, detail::int2type<0>)
const;
578 void render(
float p);
579 void dispatch(std::vector<typename traits::callbackType> & cbVector);
580 uint16_t pointAt(
float progress)
const;
607 const T &
step(int32_t dt,
bool suppressCallbacks =
false);
608 const T &
step(uint32_t dt,
bool suppressCallbacks =
false);
609 const T &
step(
float dp,
bool suppressCallbacks =
false);
610 const T &
seek(
float p,
bool suppressCallbacks =
false);
611 const T &
seek(int32_t d,
bool suppressCallbacks =
false);
612 const T &
seek(uint32_t d,
bool suppressCallbacks =
false);
614 tween<T> &
onStep(
typename detail::tweentraits<T>::noValuesCallbackType callback);
615 tween<T> &
onStep(
typename detail::tweentraits<T>::noTweenCallbackType callback);
617 tween<T> &
onSeek(
typename detail::tweentraits<T>::noValuesCallbackType callback);
618 tween<T> &
onSeek(
typename detail::tweentraits<T>::noTweenCallbackType callback);
627 const T &
jump(
size_t point,
bool suppressCallbacks =
false);
631 using traits = detail::tweentraits<T>;
635 uint16_t currentPoint = 0;
636 float currentProgress = 0;
637 std::vector<detail::tweenpoint<T>> points;
639 std::vector<typename traits::callbackType> onStepCallbacks;
640 std::vector<typename traits::callbackType> onSeekCallbacks;
641 int8_t currentDirection = 1;
646 void interpolate(
float prog,
unsigned point, T & value)
const;
647 void render(
float p);
648 void dispatch(std::vector<typename traits::callbackType> & cbVector);
649 uint16_t pointAt(
float progress)
const;
654 #include "tweenone.tcc"
enumerated
Enumerates all easings to aid in runtime when adding easins to a tween using tween::via.
Definition: easing.h:138
The easing class holds all the bundled easings.
Definition: easing.h:130
tween< T > & onStep(typename detail::tweentraits< T >::callbackType callback)
const T & step(int32_t dt, bool suppressCallbacks=false)
const T & seek(uint32_t d, bool suppressCallbacks=false)
tween< T > & onSeek(typename detail::tweentraits< T >::noValuesCallbackType callback)
tween< T > & via(Fs... fs)
tween< T > & via(tweeny::easing::enumerated enumerated, Fs... fs)
T peek(float progress) const
tween< T > & via(const char *easing, Fs... fs)
const T & step(uint32_t dt, bool suppressCallbacks=false)
T peek(uint32_t time) const
tween< T > & during(Ds... ds)
tween< T > & via(const std::string &easing, Fs... fs)
tween< T > & via(int index, Fs... fs)
tween< T > & onStep(typename detail::tweentraits< T >::noTweenCallbackType callback)
uint32_t duration() const
const T & seek(int32_t d, bool suppressCallbacks=false)
tween< T > & onSeek(typename detail::tweentraits< T >::noTweenCallbackType callback)
const T & seek(float p, bool suppressCallbacks=false)
tween< T > & onSeek(typename detail::tweentraits< T >::callbackType callback)
tween< T > & onStep(typename detail::tweentraits< T >::noValuesCallbackType callback)
const T & step(float dp, bool suppressCallbacks=false)
const T & jump(size_t point, bool suppressCallbacks=false)
Class specialization when a tween has a single value.
Definition: tween.h:594
const detail::tweentraits< T, Ts... >::valuesType & seek(float p, bool suppressCallbacks=false)
Seeks to a specified point in time based on the currentProgress.
tween< T, Ts... > & onStep(typename detail::tweentraits< T, Ts... >::noValuesCallbackType callback)
Adds a callback that will be called when stepping occurs, accepting only the tween.
const detail::tweentraits< T, Ts... >::valuesType peek(float progress) const
Calculates and returns the tween values at a given progress.
tween< T, Ts... > & onSeek(typename detail::tweentraits< T, Ts... >::callbackType callback)
Adds a callback for that will be called when seeking occurs.
int direction() const
Returns the current direction of this tween.
tween< T, Ts... > & forward()
Sets the direction of this tween forward.
const detail::tweentraits< T, Ts... >::valuesType & step(int32_t dt, bool suppressCallbacks=false)
Steps the animation by the designated delta amount.
const detail::tweentraits< T, Ts... >::valuesType & seek(int32_t d, bool suppressCallbacks=false)
Seeks to a specified point in time.
tween< T, Ts... > & onSeek(typename detail::tweentraits< T, Ts... >::noValuesCallbackType callback)
Adds a callback for that will be called when seeking occurs, accepting only the tween.
uint16_t point() const
Returns the current tween point.
tween< T, Ts... > & to(T t, Ts... vs)
Adds a new point in this tweening.
const detail::tweentraits< T, Ts... >::valuesType & step(uint32_t dt, bool suppressCallbacks=false)
Steps the animation by the designated delta amount.
const detail::tweentraits< T, Ts... >::valuesType & jump(size_t point, bool suppressCallbacks=false)
Jumps to a specific tween point.
tween< T, Ts... > & onSeek(typename detail::tweentraits< T, Ts... >::noTweenCallbackType callback)
Adds a callback for that will be called when seeking occurs, accepting only the tween values.
tween()
Default constructor for a tween.
tween< T, Ts... > & during(Ds... ds)
Specifies the easing function for the last added point, accepting an easing name as a const char * va...
tween< T, Ts... > & onStep(typename detail::tweentraits< T, Ts... >::noTweenCallbackType callback)
Adds a callback that will be called when stepping occurs, accepting only the tween values.
tween< T, Ts... > & backward()
Sets the direction of this tween backward.
const detail::tweentraits< T, Ts... >::valuesType & seek(uint32_t d, bool suppressCallbacks=false)
Seeks to a specified point in time.
const detail::tweentraits< T, Ts... >::valuesType & step(float dp, bool suppressCallbacks=false)
Steps the animation by the designated percentage amount.
tween< T, Ts... > & via(Fs... fs)
Specifies the easing function for the last added point.
tween< T, Ts... > & onStep(typename detail::tweentraits< T, Ts... >::callbackType callback)
Adds a callback that will be called when stepping occurs, accepting both the tween and its values.
uint32_t duration() const
Returns the total duration of this tween.
static tween< T, Ts... > from(T t, Ts... vs)
Instantiates a tween from a starting point.
const detail::tweentraits< T, Ts... >::valuesType & peek() const
Returns the current tween values.
const detail::tweentraits< T, Ts... >::valuesType peek(uint32_t time) const
Calculates and return the tween values at a given time.
float progress() const
Returns the current currentProgress of the interpolation.
The tween class is the core class of tweeny. It controls the interpolation steps, easings and duratio...
Definition: tween.h:48
The tweeny namespace contains all symbols and names for the Tweeny library.
Definition: MANUAL.dox:1