TGUI  v0.6.10
Slider2d.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_SLIDER2D_HPP
27 #define TGUI_SLIDER2D_HPP
28 
29 
30 #include <TGUI/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Slider2d : public ClickableWidget
39  {
40  public:
41 
43 
44 
49  Slider2d();
50 
51 
58  Slider2d(const Slider2d& copy);
59 
60 
65  virtual ~Slider2d();
66 
67 
76  Slider2d& operator= (const Slider2d& right);
77 
78 
80  // Makes a copy of the widget by calling the copy constructor.
81  // This function calls new and if you use this function then you are responsible for calling delete.
83  virtual Slider2d* clone();
84 
85 
95  bool load(const std::string& configFileFilename, const std::string& sectionName = "Slider2d");
96 
97 
105  const std::string& getLoadedConfigFile() const;
106 
107 
115  void setSize(float width, float height);
116 
117 
127  void setMinimum(const sf::Vector2f& minimum);
128 
129 
139  void setMaximum(const sf::Vector2f& maximum);
140 
141 
150  void setValue(const sf::Vector2f& value);
151 
152 
161  sf::Vector2f getMinimum() const;
162 
163 
172  sf::Vector2f getMaximum() const;
173 
174 
183  sf::Vector2f getValue() const;
184 
185 
196  void setFixedThumbSize(bool fixedSize);
197 
198 
207  bool getFixedThumbSize() const;
208 
209 
218  void enableThumbCenter(bool autoCenterThumb);
219 
220 
227  void centerThumb();
228 
229 
240  virtual void setTransparency(unsigned char transparency);
241 
242 
246  virtual void leftMousePressed(float x, float y);
247 
251  virtual void leftMouseReleased(float x, float y);
252 
256  virtual void mouseMoved(float x, float y);
257 
261  virtual void widgetFocused();
262 
266  virtual void mouseNoLongerDown();
267 
268 
271  // This function is a (slow) way to set properties on the widget, no matter what type it is.
272  // When the requested property doesn't exist in the widget then the functions will return false.
274  virtual bool setProperty(std::string property, const std::string& value);
275 
278  // This function is a (slow) way to get properties of the widget, no matter what type it is.
279  // When the requested property doesn't exist in the widget then the functions will return false.
281  virtual bool getProperty(std::string property, std::string& value) const;
282 
283 
286  // Returns a list of all properties that can be used in setProperty and getProperty.
287  // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
289  virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;
290 
291 
293  protected:
294 
296  // Draws the widget on the render target.
298  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
299 
300 
302  public:
303 
308  {
309  ValueChanged = ClickableWidgetCallbacksCount * 1,
310  ThumbReturnedToCenter = ClickableWidgetCallbacksCount * 2,
311  AllSlider2dCallbacks = ClickableWidgetCallbacksCount * 4 - 1,
312  Slider2dCallbacksCount = ClickableWidgetCallbacksCount * 4
313  };
314 
315 
317  protected:
318 
319  std::string m_LoadedConfigFile;
320 
321  sf::Vector2f m_Minimum;
322  sf::Vector2f m_Maximum;
323  sf::Vector2f m_Value;
324 
325  bool m_ReturnThumbToCenter;
326  bool m_FixedThumbSize;
327 
328  Texture m_TextureThumbNormal;
329  Texture m_TextureThumbHover;
330  Texture m_TextureTrackNormal;
331  Texture m_TextureTrackHover;
332 
333  bool m_SeparateHoverImage;
334  };
335 
337 }
338 
340 
341 #endif // TGUI_SLIDER2D_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
Definition: TextureManager.hpp:52
Definition: ClickableWidget.hpp:38
Slider2dCallbacks
Defines specific triggers to Slider2d.
Definition: Slider2d.hpp:307
Definition: Slider2d.hpp:38
Definition: SharedWidgetPtr.hpp:44