Papyrus::Animator Class Reference

#include <papyrus/animator.h>

Inheritance diagram for Papyrus::Animator:

Inheritance graph
[legend]
List of all members.

Detailed Description

Todo:
TODO Change bounce frames to bounce limits
Author:
Rick L Vinyard Jr <rvinyard@cs.nmsu.edu>


Public Types

typedef PapyrusSmartPointer<
Animator
pointer
 Class level smart pointer typedef.

Public Member Functions

virtual int advance (int n=1)
 Advance the animation by n frames.
virtual int reverse (int n=1)
 Reverse the animation by n frames.
virtual void set_interval (unsigned int interval_ms)
virtual unsigned int interval ()
virtual double frame_rate ()
virtual void set_frame_rate (unsigned int frames_per_second)
 Sets the number of frames per second.
virtual void start ()
virtual void start (unsigned int interval_ms)
virtual void stop ()
virtual bool is_started ()
int bounce_frames ()
 Returns the bounce frame setting.
int bounce_direction ()
 Returns the current bounce direction.
void set_bounce_frames (int frames)
 Sets the number of 'bounce' frames.
sigc::signal< void, int > signal_advanced ()

Protected Member Functions

bool timeout_handler ()
virtual int animate (int n)=0
 Pure virtual method that children should implement to perform actual animation.

Protected Attributes

unsigned int m_interval
int m_bounce_frames
int m_bounce_direction
int m_bounce_position
guint m_timeout_source_id
sigc::signal< void, int > m_signal_advanced


Member Function Documentation

void Papyrus::Animator::set_frame_rate ( unsigned int  frames_per_second  )  [virtual]

Sets the number of frames per second.

Since the interval is an integer is in milliseconds, and the set frames per second may not evenly divide 1000, the rounded result of 1000/frames_per_second is used.

For example, setting the frame rate to 30 would result in an interval of 33.333333. Therefore, an interval of 33 is used, yielding a frame rate of 33 frames per second.

int Papyrus::Animator::bounce_direction (  ) 

Returns the current bounce direction.

Returns:
bounce direction
  • < 0 - reversing
  • = 0 - bounce disabled
  • > 0 - advancing

void Papyrus::Animator::set_bounce_frames ( int  frames  ) 

Sets the number of 'bounce' frames.

When set, the animation will proceed in a given direction and then reverse back to the original position creating a bounce effect. This allows a single callback point, such as advance() to effectively work as a series of calls to advance() followed by a series of calls to reverse() .

The advantage of using the bounce effect is that you don't need to keep track of when to call advance() and when to call reverse() .

Parameters:
frames Sets the number of bounce frames
  • > 0 - Advances the specified number of frames, then reverses, then advances...
  • = 0 - Disables bounce
  • < 0 - Reverses the specified number of frames, then advances, then reverses...

virtual int Papyrus::Animator::animate ( int  n  )  [protected, pure virtual]

Pure virtual method that children should implement to perform actual animation.

Parameters:
n The number of animation frames to perform
  • > 0 - Advance n frames
  • = 0 - Do nothing
  • < 0 - Reverse n frames
Returns:
Zero if animation couldn't occur, non-zero otherwise. If possible, a child should also return the number of frames animated. Also, if possible, a child should return a positive number when frames are advanced and a negative when frames are reversed.


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 10:01:31 2007 by  doxygen 1.5.1