TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
AnimatedPicture.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012 Bruno Van de Velde (VDV_B@hotmail.com)
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_INCLUDED_
27 #define _TGUI_ANIMATED_PICTURE_INCLUDED_
28 
30 
31 namespace tgui
32 {
36  struct TGUI_API AnimatedPicture : public OBJECT, OBJECT_ANIMATION
37  {
42 
43 
47  AnimatedPicture(const AnimatedPicture& copy);
48 
49 
53  virtual ~AnimatedPicture();
54 
55 
59  AnimatedPicture& operator= (const AnimatedPicture& right);
60 
61 
65  virtual AnimatedPicture* clone();
66 
67 
83  virtual unsigned int addFrame(const std::string& filename, sf::Time frameDurarion = sf::Time());
84 
85 
95  virtual void setSize(float width, float height);
96 
97 
101  virtual Vector2u getSize() const;
102 
103 
107  virtual Vector2f getScaledSize() const;
108 
109 
116  virtual void play();
117 
118 
127  virtual void pause();
128 
129 
138  virtual void stop();
139 
140 
147  virtual void setFrame(unsigned int frame);
148 
149 
155  virtual unsigned int getCurrentFrame() const;
156 
157 
168  virtual void setFrameDuration(unsigned int frame, sf::Time frameDuration = sf::Time());
169 
170 
176  virtual sf::Time getCurrentFrameDuration() const;
177 
178 
182  virtual unsigned int getFrames() const;
183 
184 
190  virtual std::vector<std::string> getLoadedFilenames() const;
191 
192 
201  virtual void removeFrame(unsigned int frame);
202 
203 
209  virtual void removeAllFrames();
210 
211 
213  // With this function, the object will tell the EventManager if the mouse is on top of it or not.
215  virtual bool mouseOnObject(float x, float y);
216 
217 
219  protected:
220 
222  // When the elapsed time changes then this function is called.
224  virtual void update();
225 
226 
228  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
229  // This function will be called and it will draw the picture on the render target.
231  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
232 
233 
235  public:
236 
237  bool loop;
238 
239 
241  protected:
242 
243  Vector2f m_Size;
244 
245  std::vector<sf::Texture*> m_Textures;
246  std::vector<sf::Sprite> m_Sprites;
247  std::vector<std::string> m_LoadedFilenames;
248  std::vector<sf::Time> m_FrameDuration;
249 
250  unsigned int m_CurrentFrame;
251 
252  bool m_Playing;
253  };
254 
256 }
257 
259 
260 #endif //_TGUI_ANIMATED_PICTURE_INCLUDED_
261 
Load multiple images and add then behind each other to create a simple animation or even a movie...
Definition: AnimatedPicture.hpp:36
The parent struct for every object.
Definition: Objects.hpp:36
Parent object for all objects that need to access the internal clock of the window.
Definition: Objects.hpp:338