papyrus logo

Papyrus::Animator Class Reference

#include <animator.h>

Inheritance diagram for Papyrus::Animator:
Inheritance graph
[legend]

List of all members.

Public Types

typedef PapyrusPointer< Animatorpointer

Public Member Functions

virtual ~Animator ()
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

 Animator (const Glib::ustring &id)
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

Static Private Member Functions

static gboolean timeout_handler_proxy (gpointer data)

Detailed Description

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

Member Typedef Documentation

typedef PapyrusPointer<Animator> Papyrus::Animator::pointer

Reimplemented from Papyrus::Controller.

Reimplemented in Papyrus::AffineAnimator.


Constructor & Destructor Documentation

Papyrus::Animator::Animator ( const Glib::ustring &  id  )  [protected]
Papyrus::Animator::~Animator (  )  [virtual]

References m_timeout_source_id, and stop().


Member Function Documentation

int Papyrus::Animator::advance ( int  n = 1  )  [virtual]

Advance the animation by n frames.

References animate(), m_bounce_direction, m_bounce_frames, m_bounce_position, and m_signal_advanced.

Referenced by reverse(), set_bounce_frames(), and timeout_handler().

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.

Implemented in Papyrus::AffineAnimator.

Referenced by advance().

int Papyrus::Animator::bounce_direction (  ) 

Returns the current bounce direction.

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

References m_bounce_direction.

int Papyrus::Animator::bounce_frames (  ) 

Returns the bounce frame setting.

References m_bounce_frames.

double Papyrus::Animator::frame_rate (  )  [virtual]

References m_interval.

unsigned int Papyrus::Animator::interval (  )  [virtual]

References m_interval.

bool Papyrus::Animator::is_started (  )  [virtual]

References m_timeout_source_id.

int Papyrus::Animator::reverse ( int  n = 1  )  [virtual]

Reverse the animation by n frames.

References advance().

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...

References advance(), m_bounce_direction, m_bounce_frames, and m_bounce_position.

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.

References set_interval().

void Papyrus::Animator::set_interval ( unsigned int  interval_ms  )  [virtual]

References m_interval, m_timeout_source_id, start(), and stop().

Referenced by set_frame_rate().

sigc::signal< void, int > Papyrus::Animator::signal_advanced (  ) 

References m_signal_advanced.

void Papyrus::Animator::start ( unsigned int  interval_ms  )  [virtual]

References m_interval, and start().

void Papyrus::Animator::start (  )  [virtual]
void Papyrus::Animator::stop (  )  [virtual]

References m_timeout_source_id.

Referenced by set_interval(), start(), and ~Animator().

bool Papyrus::Animator::timeout_handler (  )  [protected]

References advance().

Referenced by timeout_handler_proxy().

gboolean Papyrus::Animator::timeout_handler_proxy ( gpointer  data  )  [static, private]

References timeout_handler().

Referenced by start().


Member Data Documentation

Referenced by advance(), and set_bounce_frames().

unsigned int Papyrus::Animator::m_interval [protected]
sigc::signal<void, int> Papyrus::Animator::m_signal_advanced [protected]

Referenced by advance(), and signal_advanced().


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

Generated on Fri Apr 16 12:41:05 2010 for papyrus by doxygen 1.6.1