GG
|
#include <DynamicGraphic.h>
Protected Attributes | |
const unsigned int | m_margin |
const X | m_frame_width |
const Y | m_frame_height |
![]() | |
Clr | m_color |
bool | m_disabled |
![]() | |
bool | m_done |
Signal Types | |
typedef boost::signal< void(std::size_t)> | StoppedSignalType |
typedef boost::signal< void(std::size_t)> | EndFrameSignalType |
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 >()) | |
DynamicGraphic () |
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 |
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 |
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) |
Exceptions | |
GG_ABSTRACT_EXCEPTION (Exception) | |
GG_CONCRETE_EXCEPTION (CannotAddFrame, GG::DynamicGraphic, Exception) |
Additional Inherited Members | |
![]() | |
virtual void | DropsAcceptable (DropsAcceptableIter first, DropsAcceptableIter last, const Pt &pt) const |
Clr | Color () const |
bool | Disabled () const |
virtual void | AcceptDrops (const std::vector< Wnd * > &wnds, const Pt &pt) |
virtual void | SetColor (Clr c) |
virtual void | Disable (bool b=true) |
![]() | |
virtual void | MouseWheel (const Pt &pt, int move, Flags< ModKey > mod_keys) |
virtual void | KeyPress (Key key, boost::uint32_t key_code_point, Flags< ModKey > mod_keys) |
virtual void | KeyRelease (Key key, boost::uint32_t key_code_point, Flags< ModKey > mod_keys) |
Control () | |
Control (X x, Y y, X w, Y h, Flags< WndFlag > flags=INTERACTIVE) | |
![]() | |
Wnd () | |
Wnd (X x, Y y, X w, Y h, Flags< WndFlag > flags=INTERACTIVE|DRAGABLE) | |
DragDropRenderingState | GetDragDropRenderingState () const |
virtual void | LButtonDown (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | LDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys) |
virtual void | LButtonUp (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | LClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | LDoubleClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MButtonDown (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys) |
virtual void | MButtonUp (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MDoubleClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | RButtonDown (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | RDrag (const Pt &pt, const Pt &move, Flags< ModKey > mod_keys) |
virtual void | RButtonUp (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | RClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | RDoubleClick (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MouseEnter (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MouseHere (const Pt &pt, Flags< ModKey > mod_keys) |
virtual void | MouseLeave () |
virtual void | DragDropEnter (const Pt &pt, const std::map< Wnd *, Pt > &drag_drop_wnds, Flags< ModKey > mod_keys) |
virtual void | DragDropHere (const Pt &pt, const std::map< Wnd *, Pt > &drag_drop_wnds, Flags< ModKey > mod_keys) |
virtual void | DragDropLeave () |
virtual void | GainingFocus () |
virtual void | LosingFocus () |
virtual void | TimerFiring (unsigned int ticks, Timer *timer) |
virtual bool | EventFilter (Wnd *w, const WndEvent &event) |
void | HandleEvent (const WndEvent &event) |
void | ForwardEventToParent () |
void | BeginClipping () |
void | EndClipping () |
void | BeginNonclientClipping () |
void | EndNonclientClipping () |
A control that replays images in sequence, forwards or backwards, animated or one frame at a time.
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.
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.
Flags<GraphicStyle> GG::DynamicGraphic::Style | ( | ) | const |
Returns the style of the DynamicGraphic
|
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::SetFPS | ( | double | fps | ) |
Sets the frames per second playback speed (default is 15.0 FPS). Negative rates indicate reverse playback.
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
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.