TGUI  v0.6.10
Public Types | Public Member Functions | List of all members
tgui::AnimatedPicture Class Reference

Load multiple images and add then behind each other to create a simple animation or even a movie. More...

#include <AnimatedPicture.hpp>

Inheritance diagram for tgui::AnimatedPicture:
tgui::ClickableWidget tgui::Widget tgui::Transformable tgui::CallbackManager

Public Types

- Public Types inherited from tgui::ClickableWidget
- Public Types inherited from tgui::Widget

Public Member Functions

 AnimatedPicture ()
 Default constructor. More...
 
 AnimatedPicture (const AnimatedPicture &copy)
 Copy constructor. More...
 
virtual ~AnimatedPicture ()
 Destructor. More...
 
AnimatedPictureoperator= (const AnimatedPicture &right)
 Overload of assignment operator. More...
 
bool addFrame (const std::string &filename, sf::Time frameDuration=sf::Time())
 Load another image/frame from a file. More...
 
void setSize (float width, float height)
 Changes the size of the displayed image. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the the displayed image. More...
 
void play ()
 Starts or resumes playing the animation. More...
 
void pause ()
 Pauses the animation. More...
 
void stop ()
 Stops the animation. More...
 
bool setFrame (unsigned int frame)
 Sets the animation at a specific frame. More...
 
int getCurrentFrame () const
 Returns the current displayed frame. More...
 
sf::Time getCurrentFrameDuration () const
 Returns the duration of the currently displayed frame. More...
 
unsigned int getFrames () const
 Returns the amount of frames in the animation. More...
 
bool removeFrame (unsigned int frame)
 Removes a frame from the animation. More...
 
void removeAllFrames ()
 Remove all frames from the animation. More...
 
void setLooping (bool loop=true)
 Turn the looping of the animation on or off. More...
 
bool getLooping () const
 Returns whether the looping of the animation is on or off. More...
 
bool isPlaying () const
 Returns whether the animation is still playing. More...
 
virtual void setTransparency (unsigned char transparency)
 Changes the transparency of the widget. More...
 
- Public Member Functions inherited from tgui::ClickableWidget
 ClickableWidget ()
 Default constructor. More...
 
 ClickableWidget (const ClickableWidget &copy)
 Copy constructor. More...
 
virtual ~ClickableWidget ()
 Destructor. More...
 
ClickableWidgetoperator= (const ClickableWidget &right)
 Overload of assignment operator. More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor. More...
 
 Widget (const Widget &copy)
 Copy constructor. More...
 
virtual ~Widget ()
 Destructor. More...
 
Widgetoperator= (const Widget &right)
 Overload of assignment operator. More...
 
virtual sf::Vector2f getAbsolutePosition () const
 Get the absolute position of the widget on the screen. More...
 
virtual void show ()
 Shows the widget. More...
 
virtual void hide ()
 Hides the widget. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
virtual void enable ()
 Enables the widget. More...
 
virtual void disable ()
 Disables the widget. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isDisabled () const
 Returns true when the widget is disabled. More...
 
bool isLoaded () const
 Returns true when the widget is loaded successfully. More...
 
virtual void focus ()
 Focus the widget. More...
 
virtual void unfocus ()
 Unfocus the widget. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
WidgetTypes getWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
unsigned char getTransparency () const
 Returns the transparency of the widget. More...
 
virtual void moveToFront ()
 Places the widget before all other widgets. More...
 
virtual void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setCallbackId (unsigned int callbackId)
 Changes the callback id of the widget. More...
 
unsigned int getCallbackId ()
 Returns the callback id of the widget. More...
 
- Public Member Functions inherited from tgui::Transformable
 Transformable ()
 Default constructor. More...
 
virtual ~Transformable ()
 Destructor. More...
 
virtual void setPosition (float x, float y)
 Set the position of the widget. More...
 
void setPosition (const sf::Vector2f &position)
 set the position of the widget More...
 
const sf::Vector2f & getPosition () const
 get the position of the widget More...
 
void move (float offsetX, float offsetY)
 Move the widget by a given offset. More...
 
void move (const sf::Vector2f &offset)
 Move the widget by a given offset. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
void scale (float factorX, float factorY)
 Scale the widget. More...
 
void scale (const sf::Vector2f &factors)
 Scale the widget. More...
 
