Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8115 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 2, 2006, 10:56:41 AM (18 years ago)
Author:
bensch
Message:

gui: new borders (border on each side can differ now)

Location:
branches/gui/src/lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/event/event_handler.cc

    r8061 r8115  
    337337  else
    338338  {
    339     SDL_WM_GrabInput(SDL_GRAB_ON);
     339//    SDL_WM_GrabInput(SDL_GRAB_ON);
    340340    SDL_ShowCursor(SDL_DISABLE);
    341341  }
  • branches/gui/src/lib/gui/gl_gui/glgui_box.cc

    r8035 r8115  
    109109    if (orientation() == OrxGui::Vertical)
    110110    {
    111       float height = this->borderSize();
     111      float height = this->borderTop();
    112112      float width = 0.0f;
    113113      std::vector<GLGuiWidget*>::iterator widget;
     
    116116      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    117117      {
    118         (*widget)->setRelCoor2D(this->borderSize(), height);
     118        (*widget)->setRelCoor2D(this->borderLeft(), height);
    119119        height += (*widget)->getSizeY2D();
    120120        width = fmax(width, (*widget)->getSizeX2D());
    121121      }
    122122
    123       width += this->borderSize() * 2.0;
    124       height += this->borderSize(); /* *2 done further up */
     123      width += this->borderLeft() + this->borderRight();
     124      height += this->borderBottom(); /* *2 done further up */
    125125
    126126      printf("%f %f\n", width, height);
     
    129129    else
    130130    {
    131       float height = this->borderSize();
    132       float width = this->borderSize();
     131      float height = this->borderTop();
     132      float width = this->borderLeft();
    133133      std::vector<GLGuiWidget*>::iterator widget;
    134134
     
    136136      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    137137      {
    138         (*widget)->setRelCoor2D(width, this->borderSize());
     138        (*widget)->setRelCoor2D(width, this->borderTop());
    139139        height = fmax(height, (*widget)->getSizeY2D());
    140140        width += (*widget)->getSizeX2D();
    141141      }
    142142
    143       width += this->borderSize() ;
    144       height += this->borderSize(); /* *2 done further up */
     143      width += this->borderRight() ;
     144      height += this->borderBottom(); /* *2 done further up */
    145145
    146146      printf("%f %f\n", width, height);
  • branches/gui/src/lib/gui/gl_gui/glgui_button.cc

    r8035 r8115  
    3030    this->init();
    3131
    32     this->label.setText( label );
     32    this->_label.setText( label );
    3333  }
    3434
     
    5454    this->setClickable(true);
    5555
    56     this->label.setFont("fonts/final_frontier.ttf", 20);
     56    this->_label.setFont("fonts/final_frontier.ttf", 20);
    5757    this->frontMaterial().setDiffuse(1, 0, 0);
    5858
    59     this->label.setParent2D(this);
     59    this->_label.setParent2D(this);
     60    this->_label.setVisibility(false);
    6061  }
    6162
     
    6364  void GLGuiButton::setLabel(const std::string& label)
    6465  {
    65     this->label.setText(label);
     66    this->_label.setText(label);
    6667    this->resize();
    6768  }
     
    7879  }
    7980
     81  void GLGuiButton::hiding()
     82  {
     83    this->_label.setVisibility(false);
     84  }
     85
     86  void GLGuiButton::showing()
     87  {
     88    this->_label.setVisibility(true);
     89  }
     90
     91
    8092  /**
    8193   * @brief draws the GLGuiButton
  • branches/gui/src/lib/gui/gl_gui/glgui_button.h

    r8035 r8115  
    3636      virtual ~GLGuiButton();
    3737
    38       const std::string& getLabel() const { return this->label.getText(); };
     38      const std::string& label() const { return this->_label.getText(); };
    3939      void setLabel(const std::string& label);
    4040
     
    4747      virtual void clicking(const Vector2D& pos);
    4848      virtual void releasing(const Vector2D& pos);
     49      virtual void hiding();
     50      virtual void showing();
     51
     52      /** @returns the Text. (the physical Text) */
     53      Text& labelText() { return this->_label; }
     54      /** @returns the constant Text. (the physical Text) */
     55      const Text& labelText() const { return this->_label; }
    4956
    5057    private:
     
    5259
    5360
    54 
    55     protected:
    56 
    57       Text                 label;
    58 
    5961    private:
     62      Text                 _label;
    6063      ButtonState          state;
    6164  };
  • branches/gui/src/lib/gui/gl_gui/glgui_checkbutton.cc

    r8035 r8115  
    6565  void GLGuiCheckButton::resize()
    6666  {
    67     this->label.setRelCoor2D(25, 5);
    68     this->setSize2D(this->label.getSizeX2D() + 30, this->label.getSizeY2D() + 10);
     67    this->labelText().setRelCoor2D(25, 5);
     68    this->setSize2D(this->labelText().getSizeX2D() + 30, this->labelText().getSizeY2D() + 10);
    6969    GLGuiWidget::resize();
    70     this->frontRect().setTopLeft(borderSize(), borderSize());
    71     this->frontRect().setSize(this->getSizeX2D() -2.0*borderSize(), this->getSizeY2D() -2.0*borderSize());
     70    this->frontRect().setTopLeft(borderLeft(), borderTop());
     71    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));
    7272  }
    7373
  • branches/gui/src/lib/gui/gl_gui/glgui_image.cc

    r8035 r8115  
    7575  void GLGuiImage::resize()
    7676  {
    77     this->frontRect().setTopLeft(this->borderSize(), this->borderSize());
    78     this->frontRect().setSize(this->getSizeX2D() -2.0*this->borderSize(), this->getSizeY2D() - 2.0* this->borderSize() );
     77    this->frontRect().setTopLeft(this->borderLeft(), this->borderRight());
     78    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );
    7979    GLGuiWidget::resize();
    8080  }
  • branches/gui/src/lib/gui/gl_gui/glgui_inputline.cc

    r8035 r8115  
    164164    this->setSize2D( this->text.getSize2D() + Vector2D(8, 8));
    165165    GLGuiWidget::resize();
    166     this->frontRect().setTopLeft(borderSize(), borderSize());
    167     this->frontRect().setSize(this->getSize2D() - Vector2D(borderSize(), borderSize()));
     166    this->frontRect().setTopLeft(borderLeft(), borderTop());
     167    this->frontRect().setSize(this->getSize2D() - Vector2D(borderRight(), borderBottom()));
    168168  }
    169169
  • branches/gui/src/lib/gui/gl_gui/glgui_pushbutton.cc

    r8035 r8115  
    4545  void GLGuiPushButton::resize()
    4646  {
    47     this->label.setRelCoor2D(5, 5);
    48     this->setSize2D(this->label.getSizeX2D() + 10, this->label.getSizeY2D() + 10);
     47    this->labelText().setRelCoor2D(5, 5);
     48    this->setSize2D(this->labelText().getSizeX2D() + 10, this->labelText().getSizeY2D() + 10);
    4949
    5050    GLGuiWidget::resize();
     
    6363  void GLGuiPushButton::receivedFocus()
    6464  {
    65     printf("%s received focus\n", this->getLabel().c_str());
     65    printf("%s received focus\n", this->label().c_str());
    6666    GLGuiWidget::receivedFocus();
    6767  }
     
    6969  void GLGuiPushButton::removedFocus()
    7070  {
    71     printf("%s removed focus\n", this->getLabel().c_str());
     71    printf("%s removed focus\n", this->label().c_str());
    7272    GLGuiWidget::removedFocus();
    7373
     
    7676  void GLGuiPushButton::clicking(const Vector2D& pos)
    7777  {
    78     printf("%s clicked\n", this->getLabel().c_str());
     78    printf("%s clicked\n", this->label().c_str());
    7979    GLGuiButton::clicking(pos);
    8080  }
     
    8383  void GLGuiPushButton::releasing(const Vector2D& pos)
    8484  {
    85     printf("%s released\n", this->getLabel().c_str());
     85    printf("%s released\n", this->label().c_str());
    8686    GLGuiButton::releasing(pos);
    8787  }
  • branches/gui/src/lib/gui/gl_gui/glgui_slider.cc

    r8035 r8115  
    201201  {
    202202    return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) *
    203            (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) +
    204            (borderSize() +_sliderWidth);
     203           (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) +
     204           (borderLeft() +_sliderWidth);
    205205  }
    206206
     
    211211  float GLGuiSlider::sliderValue(float position) const
    212212  {
    213     return (position - (borderSize()+_sliderWidth)) / (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth))
     213    return (position - (borderLeft()+_sliderWidth)) / (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth))
    214214           *( this->_maxValue - this->_minValue) +
    215215           this->_minValue ;
     
    231231    this->drawRect(this->frontRect());
    232232
    233     this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, borderSize(), _sliderWidth, this->getSizeY2D() - 2 * borderSize()));
     233    this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, borderLeft(), _sliderWidth, this->getSizeY2D() - (borderLeft() + borderRight())));
    234234
    235235    this->endDraw();
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.cc

    r8035 r8115  
    6868    this->_backMat.setDiffuse(1.0, 1.0, 1.0);
    6969    this->_frontMat.setDiffuse(1.0, 0.0, 0.0);
    70     this->_borderSize = 1.0;
     70
     71    this->_borderLeft = 1.0;
     72    this->_borderRight = 1.0;
     73    this->_borderTop = 1.0;
     74    this->_borderBottom = 1.0;
    7175  }
    7276
     
    114118  void GLGuiWidget::setBorderSize(float borderSize)
    115119  {
    116     this->_borderSize = borderSize;
    117     this->resize();
    118   }
     120    this->_borderLeft = borderSize;
     121    this->_borderRight = borderSize;
     122    this->_borderTop = borderSize;
     123    this->_borderBottom = borderSize;
     124    this->resize();
     125  }
     126
     127  void GLGuiWidget::setBorderLeft(float borderLeft)
     128  {
     129    this->_borderLeft = borderLeft;
     130    this->resize();
     131  }
     132  void GLGuiWidget::setBorderRight(float borderRight)
     133  {
     134    this->_borderRight = borderRight;
     135    this->resize();
     136  }
     137  void GLGuiWidget::setBorderTop(float borderTop)
     138  {
     139    this->_borderTop = borderTop;
     140    this->resize();
     141  }
     142  void GLGuiWidget::setBorderBottom(float borderBottom)
     143  {
     144    this->_borderBottom = borderBottom;
     145    this->resize();
     146  }
     147
    119148
    120149
     
    201230  {
    202231    this->setVisibility(true);
     232    this->showing();
    203233  }
    204234
     
    207237  {
    208238    this->setVisibility(false);
     239    this->hiding();
    209240  }
    210241
  • branches/gui/src/lib/gui/gl_gui/glgui_widget.h

    r8035 r8115  
    8787    const Rect2D& frontRect() const { return this->_frontRect; };
    8888
    89     float borderSize() const { return this->_borderSize; };
     89    /** @brief sets all borders to the same value. */
    9090    void setBorderSize(float borderSize);
     91    void setBorderLeft(float borderLeft);
     92    void setBorderRight(float borderRight);
     93    void setBorderTop(float borderTop);
     94    void setBorderBottom(float borderBottom);
     95
     96    float borderLeft() const { return this->_borderLeft; };
     97    float borderRight() const { return this->_borderRight; };
     98    float borderTop() const { return this->_borderTop; };
     99    float borderBottom() const { return this->_borderBottom; };
     100
    91101
    92102    void setWidgetSize(const Vector2D& size);
     
    117127    virtual void resize();
    118128
     129    virtual void hiding() {};
     130    virtual void showing() {};
    119131    // if something was clickt on the GUI-widget.
    120132    virtual void clicking(const Vector2D& pos);
     
    143155    Rect2D                         _frontRect;
    144156
    145     float                          _borderSize;
     157    float                          _borderLeft;
     158    float                          _borderRight;
     159    float                          _borderTop;
     160    float                          _borderBottom;
    146161
    147162    /// EVENTS
Note: See TracChangeset for help on using the changeset viewer.