Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8584 in orxonox.OLD


Ignore:
Timestamp:
Jun 19, 2006, 2:32:23 PM (18 years ago)
Author:
bensch
Message:

orxonox/gui: more implemented inside of the State, not it looks worse than before :(

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

Legend:

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

    r8450 r8584  
    110110    if (orientation() == OrxGui::Vertical)
    111111    {
    112       float height = this->borderTop();
     112      float height = style().borderTop();
    113113      float width = 0.0f;
    114114      std::vector<GLGuiWidget*>::iterator widget;
     
    117117      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    118118      {
    119         (*widget)->setRelCoor2D(this->borderLeft(), height);
     119        (*widget)->setRelCoor2D(style().borderLeft(), height);
    120120        height += (*widget)->getSizeY2D();
    121121        width = fmax(width, (*widget)->getSizeX2D());
    122122      }
    123123
    124       width += this->borderLeft() + this->borderRight();
    125       height += this->borderBottom(); /* *2 done further up */
     124      width += style().borderLeft() + style().borderRight();
     125      height += style().borderBottom(); /* *2 done further up */
    126126
    127127      printf("%f %f\n", width, height);
     
    130130    else
    131131    {
    132       float height = this->borderTop();
    133       float width = this->borderLeft();
     132      float height = style().borderTop();
     133      float width = style().borderLeft();
    134134      std::vector<GLGuiWidget*>::iterator widget;
    135135
     
    137137      for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    138138      {
    139         (*widget)->setRelCoor2D(width, this->borderTop());
     139        (*widget)->setRelCoor2D(width, style().borderTop());
    140140        height = fmax(height, (*widget)->getSizeY2D());
    141141        width += (*widget)->getSizeX2D();
    142142      }
    143143
    144       width += this->borderRight() ;
    145       height += this->borderBottom(); /* *2 done further up */
     144      width += style().borderRight() ;
     145      height += style().borderBottom(); /* *2 done further up */
    146146
    147147      printf("%f %f\n", width, height);
  • branches/gui/src/lib/gui/gl/glgui_button.cc

    r8583 r8584  
    5555
    5656    this->_label.setFont("fonts/final_frontier.ttf", 20);
    57     this->_label.setColor(this->foregroundColor() );
     57    this->_label.setColor(this->style().foregroundColor() );
    5858
    5959    this->_label.setParent2D(this);
     
    7171  void GLGuiButton::updateFrontColor()
    7272  {
    73     this->_label.setColor(this->foregroundColor());
     73    this->_label.setColor(this->style().foregroundColor());
    7474  }
    7575
  • branches/gui/src/lib/gui/gl/glgui_checkbutton.cc

    r8583 r8584  
    6666  {
    6767
    68     this->labelText().setRelCoor2D( borderLeft() + 15.0, borderTop() + 5);
    69     this->setSize2D(this->labelText().getSizeX2D() + 15.0 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom());
     68    this->labelText().setRelCoor2D( style().borderLeft() + 15.0, style().borderTop() + 5);
     69    this->setSize2D(this->labelText().getSizeX2D() + 15.0 + style().borderLeft() + style().borderRight(), this->labelText().getSizeY2D() + 10 + style().borderTop()+style().borderBottom());
    7070    GLGuiWidget::resize();
    7171
    7272    this->_checkBox.setSize(10.0, 10.0);
    73     this->_checkBox.setCenter( borderLeft() + _checkBox.height()/2.0, borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0);
     73    this->_checkBox.setCenter( style().borderLeft() + _checkBox.height()/2.0, style().borderTop() + (this->getSizeY2D() - style().borderTop() - style().borderBottom()) / 2.0);
    7474
    7575/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     
    9999    if (this->bActive)
    100100    {
    101       glColor3fv( &this->foregroundColor()[0]);
     101      glColor3fv( &this->style().foregroundColor()[0]);
    102102      this->drawRect(this->_checkBox);
    103103
     
    124124    else
    125125    {
    126       glColor3fv( &this->foregroundColor()[0]);
     126      glColor3fv( &this->style().foregroundColor()[0]);
    127127      this->drawRect(this->_checkBox);
    128128    }
  • branches/gui/src/lib/gui/gl/glgui_cursor.cc

    r8583 r8584  
    126126    this->beginDraw();
    127127
    128     this->background().select();
     128    this->style().background().select();
    129129    if (!this->seq.empty())
    130130      glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber));
  • branches/gui/src/lib/gui/gl/glgui_image.cc

    r8583 r8584  
    7676  void GLGuiImage::updateFrontColor()
    7777  {
    78     this->_imageMaterial.setDiffuseColor(this->foregroundColor());
     78    this->_imageMaterial.setDiffuseColor(style().foregroundColor());
    7979  }
    8080
    8181  void GLGuiImage::resize()
    8282  {
    83     this->_imagePlane.setTopLeft(this->borderLeft(), this->borderTop());
    84     this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );
     83    this->_imagePlane.setTopLeft(style().borderLeft(), style().borderTop());
     84    this->_imagePlane.setSize(this->getSizeX2D() - (style().borderLeft() + style().borderRight()), this->getSizeY2D() - (style().borderTop() + style().borderBottom()) );
    8585    GLGuiWidget::resize();
    8686  }
  • branches/gui/src/lib/gui/gl/glgui_inputline.cc

    r8583 r8584  
    5454    this->_text.setLineWidth(400);
    5555    this->_text.setDotsPosition(LimitedWidthText::Begin);
    56     this->_text.setColor(this->foregroundColor());
     56    this->_text.setColor(style().foregroundColor());
    5757    this->_text.setVisibility(false);
    5858    this->resize();
     
    203203  void GLGuiInputLine::resize()
    204204  {
    205     this->_text.setRelCoor2D(this->borderLeft(), this->borderTop());
    206     this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
     205    this->_text.setRelCoor2D(style().borderLeft(), style().borderTop());
     206    this->setSize2D( this->_text.getSize2D() + Vector2D(style().borderLeft() + style().borderRight(), style().borderTop() + style().borderBottom()));
    207207    GLGuiWidget::resize();
    208208    /*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     
    212212  void GLGuiInputLine::updateFrontColor()
    213213  {
    214     this->_text.setColor(this->foregroundColor());
     214    this->_text.setColor(style().foregroundColor());
    215215  }
    216216
  • branches/gui/src/lib/gui/gl/glgui_pushbutton.cc

    r8448 r8584  
    4545  void GLGuiPushButton::resize()
    4646  {
    47     this->labelText().setRelCoor2D(borderLeft(), borderTop());
    48     this->setSize2D(this->labelText().getSizeX2D() + borderLeft() + borderRight(), this->labelText().getSizeY2D() + borderTop() + borderBottom() );
     47    this->labelText().setRelCoor2D(style().borderLeft(), style().borderTop());
     48    this->setSize2D(this->labelText().getSizeX2D() + style().borderLeft() + style().borderRight(), this->labelText().getSizeY2D() + style().borderTop() + style().borderBottom() );
    4949
    5050    GLGuiWidget::resize();
  • branches/gui/src/lib/gui/gl/glgui_slider.cc

    r8583 r8584  
    7474    else
    7575      this->_value = value;
    76     this->_handle.setCenter(this->sliderPosition(), this->borderTop() + (this->getSizeY2D() - this->borderTop() - borderBottom()) / 2.0);
     76    this->_handle.setCenter(this->sliderPosition(), style().borderTop() + (this->getSizeY2D() - style().borderTop() - style().borderBottom()) / 2.0);
    7777
    7878    emit(valueChanged(this->_value));
     
    165165//    this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0);
    166166//    this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0);
    167     this->_slider.setTopLeft(this->borderLeft(), this->getSizeY2D() / 2.0 -2.0);
    168     this->_slider.setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0);
    169     this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - borderTop() - borderBottom());
     167    this->_slider.setTopLeft(style().borderLeft(), this->getSizeY2D() / 2.0 -2.0);
     168    this->_slider.setSize(this->getSizeX2D() - style().borderLeft() - style().borderRight(), 4.0);
     169    this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - style().borderTop() - style().borderBottom());
    170170  }
    171171
     
    211211  {
    212212    return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) *
    213            (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) +
    214            (borderLeft() +_sliderWidth);
     213        (this->getSizeX2D() - (style().borderLeft() + style().borderRight() + 2.0*_sliderWidth)) +
     214        (style().borderLeft() +_sliderWidth);
    215215  }
    216216
     
    221221  float GLGuiSlider::sliderValue(float position) const
    222222  {
    223     return (position - (borderLeft()+_sliderWidth)) / (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth))
     223    return (position - (style().borderLeft()+_sliderWidth)) / (this->getSizeX2D() - (style().borderLeft() + style().borderRight() + 2.0*_sliderWidth))
    224224           *( this->_maxValue - this->_minValue) +
    225225           this->_minValue ;
     
    239239    GLGuiWidget::draw();
    240240
    241     glColor4fv(&this->foregroundColor()[0]);
     241    glColor4fv(&this->style().foregroundColor()[0]);
    242242    this->drawRect(this->_slider);
    243243    this->drawRect(this->_handle);
  • branches/gui/src/lib/gui/gl/glgui_style.cc

    r8582 r8584  
    3131  {
    3232    _font = NULL;
     33    this->_currentState = OrxGui::Normal;
     34    this->_animationCycle = -1.0;
     35    this->_animationDuration = 1.0;
     36
     37    /// current-style
     38    this->_currentStyle._borderLeft = 1.0;
     39    this->_currentStyle._borderRight = 1.0;
     40    this->_currentStyle._borderTop = 1.0;
     41    this->_currentStyle._borderBottom = 1.0;
     42    this->_currentStyle._textSize = 20.0;
     43
    3344    this->reset();
    3445
  • branches/gui/src/lib/gui/gl/glgui_style.h

    r8583 r8584  
    2525    virtual ~GLGuiStyle();
    2626
     27    ////////////////////////////////
     28    /// Retrieve Current Values. ///
     29    ////////////////////////////////
     30    /** @returns current left borderWidth */
     31    inline float borderLeft() const { return _currentStyle._borderLeft; }
     32    /** @returns current right borderWidth */
     33    inline float borderRight() const { return _currentStyle._borderRight; }
     34    /** @returns current top borderWidth */
     35    inline float borderTop() const { return _currentStyle._borderTop; }
     36    /** @returns burrent bottom borderWidth */
     37    inline float borderBottom() const { return _currentStyle._borderBottom; }
    2738
    28     /// Retrieve (ALL THESE FUNCTIONS ARE AGAIN IN THE GLGUI-WIDGET FOR EASY RETRIEVAL)
    29     /** @returns left borderWidth @param state the State to retrieve from */
    30     inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; }
    31     /** @returns right borderWidth @param state the State to retrieve from */
    32     inline float borderRight(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderRight; }
    33     /** @returns top borderWidth @param state the State to retrieve from */
    34     inline float borderTop(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderTop; }
    35     /** @returns bottom borderWidth @param state the State to retrieve from */
    36     inline float borderBottom(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderBottom; }
    3739
    38     /** @returns textSize @param state the State to retrieve from */
    39     inline float textSize(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._textSize; }
    40     /** @returns the Background Color @param state the State to retrieve from */
    41     inline const Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._background.diffuseColor(); }
    42     /** @returns the Background Material. @param state the state to retrieve from */
    43     inline const Material& background(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._background; }
    44     /** @returns background Texture. @param state the State to retrieve from */
    45     inline const Texture& backgroundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._background.diffuseTexture(); }
    46     /** @returns the foreground Color @param state the State to retrieve from */
    47     inline const Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._foreground.diffuseColor(); }
    48     /** @returns the ForeGroung Material. @param state the state to retrieve from */
    49     inline const Material& foreground(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._foreground; }
     40    /** @returns current textSize */
     41    inline float textSize() const { return _currentStyle._textSize; }
     42    /** @returns the Background Color */
     43    inline const Color& backgroundColor() const { return _currentStyle._background.diffuseColor(); }
     44    /** @returns the current Background Material. */
     45    inline const Material& background() const { return _currentStyle._background; }
     46    /** @returns the current background Texture. */
     47    inline const Texture& backgroundTexture() const { return _currentStyle._background.diffuseTexture(); }
     48    /** @returns the current foreground Color */
     49    inline const Color& foregroundColor() const { return _currentStyle._foreground.diffuseColor(); }
     50    /** @returns the current ForeGroung Material. */
     51    inline const Material& foreground() const { return _currentStyle._foreground; }
     52
    5053
    5154    /** @returns FeaturePosition */
     
    5861    inline bool animatedStateChanges() const { return _animatedStateChanges; }
    5962
     63
     64    ///////////////////////////////////////////////////////////////
     65    /// Retrieve Values for the Saved Values inside the States. ///
     66    ///////////////////////////////////////////////////////////////
     67    /** @returns left borderWidth @param state the State to retrieve from */
     68    inline float borderLeft(OrxGui::State state) const { return _style[state]._borderLeft; }
     69    /** @returns right borderWidth @param state the State to retrieve from */
     70    inline float borderRight(OrxGui::State state) const { return _style[state]._borderRight; }
     71    /** @returns top borderWidth @param state the State to retrieve from */
     72    inline float borderTop(OrxGui::State state) const { return _style[state]._borderTop; }
     73    /** @returns bottom borderWidth @param state the State to retrieve from */
     74    inline float borderBottom(OrxGui::State state) const { return _style[state]._borderBottom; }
     75
     76    /** @returns textSize @param state the State to retrieve from */
     77    inline float textSize(OrxGui::State state) const { return _style[state]._textSize; }
     78    /** @returns the Background Color @param state the State to retrieve from */
     79    inline const Color& backgroundColor(OrxGui::State state) const { return _style[state]._background.diffuseColor(); }
     80    /** @returns the Background Material. @param state the state to retrieve from */
     81    inline const Material& background(OrxGui::State state) const { return _style[state]._background; }
     82    /** @returns background Texture. @param state the State to retrieve from */
     83    inline const Texture& backgroundTexture(OrxGui::State state) const { return _style[state]._background.diffuseTexture(); }
     84    /** @returns the foreground Color @param state the State to retrieve from */
     85    inline const Color& foregroundColor(OrxGui::State state) const { return _style[state]._foreground.diffuseColor(); }
     86    /** @returns the ForeGroung Material. @param state the state to retrieve from */
     87    inline const Material& foreground(OrxGui::State state) const { return _style[state]._foreground; }
    6088
    6189
     
    121149    void setAnimatedStateChanges(bool animated);
    122150
     151
     152    void tick(float dt);
     153    void switchState(OrxGui::State state);
     154
     155
    123156  private:
    124157    bool getState(const std::string& stateName, OrxGui::State* state);
     
    147180
    148181
     182    /// ANIMATION STUFF:
    149183    bool                _animated;             //!< If the Widget is animated (Texture might be an AnimatedTexture.)
    150184    bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
     185
     186    float               _animationCycle;
     187    float               _animationDuration;
     188    StatedStyle         _currentStyle;
     189    OrxGui::State       _currentState;
    151190  };
    152191}
  • branches/gui/src/lib/gui/gl/glgui_widget.cc

    r8583 r8584  
    250250  void GLGuiWidget::draw() const
    251251  {
    252     this->background().select();
     252    this->style().background().select();
    253253    this->drawRect(this->backRect());
    254     this->background().unselect();
     254    this->style().background().unselect();
    255255  }
    256256
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8583 r8584  
    7070    GLGuiStyle& style() { return this->_style; };
    7171    const GLGuiStyle style() const { return this->_style; };
    72 
    73 
    74     /// STYLE-CONNECTION
    75     /** @returns left borderWidth */
    76     inline float borderLeft() const { return _style.borderLeft(_state); }
    77     /** @returns right borderWidth */
    78     inline float borderRight() const { return _style.borderRight(_state); }
    79     /** @returns top borderWidth */
    80     inline float borderTop() const { return _style.borderTop(_state); }
    81     /** @returns bottom borderWidth */
    82     inline float borderBottom() const { return _style.borderBottom(_state); }
    83 
    84     /** @returns textSize */
    85     inline float textSize() const { return _style.textSize(_state); }
    86     /** @returns the Background Color */
    87     inline const Color& backgroundColor() const { return _style.backgroundColor(_state); }
    88     /** @returns background Texture. */
    89     inline const Texture& backgroundTexture() const { return _style.backgroundTexture(_state); };
    90     /** @returns the Background Material. */
    91     inline const Material& background() const { return _style.background(_state); }
    92     /** @returns the foreground Color */
    93     inline const Color& foregroundColor() const { return _style.foregroundColor(_state); }
    94     /** @returns the ForeGroung Material. */
    95     inline const Material& foreground() const { return _style.foreground(_state); }
    96 
    97     /** @returns FeaturePosition */
    98     inline FeaturePosition featurePosition() const { return _style.featurePosition(); }
    99     /** @returns the font */
    100     inline const Font* const font() const { return _style.font(); }
    101     /** @returns true if the Element is Animated */
    102     inline bool animated() const { return _style.animated(); }
    103     /** @returns true if State-Changes are animated */
    104     inline bool animatedStateChanges() const { return _style.animatedStateChanges(); }
    105 
    106 
    10772
    10873    Rect2D& backRect() { return this->_backRect; };
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc

    r8583 r8584  
    200200    this->beginDraw();
    201201
    202     this->background().select();
     202    this->style().background().select();
    203203    this->drawRect(this->backRect());
    204204    this->endDraw();
     
    216216  Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber)
    217217  {
    218     return Vector2D(0.0f, (float)(this->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
     218    return Vector2D(0.0f, (float)(style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));
    219219  }
    220220
Note: See TracChangeset for help on using the changeset viewer.