GG: GG::DynamicGraphic Class Reference

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Protected Attributes | List of all members
GG::DynamicGraphic Class Reference

`#include <DynamicGraphic.h>`

Inheritance diagram for GG::DynamicGraphic:

## Protected Attributes
const unsigned int | m_margin
const X | m_frame_width
const Y | m_frame_height
Protected Attributes inherited from GG::Control
Clr | m_color
bool | m_disabled
Protected Attributes inherited from GG::Wnd
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
Public Types inherited from GG::Wnd
enum | ChildClippingMode { DontClip, ClipToClient, ClipToWindow, ClipToClientAndWindowSeparately }
typedef std::map< const Wnd *, bool >::iterator | DropsAcceptableIter
Public Member Functions inherited from GG::Control
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)
Public Member Functions inherited from GG::Wnd
virtual | ~Wnd ()
bool | Interactive () const
bool | RepeatButtonDown () const
bool | Dragable () const
bool | Resizable () const
bool | OnTop () const
bool | Modal () const
ChildClippingMode | GetChildClippingMode () const
bool | NonClientChild () const
bool | Visible () const
const std::string & | Name () const
const std::string & | DragDropDataType () const
Pt | UpperLeft () const
Pt | LowerRight () const
Pt | RelativeUpperLeft () const
Pt | RelativeLowerRight () const
X | Width () const
Y | Height () const
int | ZOrder () const
Pt | Size () const
Pt | MinSize () const
Pt | MaxSize () const
virtual Pt | MinUsableSize () const
virtual Pt | ClientUpperLeft () const
virtual Pt | ClientLowerRight () const
Pt | ClientSize () const
X | ClientWidth () const
Y | ClientHeight () const
Pt | ScreenToWindow (const Pt &pt) const
Pt | ScreenToClient (const Pt &pt) const
virtual bool | InWindow (const Pt &pt) const
virtual bool | InClient (const Pt &pt) const
const std::list< Wnd * > & | Children () const
Wnd * | Parent () const
Wnd * | RootParent () const
Layout * | GetLayout () const
Layout * | ContainingLayout () const
const std::vector < BrowseInfoMode > & | BrowseModes () const
const std::string & | BrowseInfoText (std::size_t mode) const
const boost::shared_ptr < StyleFactory > & | GetStyleFactory () const
virtual WndRegion | WindowRegion (const Pt &pt) const
void | SetDragDropDataType (const std::string &data_type)
virtual void | StartingChildDragDrop (const Wnd *wnd, const Pt &offset)
virtual void | CancellingChildDragDrop (const std::vector< const Wnd * > &wnds)
virtual void | ChildrenDraggedAway (const std::vector< Wnd * > &wnds, const Wnd *destination)
void | SetName (const std::string &name)
void | Hide (bool children=true)
void | Show (bool children=true)
virtual void | ModalInit ()
void | SetChildClippingMode (ChildClippingMode mode)
void | NonClientChild (bool b)
void | MoveTo (const Pt &pt)
void | OffsetMove (const Pt &pt)
virtual void | SizeMove (const Pt &ul, const Pt &lr)
void | Resize (const Pt &sz)
void | SetMinSize (const Pt &sz)
void | SetMaxSize (const Pt &sz)
void | AttachChild (Wnd *wnd)
void | MoveChildUp (Wnd *wnd)
void | MoveChildDown (Wnd *wnd)
void | DetachChild (Wnd *wnd)
void | DetachChildren ()
void | DeleteChild (Wnd *wnd)
void | DeleteChildren ()
void | InstallEventFilter (Wnd *wnd)
void | RemoveEventFilter (Wnd *wnd)
void | HorizontalLayout ()
void | VerticalLayout ()
void | GridLayout ()
void | SetLayout (Layout *layout)
void | RemoveLayout ()
Layout * | DetachLayout ()
void | SetLayoutBorderMargin (unsigned int margin)
void | SetLayoutCellMargin (unsigned int margin)
virtual bool | Run ()
void | EndRun ()
void | SetBrowseModeTime (unsigned int time, std::size_t mode=0)
void | SetBrowseInfoWnd (const boost::shared_ptr< BrowseInfoWnd > &wnd, std::size_t mode=0)
void | ClearBrowseInfoWnd (std::size_t mode=0)
void | SetBrowseText (const std::string &text, std::size_t mode=0)
void | SetBrowseModes (const std::vector< BrowseInfoMode > &modes)
void | SetStyleFactory (const boost::shared_ptr< StyleFactory > &factory)
| GG_ABSTRACT_EXCEPTION (Exception)
| GG_CONCRETE_EXCEPTION (BadLayout, GG::Wnd, Exception)
Static Public Member Functions inherited from GG::Wnd
static unsigned int | DefaultBrowseTime ()
static void | SetDefaultBrowseTime (unsigned int time)
static const boost::shared_ptr < BrowseInfoWnd > & | DefaultBrowseInfoWnd ()
static void | SetDefaultBrowseInfoWnd (const boost::shared_ptr< BrowseInfoWnd > &browse_info_wnd)
Protected Types inherited from GG::Wnd
enum | DragDropRenderingState { NOT_DRAGGED, IN_PLACE_COPY, DRAGGED_OVER_UNACCEPTING_DROP_TARGET, DRAGGED_OVER_ACCEPTING_DROP_TARGET }
Protected Member Functions inherited from GG::Control
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)

