TGUI  v0.6.10
AnimatedPicture.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2015 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_ANIMATED_PICTURE_HPP
27 #define TGUI_ANIMATED_PICTURE_HPP
28 
29 #include <TGUI/ClickableWidget.hpp>
30 
32 
33 namespace tgui
34 {
38  class TGUI_API AnimatedPicture : public ClickableWidget
39  {
40  public:
41 
43 
44 
50 
51 
58  AnimatedPicture(const AnimatedPicture& copy);
59 
60 
65  virtual ~AnimatedPicture();
66 
67 
76  AnimatedPicture& operator= (const AnimatedPicture& right);
77 
78 
81  // Makes a copy of the widget by calling the copy constructor.
82  // This function calls new and if you use this function then you are responsible for calling delete.
84  virtual AnimatedPicture* clone();
85 
86 
97  bool addFrame(const std::string& filename, sf::Time frameDuration = sf::Time());
98 
99 
107  void setSize(float width, float height);
108 
109 
116  virtual sf::Vector2f getSize() const;
117 
118 
126  void play();
127 
128 
138  void pause();
139 
140 
150  void stop();
151 
152 
164  bool setFrame(unsigned int frame);
165 
166 
176  int getCurrentFrame() const;
177 
178 
185  sf::Time getCurrentFrameDuration() const;
186 
187 
194  unsigned int getFrames() const;
195 
196 
210  bool removeFrame(unsigned int frame);
211 
212 
219  void removeAllFrames();
220 
221 
230  void setLooping(bool loop = true);
231 
232 
241  bool getLooping() const;
242 
243 
250  bool isPlaying() const;
251 
252 
263  virtual void setTransparency(unsigned char transparency);
264 
265 
268  // This function is a (slow) way to set properties on the widget, no matter what type it is.
269  // When the requested property doesn't exist in the widget then the functions will return false.
271  virtual bool setProperty(std::string property, const std::string& value);
272 
275  // This function is a (slow) way to get properties of the widget, no matter what type it is.
276  // When the requested property doesn't exist in the widget then the functions will return false.
278  virtual bool getProperty(std::string property, std::string& value) const;
279 
280 
283  // Returns a list of all properties that can be used in setProperty and getProperty.
284  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
286  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
287 
288 
290  protected:
291 
294  // When the elapsed time changes then this function is called.
296  virtual void update();
297 
298 
301  // Draws the widget on the render target.
303  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
304 
305 
307  public:
308 
313  {
314  AnimationFinished = ClickableWidgetCallbacksCount * 1,
315  AllAnimatedPictureCallbacks = ClickableWidgetCallbacksCount * 2 - 1,
316  AnimatedPictureCallbacksCount = ClickableWidgetCallbacksCount * 2
317  };
318 
320  protected:
321 
322  std::vector<Texture> m_Textures;
323  std::vector<sf::Time> m_FrameDuration;
324 
325  int m_CurrentFrame;
326 
327  bool m_Playing;
328  bool m_Looping;
329  };
330 
332 }
333 
335 
336 #endif // TGUI_ANIMATED_PICTURE_HPP
337 
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
Definition: ClickableWidget.hpp:38
Load multiple images and add then behind each other to create a simple animation or even a movie...
Definition: AnimatedPicture.hpp:38
AnimatedPictureCallbacks
Defines specific triggers to AnimatedPicture.
Definition: AnimatedPicture.hpp:312
Definition: SharedWidgetPtr.hpp:44