/** Handle one animation function by using a timer for frequent calls to theanimationsoperator().
*/ class Animator::Animation
{ public:
Animation (
Animator::AnimationFunctor aAnimation, constdouble nStartOffset, constdouble nDuration, constdouble nGlobalTime, const Animator::AnimationId nAnimationId,
Animator::FinishFunctor aFinishFunctor); /** Run next animation step. If animation has reached its end it is expired.
*/ bool Run (constdouble nGlobalTime);
/** Typically called when an animation has finished, but also from Animator::Disposed().Thefinishfunctoriscalledandthe animationismarkedasexpiredtopreventanotherrun.
*/ void Expire(); bool IsExpired() const { return mbIsExpired;}
AnimationList aCopy (maAnimations); for (constauto& rxAnimation : aCopy)
rxAnimation->Expire();
maIdle.Stop(); if (mpDrawLock)
{
mpDrawLock->Dispose();
mpDrawLock.reset();
}
}
Animator::AnimationId Animator::AddAnimation ( const AnimationFunctor& rAnimation, const FinishFunctor& rFinishFunctor)
{ // When the animator is already disposed then ignore this call // silently (well, we show an assertion, but do not throw an exception.)
OSL_ASSERT( ! mbIsDisposed); if (mbIsDisposed) return -1;
void Animator::CleanUpAnimationList()
{
OSL_ASSERT( ! mbIsDisposed); if (mbIsDisposed) return;
AnimationList aActiveAnimations;
for (constauto& rxAnimation : maAnimations)
{ if ( ! rxAnimation->IsExpired())
aActiveAnimations.push_back(rxAnimation);
}
maAnimations.swap(aActiveAnimations);
}
void Animator::RequestNextFrame ()
{ if ( ! maIdle.IsActive())
{ // Prevent redraws except for the ones in TimeoutHandler. While the // Animator is active it will schedule repaints regularly. Repaints // in between would only lead to visual artifacts.
mpDrawLock.reset(new view::SlideSorterView::DrawLock(mrSlideSorter));
maIdle.Start();
}
}
IMPL_LINK_NOARG(Animator, TimeoutHandler, Timer *, void)
{ if (mbIsDisposed) return;
if (ProcessAnimations(maElapsedTime.getElapsedTime()))
CleanUpAnimationList();
// Unlock the draw lock. This should lead to a repaint.
mpDrawLock.reset();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.