Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8717 in orxonox.OLD for trunk/src/lib/gui/gl/glgui_widget.cc


Ignore:
Timestamp:
Jun 22, 2006, 2:04:28 PM (18 years ago)
Author:
bensch
Message:

merged the gui back

File:
1 edited

Legend:

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

    r8619 r8717  
    7272  GLGuiWidget::~GLGuiWidget()
    7373  {
    74     if (this == GLGuiWidget::_focused)
    75       GLGuiWidget::_focused = NULL;
     74    if (this == GLGuiWidget::_mouseFocused)
     75      GLGuiWidget::_mouseFocused = NULL;
     76    if (this == GLGuiWidget::selected())
     77      this->unselect();
    7678  }
    7779
    7880  GLGuiWidget* GLGuiWidget::_selected = NULL;
    79   GLGuiWidget* GLGuiWidget::_focused = NULL;
     81  GLGuiWidget* GLGuiWidget::_mouseFocused = NULL;
    8082  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
    8183
     
    9193    this->_focusable = false;
    9294    this->_clickable = false;
     95    this->_selectable = false;
    9396    this->_pushed = false;
    9497    this->_state = OrxGui::Normal;
     
    133136  }
    134137
     138
     139  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
     140  {
     141    this->_currentStyle._foreground.setDiffuseColor(frontColor);
     142    this->animateBack();
     143  };
     144
     145
     146  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
     147  {
     148    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
     149        this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
     150  }
     151
     152  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
     153  {
     154    return this->focusOverWidget(cursor->getAbsCoor2D());
     155  }
     156
     157
     158
    135159  /** @brief gives focus to this widget */
    136   void GLGuiWidget::giveFocus()
    137   {
    138     if (GLGuiWidget::focused() != NULL)
    139       GLGuiWidget::focused()->breakFocus();
    140     GLGuiWidget::_focused = this;
     160  void GLGuiWidget::giveMouseFocus()
     161  {
     162    if (this->_state == OrxGui::Insensitive)
     163      return ;
     164
     165    if (GLGuiWidget::mouseFocused() != NULL)
     166      GLGuiWidget::mouseFocused()->breakMouseFocus();
     167    GLGuiWidget::_mouseFocused = this;
     168
     169    this->switchState(OrxGui::Focused);
     170
    141171    this->receivedFocus();
    142172  };
    143173
    144   void GLGuiWidget::breakFocus()
    145   {
    146     if (GLGuiWidget::_focused == this)
     174  void GLGuiWidget::breakMouseFocus()
     175  {
     176    if (GLGuiWidget::_mouseFocused == this)
    147177    {
    148       GLGuiWidget::_focused = NULL;
    149       this->_pushed = false;
     178      GLGuiWidget::_mouseFocused = NULL;
     179
     180      if (GLGuiWidget::_selected != this)
     181        this->switchState(OrxGui::Normal);
     182      else
     183        this->switchState(OrxGui::Selected);
     184
    150185      this->removedFocus();
    151186    }
    152187  };
    153188
    154 
    155   bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
    156   {
    157     return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
    158             this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
    159   }
    160 
    161   bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
    162   {
    163     return this->focusOverWidget(cursor->getAbsCoor2D());
    164   }
    165 
    166 
    167 
    168   void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
    169   {
    170     this->_currentStyle._foreground.setDiffuseColor(frontColor);
    171     this->animateBack();
    172   };
     189  /**
     190   * @brief selects the Widget, unselecting the old one (if existing)
     191   */
     192  void GLGuiWidget::select()
     193  {
     194    if (GLGuiWidget::_selected != NULL)
     195      GLGuiWidget::selected()->unselect();
     196    GLGuiWidget::_selected = this;
     197
     198    this->switchState(OrxGui::Selected);
     199  }
     200
     201  /**
     202   * @brief unselects the current Widget.
     203   *
     204   * if the current Widget is not selected, nothing is done here.
     205   */
     206  void GLGuiWidget::unselect()
     207  {
     208    if (GLGuiWidget::_selected != this)
     209      return;
     210
     211    if (GLGuiWidget::_mouseFocused == this)
     212      this->switchState(OrxGui::Focused);
     213    else
     214      this->switchState(OrxGui::Normal);
     215
     216    GLGuiWidget::_selected = NULL;
     217  }
    173218
    174219
     
    193238    if (this->_pushed)
    194239    {
    195       this->releasing(pos);
     240      this->releasing(pos, GLGuiWidget::_mouseFocused == this);
    196241      this->_pushed = false;
    197242    }
     
    200245
    201246  void GLGuiWidget::clicking(const Vector2D& pos)
    202   {
    203     this->switchState(OrxGui::Selected);
    204   }
    205 
    206   void GLGuiWidget::releasing(const Vector2D& pos)
    207   {
    208     this->switchState(OrxGui::Normal);
    209   }
     247  {}
     248
     249  void GLGuiWidget::releasing(const Vector2D& pos, bool focused)
     250  {}
    210251
    211252  void GLGuiWidget::receivedFocus()
    212253  {
    213     this->switchState(OrxGui::Focused);
    214254  }
    215255
    216256  void GLGuiWidget::removedFocus()
    217257  {
    218     this->switchState(OrxGui::Normal);
    219 
    220   }
    221 
    222   void GLGuiWidget::destroyed()
    223   {}
    224   ;
     258
     259  }
     260
     261  void GLGuiWidget::selecting()
     262  {
     263  }
     264
     265  void GLGuiWidget::unselecting()
     266  {
     267  }
     268
     269
     270  void GLGuiWidget::destroying()
     271  {
     272  }
    225273
    226274
     
    706754    //this->_currentStyle = this->_style[state];
    707755    this->_state = state;
    708     PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
     756    PRINTF(3)("%s::%s Switches to state %s\n", this->getClassName(), this->getName(), OrxGui::StateString[state].c_str());
    709757
    710758    this->animateBack();
     
    762810    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    763811      if (stateName == OrxGui::StateString[i])
    764     {
    765       *state = (OrxGui::State)i;
    766       return true;
    767     }
     812      {
     813        *state = (OrxGui::State)i;
     814        return true;
     815      }
    768816    return false;
    769817  }
     
    772820   * @brief print out some nice debug output about the Widget.
    773821   */
    774   void GLGuiWidget::debug() const
     822  void GLGuiWidget::debug(unsigned int level) const
    775823  {
    776824    PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
Note: See TracChangeset for help on using the changeset viewer.