Guiliani  Version 2.5 revision 6773 (build 33)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 *pAnimatable)
 
eC_UInt GetIdleTime ()
 
virtual eC_UInt GetTime ()
 
eC_Bool IsAnimating (const CGUIAnimatable *pAnimatable) const
 
void Process ()
 
void RemoveAnimationCallback (CGUIAnimatable *pAnimatable)
 

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

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

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).
pAnimatableThe animatable whose DoAnimate method is called when the timer expires.
void CGUITimer::CreateInstance ( )
static

Create Instance

void CGUITimer::DeleteInstance ( )
static

Delete Instance

eC_UInt CGUITimer::GetIdleTime ( )

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

Returns
Time until the next timer expires (milliseconds).
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).
eC_Bool CGUITimer::IsAnimating ( const CGUIAnimatable pAnimatable) const

Checks whether an animation callback for a given animatable is registered

Parameters
pAnimatablePointer to animatable.
Returns
True if an animation callback for this animatable is currently registered, False otherwise
void CGUITimer::Process ( )

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

void CGUITimer::RemoveAnimationCallback ( CGUIAnimatable pAnimatable)

Removes all callbacks for the given animatable.

Parameters
pAnimatableThe animatable to be removed.

Friends And Related Function Documentation

friend class CGUIComponentManager
friend

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