LibreOffice Module sd (master) 1
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
sd::slidesorter::controller::Animator Class Reference

Experimental class for simple eye candy animations. More...

#include <SlsAnimator.hxx>

Collaboration diagram for sd::slidesorter::controller::Animator:
[legend]

Classes

class  Animation
 Handle one animation function by using a timer for frequent calls to the animations operator(). More...
 

Public Types

enum  AnimationMode {
  AM_Animated ,
  AM_Immediate
}
 In some circumstances we have to avoid animation and jump to the final animation state immediately. More...
 
typedef ::std::function< void(double)> AnimationFunctor
 An animation object is called with values between 0 and 1 as single argument to its operator() method. More...
 
typedef ::std::function< void()> FinishFunctor
 
typedef sal_Int32 AnimationId
 

Public Member Functions

 Animator (SlideSorter &rSlideSorter)
 
 ~Animator ()
 
 Animator (const Animator &)=delete
 
Animatoroperator= (const Animator &)=delete
 
void Dispose ()
 When disposed the animator will stop its work immediately and not process any timer events anymore. More...
 
AnimationId AddAnimation (const AnimationFunctor &rAnimation, const FinishFunctor &rFinishFunctor)
 Schedule a new animation for execution. More...
 
void RemoveAnimation (const AnimationId nAnimationId)
 Abort and remove an animation. More...
 
void RemoveAllAnimations ()
 A typical use case for this method is the temporary shutdown of the slidesorter when the slide sorter bar is put into a cache due to a change of the edit mode. More...
 

Static Public Attributes

static const AnimationId NotAnAnimationId = -1
 

Private Types

typedef ::std::vector< std::shared_ptr< Animation > > AnimationList
 

Private Member Functions

 DECL_LINK (TimeoutHandler, Timer *, void)
 
bool ProcessAnimations (const double nTime)
 Execute one step of every active animation. More...
 
void CleanUpAnimationList ()
 Remove animations that have expired. More...
 
void RequestNextFrame ()
 

Private Attributes

SlideSortermrSlideSorter
 
Idle maIdle
 
bool mbIsDisposed
 
AnimationList maAnimations
 
::canvas::tools::ElapsedTime maElapsedTime
 
std::unique_ptr< view::SlideSorterView::DrawLock, o3tl::default_delete< view::SlideSorterView::DrawLock > > mpDrawLock
 
AnimationId mnNextAnimationId
 

Detailed Description

Experimental class for simple eye candy animations.

Definition at line 38 of file SlsAnimator.hxx.

Member Typedef Documentation

◆ AnimationFunctor

typedef ::std::function<void (double)> sd::slidesorter::controller::Animator::AnimationFunctor

An animation object is called with values between 0 and 1 as single argument to its operator() method.

Definition at line 60 of file SlsAnimator.hxx.

◆ AnimationId

Definition at line 63 of file SlsAnimator.hxx.

◆ AnimationList

typedef ::std::vector<std::shared_ptr<Animation> > sd::slidesorter::controller::Animator::AnimationList
private

Definition at line 94 of file SlsAnimator.hxx.

◆ FinishFunctor

typedef ::std::function<void ()> sd::slidesorter::controller::Animator::FinishFunctor

Definition at line 61 of file SlsAnimator.hxx.

Member Enumeration Documentation

◆ AnimationMode

In some circumstances we have to avoid animation and jump to the final animation state immediately.

Use this enum instead of a bool to be more expressive.

Enumerator
AM_Animated 
AM_Immediate 

Definition at line 45 of file SlsAnimator.hxx.

Constructor & Destructor Documentation

◆ Animator() [1/2]

sd::slidesorter::controller::Animator::Animator ( SlideSorter rSlideSorter)
explicit

Definition at line 61 of file SlsAnimator.cxx.

References LINK, maIdle, Timer::SetInvokeHandler(), and Task::SetPriority().

◆ ~Animator()

sd::slidesorter::controller::Animator::~Animator ( )

Definition at line 71 of file SlsAnimator.cxx.

References Dispose(), and mbIsDisposed.

◆ Animator() [2/2]

sd::slidesorter::controller::Animator::Animator ( const Animator )
delete

Member Function Documentation

◆ AddAnimation()

Animator::AnimationId sd::slidesorter::controller::Animator::AddAnimation ( const AnimationFunctor rAnimation,
const FinishFunctor rFinishFunctor 
)

Schedule a new animation for execution.

The () operator of that animation will be called with increasing values between 0 and 1 for the specified duration.

