Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7919 in orxonox.OLD for trunk/src/lib/gui/gl_gui/glgui_widget.cc


Ignore:
Timestamp:
May 28, 2006, 3:48:13 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the gui branche back
merged with command:
https://svn.orxonox.net/orxonox/branches/gui
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl_gui/glgui_widget.cc

    r7855 r7919  
    1818#include "glgui_widget.h"
    1919
     20#include "glgui_cursor.h"
     21
    2022#include "material.h"
    2123
     
    3941  GLGuiWidget::~GLGuiWidget()
    4042  {
    41   }
     43    if (this == GLGuiWidget::_focused)
     44      GLGuiWidget::_focused = NULL;
     45  }
     46
     47  GLGuiWidget* GLGuiWidget::_focused = NULL;
     48  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
     49
    4250
    4351
     
    4957    this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget");
    5058
    51     this->focusable = true;
    52     this->clickable = true;
     59    this->_focusable = false;
     60    this->_clickable = false;
     61    this->_pushed = false;
     62
    5363    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    54     //  this->setParent2D((Element2D*)NULL);
    5564
    5665    this->backMat.setDiffuse(1.0, 1.0, 1.0);
    57 
    58     this->frontModel = 0;
     66    this->frontMat.setDiffuse(1.0, 0.0, 0.0);
    5967
    6068    this->widgetSignals.resize(SignalCount, SignalConnector());
     
    6270
    6371
    64   bool GLGuiWidget::focusOverWidget(float x, float y)
    65   {
    66     if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x &&
    67         this->getAbsCoor2D().y < y && this->getAbsCoor2D().y + this->getSizeY2D() > y)
    68       return true;
    69     else
    70       return false;
    71   }
     72  /** @brief gives focus to this widget */
     73  void GLGuiWidget::giveFocus()
     74  {
     75    if (GLGuiWidget::focused() != NULL)
     76      GLGuiWidget::focused()->breakFocus();
     77    GLGuiWidget::_focused = this;
     78    this->receivedFocus();
     79  };
     80
     81  void GLGuiWidget::breakFocus()
     82  {
     83    if (GLGuiWidget::_focused == this)
     84    {
     85      GLGuiWidget::_focused = NULL;
     86      this->_pushed = false;
     87      this->removedFocus();
     88    }
     89  };
     90
     91
     92  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
     93  {
     94    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
     95        this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
     96  }
     97
     98  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
     99  {
     100    return this->focusOverWidget(cursor->getAbsCoor2D());
     101  }
     102
     103  void GLGuiWidget::click()
     104  {
     105    assert (!this->_pushed);
     106    this->widgetSignals[Signal_click]("none");
     107    this->_pushed = true;
     108
     109    this->clicked();
     110  }
     111
     112  void GLGuiWidget::release()
     113  {
     114    if (this->_pushed)
     115    {
     116      this->widgetSignals[Signal_release]("none");
     117
     118      this->released();
     119      this->_pushed = false;
     120    }
     121  }
     122
     123
     124  void GLGuiWidget::clicked()
     125  {
     126    this->frontMaterial().setDiffuse(0, 0, 1);
     127
     128  }
     129
     130  void GLGuiWidget::released()
     131  {
     132    this->frontMat.setDiffuse(0,1,0);
     133
     134  }
     135
     136  void GLGuiWidget::receivedFocus()
     137  {
     138    this->frontMaterial().setDiffuse(0, 1, 0);
     139  }
     140
     141  void GLGuiWidget::removedFocus()
     142  {
     143    this->frontMaterial().setDiffuse(1, 0, 0);
     144
     145  }
     146
     147  void GLGuiWidget::destroyed()
     148  {
     149  };
     150
     151
     152
    72153
    73154  /**
     
    116197
    117198    glBegin(GL_QUADS);
    118     glTexCoord2i(0,1); glVertex2d(0, 0);
    119     glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
    120     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
    121     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
     199    glTexCoord2i(0,0); glVertex2d(0, 0);
     200    glTexCoord2i(0,1); glVertex2d(0, this->getSizeY2D());
     201    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
     202    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), 0);
    122203    glEnd();
    123204  }
Note: See TracChangeset for help on using the changeset viewer.