23#include <osl/diagnose.h>
35 const double nStartOffset,
36 const double nDuration,
37 const double nGlobalTime,
43 bool Run (
const double nGlobalTime);
63 maIdle(
"sd slidesorter controller Animator"),
85 for (
const auto& rxAnimation : aCopy)
86 rxAnimation->Expire();
106 std::shared_ptr<Animation> pAnimation =
107 std::make_shared<Animation>(
118 return pAnimation->mnAnimationId;
125 const AnimationList::iterator iAnimation (::std::find_if(
128 [
nId] (std::shared_ptr<Animation>
const& pAnim)
129 { return nId == pAnim->mnAnimationId; }));
132 OSL_ASSERT((*iAnimation)->mnAnimationId ==
nId);
133 (*iAnimation)->Expire();
164 bool bExpired (
false);
171 for (
const auto& rxAnimation : aCopy)
173 bExpired |= rxAnimation->Run(nTime);
189 if ( ! rxAnimation->IsExpired())
190 aActiveAnimations.push_back(rxAnimation);
213 if (ProcessAnimations(maElapsedTime.getElapsedTime()))
214 CleanUpAnimationList();
227 const double nStartOffset,
228 const double nDuration,
229 const double nGlobalTime,
233 maFinishFunctor(
std::move(aFinishFunctor)),
235 mnDuration(nDuration),
236 mnEnd(nGlobalTime + nDuration + nStartOffset),
237 mnGlobalTimeAtStart(nGlobalTime + nStartOffset),
249 if (nGlobalTime >=
mnEnd)
254 else if (nGlobalTime >= mnGlobalTimeAtStart)
256 maAnimation((nGlobalTime - mnGlobalTimeAtStart) / mnDuration);
259 else if (mnDuration < 0)
controller::Animator::AnimationId mnAnimationId
SlideSorter & mrSlideSorter
virtual void Start(bool bStartTimer=true) override
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Handle one animation function by using a timer for frequent calls to the animations operator().
Animator::FinishFunctor maFinishFunctor
Animator::AnimationFunctor maAnimation
bool Run(const double nGlobalTime)
Run next animation step.
const Animator::AnimationId mnAnimationId
void Expire()
Typically called when an animation has finished, but also from Animator::Disposed().
Animation(Animator::AnimationFunctor aAnimation, const double nStartOffset, const double nDuration, const double nGlobalTime, const Animator::AnimationId nAnimationId, Animator::FinishFunctor aFinishFunctor)
const double mnGlobalTimeAtStart
Experimental class for simple eye candy animations.
AnimationList maAnimations
Animator(SlideSorter &rSlideSorter)
std::unique_ptr< view::SlideSorterView::DrawLock, o3tl::default_delete< view::SlideSorterView::DrawLock > > mpDrawLock
void RemoveAnimation(const AnimationId nAnimationId)
Abort and remove an animation.
::std::function< void()> FinishFunctor
void RemoveAllAnimations()
A typical use case for this method is the temporary shutdown of the slidesorter when the slide sorter...
AnimationId mnNextAnimationId
void Dispose()
When disposed the animator will stop its work immediately and not process any timer events anymore.
bool ProcessAnimations(const double nTime)
Execute one step of every active animation.
AnimationId AddAnimation(const AnimationFunctor &rAnimation, const FinishFunctor &rFinishFunctor)
Schedule a new animation for execution.
::std::function< void(double)> AnimationFunctor
An animation object is called with values between 0 and 1 as single argument to its operator() method...
void CleanUpAnimationList()
Remove animations that have expired.
::std::vector< std::shared_ptr< Animation > > AnimationList
SlideSorter & mrSlideSorter
::canvas::tools::ElapsedTime maElapsedTime
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(Animator, TimeoutHandler, Timer *, void)
SlideAnimations maAnimations