## Detailed Description

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.

Note
  This is a situation in which the "last+1" idiom used throughout GG does not apply; when you set the end frame index to N, the last frame to be shown will be N, not N - 1. Also, while this control does not need to be the same size as the frames replayed within it, the size of the frames is taken from the size of the control when it is contructed.

Definition at line 68 of file DynamicGraphic.h.

## Member Typedef Documentation

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

Note
  Unlike most other signals, this one is emitted during the execution of Render(), so keep this in mind when processing this signal.

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

Note
  Unlike most other signals, this one is emitted during the execution of Render(), so keep this in mind when processing this signal.

Definition at line 84 of file DynamicGraphic.h.

## Constructor & Destructor Documentation

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.

## Member Function Documentation

std::size_t GG::DynamicGraphic::StartFrame | ( |  | ) | const

Returns the index of the earliest frame to be shown during playback.

Note
  when playing backwards this will be the last frame shown.

std::size_t GG::DynamicGraphic::EndFrame | ( |  | ) | const

Returns the index of the latest frame to be shown during playback.

Note
  when playing backwards this will be the first frame shown.

Flags<GraphicStyle> GG::DynamicGraphic::Style | ( |  | ) | const

Returns the style of the DynamicGraphic

See Also
  GraphicStyle

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.

Warning
  Calling code must not delete texture; texture becomes the property of a shared_ptr inside the DynamicGraphic.

Exceptions

  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.

Exceptions

  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.

Exceptions

  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.

Note
  Calling SetFPS(0.0) is equivalent to calling Pause().

void GG::DynamicGraphic::SetTimeIndex | ( | unsigned int | time | ) |

Sets the frame index to the frame nearest time index idx, where idx measures time in ms from the beginning of the animation ( value is locked to range [0, Frames() * FPS()) ).

Note
  If looping is enabled, the time index may be any value >= 0.0, and values will "wrap" around the length of a loop. If looping is disabled, any time index idx that is later than Frames() * FPS() is mapped to the last frame.

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()] ).

Note
  when playing backwards this will be the last frame shown.

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()] ).

Note
  when playing backwards this will be the first frame shown.

void GG::DynamicGraphic::SetStyle | ( | Flags< GraphicStyle > | style | ) |

Sets the style flags, and perfroms sanity checking

See Also
  GraphicStyle

GG::DynamicGraphic::GG_ABSTRACT_EXCEPTION | ( | Exception |  | ) |

The base class for DynamicGraphic exceptions.

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.

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

- DynamicGraphic.h