- Public Member Functions inherited from tgui::CallbackManager
void bindCallback (std::function< void()> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallback (void(T::*func)(), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallbackEx (std::function< void(const Callback &)> func, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
template<typename T >
void bindCallbackEx (void(T::*func)(const Callback &), T *const classPtr, unsigned int trigger)
 Bind a function to one or more specific callback trigger(s). More...
 
void bindCallback (unsigned int trigger)
 Bind one or more specific callback trigger(s) to the parent widget. More...
 
void unbindCallback (unsigned int trigger)
 Unbind all callback function bound to the given trigger. More...
 
void unbindAllCallback ()
 Unbind all callback functions bound to any callback. More...
 

Detailed Description

Load multiple images and add then behind each other to create a simple animation or even a movie.

Member Enumeration Documentation

Defines specific triggers to AnimatedPicture.

Enumerator
AnimationFinished 

Animation ended.

AllAnimatedPictureCallbacks 

All triggers defined in AnimatedPicture and its base classes.

Constructor & Destructor Documentation

tgui::AnimatedPicture::AnimatedPicture ( )

Default constructor.

tgui::AnimatedPicture::AnimatedPicture ( const AnimatedPicture copy)

Copy constructor.

Parameters
copyInstance to copy
virtual tgui::AnimatedPicture::~AnimatedPicture ( )
virtual

Destructor.

Member Function Documentation

bool tgui::AnimatedPicture::addFrame ( const std::string &  filename,
sf::Time  frameDuration = sf::Time() 
)

Load another image/frame from a file.

Parameters
filenameThe filename of the image that you want to use as next frame.
frameDurationThe amount of time that the frame will be displayed on the screen. When the duration is 0 (default) then the animation will be blocked at that frame.
Returns
True when the frame was loaded.
int tgui::AnimatedPicture::getCurrentFrame ( ) const

Returns the current displayed frame.

Returns
Number of the frame that is currently displayed.

The number is the index of the frame, so the first frame is number 0. If no frames were loaded then this function will return -1.

sf::Time tgui::AnimatedPicture::getCurrentFrameDuration ( ) const

Returns the duration of the currently displayed frame.

Returns
Duration of the frame that is currently displayed.
unsigned int tgui::AnimatedPicture::getFrames ( ) const

Returns the amount of frames in the animation.

Returns
Number of frames
bool tgui::AnimatedPicture::getLooping ( ) const

Returns whether the looping of the animation is on or off.

By default, the animation will not loop.

Returns
Will the animation start over from the beginning when it finishes?
virtual sf::Vector2f tgui::AnimatedPicture::getSize ( ) const
virtual

Returns the size of the the displayed image.

Returns
Size of the picture

Reimplemented from tgui::ClickableWidget.

bool tgui::AnimatedPicture::isPlaying ( ) const

Returns whether the animation is still playing.

Returns
Is the animation still playing?
AnimatedPicture& tgui::AnimatedPicture::operator= ( const AnimatedPicture right)

Overload of assignment operator.

Parameters
rightInstance to assign
Returns
Reference to itself
void tgui::AnimatedPicture::pause ( )

Pauses the animation.

You can continue the animation with the start() function.

See also
play
stop
void tgui::AnimatedPicture::play ( )

Starts or resumes playing the animation.

See also
pause
stop
void tgui::AnimatedPicture::removeAllFrames ( )

Remove all frames from the animation.

See also
removeFrame
bool tgui::AnimatedPicture::removeFrame ( unsigned int  frame)

Removes a frame from the animation.

Parameters
frameThe number of the frame to remove

The number is the index of the frame, so the first frame is number 0.

Returns
True when the frame was removed. False if the index was too high.
See also
removeAllFrames
bool tgui::AnimatedPicture::setFrame ( unsigned int  frame)

Sets the animation at a specific frame.

Parameters
frameThe frame that should be displayed

The number is the index of the frame, so the first frame is number 0.

Returns
True when the frame was selected. False when the index was too high.
void tgui::AnimatedPicture::setLooping ( bool  loop = true)

Turn the looping of the animation on or off.

By default, when this function isn't called, the animation will not loop.

Parameters
loopShould the animation start over from the beginning when it finishes?
void tgui::AnimatedPicture::setSize ( float  width,
float  height 
)
virtual

Changes the size of the displayed image.

Parameters
widthThe new width of the picture
heightThe new height of the picture

Reimplemented from tgui::ClickableWidget.

virtual void tgui::AnimatedPicture::setTransparency ( unsigned char  transparency)
virtual

Changes the transparency of the widget.

Parameters
transparencyThe transparency of the widget. 0 is completely transparent, while 255 (default) means fully opaque.

Note that this will only change the transparency of the images. The parts of the widgets that use a color will not be changed. You must change them yourself by setting the alpha channel of the color.

Reimplemented from tgui::Widget.

void tgui::AnimatedPicture::stop ( )

Stops the animation.

When calling start() after calling this function, the animation will restart from the first frame.

See also
play
pause

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