Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gdk::PixbufAnimation Class Reference

A GdkPixbufAnimation C++ wrapper class. More...

#include <xfc/gdk-pixbuf/pixbuf-animation.hh>

Inheritance diagram for Xfc::Gdk::PixbufAnimation:

Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable List of all members.

Public Member Functions

Accessors

Static Public Member Functions

Constructors

Detailed Description

A GdkPixbufAnimation C++ wrapper class.

PixbufAnimation provides a simple mechanism to load and represent animations. An animation is conceptually a series of frames to be displayed over time. Each frame is the same size. The animation may not be represented as a series of frames internally; for example, it may be stored as a sprite and instructions for moving the sprite around a background. To display an animation you don't need to understand its representation, however; you just ask gdk-pixbuf what should be displayed at a given point in time.


Constructor & Destructor Documentation

Xfc::Gdk::PixbufAnimation::PixbufAnimation ( GdkPixbufAnimation *  pixbuf_animation,
bool  owns_reference = true 
) [explicit, protected]

Construct a new PixbufAnimation from an existing GdkPixbufAnimation.

Parameters:
pixbuf_animation A pointer to a GdkPixbufAnimation.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The pixbuf_animation can be a newly created GdkPixbufAnimation or an existing GdkPixbufAnimation. (see G::Object::Object).

Xfc::Gdk::PixbufAnimation::PixbufAnimation ( GdkPixbufAnimation *  pixbuf_animation,
bool  owns_reference = true 
) [explicit, protected]

Construct a new PixbufAnimation from an existing GdkPixbufAnimation.

Parameters:
pixbuf_animation A pointer to a GdkPixbufAnimation.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The pixbuf_animation can be a newly created GdkPixbufAnimation or an existing GdkPixbufAnimation. (see G::Object::Object).


Member Function Documentation

static Pointer<PixbufAnimation> Xfc::Gdk::PixbufAnimation::create ( const String filename,
G::Error error 
) [static]

Constructs a new animation by loading it from a file.

Parameters:
filename Ther name of file to load.
error The return location for any error.
Returns:
A PixbufAnimation smart pointer.
The file format is detected automatically. If the file's format does not support multi-frame images, then an animation with a single frame will be created. Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. Possible error conditions include: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.

bool Xfc::Gdk::PixbufAnimation::is_static_image (  )  const

If you load a file and it turns out to be a plain, unanimated image, then this method will return true.

Returns:
true if the "animation" was really just an image.
Use get_static_image() to retrieve the image.

Pixbuf* Xfc::Gdk::PixbufAnimation::get_static_image (  )  const

If an animation is really just a plain image (has only one frame), this method returns that image.

Returns:
An unanimated image representing the animation.
If the animation is an animation, this function returns a reasonable thing to display as a static unanimated image, which might be the first frame, or something more sophisticated. If an animation hasn't loaded any frames yet, this function will return null.

Pointer<PixbufAnimationIter> Xfc::Gdk::PixbufAnimation::get_iter ( const GTimeVal *  start_time = 0  )  const

Get an iterator for displaying an animation.

Parameters:
start_time The time when the animation starts playing, or null to automatically use the result of g_get_current_time().
Returns:
An iterator to move over the animation
The iterator provides the frames that should be displayed at a given time. start_time would normally come from g_get_current_time(), and marks the beginning of animation playback. After creating an iterator, you should immediately display the pixbuf returned by Gdk::PixbufAnimationIter::get_pixbuf(). Then, you should install a timeout (with g_timeout_add()) or by some other mechanism to ensure that you'll update the image after Gdk::PixbufAnimationIter::get_delay_time() milliseconds. Each time the image is updated, you should reinstall the timeout with the new, possibly-changed delay time. As a shortcut, if start_time is null, the result of g_get_current_time() will be used automatically.

To update the image (i.e. possibly change the result of Gdk::PixbufAnimationIter::get_pixbuf() to a new frame of the animation), call Gdk::PixbufAnimationIter::advance().

If you're using PixbufLoader, in addition to updating the image after the delay time, you should also update it whenever you receive the area_updated signal and Gdk::PixbufAnimationIter::on_currently_loading_frame() returns true. In this case, the frame currently being fed into the loader has received new data, so needs to be refreshed. The delay time for a frame may also be modified after an area_updated signal, for example if the delay time for a frame is encoded in the data after the frame itself. So your timeout should be reinstalled after any area_updated signal. A delay time of -1 is possible, indicating "infinite."


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3