TGUI  v0.5.2
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Slider.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_SLIDER_INCLUDED_
27 #define _TGUI_SLIDER_INCLUDED_
28 
30 
31 namespace tgui
32 {
34 
35  struct TGUI_API Slider : public OBJECT
36  {
40  Slider();
41 
42 
46  Slider(const Slider& copy);
47 
48 
52  virtual ~Slider();
53 
54 
58  Slider& operator= (const Slider& right);
59 
60 
64  virtual Slider* clone();
65 
66 
82  virtual bool load(const std::string& pathname);
83 
84 
92  virtual void setSize(float width, float height);
93 
94 
98  virtual Vector2u getSize() const;
99 
100 
104  virtual Vector2f getScaledSize() const;
105 
106 
112  virtual std::string getLoadedPathname() const;
113 
114 
121  virtual void setMinimum(unsigned int minimum);
122 
123 
130  virtual void setMaximum(unsigned int maximum);
131 
132 
138  virtual void setValue(unsigned int value);
139 
140 
147  virtual void setVerticalScroll(bool verticallScroll);
148 
149 
155  virtual unsigned int getMinimum() const;
156 
157 
163  virtual unsigned int getMaximum() const;
164 
165 
169  virtual unsigned int getValue() const;
170 
171 
178  virtual bool getVerticalScroll();
179 
180 
182  // These functions are used to receive callback from the EventManager.
183  // You normally don't need them, but you can use them to simulate an event.
185  virtual bool mouseOnObject(float x, float y);
186  virtual void leftMousePressed(float x, float y);
187  virtual void leftMouseReleased(float x, float y);
188  virtual void mouseMoved(float x, float y);
189  virtual void mouseWheelMoved(int delta);
190  virtual void keyPressed(sf::Keyboard::Key key);
191  virtual void objectFocused();
192 
193 
195  protected:
196 
198  // Because this struct is derived from sf::Drawable, you can just call the draw function from your sf::RenderTarget.
199  // This function will be called and it will draw the slider on the render target.
201  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
202 
203 
205  protected:
206 
207  // When the mouse went down, did it go down on top of the thumb? If so, where?
208  bool m_MouseDownOnThumb;
209  Vector2f m_MouseDownOnThumbPos;
210 
211  unsigned int m_Minimum;
212  unsigned int m_Maximum;
213  unsigned int m_Value;
214 
215  // Is the slider draw vertically?
216  bool m_VerticalScroll;
217 
218  // Does the image lie vertically?
219  bool m_VerticalImage;
220 
221  // If this is true then the L, M and R images will be used.
222  // If it is false then the slider is just one big image that will be stored in the M image.
223  bool m_SplitImage;
224 
225  // Is there a separate hover image, or is it a semi-transparent image that is drawn on top of the others?
226  bool m_SeparateHoverImage;
227 
228  // The size of the slider and its thumb
229  Vector2f m_Size;
230  Vector2f m_ThumbSize;
231 
232  sf::Texture* m_TextureTrackNormal_L;
233  sf::Texture* m_TextureTrackHover_L;
234  sf::Texture* m_TextureTrackNormal_M;
235  sf::Texture* m_TextureTrackHover_M;
236  sf::Texture* m_TextureTrackNormal_R;
237  sf::Texture* m_TextureTrackHover_R;
238  sf::Texture* m_TextureThumbNormal;
239  sf::Texture* m_TextureThumbHover;
240 
241  sf::Sprite m_SpriteTrackNormal_L;
242  sf::Sprite m_SpriteTrackHover_L;
243  sf::Sprite m_SpriteTrackNormal_M;
244  sf::Sprite m_SpriteTrackHover_M;
245  sf::Sprite m_SpriteTrackNormal_R;
246  sf::Sprite m_SpriteTrackHover_R;
247  sf::Sprite m_SpriteThumbNormal;
248  sf::Sprite m_SpriteThumbHover;
249 
250  // The pathname used to load the slider
251  std::string m_LoadedPathname;
252  };
253 
255 }
256 
258 
259 #endif //_TGUI_SLIDER_INCLUDED_
The parent struct for every object.
Definition: Objects.hpp:36
Definition: Slider.hpp:35