Changeset 7939 in orxonox.OLD for branches/gui/src/lib
- Timestamp:
- May 28, 2006, 10:53:10 PM (19 years ago)
- Location:
- branches/gui/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl_gui/glgui_handler.cc
r7931 r7939 150 150 } 151 151 152 const Vector2D& GLGuiHandler::cursorPositionAbs() const 153 { 154 if (this->cursor) 155 return this->cursor->getAbsCoor2D(); 156 else 157 return Vector2D::nullVector(); 158 } 159 const Vector2D& GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const 160 { 161 assert (widget != NULL); 162 if (this->cursor) 163 return this->cursor->getAbsCoor2D() - widget->getAbsCoor2D(); 164 else 165 return Vector2D::nullVector(); 166 } 167 152 168 153 169 void GLGuiHandler::draw() -
branches/gui/src/lib/gui/gl_gui/glgui_handler.h
r7931 r7939 31 31 32 32 Vector2D cursorPositionOverFocusedWidget() const; 33 const Vector2D& cursorPositionAbs() const; 34 const Vector2D& cursorPositionRel(const GLGuiWidget* const widget) const; 33 35 34 36 void activate(); -
branches/gui/src/lib/gui/gl_gui/glgui_slider.cc
r7936 r7939 18 18 #include "glgui_slider.h" 19 19 #include "event_def.h" 20 21 #include "glgui_handler.h" 20 22 21 23 namespace OrxGui … … 149 151 float GLGuiSlider::sliderPosition() const 150 152 { 151 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * (this->getSizeX2D() - 4.0) + 2.0; 153 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * 154 (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) + 155 (borderSize() +_sliderWidth); 152 156 } 153 157 154 158 float GLGuiSlider::sliderValue(float position) const 155 159 { 156 return (position - 2.0) / (this->getSizeX2D() - 4.0) *( this->_maxValue - this->_minValue) +this->_minValue ; 160 return (position - (borderSize()+_sliderWidth)) / (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) 161 *( this->_maxValue - this->_minValue) + 162 this->_minValue ; 157 163 } 158 164 … … 165 171 }*/ 166 172 173 void GLGuiSlider::tick(float dt) 174 { 175 /* this->setValue(this->value() + dt); 176 if (this->value() >= this->max()) 177 this->setValue(this->min()); 178 */ 179 } 180 167 181 /** 168 182 * @brief draws the GLGuiSlider … … 181 195 } 182 196 197 183 198 bool GLGuiSlider::processEvent( const Event& event ) 184 199 { 185 200 if (this->grabbed && event.type == EV_MOUSE_MOTION) 186 201 { 187 this->setValue(sliderValue( event.x - this->getAbsCoor2D().x));202 this->setValue(sliderValue(GLGuiHandler::getInstance()->cursorPositionRel(this).x)); 188 203 return true; 189 204 } -
branches/gui/src/lib/gui/gl_gui/glgui_slider.h
r7931 r7939 44 44 45 45 46 //virtual void tick(float dt);46 virtual void tick(float dt); 47 47 virtual bool processEvent(const Event& event); 48 48 virtual void draw() const; -
branches/gui/src/lib/math/vector.h
r7711 r7939 32 32 //! this is a small and performant 3D vector 33 33 typedef float sVec3D[3]; 34 35 36 //! small and performant 2D vector37 typedef float sVec2D[2];38 39 34 40 35 -
branches/gui/src/lib/math/vector2D.h
r7919 r7939 93 93 void slerp(const Vector2D& v, float val) { *this += (*this - v) * val; } 94 94 95 /** @returns a Vector of (0,0) */ 96 static const Vector2D& nullVector() { static Vector2D nullVector; return nullVector; }; 97 95 98 void debug() const; 96 99
Note: See TracChangeset
for help on using the changeset viewer.