Guiliani  Version 2.6 revision 7136 (documentation build 22)
CGUITimer Class Reference

Timer used for timer callbacks to instances of CGUIAnimatable. More...

#include <GUITimer.h>

Public Member Functions

void AddAnimationCallback (eC_UInt uiTime, CGUIAnimatable *pkAnimatable)
 
eC_UInt GetIdleTime ()
 
eC_UInt GetStepDuration () const
 
eC_Bool GetStepMode () const
 
virtual eC_UInt GetTime ()
 
eC_Bool IsAnimating (const CGUIAnimatable *pkAnimatable) const
 
void NextTick ()
 
void Process ()
 
void RemoveAnimationCallback (CGUIAnimatable *pkAnimatable)
 
void SetStepDuration (const eC_UInt &uiStepDuration)
 
void SetStepMode (const eC_Bool &bStepMode)
 

Static Public Member Functions

static void CreateInstance ()
 
static void DeleteInstance ()
 

Friends

class CGUIComponentManager
 

Detailed Description

Timer used for timer callbacks to instances of CGUIAnimatable.

This timer class is useful if you wish to initiate actions in certain (maybe cyclically repeating) time intervals. You may add a virtually unlimited number of timer-callbacks to the timer instance and whenever one of them expires, the registered animatable's CGUIAnimatable::DoAnimate() method is called.

Example:

// Create an instance of a custom control.
CMyAnimatedWidget* pkWidget = new CMyAnimatedWidget(eC_FromInt(0), eC_FromInt(0), eC_FromInt(100), eC_FromInt(100));
// Register the widget for a 500 ms callback.
GETTIMER.AddAnimationCallback(500, pkWidget);

This example's widget would need to have an implementation of the CGUIAnimatable::DoAnimate() method:

void CMyAnimatedWidget::DoAnimate(const eC_Value& vTimes)
{
InvalidateArea(); // Invalidate the old area covered by this object.
// ...
// Change this widget's size or position or other attributes.
// ...
InvalidateArea(); // Invalidate the new area as well if the object has been moved or resized.
if (some_condition)
{
GETTIMER.RemoveAnimationCallback(this); // End the animation if some_condition is true.
}
}

For a more comprehensive example of a control with animations, please see Widget library.

Member Function Documentation

◆ AddAnimationCallback()

void CGUITimer::AddAnimationCallback ( eC_UInt  uiTime,
CGUIAnimatable pkAnimatable 
)

Adds a new callback to the list. If another callback for the same animatable exists, it will be updated with the new time.

Parameters
uiTimeThe minimum amount of time that has to pass before the timer expires (milliseconds).
pkAnimatableThe animatable whose DoAnimate method is called when the timer expires.

◆ CreateInstance()

void CGUITimer::CreateInstance ( )
static

Create Instance

◆ DeleteInstance()

void CGUITimer::DeleteInstance ( )
static

Delete Instance

◆ GetIdleTime()

eC_UInt CGUITimer::GetIdleTime ( )

Returns the time span in ms until the next animation timer expires.

Returns
Time until the next timer expires (milliseconds).

◆ GetStepDuration()

eC_UInt CGUITimer::GetStepDuration ( ) const

get the currently set step duration

Returns
step duration

◆ GetStepMode()

eC_Bool CGUITimer::GetStepMode ( ) const

get currently set stepping mode

Returns
true if step mode is active

◆ GetTime()

eC_UInt CGUITimer::GetTime ( )
virtual

Returns the current 'Guiliani time'. Internally, this is mapped to a tick count and should therefore only be used for difference calculations.

Returns
The current Guiliani time (milliseconds).

◆ IsAnimating()

eC_Bool CGUITimer::IsAnimating ( const CGUIAnimatable pkAnimatable) const

Checks whether an animation callback for a given animatable is registered

Parameters
pkAnimatablePointer to animatable.
Returns
True if an animation callback for this animatable is currently registered, False otherwise

◆ NextTick()

void CGUITimer::NextTick ( )

advance the internal timer by the step duration

◆ Process()

void CGUITimer::Process ( )

Traverses the registered timer callbacks and executes an animatable's CGUIAnimatable::DoAnimate() method if its timer has expired.

◆ RemoveAnimationCallback()

void CGUITimer::RemoveAnimationCallback ( CGUIAnimatable pkAnimatable)

Removes all callbacks for the given animatable.

Parameters
pkAnimatableThe animatable to be removed.

◆ SetStepDuration()

void CGUITimer::SetStepDuration ( const eC_UInt &  uiStepDuration)

set step duration when advancing with NextTick

Parameters
uiStepDurationnumber of milliseconds a single call to NextTick advances the timer

◆ SetStepMode()

void CGUITimer::SetStepMode ( const eC_Bool &  bStepMode)

set stepping mode which will decouple the timer from the platform time

Parameters
bStepModeif true the timer will stop advancing until NextTick is called

Friends And Related Function Documentation

◆ CGUIComponentManager

friend class CGUIComponentManager
friend

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