15 std::vector<std::shared_ptr<TweenBase>> deleteKeys;
17 auto& tween = el.first;
18 auto& updateFn = el.second;
21 keep = tween->update_();
22 if ( updateFn && tween->isStarted_() ) {
25 if ( tween->isDone_() ) {
30 deleteKeys.push_back( tween );
34 for (
auto& key : deleteKeys ) {
38 if ( !wasEmpty && isEmpty ) {
40 }
else if ( wasEmpty && !isEmpty ) {
45 template <
typename T,
typename Fn>
46 void add( std::shared_ptr<
Tween<T>> tween, Fn updateFn =
nullptr )
49 m_tweenRefMap[tween] = [updateFn]( std::shared_ptr<TweenBase> t ) { updateFn( std::static_pointer_cast<
Tween<T>>( t )->getValue() ); };
56 void add( std::shared_ptr<
Tween<T>> tween, std::function<
void(
const T& )> updateFn =
nullptr )
59 m_tweenRefMap[tween] = [updateFn]( std::shared_ptr<TweenBase> t ) { updateFn( std::static_pointer_cast<
Tween<T>>( t )->getValue() ); };
65 template <
typename T,
typename Fn>
66 std::shared_ptr<Tween<T>>
add(
const T& startVal,
const T& endVal, std::function<
float(
float )>
easeFn, Fn updateFn =
nullptr, std::function<
void()> onDone =
nullptr )
68 auto tween = std::make_shared<Tween<T>>( startVal, endVal,
easeFn, onDone );
69 this->
add( tween, std::function<
void(
const T& )>( updateFn ) );
74 std::shared_ptr<Tween<T>>
add(
const T& startVal,
const T& endVal, std::function<
float(
float )>
easeFn, std::function<
void(
const T& )> updateFn =
nullptr, std::function<
void()> onDone =
nullptr )
76 auto tween = std::make_shared<Tween<T>>( startVal, endVal,
easeFn, onDone );
77 this->
add( tween, updateFn );
85 m_tweenRefMap.at( tween ) = [updateFn]( std::shared_ptr<TweenBase> t ) { updateFn( std::static_pointer_cast<
Tween<T>>( t )->getValue() ); };
99 std::vector<std::shared_ptr<TweenBase>> refs;
102 refs.push_back( el.first );
115 std::map<std::shared_ptr<TweenBase>, std::function<void( std::shared_ptr<TweenBase> )>>
m_tweenRefMap;
Definition: component.h:11
Definition: timeline_component.h:11
bool setTweenUpdate(std::shared_ptr< Tween< T > > tween, std::function< void(const T &)> updateFn)
Definition: timeline_component.h:82
std::shared_ptr< Tween< T > > add(const T &startVal, const T &endVal, std::function< float(float)> easeFn, Fn updateFn=nullptr, std::function< void()> onDone=nullptr)
Definition: timeline_component.h:66
void add(std::shared_ptr< Tween< T > > tween, Fn updateFn=nullptr)
Definition: timeline_component.h:46
ga::Signal< Timeline * > onTimelineStart
Definition: timeline_component.h:112
ga::Signal< Timeline * > onTimelineDone
Definition: timeline_component.h:112
std::shared_ptr< Tween< T > > add(const T &startVal, const T &endVal, std::function< float(float)> easeFn, std::function< void(const T &)> updateFn=nullptr, std::function< void()> onDone=nullptr)
Definition: timeline_component.h:74
void update() override
Definition: timeline_component.h:13
bool isActive()
Definition: timeline_component.h:107
void add(std::shared_ptr< Tween< T > > tween, std::function< void(const T &)> updateFn=nullptr)
Definition: timeline_component.h:56
std::map< std::shared_ptr< TweenBase >, std::function< void(std::shared_ptr< TweenBase >)> > m_tweenRefMap
Definition: timeline_component.h:115
void clear()
Definition: timeline_component.h:92
std::vector< std::shared_ptr< TweenBase > > getTweens()
Definition: timeline_component.h:97
Definition: sigslot.hpp:1134
std::function< float(float)> easeFn(const EaseType &type)
Definition: easing.h:102