Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7876 in orxonox.OLD for branches/gui/src


Ignore:
Timestamp:
May 26, 2006, 10:50:45 PM (19 years ago)
Author:
bensch
Message:

fancy mouse-cursor :)

Location:
branches/gui/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/graphics/importer/material.h

    r7788 r7876  
    5151    void setTransparency (char* trans);
    5252
     53    void getDiffuseColor(float& r, float& g, float& b) const { r = diffuse[0], g = diffuse[1], b = diffuse[2]; }
    5354
    5455    // MAPPING //
  • branches/gui/src/lib/graphics/render2D/element_2d.cc

    r7874 r7876  
    449449  this->relCoordinate += shift;
    450450  this->bRelCoorChanged = true;
    451 
    452451}
    453452
  • branches/gui/src/lib/gui/gl_gui/glgui.h

    r7873 r7876  
    1414#include "glgui_colorselector.h"
    1515#include "glgui_pushbutton.h"
     16#include "glgui_cursor.h"
    1617
    1718namespace OrxGui
  • branches/gui/src/lib/gui/gl_gui/glgui_cursor.cc

    r7873 r7876  
    1717
    1818#include "glgui_cursor.h"
     19#include "color.h"
    1920
    2021namespace OrxGui
     
    2829    this->init();
    2930
     31    this->subscribeEvent(ES_MENU,  EV_MOUSE_MOTION);
     32
     33
    3034  }
    3135
    3236
    3337  /**
    34    * standard deconstructor
    35   */
     38   * @brief standard deconstructor
     39   */
    3640  GLGuiCursor::~GLGuiCursor()
    37   {
    38   }
     41  {}
     42
     43  float GLGuiCursor::_mouseSensitivity = 1.0;
     44
    3945
    4046  /**
    41    * initializes the GUI-element
     47   * @brief initializes the GUI-element
    4248   */
    4349  void GLGuiCursor::init()
     
    4551    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
    4652
     53    this->backMaterial().setDiffuse(1.0,0.0,0.0);
     54    this->setSize2D(10, 20);
     55    this->setAbsCoor2D(100, 100);
     56    this->setLayer(E2D_LAYER_ABOVE_ALL);
     57
     58  }
     59
     60  void GLGuiCursor::tick(float dt)
     61  {
     62    Vector color;
     63    this->backMaterial().getDiffuseColor(color.x, color.y, color.z);
     64    color =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(80.0*dt,0.0,.0));
     65    this->backMaterial().setDiffuse(color.x, color.y, color.z);
     66
     67    if (this->movement != Vector2D())
     68    {
     69/*      if (this->getAbsCoor2D().x < 0.0 )
     70        movement.x = -this->getAbsCoor2D().x;
     71      if (this->getAbsCoor2D().x > 200.0)
     72        movement.x = (200.0-this->getAbsCoor2D().x);
     73      if (this->getAbsCoor2D().y < 0.0 )
     74        movement.x = -this->getAbsCoor2D().y;
     75      if (this->getAbsCoor2D().y > 200.0)
     76        movement.x = (200.0-this->getAbsCoor2D().y);*/
     77
     78
     79
     80      //this->shiftCoor2D(movement);
     81      this->setAbsCoor2D(newPos);
     82      movement = Vector2D();
     83    }
    4784  }
    4885
    4986  /**
    50    * draws the GLGuiCursor
     87   * @brief draws the GLGuiCursor
    5188   */
    52   void GLGuiCursor::draw()
     89  void GLGuiCursor::draw() const
    5390  {
     91    this->startDraw();
     92    GLGuiWidget::draw();
     93    this->endDraw();
     94  }
     95
     96  void GLGuiCursor::process(const Event& event)
     97  {
     98    switch (event.type)
     99    {
     100      case EV_MOUSE_MOTION:
     101        newPos = Vector2D(event.x, event.y);
     102        movement += Vector2D(event.xRel * _mouseSensitivity, event.yRel * _mouseSensitivity);
     103        break;
     104
     105    }
    54106  }
    55107}
  • branches/gui/src/lib/gui/gl_gui/glgui_cursor.h

    r7873 r7876  
    1010#include "glgui_widget.h"
    1111#include "event_listener.h"
     12#include "vector2D.h"
    1213
    1314namespace OrxGui
     
    2627    virtual ~GLGuiCursor();
    2728
     29    static void setMouseSensitivity(float mouseSensitivity);
     30    static float mouseSensitivity() { return GLGuiCursor::_mouseSensitivity; };
     31
    2832    void init();
     33    const Vector2D& position() const { return Element2D::getAbsCoor2D(); }
    2934
    30     virtual void draw();
    3135
     36    virtual void tick(float dt);
     37    virtual void draw() const;
     38    virtual void process(const Event& event);
    3239  private:
     40
     41    Vector2D      newPos;
     42    Vector2D      movement;
     43
     44    static float _mouseSensitivity;
    3345
    3446  };
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.cc

    r7855 r7876  
    5252    this->clickable = true;
    5353    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    54     //  this->setParent2D((Element2D*)NULL);
    5554
    5655    this->backMat.setDiffuse(1.0, 1.0, 1.0);
  • branches/gui/src/lib/math/vector2D.h

    r6616 r7876  
    4040
    4141  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
    42   inline bool operator== (const Vector2D& v) const { return (this->x==v.x && this->y==v.y)?true:false; };
     42  inline bool operator== (const Vector2D& v) const { return (this->x==v.x && this->y==v.y); };
     43  /** @param v: the Vector to negative-compare with this one @returns true if the two vectors are different */
     44  inline bool operator!= (const Vector2D& v) const { return (this->x!=v.x && this->y!=v.y); };
    4345  /** @param index The index of the "array" @returns the x/y coordinate */
    4446  inline float operator[] (float index) const { return ( index == 0)? this->x : this->y; }
  • branches/gui/src/story_entities/simple_game_menu.cc

    r7873 r7876  
    6666  pb->show();
    6767  pb->setAbsCoor2D(50, 50);
     68
     69  OrxGui::GLGuiCursor* cursor = new OrxGui::GLGuiCursor();
     70  cursor->show();
    6871
    6972  if (root != NULL)
Note: See TracChangeset for help on using the changeset viewer.