Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7939 in orxonox.OLD for branches/gui/src/lib


Ignore:
Timestamp:
May 28, 2006, 10:53:10 PM (19 years ago)
Author:
bensch
Message:

gui: Silder Works perfectly

Location:
branches/gui/src/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl_gui/glgui_handler.cc

    r7931 r7939  
    150150  }
    151151
     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
    152168
    153169  void GLGuiHandler::draw()
  • branches/gui/src/lib/gui/gl_gui/glgui_handler.h

    r7931 r7939  
    3131
    3232    Vector2D cursorPositionOverFocusedWidget() const;
     33    const Vector2D& cursorPositionAbs() const;
     34    const Vector2D& cursorPositionRel(const GLGuiWidget* const widget) const;
    3335
    3436    void activate();
  • branches/gui/src/lib/gui/gl_gui/glgui_slider.cc

    r7936 r7939  
    1818#include "glgui_slider.h"
    1919#include "event_def.h"
     20
     21#include "glgui_handler.h"
    2022
    2123namespace OrxGui
     
    149151  float GLGuiSlider::sliderPosition() const
    150152  {
    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);
    152156  }
    153157
    154158  float GLGuiSlider::sliderValue(float position) const
    155159  {
    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 ;
    157163  }
    158164
     
    165171    }*/
    166172
     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
    167181  /**
    168182   * @brief draws the GLGuiSlider
     
    181195  }
    182196
     197
    183198  bool GLGuiSlider::processEvent( const Event& event )
    184199  {
    185200    if (this->grabbed && event.type == EV_MOUSE_MOTION)
    186201    {
    187       this->setValue(sliderValue(event.x - this->getAbsCoor2D().x));
     202      this->setValue(sliderValue(GLGuiHandler::getInstance()->cursorPositionRel(this).x));
    188203      return true;
    189204    }
  • branches/gui/src/lib/gui/gl_gui/glgui_slider.h

    r7931 r7939  
    4444
    4545
    46 //    virtual void tick(float dt);
     46    virtual void tick(float dt);
    4747    virtual bool processEvent(const Event& event);
    4848    virtual void draw() const;
  • branches/gui/src/lib/math/vector.h

    r7711 r7939  
    3232//! this is a small and performant 3D vector
    3333typedef float sVec3D[3];
    34 
    35 
    36 //! small and performant 2D vector
    37 typedef float sVec2D[2];
    38 
    3934
    4035
  • branches/gui/src/lib/math/vector2D.h

    r7919 r7939  
    9393  void slerp(const Vector2D& v, float val) { *this += (*this - v) * val; }
    9494
     95  /** @returns a Vector of (0,0) */
     96  static const Vector2D& nullVector() { static Vector2D nullVector; return nullVector; };
     97
    9598  void debug() const;
    9699
Note: See TracChangeset for help on using the changeset viewer.