| 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 |  | 
|---|
| 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 | DeclareSignal1(valueChanged, float); | 
|---|
| 54 | DeclareSignal2(rangeChanged, float, float); | 
|---|
| 55 |  | 
|---|
| 56 | protected: | 
|---|
| 57 | virtual void resize(); | 
|---|
| 58 |  | 
|---|
| 59 | virtual void clicking(const Vector2D& pos); | 
|---|
| 60 | virtual void releasing(const Vector2D& pos); | 
|---|
| 61 | virtual void removedFocus(); | 
|---|
| 62 |  | 
|---|
| 63 | private: | 
|---|
| 64 | void init(); | 
|---|
| 65 | float sliderPosition() const; | 
|---|
| 66 | float sliderValue(float position) const; | 
|---|
| 67 |  | 
|---|
| 68 | private: | 
|---|
| 69 | Orientation      orientation; | 
|---|
| 70 |  | 
|---|
| 71 | float            _maxValue; | 
|---|
| 72 | float            _minValue; | 
|---|
| 73 | float            _step; | 
|---|
| 74 |  | 
|---|
| 75 | float            _value; | 
|---|
| 76 |  | 
|---|
| 77 | float            _sliderWidth; | 
|---|
| 78 |  | 
|---|
| 79 | bool             grabbed; | 
|---|
| 80 |  | 
|---|
| 81 | }; | 
|---|
| 82 | } | 
|---|
| 83 | #endif /* _GLGUI_SLIDER_H */ | 
|---|