Changeset 7942 in orxonox.OLD for branches/gui/src
- Timestamp:
- May 28, 2006, 11:25:19 PM (19 years ago)
- Location:
- branches/gui/src/lib/gui/gl_gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl_gui/glgui_slider.cc
r7939 r7942 25 25 26 26 /** 27 * standard constructor28 */27 * @brief standard constructor 28 */ 29 29 GLGuiSlider::GLGuiSlider () 30 30 { … … 35 35 36 36 /** 37 * standard deconstructor38 */37 * @brief standard deconstructor 38 */ 39 39 GLGuiSlider::~GLGuiSlider() 40 40 {} 41 41 42 42 /** 43 * initializes the GUI-element43 * @brief initializes the GUI-element 44 44 */ 45 45 void GLGuiSlider::init() … … 62 62 } 63 63 64 64 /** 65 * @param value the new Value. 66 * @note will automatically be set between max() and min() 67 */ 65 68 void GLGuiSlider::setValue(float value) 66 69 { … … 74 77 } 75 78 79 /** 80 * @param minimum the minumum of the range. 81 * 82 * @note will rearange value if necessary and will not be made bigger than max() 83 */ 76 84 void GLGuiSlider::setMin(float minimum) 77 85 { 78 86 if (minimum <= max()) 79 this->_minValue = minimum;87 this->_minValue = minimum; 80 88 81 89 if (this->value() < minimum) … … 83 91 } 84 92 93 94 /** 95 * @param maximum the maximum of the range. 96 * 97 * @note will rearange value if necessary and will not be made smaller than min() 98 */ 85 99 void GLGuiSlider::setMax(float maximum) 86 100 { … … 92 106 } 93 107 108 /** 109 * @param minimum the minimum 110 * @param maximum the maximum 111 * 112 * @see setMax 113 * @see setMin 114 */ 94 115 void GLGuiSlider::setRange(float minimum, float maximum) 95 116 { … … 105 126 } 106 127 128 /** 129 * @brief sets the stepSize 130 */ 107 131 void GLGuiSlider::setStep(float step) 108 132 { … … 110 134 } 111 135 112 136 /** 137 * @brief makes one step into the minus direction 138 */ 139 void GLGuiSlider::stepMinus() 140 { 141 this->setValue(value() - step()); 142 } 143 144 /** 145 * @brief makes one step into the minus direction 146 */ 147 void GLGuiSlider::stepPlus() 148 { 149 this->setValue(value() + step()); 150 } 151 152 /** 153 * @brief resizes the Slider, and through this Synchronizes the GUI-size. 154 */ 113 155 void GLGuiSlider::resize() 114 156 { 115 157 GLGuiWidget::resize(); 116 this->frontRect().setTopLeft(5, this->getSizeY2D()/2.0 - borderSize()); 117 this->frontRect().setSize(this->getSizeX2D() - 10.0, borderSize()); 118 } 119 120 158 this->frontRect().setTopLeft(5, this->getSizeY2D()/2.0 - 2.0); 159 this->frontRect().setSize(this->getSizeX2D() - 10.0, 4.0); 160 } 161 162 /** 163 * @brief handle the clicked event. 164 * @param pos the position the Click occured (from the topleft corner out) 165 */ 121 166 void GLGuiSlider::clicked(const Vector2D& pos) 122 167 { … … 131 176 else 132 177 this->grabbed = true; 133 134 135 136 printf("clicked at position: "), pos.debug();137 178 } 138 179 … … 149 190 } 150 191 192 /** 193 * @returns the current SliderPosition calculated from the current value and the Silders' size. 194 */ 151 195 float GLGuiSlider::sliderPosition() const 152 196 { 153 197 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * 154 (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) + 155 (borderSize() +_sliderWidth); 156 } 157 198 (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) + 199 (borderSize() +_sliderWidth); 200 } 201 202 /** 203 * @param position the position relative from the left border. 204 * @returns the Value at the given position. 205 */ 158 206 float GLGuiSlider::sliderValue(float position) const 159 207 { 160 208 return (position - (borderSize()+_sliderWidth)) / (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) 161 *( this->_maxValue - this->_minValue) + 162 this->_minValue ; 163 } 164 165 /* virtual void GLGuiSlider::tick(float dt) 166 { 167 if (this->grabbed) 168 { 169 this->setValue( 1); 170 } 171 }*/ 209 *( this->_maxValue - this->_minValue) + 210 this->_minValue ; 211 } 172 212 173 213 void GLGuiSlider::tick(float dt) 174 214 { 175 /* this->setValue(this->value() + dt);176 if (this->value() >= this->max())177 this->setValue(this->min());178 */179 215 } 180 216 … … 203 239 return true; 204 240 } 241 else if (event.bPressed) 242 { 243 if (event.type == SDLK_LEFT) 244 { 245 this->stepMinus(); 246 return true; 247 } 248 else if (event.type == SDLK_RIGHT) 249 { 250 this->stepPlus(); 251 return true; 252 } 253 } 205 254 return false; 206 255 } -
branches/gui/src/lib/gui/gl_gui/glgui_slider.h
r7939 r7942 43 43 void setStep(float step); 44 44 45 void stepPlus(); 46 void stepMinus(); 45 47 46 48 virtual void tick(float dt); … … 59 61 float sliderPosition() const; 60 62 float sliderValue(float position) const; 63 61 64 private: 62 63 65 Orientation orientation; 64 66
Note: See TracChangeset
for help on using the changeset viewer.