[4838] | 1 | /*! |
---|
[5365] | 2 | * @file glgui_slider.h |
---|
[5360] | 3 | * The gl_ widget of th openglGUI |
---|
| 4 | * |
---|
| 5 | */ |
---|
[1853] | 6 | |
---|
[5365] | 7 | #ifndef _GLGUI_SLIDER_H |
---|
| 8 | #define _GLGUI_SLIDER_H |
---|
[1853] | 9 | |
---|
[7919] | 10 | #include "glgui_widget.h" |
---|
| 11 | #include "glgui_defs.h" |
---|
[1853] | 12 | |
---|
[7779] | 13 | namespace OrxGui |
---|
| 14 | { |
---|
| 15 | // FORWARD DECLARATION |
---|
[3543] | 16 | |
---|
[7779] | 17 | //! This is part of the openglGUI class |
---|
| 18 | /** |
---|
[8035] | 19 | * The Slider is a Widget, with a Range and a Value. |
---|
[7779] | 20 | */ |
---|
[7919] | 21 | class GLGuiSlider : public GLGuiWidget |
---|
[7779] | 22 | { |
---|
[2036] | 23 | |
---|
[7779] | 24 | public: |
---|
| 25 | GLGuiSlider(); |
---|
| 26 | virtual ~GLGuiSlider(); |
---|
[1853] | 27 | |
---|
[8035] | 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; }; |
---|
[1853] | 36 | |
---|
[8035] | 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); |
---|
[7919] | 51 | virtual void draw() const; |
---|
[3245] | 52 | |
---|
[9406] | 53 | sigslot::signal1<float> valueChanged; |
---|
| 54 | sigslot::signal2<float, float> rangeChanged; |
---|
[8035] | 55 | |
---|
| 56 | protected: |
---|
| 57 | virtual void resize(); |
---|
[8448] | 58 | virtual void updateFrontColor(); |
---|
[8035] | 59 | |
---|
| 60 | virtual void clicking(const Vector2D& pos); |
---|
[8717] | 61 | virtual void releasing(const Vector2D& pos, bool focused); |
---|
[8035] | 62 | virtual void removedFocus(); |
---|
| 63 | |
---|
[7779] | 64 | private: |
---|
[8035] | 65 | void init(); |
---|
| 66 | float sliderPosition() const; |
---|
| 67 | float sliderValue(float position) const; |
---|
| 68 | |
---|
| 69 | private: |
---|
[7919] | 70 | Orientation orientation; |
---|
[1853] | 71 | |
---|
[8448] | 72 | Rect2D _slider; |
---|
| 73 | Rect2D _handle; |
---|
| 74 | |
---|
[7919] | 75 | float _maxValue; |
---|
| 76 | float _minValue; |
---|
[8035] | 77 | float _step; |
---|
[7919] | 78 | |
---|
| 79 | float _value; |
---|
| 80 | |
---|
[8035] | 81 | float _sliderWidth; |
---|
| 82 | |
---|
| 83 | bool grabbed; |
---|
| 84 | |
---|
[7779] | 85 | }; |
---|
| 86 | } |
---|
[5365] | 87 | #endif /* _GLGUI_SLIDER_H */ |
---|