30 #ifndef TWEENY_TWEEN_H 31 #define TWEENY_TWEEN_H 37 #include "tweentraits.h" 38 #include "tweenpoint.h" 47 template<
typename T,
typename... Ts>
57 static tween<T, Ts...>
from(T t, Ts... vs);
83 tween<T, Ts...> &
to(T t, Ts... vs);
109 template<
typename... Fs>
tween<T, Ts...> &
via(Fs... fs);
123 template<
typename... Fs>
tween<T, Ts...> &
via(
int index, Fs... fs);
142 template<
typename... Ds>
tween<T, Ts...> &
during(Ds... ds);
164 const typename detail::tweentraits<T, Ts...>::valuesType &
step(int32_t dt,
bool suppressCallbacks =
false);
176 const typename detail::tweentraits<T, Ts...>::valuesType &
step(uint32_t dt,
bool suppressCallbacks =
false);
197 const typename detail::tweentraits<T, Ts...>::valuesType &
step(
float dp,
bool suppressCallbacks =
false);
208 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(
float p,
bool suppressCallbacks =
false);
220 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(int32_t d,
bool suppressCallbacks =
false);
232 const typename detail::tweentraits<T, Ts...>::valuesType &
seek(uint32_t d,
bool suppressCallbacks =
false);
265 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::callbackType callback);
297 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::noValuesCallbackType callback);
329 tween<T, Ts...> &
onStep(
typename detail::tweentraits<T, Ts...>::noTweenCallbackType callback);
358 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::callbackType callback);
387 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::noTweenCallbackType callback);
416 tween<T, Ts...> &
onSeek(
typename detail::tweentraits<T, Ts...>::noValuesCallbackType callback);
432 const typename detail::tweentraits<T, Ts...>::valuesType &
peek()
const;
441 const typename detail::tweentraits<T, Ts...>::valuesType
peek(
float progress)
const;
451 const typename detail::tweentraits<T, Ts...>::valuesType
peek(uint32_t time)
const;
496 const typename detail::tweentraits<T, Ts...>::valuesType &
jump(int32_t
point,
bool suppressCallbacks =
false);
503 uint16_t
point()
const;
506 using traits = detail::tweentraits<T, Ts...>;
510 uint16_t currentPoint = 0;
511 float currentProgress = 0;
512 std::vector<detail::tweenpoint<T, Ts...>> points;
513 typename traits::valuesType current;
514 std::vector<typename traits::callbackType> onStepCallbacks;
515 std::vector<typename traits::callbackType> onSeekCallbacks;
516 int8_t currentDirection = 1;
520 tween(T t, Ts... vs);
521 template<
size_t I>
void interpolate(
float prog,
unsigned point,
typename traits::valuesType & values, detail::int2type<I>)
const;
522 void interpolate(
float prog,
unsigned point,
typename traits::valuesType & values, detail::int2type<0>)
const;
523 void render(
float p);
524 void dispatch(std::vector<typename traits::callbackType> & cbVector);
525 uint16_t pointAt(
float progress)
const;
547 template<
typename... Fs>
tween<T> &
via(
int index, Fs... fs);
549 const T &
step(int32_t dt,
bool suppressCallbacks =
false);
550 const T &
step(uint32_t dt,
bool suppressCallbacks =
false);
551 const T &
step(
float dp,
bool suppressCallbacks =
false);
552 const T &
seek(
float p,
bool suppressCallbacks =
false);
553 const T &
seek(int32_t d,
bool suppressCallbacks =
false);
554 const T &
seek(uint32_t d,
bool suppressCallbacks =
false);
555 tween<T> &
onStep(
typename detail::tweentraits<T>::callbackType callback);
556 tween<T> &
onStep(
typename detail::tweentraits<T>::noValuesCallbackType callback);
557 tween<T> &
onStep(
typename detail::tweentraits<T>::noTweenCallbackType callback);
558 tween<T> &
onSeek(
typename detail::tweentraits<T>::callbackType callback);
559 tween<T> &
onSeek(
typename detail::tweentraits<T>::noValuesCallbackType callback);
560 tween<T> &
onSeek(
typename detail::tweentraits<T>::noTweenCallbackType callback);
561 const T &
peek()
const;
563 T
peek(uint32_t time)
const;
569 const T &
jump(int32_t
point,
bool suppressCallbacks =
false);
570 uint16_t
point()
const;
573 using traits = detail::tweentraits<T>;
577 uint16_t currentPoint = 0;
578 float currentProgress = 0;
579 std::vector<detail::tweenpoint<T>> points;
581 std::vector<typename traits::callbackType> onStepCallbacks;
582 std::vector<typename traits::callbackType> onSeekCallbacks;
583 int8_t currentDirection = 1;
588 void interpolate(
float prog,
unsigned point, T & value)
const;
589 void render(
float p);
590 void dispatch(std::vector<typename traits::callbackType> & cbVector);
591 uint16_t pointAt(
float progress)
const;
596 #include "tweenone.tcc" 598 #endif //TWEENY_TWEEN_H Class specialization when a tween has a single value.
Definition: tween.h:539
uint32_t duration() const
Returns the total duration of this tween.
The tween class is the core class of tweeny. It controls the interpolation steps, easings and duratio...
Definition: tween.h:48
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...
tween()
Default constructor for a tween.
The tweeny namespace contains all symbols and names for the Tweeny library.
Definition: MANUAL.dox:1
const detail::tweentraits< T, Ts... >::valuesType & peek() const
Returns the current tween values.
tween< T, Ts... > & via(Fs... fs)
Specifies the easing function for the last added currentPoint.
uint16_t point() const
Returns the current tween point.
const detail::tweentraits< T, Ts... >::valuesType & jump(int32_t point, bool suppressCallbacks=false)
Jumps to a specific tween currentPoint.
tween< T, Ts... > & during(Ds... ds)
Specifies the duration, typically in milliseconds, for the tweening of values in last currentPoint...
float progress() const
Returns the current currentProgress of the interpolation.
static tween< T, Ts... > from(T t, Ts... vs)
Instantiates a tween from a starting currentPoint.
tween< T, Ts... > & onSeek(typename detail::tweentraits< T, Ts... >::callbackType callback)
Adds a callback for that will be called when seeking occurs.
tween< T, Ts... > & backward()
Sets the direction of this tween backward.
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(float p, bool suppressCallbacks=false)
Seeks to a specified currentPoint in time based on the currentProgress.
tween< T, Ts... > & forward()
Sets the direction of this tween forward.
int direction() const
Returns the current direction of this tween.
tween< T, Ts... > & to(T t, Ts... vs)
Adds a new currentPoint in this tweening.