| 1 | /*! | 
|---|
| 2 |  * @file glgui_slider.h | 
|---|
| 3 |  * The gl_ widget of th openglGUI | 
|---|
| 4 |  * | 
|---|
| 5 |  */ | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef _GLGUI_SLIDER_H | 
|---|
| 8 | #define _GLGUI_SLIDER_H | 
|---|
| 9 |  | 
|---|
| 10 | #include "glgui_widget.h" | 
|---|
| 11 | #include "glgui_defs.h" | 
|---|
| 12 |  | 
|---|
| 13 | namespace OrxGui | 
|---|
| 14 | { | 
|---|
| 15 |   // FORWARD DECLARATION | 
|---|
| 16 |  | 
|---|
| 17 |   //! This is part of the openglGUI class | 
|---|
| 18 |   /** | 
|---|
| 19 |    * The Slider is a Widget, with a Range and a Value. | 
|---|
| 20 |    */ | 
|---|
| 21 |   class GLGuiSlider : public GLGuiWidget | 
|---|
| 22 |   { | 
|---|
| 23 |     ObjectListDeclaration(GLGuiSlider); | 
|---|
| 24 |   public: | 
|---|
| 25 |     GLGuiSlider(); | 
|---|
| 26 |     virtual ~GLGuiSlider(); | 
|---|
| 27 |  | 
|---|
| 28 |     /** @returns the Value of the Slider. */ | 
|---|
| 29 |     float value() const { return this->_value; } | 
|---|
| 30 |     /** @returns the minimum of the sliders range */ | 
|---|
| 31 |     float min() const { return this->_minValue; }; | 
|---|
| 32 |     /** @returns the maximum of the sliders range */ | 
|---|
| 33 |     float max() const { return this->_maxValue; }; | 
|---|
| 34 |     /** @returns the step size */ | 
|---|
| 35 |     float step() const { return this->_step; }; | 
|---|
| 36 |  | 
|---|
| 37 |     void setValue(float value); | 
|---|
| 38 |  | 
|---|
| 39 |     void setMin(float minimum); | 
|---|
| 40 |     void setMax(float maximum); | 
|---|
| 41 |     void setRange(float minimum, float maximum); | 
|---|
| 42 |  | 
|---|
| 43 |     void setStep(float step); | 
|---|
| 44 |  | 
|---|
| 45 |     void stepPlus(); | 
|---|
| 46 |     void stepMinus(); | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 |     virtual void tick(float dt); | 
|---|
| 50 |     virtual bool processEvent(const Event& event); | 
|---|
| 51 |     virtual void draw() const; | 
|---|
| 52 |  | 
|---|
| 53 |     sigslot::signal1<float> valueChanged; | 
|---|
| 54 |     sigslot::signal2<float, float> rangeChanged; | 
|---|
| 55 |  | 
|---|
| 56 |   protected: | 
|---|
| 57 |     virtual void resize(); | 
|---|
| 58 |     virtual void updateFrontColor(); | 
|---|
| 59 |  | 
|---|
| 60 |     virtual void clicking(const Vector2D& pos); | 
|---|
| 61 |     virtual void releasing(const Vector2D& pos, bool focused); | 
|---|
| 62 |     virtual void removedFocus(); | 
|---|
| 63 |  | 
|---|
| 64 |   private: | 
|---|
| 65 |     void init(); | 
|---|
| 66 |     float sliderPosition() const; | 
|---|
| 67 |     float sliderValue(float position) const; | 
|---|
| 68 |  | 
|---|
| 69 |   private: | 
|---|
| 70 |     Orientation      orientation; | 
|---|
| 71 |  | 
|---|
| 72 |     Rect2D           _slider; | 
|---|
| 73 |     Rect2D           _handle; | 
|---|
| 74 |  | 
|---|
| 75 |     float            _maxValue; | 
|---|
| 76 |     float            _minValue; | 
|---|
| 77 |     float            _step; | 
|---|
| 78 |  | 
|---|
| 79 |     float            _value; | 
|---|
| 80 |  | 
|---|
| 81 |     float            _sliderWidth; | 
|---|
| 82 |  | 
|---|
| 83 |     bool             grabbed; | 
|---|
| 84 |  | 
|---|
| 85 |   }; | 
|---|
| 86 | } | 
|---|
| 87 | #endif /* _GLGUI_SLIDER_H */ | 
|---|