TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
LoadingBar.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_LOADING_BAR_INCLUDED_
27 #define _TGUI_LOADING_BAR_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API LoadingBar : public OBJECT
36  {
40  LoadingBar();
41 
42 
46  LoadingBar(const LoadingBar& copy);
47 
48 
52  virtual ~LoadingBar();
53 
54 
58  LoadingBar& operator= (const LoadingBar& right);
59 
60 
64  virtual void initialize();
65 
66 
70  virtual LoadingBar* clone();
71 
72 
85  virtual bool load(const std::string& pathname);
86 
87 
91  virtual void setSize(float width, float height);
92 
93 
97  virtual Vector2u getSize() const;
98 
99 
103  virtual Vector2f getScaledSize() const;
104 
105 
111  virtual std::string getLoadedPathname() const;
112 
113 
120  virtual void setMinimum(unsigned int minimum);
121 
122 
129  virtual void setMaximum(unsigned int maximum);
130 
131 
137  virtual void setValue(unsigned int value);
138 
139 
145  virtual unsigned int getMinimum() const;
146 
147 
153  virtual unsigned int getMaximum() const;
154 
155 
159  virtual unsigned int getValue() const;
160 
161 
169  virtual unsigned int incrementValue();
170 
171 
177  virtual void setText(const sf::String& text);
178 
179 
183  virtual sf::String getText() const;
184 
185 
192  virtual void setTextFont(const sf::Font& font);
193 
194 
198  virtual const sf::Font* getTextFont() const;
199 
200 
204  virtual void setTextColor(const sf::Color& color);
205 
206 
210  virtual const sf::Color& getTextColor() const;
211 
212 
218  virtual void setTextSize(unsigned int size);
219 
220 
224  virtual unsigned int getTextSize() const;
225 
226 
228  // This function tells the EventManager if the mouse is on top of the loading bar.
230  bool mouseOnObject(float x, float y);
231 
232 
234  protected:
235 
236 
238  // When the value changes, or when the minimum/maximum limits change then a smaller of bigger piece of the front image
239  // must be drawn. This function is called to calculate the size of the piece to draw.
241  virtual void recalculateSize();
242 
243 
245  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
246  // This function will be called and it will draw the loading bar on the render target.
248  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
249 
250 
252  protected:
253 
254  unsigned int m_Minimum;
255  unsigned int m_Maximum;
256  unsigned int m_Value;
257 
258  // If this is true then the L, M and R images will be used.
259  // If it is false then the button is just one big image that will be stored in the M image.
260  bool m_SplitImage;
261 
262  // The size of the loading bar
263  Vector2f m_Size;
264 
265  sf::Texture* m_TextureBack_L;
266  sf::Texture* m_TextureBack_M;
267  sf::Texture* m_TextureBack_R;
268  sf::Texture* m_TextureFront_L;
269  sf::Texture* m_TextureFront_M;
270  sf::Texture* m_TextureFront_R;
271 
272  sf::Sprite m_SpriteBack_L;
273  sf::Sprite m_SpriteBack_M;
274  sf::Sprite m_SpriteBack_R;
275  sf::Sprite m_SpriteFront_L;
276  sf::Sprite m_SpriteFront_M;
277  sf::Sprite m_SpriteFront_R;
278 
279  // The text that is (optionally) drawn on top of the loading bar
280  sf::Text m_Text;
281  unsigned int m_TextSize;
282 
283  // The pathname used to load the loading bar
284  std::string m_LoadedPathname;
285  };
286 
288 }
289 
291 
292 #endif //_TGUI_LOADING_BAR_INCLUDED_
The parent struct for every object.
Definition: Objects.hpp:36
Definition: LoadingBar.hpp:35