Parameters
rAnimationThe animation operation.

Definition at line 96 of file SlsAnimator.cxx.

References canvas::tools::ElapsedTime::getElapsedTime(), maAnimations, maElapsedTime, mbIsDisposed, mnNextAnimationId, and RequestNextFrame().

◆ CleanUpAnimationList()

void sd::slidesorter::controller::Animator::CleanUpAnimationList ( )
private

Remove animations that have expired.

Definition at line 179 of file SlsAnimator.cxx.

References maAnimations, and mbIsDisposed.

◆ DECL_LINK()

sd::slidesorter::controller::Animator::DECL_LINK ( TimeoutHandler  ,
Timer ,
void   
)
private

◆ Dispose()

void sd::slidesorter::controller::Animator::Dispose ( )

When disposed the animator will stop its work immediately and not process any timer events anymore.

Definition at line 80 of file SlsAnimator.cxx.

References maAnimations, maIdle, mbIsDisposed, mpDrawLock, and Task::Stop().

Referenced by ~Animator().

◆ operator=()

Animator & sd::slidesorter::controller::Animator::operator= ( const Animator )
delete

◆ ProcessAnimations()

bool sd::slidesorter::controller::Animator::ProcessAnimations ( const double  nTime)
private

Execute one step of every active animation.

Parameters
nTimeTime measured in milliseconds with some arbitrary reference point.
Returns
When one or more animation has finished then <TRUE> is returned. Call CleanUpAnimationList() in this case.

Definition at line 162 of file SlsAnimator.cxx.

References maAnimations, and mbIsDisposed.

◆ RemoveAllAnimations()

void sd::slidesorter::controller::Animator::RemoveAllAnimations ( )

A typical use case for this method is the temporary shutdown of the slidesorter when the slide sorter bar is put into a cache due to a change of the edit mode.

Definition at line 148 of file SlsAnimator.cxx.

References maAnimations, mnNextAnimationId, and mpDrawLock.

◆ RemoveAnimation()

void sd::slidesorter::controller::Animator::RemoveAnimation ( const AnimationId  nAnimationId)

Abort and remove an animation.

In order to reduce the bookkeeping on the caller side, it is OK to call this method with an animation function that is not currently being animated. Such a call is silently ignored.

Definition at line 121 of file SlsAnimator.cxx.

References maAnimations, mbIsDisposed, mnNextAnimationId, mpDrawLock, and nId.

◆ RequestNextFrame()

void sd::slidesorter::controller::Animator::RequestNextFrame ( )
private

Definition at line 196 of file SlsAnimator.cxx.

References Task::IsActive(), maIdle, mpDrawLock, mrSlideSorter, and Idle::Start().

Referenced by AddAnimation().

Member Data Documentation

◆ maAnimations

AnimationList sd::slidesorter::controller::Animator::maAnimations
private

◆ maElapsedTime

::canvas::tools::ElapsedTime sd::slidesorter::controller::Animator::maElapsedTime
private

Definition at line 96 of file SlsAnimator.hxx.

Referenced by AddAnimation().

◆ maIdle

Idle sd::slidesorter::controller::Animator::maIdle
private

Definition at line 91 of file SlsAnimator.hxx.

Referenced by Animator(), Dispose(), and RequestNextFrame().

◆ mbIsDisposed

bool sd::slidesorter::controller::Animator::mbIsDisposed
private

◆ mnNextAnimationId

AnimationId sd::slidesorter::controller::Animator::mnNextAnimationId
private

Definition at line 100 of file SlsAnimator.hxx.

Referenced by AddAnimation(), RemoveAllAnimations(), and RemoveAnimation().

◆ mpDrawLock

std::unique_ptr<view::SlideSorterView::DrawLock, o3tl::default_delete<view::SlideSorterView::DrawLock> > sd::slidesorter::controller::Animator::mpDrawLock
private

Definition at line 98 of file SlsAnimator.hxx.

Referenced by Dispose(), RemoveAllAnimations(), RemoveAnimation(), and RequestNextFrame().

◆ mrSlideSorter

SlideSorter& sd::slidesorter::controller::Animator::mrSlideSorter
private

Definition at line 90 of file SlsAnimator.hxx.

Referenced by RequestNextFrame().

◆ NotAnAnimationId

const AnimationId sd::slidesorter::controller::Animator::NotAnAnimationId = -1
static

Definition at line 64 of file SlsAnimator.hxx.


The documentation for this class was generated from the following files: