TGUI  v0.6.10
SpriteSheet.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_SPRITE_SHEET_HPP
27 #define TGUI_SPRITE_SHEET_HPP
28 
29 
30 #include <TGUI/Picture.hpp>
31 
33 
34 namespace tgui
35 {
39  class TGUI_API SpriteSheet : public Picture
40  {
41  public:
42 
44 
45 
50  SpriteSheet();
51 
52 
59  SpriteSheet(const SpriteSheet& copy);
60 
61 
70  SpriteSheet& operator= (const SpriteSheet& right);
71 
72 
74  // Makes a copy of the widget by calling the copy constructor.
75  // This function calls new and if you use this function then you are responsible for calling delete.
77  virtual SpriteSheet* clone();
78 
79 
87  void setSize(float width, float height);
88 
89 
96  virtual sf::Vector2f getSize() const;
97 
98 
106  void setCells(unsigned int rows, unsigned int columns);
107 
108 
115  void setRows(unsigned int rows);
116 
117 
124  unsigned int getRows() const;
125 
126 
133  void setColumns(unsigned int columns);
134 
135 
142  unsigned int getColumns() const;
143 
144 
152  void setVisibleCell(unsigned int row, unsigned int column);
153 
154 
161  sf::Vector2u getVisibleCell() const;
162 
163 
166  // This function is a (slow) way to set properties on the widget, no matter what type it is.
167  // When the requested property doesn't exist in the widget then the functions will return false.
169  virtual bool setProperty(std::string property, const std::string& value);
170 
173  // This function is a (slow) way to get properties of the widget, no matter what type it is.
174  // When the requested property doesn't exist in the widget then the functions will return false.
176  virtual bool getProperty(std::string property, std::string& value) const;
177 
178 
181  // Returns a list of all properties that can be used in setProperty and getProperty.
182  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
184  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
185 
186 
188  public:
189 
194  {
195  AllSpriteSheetCallbacks = PictureCallbacksCount - 1,
196  SpriteSheetCallbacksCount = PictureCallbacksCount
197  };
198 
199 
201  protected:
202 
203  unsigned int m_Rows;
204  unsigned int m_Columns;
205 
206  sf::Vector2u m_VisibleCell;
207  };
208 
210 }
211 
213 
214 #endif // TGUI_SPRITE_SHEET_HPP
215 
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
SpriteSheetCallbacks
Defines specific triggers to SpriteSheet.
Definition: SpriteSheet.hpp:193
Load one big image and split it into smaller images so that you can display tiles or play an animatio...
Definition: SpriteSheet.hpp:39
Definition: SharedWidgetPtr.hpp:44
Definition: Picture.hpp:38