Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8667 in orxonox.OLD


Ignore:
Timestamp:
Jun 21, 2006, 1:50:54 PM (18 years ago)
Author:
bensch
Message:

widgets are selectable now

Location:
branches/gui/src/lib/gui/gl
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/gui/gl/glgui_button.cc

    r8619 r8667  
    7979    emit(clicked());
    8080  }
    81   void GLGuiButton::releasing(const Vector2D& pos)
     81  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
    8282  {
    83     GLGuiWidget::releasing(pos);
     83    GLGuiWidget::releasing(pos, focused);
    8484    emit(released());
    8585  }
  • branches/gui/src/lib/gui/gl/glgui_button.h

    r8619 r8667  
    4848
    4949      virtual void clicking(const Vector2D& pos);
    50       virtual void releasing(const Vector2D& pos);
     50      virtual void releasing(const Vector2D& pos, bool focused);
    5151      virtual void hiding();
    5252      virtual void showing();
  • branches/gui/src/lib/gui/gl/glgui_checkbutton.cc

    r8619 r8667  
    7878
    7979
    80   void GLGuiCheckButton::releasing(const Vector2D& pos)
     80  void GLGuiCheckButton::releasing(const Vector2D& pos, bool focused)
    8181  {
    82     GLGuiButton::releasing(pos);
     82    GLGuiButton::releasing(pos, focused);
    8383    this->toggleActiveState();
    8484  }
  • branches/gui/src/lib/gui/gl/glgui_checkbutton.h

    r8448 r8667  
    3838  protected:
    3939    virtual void resize();
    40     virtual void releasing(const Vector2D& pos);
     40    virtual void releasing(const Vector2D& pos, bool focused);
    4141
    4242  private:
  • branches/gui/src/lib/gui/gl/glgui_handler.cc

    r8664 r8667  
    111111            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
    112112            GLGuiWidget::mouseFocused()->select();
    113             GLGuiWidget::selected()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
     113            GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
    114114          }
    115115        }
    116         else if (GLGuiWidget::selected != NULL && !event.bPressed)
     116        else if (GLGuiWidget::selected() != NULL && !event.bPressed)
    117117        {
    118118          if (GLGuiWidget::selected()->clickable())
     
    162162      return Vector2D::nullVector();
    163163  }
     164
    164165  Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const
    165166  {
     
    172173
    173174
    174   void GLGuiHandler::draw()
    175   {
    176     //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
    177   }
    178 
    179 
    180   void GLGuiHandler::tick(float dt)
    181   {
    182     // do not change if we already clicked into a Widget.
    183     if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->clicked())
    184       return ;
    185 
    186     // CHECK THE COLLISIONS.
     175  void GLGuiHandler::checkFocus()
     176  {
     177   // CHECK THE COLLISIONS.
    187178    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
    188179
     
    209200    }
    210201  }
     202
     203  void GLGuiHandler::draw()
     204  {
     205    //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
     206  }
     207
     208
     209  void GLGuiHandler::tick(float dt)
     210  {
     211    // do not change if we already clicked into a Widget.
     212    if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->pushed())
     213      return ;
     214
     215    this->checkFocus();
     216  }
    211217}
  • branches/gui/src/lib/gui/gl/glgui_handler.h

    r8324 r8667  
    3737    void deactivate();
    3838
     39    void checkFocus();
    3940
    4041    virtual void process(const Event &event);
  • branches/gui/src/lib/gui/gl/glgui_pushbutton.cc

    r8448 r8667  
    8181
    8282
    83   void GLGuiPushButton::releasing(const Vector2D& pos)
     83  void GLGuiPushButton::releasing(const Vector2D& pos, bool focused)
    8484  {
    8585    printf("%s released\n", this->label().c_str());
    86     GLGuiButton::releasing(pos);
     86    GLGuiButton::releasing(pos, focused);
    8787  }
    8888
  • branches/gui/src/lib/gui/gl/glgui_pushbutton.h

    r8145 r8667  
    3131    virtual void draw() const;
    3232    virtual void update();
     33
    3334  protected:
    3435    virtual void resize();
    3536    virtual void clicking(const Vector2D& pos);
    36     virtual void releasing(const Vector2D& pos);
     37    virtual void releasing(const Vector2D& pos, bool focused);
    3738    virtual void receivedFocus();
    3839    virtual void removedFocus();
  • branches/gui/src/lib/gui/gl/glgui_slider.cc

    r8619 r8667  
    193193  }
    194194
    195   void GLGuiSlider::releasing(const Vector2D& pos)
    196   {
    197     GLGuiWidget::releasing(pos);
     195  void GLGuiSlider::releasing(const Vector2D& pos, bool focused)
     196  {
     197    GLGuiWidget::releasing(pos, focused);
    198198    this->grabbed = false;
    199199  }
  • branches/gui/src/lib/gui/gl/glgui_slider.h

    r8448 r8667  
    5959
    6060    virtual void clicking(const Vector2D& pos);
    61     virtual void releasing(const Vector2D& pos);
     61    virtual void releasing(const Vector2D& pos, bool focused);
    6262    virtual void removedFocus();
    6363
  • branches/gui/src/lib/gui/gl/glgui_widget.cc

    r8664 r8667  
    9595    this->_pushed = false;
    9696    this->_state = OrxGui::Normal;
    97     this->_clicked = false;
     97    this->_pushed = false;
    9898
    9999
     
    136136  }
    137137
     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
    138159  /** @brief gives focus to this widget */
    139160  void GLGuiWidget::giveMouseFocus()
    140161  {
     162    if (this->_state == OrxGui::Insensitive)
     163      return ;
     164
    141165    if (GLGuiWidget::mouseFocused() != NULL)
    142166      GLGuiWidget::mouseFocused()->breakMouseFocus();
    143167    GLGuiWidget::_mouseFocused = this;
     168
     169    this->switchState(OrxGui::Focused);
     170
    144171    this->receivedFocus();
    145172  };
     
    151178      GLGuiWidget::_mouseFocused = NULL;
    152179      this->_pushed = false;
     180
     181      if (GLGuiWidget::_selected != this)
     182        this->switchState(OrxGui::Normal);
     183      else
     184        this->switchState(OrxGui::Selected);
     185
    153186      this->removedFocus();
    154187    }
    155188  };
    156189
    157 
    158   bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
    159   {
    160     return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
    161             this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
    162   }
    163 
    164   bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
    165   {
    166     return this->focusOverWidget(cursor->getAbsCoor2D());
    167   }
    168 
    169 
    170190  /**
    171191   * @brief selects the Widget, unselecting the old one (if existing)
     
    176196      GLGuiWidget::selected()->unselect();
    177197    GLGuiWidget::_selected = this;
     198
     199    this->switchState(OrxGui::Selected);
    178200  }
    179201
     
    188210      return;
    189211
     212    if (GLGuiWidget::_mouseFocused == this)
     213      this->switchState(OrxGui::Focused);
     214    else
     215      this->switchState(OrxGui::Normal);
     216
    190217    GLGuiWidget::_selected = NULL;
    191218  }
    192 
    193 
    194 
    195   void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
    196   {
    197     this->_currentStyle._foreground.setDiffuseColor(frontColor);
    198     this->animateBack();
    199   };
    200219
    201220
     
    220239    if (this->_pushed)
    221240    {
    222       this->releasing(pos);
     241      this->releasing(pos, GLGuiWidget::_mouseFocused == this);
    223242      this->_pushed = false;
    224243    }
     
    227246
    228247  void GLGuiWidget::clicking(const Vector2D& pos)
    229   {
    230     this->_clicked = true;
    231     this->switchState(OrxGui::Selected);
    232   }
    233 
    234   void GLGuiWidget::releasing(const Vector2D& pos)
    235   {
    236     this->_clicked = false;
    237     this->switchState(OrxGui::Normal);
    238   }
     248  {}
     249
     250  void GLGuiWidget::releasing(const Vector2D& pos, bool focused)
     251  {}
    239252
    240253  void GLGuiWidget::receivedFocus()
    241254  {
    242     this->switchState(OrxGui::Focused);
    243255  }
    244256
    245257  void GLGuiWidget::removedFocus()
    246258  {
    247     this->switchState(OrxGui::Normal);
    248259
    249260  }
     
    251262  void GLGuiWidget::selecting()
    252263  {
    253     this->switchState(OrxGui::Selected);
    254264  }
    255265
    256266  void GLGuiWidget::unselecting()
    257267  {
    258     this->switchState(OrxGui::Normal);
    259268  }
    260269
    261270
    262271  void GLGuiWidget::destroying()
    263   {}
    264   ;
     272  {
     273  }
    265274
    266275
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8664 r8667  
    7070
    7171    /// CLICK
    72     bool clicked() { return _clicked; };
     72    bool pushed() { return _pushed; };
    7373    void click(const Vector2D& pos);
    7474    void release(const Vector2D& pos);
     
    255255    // mouse clicking
    256256    virtual void clicking(const Vector2D& pos);
    257     virtual void releasing(const Vector2D& pos);
     257    virtual void releasing(const Vector2D& pos, bool focused);
    258258    // mouse focusing
    259259    virtual void receivedFocus();
     
    287287    /// EVENTS
    288288    OrxGui::State                  _state;
    289     bool                           _clicked;
     289    bool                           _pushed;
    290290
    291291    bool                           _focusable;        //!< If this widget can receive focus.
     
    293293    bool                           _selectable;       //!< If this widget can be selected.
    294294
    295     bool                           _pushed;
    296295
    297296
Note: See TracChangeset for help on using the changeset viewer.