#include <DynamicGraphic.h>
Protected Attributes | |
const unsigned int | m_margin |
const X | m_frame_width |
const Y | m_frame_height |
Signal Types | |
typedef boost::signal< void(std::size_t)> | StoppedSignalType |
typedef boost::signal< void(std::size_t)> | EndFrameSignalType |
Accessors | |
StoppedSignalType | StoppedSignal |
EndFrameSignalType | EndFrameSignal |
std::size_t | Frames () const |
bool | Playing () const |
bool | Looping () const |
double | FPS () const |
std::size_t | FrameIndex () const |
unsigned int | TimeIndex () const |
std::size_t | StartFrame () const |
std::size_t | EndFrame () const |
unsigned int | Margin () const |
X | FrameWidth () const |
Y | FrameHeight () const |
Flags< GraphicStyle > | Style () const |
Structors | |
DynamicGraphic (X x, Y y, X w, Y h, bool loop, X frame_width, Y frame_height, unsigned int margin, const std::vector< boost::shared_ptr< Texture > > &textures, Flags< GraphicStyle > style=GRAPHIC_NONE, std::size_t frames=ALL_FRAMES, Flags< WndFlag > flags=Flags< WndFlag >()) | |
Mutators | |
virtual void | Render () |
void | AddFrames (const Texture *texture, std::size_t frames=ALL_FRAMES) |
void | AddFrames (const boost::shared_ptr< Texture > &texture, std::size_t frames=ALL_FRAMES) |
void | AddFrames (const std::vector< boost::shared_ptr< Texture > > &textures, std::size_t frames=ALL_FRAMES) |
void | Play () |
void | Pause () |
void | NextFrame () |
void | PrevFrame () |
void | Stop () |
void | Loop (bool b=true) |
void | SetFPS (double fps) |
void | SetFrameIndex (std::size_t idx) |
void | SetTimeIndex (unsigned int time) |
void | SetStartFrame (std::size_t idx) |
void | SetEndFrame (std::size_t idx) |
void | SetStyle (Flags< GraphicStyle > style) |
virtual void | DefineAttributes (WndEditor *editor) |
Exceptions | |
GG_ABSTRACT_EXCEPTION (Exception) | |
GG_CONCRETE_EXCEPTION (CannotAddFrame, GG::DynamicGraphic, Exception) | |
Structors | |
DynamicGraphic () | |
Accessors | |
std::size_t | FramesInTexture (const Texture *t) const |
const std::vector< FrameSet > & | Textures () const |
std::size_t | CurrentTexture () const |
std::size_t | CurrentSubTexture () const |
unsigned int | FirstFrameTime () const |
unsigned int | LastFrameTime () const |
Frames of animation are stored in GG::Textures. The frames are assumed to be laid out in rows from right to left, top to bottom, like text. The location of each frame is calculated by DynamicGraphic; the user just needs to lay out the frames in the right order in the Texture(s) and give them to DynamicGraphic. If a Texture is to be used that has "dead space" where there are no frames, that space must be at the end of the Texture, and the number of frames in the Texture should be supplied when the Texture is added. When laying out the frames in the textures, the user can leave a margin between the frames and between the frames and the edge of the overall image, to make Texture creation and editing easier. The width of this margin must be supplied to DynamicGraphic's ctor, and is constant once set. The margin applies to the top and left of each image, so the margins at the right and bottom edges of the texture are optional. The multiple-Texture ctor assumes that all Textures but the last are packed with frames; if you need to specify multiple Textures with dead space, construct with an empty textures parameter and use AddFrames(). Note that DynamicGraphic doesn't have "animated" in its name; it can replay images at any speed, and moreover it can be used as a sort of slideshow, and doesn't necessarily need to be animated at all.
Definition at line 68 of file DynamicGraphic.h.
typedef boost::signal<void (std::size_t)> GG::DynamicGraphic::StoppedSignalType |
Emitted whenever playback ends because the last frame was reached and Looping() == false; the argument is the index of the last frame (may be the first frame, if playing in reverse).
Definition at line 77 of file DynamicGraphic.h.
typedef boost::signal<void (std::size_t)> GG::DynamicGraphic::EndFrameSignalType |
Emitted whenever the last frame of animation is reached; the argument is the index of the last frame (may be the first frame, if playing in reverse).
Definition at line 84 of file DynamicGraphic.h.
GG::DynamicGraphic::DynamicGraphic | ( | X | x, | |
Y | y, | |||
X | w, | |||
Y | h, | |||
bool | loop, | |||
X | frame_width, | |||
Y | frame_height, | |||
unsigned int | margin, | |||
const std::vector< boost::shared_ptr< Texture > > & | textures, | |||
Flags< GraphicStyle > | style = GRAPHIC_NONE , |
|||
std::size_t | frames = ALL_FRAMES , |
|||
Flags< WndFlag > | flags = Flags< WndFlag >() | |||
) |
Ctor taking a vector of GG::Textures and the number of frames in those Textures. The default frames value ALL_FRAMES indicates all possible area is considered to contain valid frames. Regardless of the value of frames, all Textures but the last are assumed to have the maximum number of frames based on their sizes. This ctor allows specification of a frame size different from the size of the DynamicGraphic's size.
GG::DynamicGraphic::DynamicGraphic | ( | ) | [protected] |
default ctor
std::size_t GG::DynamicGraphic::Frames | ( | ) | const |
returns the total number of frames in all the Textures that make up the animated sequence
bool GG::DynamicGraphic::Playing | ( | ) | const |
returns true if the animation is running
bool GG::DynamicGraphic::Looping | ( | ) | const |
returns true if playback is looping instead of stopping when it reaches the end
double GG::DynamicGraphic::FPS | ( | ) | const |
returns the number of frames playing per second; may be positive, 0, or negative
std::size_t GG::DynamicGraphic::FrameIndex | ( | ) | const |
returns the index of the currently-shown frame; INVALID_INDEX if none
unsigned int GG::DynamicGraphic::TimeIndex | ( | ) | const |
returns the time in ms (measured from the time of the first frame); INVALID_TIME if none
std::size_t GG::DynamicGraphic::StartFrame | ( | ) | const |
Returns the index of the earliest frame to be shown during playback.
std::size_t GG::DynamicGraphic::EndFrame | ( | ) | const |
Returns the index of the latest frame to be shown during playback.
unsigned int GG::DynamicGraphic::Margin | ( | ) | const |
returns the number of pixels placed between frames and between the frames and the Texture edges
X GG::DynamicGraphic::FrameWidth | ( | ) | const |
returns the original width of the control (and the width of the frame images)
Y GG::DynamicGraphic::FrameHeight | ( | ) | const |
returns the original height of the control (and the height of the frame images)
Flags<GraphicStyle> GG::DynamicGraphic::Style | ( | ) | const |
Returns the style of the DynamicGraphic
virtual void GG::DynamicGraphic::Render | ( | ) | [virtual] |
Draws this Wnd. Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may wish to render themselves differently in those two cases. To determine which render is being performed, they can call GUI::GetGUI()->RenderingDragDropWnds().
Implements GG::Control.
void GG::DynamicGraphic::AddFrames | ( | const Texture * | texture, | |
std::size_t | frames = ALL_FRAMES | |||
) |
Adds a set of frames from Texture texture to the animation. If frames == ALL_FRAMES, the Texture is assumed to contain the maximum possible number of frames based on its size and the frame size.
GG::DynamicGraphic::CannotAddFrame | Throws if texture is not large enough to contain any frames. |
void GG::DynamicGraphic::AddFrames | ( | const boost::shared_ptr< Texture > & | texture, | |
std::size_t | frames = ALL_FRAMES | |||
) |
Adds a set of frames from Texture texture to the animation. If frames == ALL_FRAMES, the Texture is assumed to contain the maximum possible number of frames based on its size and the frame size.
GG::DynamicGraphic::CannotAddFrame | Throws if texture is not large enough to contain any frames. |
void GG::DynamicGraphic::AddFrames | ( | const std::vector< boost::shared_ptr< Texture > > & | textures, | |
std::size_t | frames = ALL_FRAMES | |||
) |
Adds a set of frames from Texture texture to the animation. If frames == ALL_FRAMES, the Textures are assumed to contain the maximum possible number of frames based on its size and the frame size. Regardless of the value of frames, all Textures but the last are assumed to have the maximum number of frames based on their sizes.
GG::DynamicGraphic::CannotAddFrame | Throws if no texture in textures is large enough to contain any frames. |
void GG::DynamicGraphic::Play | ( | ) |
starts the animation of the image
void GG::DynamicGraphic::Pause | ( | ) |
stops playback without adjusting the frame index
void GG::DynamicGraphic::NextFrame | ( | ) |
increments the frame index by 1. If Looping() == true and the next frame would be be past the last, the first frame is shown. Pauses playback.
void GG::DynamicGraphic::PrevFrame | ( | ) |
decrements the frame index by 1. If Looping() == true and the next frame would be be past the first, the last frame is shown. Pauses playback.
void GG::DynamicGraphic::Stop | ( | ) |
stops playback and resets the frame index to 0
void GG::DynamicGraphic::Loop | ( | bool | b = true |
) |
turns looping of playback on or off
void GG::DynamicGraphic::SetFPS | ( | double | fps | ) |
Sets the frames per second playback speed (default is 15.0 FPS). Negative rates indicate reverse playback.
void GG::DynamicGraphic::SetFrameIndex | ( | std::size_t | idx | ) |
sets the frame index to idx ( value is locked to range [0, Frames()] )
void GG::DynamicGraphic::SetTimeIndex | ( | unsigned int | time | ) |
void GG::DynamicGraphic::SetStartFrame | ( | std::size_t | idx | ) |
Sets the index of the first frame to be shown during playback ( value is locked to range [0, Frames()] ).
void GG::DynamicGraphic::SetEndFrame | ( | std::size_t | idx | ) |
Sets the index of the last frame to be shown during playback ( value is locked to range [0, Frames()] ).
void GG::DynamicGraphic::SetStyle | ( | Flags< GraphicStyle > | style | ) |
Sets the style flags, and perfroms sanity checking
virtual void GG::DynamicGraphic::DefineAttributes | ( | WndEditor * | editor | ) | [virtual] |
Provides the attributes of this object that are appropriate for a user to edit in a WndEditor; see WndEditor for details.
Reimplemented from GG::Control.
GG::DynamicGraphic::GG_ABSTRACT_EXCEPTION | ( | Exception | ) |
The base class for DynamicGraphic exceptions.
Reimplemented from GG::Wnd.
GG::DynamicGraphic::GG_CONCRETE_EXCEPTION | ( | CannotAddFrame | , | |
GG::DynamicGraphic | , | |||
Exception | ||||
) |
Thrown when an attempt is made to add a frame to a DynamicGraphic from a texture smaller than a single frame.
std::size_t GG::DynamicGraphic::FramesInTexture | ( | const Texture * | t | ) | const [protected] |
returns the maximum number of frames that could be stored in t given the size of the control and Margin()
const std::vector<FrameSet>& GG::DynamicGraphic::Textures | ( | ) | const [protected] |
returns the shared_ptrs to texture objects with all animation frames
std::size_t GG::DynamicGraphic::CurrentTexture | ( | ) | const [protected] |
returns the current Texture being shown (part of it, anyway); INVALID_INDEX if none
std::size_t GG::DynamicGraphic::CurrentSubTexture | ( | ) | const [protected] |
returns the current frame being shown within Texture number CurrTexture(); INVALID_INDEX if none
unsigned int GG::DynamicGraphic::FirstFrameTime | ( | ) | const [protected] |
returns the time index in ms that the first frame in the sequence was shown during the current playback; INVALID_TIME if none
unsigned int GG::DynamicGraphic::LastFrameTime | ( | ) | const [protected] |
returns the time index in ms of the most recent frame shown (should be m_curr_frame); INVALID_TIME if none
the end-frame signal object for this DynamicGraphic
Definition at line 125 of file DynamicGraphic.h.
const unsigned int GG::DynamicGraphic::m_margin [protected] |
the number of pixels placed between frames and between the frames and the Texture edges
Definition at line 234 of file DynamicGraphic.h.
const X GG::DynamicGraphic::m_frame_width [protected] |
const Y GG::DynamicGraphic::m_frame_height [protected] |