Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/gui/gl_gui/glgui_cursor.cc @ 7896

Last change on this file since 7896 was 7891, checked in by bensch, 18 years ago

gui: coloring of the Cursor ok

File size: 2.4 KB
RevLine 
[4744]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[5360]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5360]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
[1853]17
[7873]18#include "glgui_cursor.h"
[7885]19
20#include "glgui_handler.h"
[7876]21#include "color.h"
[1853]22
[7885]23
[7779]24namespace OrxGui
[3365]25{
[4320]26
[7779]27  /**
28   * standard constructor
29  */
[7873]30  GLGuiCursor::GLGuiCursor ()
[7779]31  {
32    this->init();
[1853]33
[7876]34    this->subscribeEvent(ES_MENU,  EV_MOUSE_MOTION);
35
36
[7779]37  }
[1853]38
[5360]39
[7779]40  /**
[7876]41   * @brief standard deconstructor
42   */
[7873]43  GLGuiCursor::~GLGuiCursor()
[7885]44  {
45    GLGuiHandler::getInstance()->deactivateCursor(false);
46  }
[5360]47
[7876]48  float GLGuiCursor::_mouseSensitivity = 1.0;
49
50
[7779]51  /**
[7876]52   * @brief initializes the GUI-element
[7779]53   */
[7873]54  void GLGuiCursor::init()
[7779]55  {
[7873]56    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
[5360]57
[7876]58    this->backMaterial().setDiffuse(1.0,0.0,0.0);
[7878]59    this->backMaterial().setDiffuseMap("cursor.png");
[7876]60    this->setSize2D(10, 20);
61    this->setAbsCoor2D(100, 100);
62    this->setLayer(E2D_LAYER_ABOVE_ALL);
[7891]63    this->color = 0.0f;
[7876]64
[7779]65  }
[5360]66
[7876]67  void GLGuiCursor::tick(float dt)
68  {
[7891]69    this->color += dt*10.0;
70    if (this->color > 360.0)
71      this->color -= 360.0;
72    Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
[7876]73    this->backMaterial().setDiffuse(color.x, color.y, color.z);
74
[7879]75    //if (this->movement != Vector2D())
[7876]76    {
77/*      if (this->getAbsCoor2D().x < 0.0 )
78        movement.x = -this->getAbsCoor2D().x;
79      if (this->getAbsCoor2D().x > 200.0)
80        movement.x = (200.0-this->getAbsCoor2D().x);
81      if (this->getAbsCoor2D().y < 0.0 )
82        movement.x = -this->getAbsCoor2D().y;
83      if (this->getAbsCoor2D().y > 200.0)
84        movement.x = (200.0-this->getAbsCoor2D().y);*/
85
86
87
88      //this->shiftCoor2D(movement);
89      this->setAbsCoor2D(newPos);
90      movement = Vector2D();
91    }
92  }
93
[7779]94  /**
[7876]95   * @brief draws the GLGuiCursor
[7779]96   */
[7876]97  void GLGuiCursor::draw() const
[7779]98  {
[7876]99    this->startDraw();
100    GLGuiWidget::draw();
101    this->endDraw();
[7779]102  }
[7876]103
104  void GLGuiCursor::process(const Event& event)
105  {
106    switch (event.type)
107    {
108      case EV_MOUSE_MOTION:
109        newPos = Vector2D(event.x, event.y);
110        movement += Vector2D(event.xRel * _mouseSensitivity, event.yRel * _mouseSensitivity);
111        break;
112
113    }
114  }
[5360]115}
Note: See TracBrowser for help on using the repository browser.