TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Slider2D.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 // Special thanks to Dmitry for the Slider2D object !
26 
27 
28 #ifndef _TGUI_SLIDER2D_INCLUDED_
29 #define _TGUI_SLIDER2D_INCLUDED_
30 
32 
33 namespace tgui
34 {
36 
37  struct Slider2D : public OBJECT
38  {
42  Slider2D();
43 
44 
48  Slider2D(const Slider2D& copy);
49 
50 
54  virtual ~Slider2D();
55 
56 
60  Slider2D& operator= (const Slider2D& right);
61 
62 
66  virtual Slider2D* clone();
67 
68 
83  virtual bool load(const std::string pathname);
84 
85 
93  virtual void setSize(float width, float height);
94 
95 
99  virtual Vector2u getSize() const;
100 
101 
105  virtual Vector2f getScaledSize() const;
106 
107 
113  virtual std::string getLoadedPathname() const;
114 
115 
122  virtual void setMinimum(const Vector2f minimum);
123 
124 
131  virtual void setMaximum(const Vector2f maximum);
132 
133 
139  virtual void setValue(const Vector2f value);
140 
141 
147  virtual Vector2f getMinimum() const;
148 
149 
155  virtual Vector2f getMaximum() const;
156 
157 
161  virtual Vector2f getValue() const;
162 
163 
169  virtual void centerThumb();
170 
171 
173  // These functions are used to receive callback from the EventManager.
174  // You normally don't need them, but you can use them to simulate an event.
176  virtual bool mouseOnObject(float x, float y);
177  virtual void leftMousePressed(float x, float y);
178  virtual void leftMouseReleased(float x, float y);
179  virtual void mouseMoved(float x, float y);
180  virtual void objectFocused();
181  virtual void mouseNoLongerDown();
182 
183 
185  protected:
186 
188  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
189  // This function will be called and it will draw the slider on the render target.
191  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
192 
193 
195  public:
196 
200 
204 
205 
207  protected:
208 
209  Vector2f m_Size;
210 
211  Vector2f m_Minimum;
212  Vector2f m_Maximum;
213  Vector2f m_Value;
214 
215  sf::Texture* m_TextureThumbNormal;
216  sf::Texture* m_TextureThumbHover;
217  sf::Texture* m_TextureTrackNormal;
218  sf::Texture* m_TextureTrackHover;
219 
220  sf::Sprite m_SpriteThumbNormal;
221  sf::Sprite m_SpriteThumbHover;
222  sf::Sprite m_SpriteTrackNormal;
223  sf::Sprite m_SpriteTrackHover;
224 
225  // The pathname used to load the slider
226  std::string m_LoadedPathname;
227  };
228 
230 }
231 
233 
234 #endif //_TGUI_SLIDER2D_INCLUDED_
virtual void setMinimum(const Vector2f minimum)
Sets a minimum value.
virtual std::string getLoadedPathname() const
Returns the pathname that was used to load the slider.
Slider2D()
Default constructor.
virtual Vector2f getScaledSize() const
Returns the size of the slider, after the scaling transformation.
Slider2D & operator=(const Slider2D &right)
Overload of assignment operator.
The parent struct for every object.
Definition: Objects.hpp:36
virtual bool load(const std::string pathname)
Loads the slider images.
virtual Vector2f getMaximum() const
Returns the maximum value.
virtual Vector2f getMinimum() const
Returns the minimum value.
bool returnToCenter
Definition: Slider2D.hpp:199
Definition: Slider2D.hpp:37
virtual void centerThumb()
Places the thumb back in the center.
bool fixedThumbSize
Definition: Slider2D.hpp:203
virtual ~Slider2D()
Destructor.
virtual void setMaximum(const Vector2f maximum)
Sets a maximum value.
virtual Vector2u getSize() const
Returns the size of the slider, unaffected by scaling.
virtual void setValue(const Vector2f value)
Changes the current value.
virtual Vector2f getValue() const
Returns the current value.
virtual void setSize(float width, float height)
Changes the size of the slider.