#include <animator.h>
Public Types | |
typedef PapyrusPointer< Animator > | pointer |
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) |
typedef PapyrusPointer<Animator> Papyrus::Animator::pointer |
Reimplemented from Papyrus::Controller.
Reimplemented in Papyrus::AffineAnimator.
Papyrus::Animator::Animator | ( | const Glib::ustring & | id | ) | [protected] |
Papyrus::Animator::~Animator | ( | ) | [virtual] |
References m_timeout_source_id, and stop().
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.
n | The number of animation frames to perform
|
Implemented in Papyrus::AffineAnimator.
Referenced by advance().
int Papyrus::Animator::bounce_direction | ( | ) |
Returns the current bounce direction.
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()
.
frames | Sets the number of bounce frames
|
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] |
References m_interval, m_timeout_source_id, stop(), and timeout_handler_proxy().
Referenced by set_interval(), and start().
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().
int Papyrus::Animator::m_bounce_direction [protected] |
Referenced by advance(), bounce_direction(), and set_bounce_frames().
int Papyrus::Animator::m_bounce_frames [protected] |
Referenced by advance(), bounce_frames(), and set_bounce_frames().
int Papyrus::Animator::m_bounce_position [protected] |
Referenced by advance(), and set_bounce_frames().
unsigned int Papyrus::Animator::m_interval [protected] |
Referenced by frame_rate(), interval(), set_interval(), and start().
sigc::signal<void, int> Papyrus::Animator::m_signal_advanced [protected] |
Referenced by advance(), and signal_advanced().
guint Papyrus::Animator::m_timeout_source_id [protected] |
Referenced by is_started(), set_interval(), start(), stop(), and ~Animator().