Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8605 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 20, 2006, 9:59:53 AM (18 years ago)
Author:
bensch
Message:

orxonox/gui: fading works again

Location:
branches/gui/src
Files:
5 edited

Legend:

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

    r8598 r8605  
    9696//     this->frontMaterial().select();
    9797//     this->drawRect(this->frontRect());
    98 
    9998    if (this->bActive)
    10099    {
  • branches/gui/src/lib/gui/gl/glgui_cursor.cc

    r8598 r8605  
    5757    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
    5858
    59     this->background().setDiffuseColor(Color(1.0,0.0,0.0, 1.0));
    60     this->background().setDiffuseMap("cursor.png");
    61     this->background().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     59    this->setBackgroundColor(Color(1.0,0.0,0.0, 1.0));
     60    this->setBackgroundTexture("cursor.png");
    6261    this->setSize2D(50, 50);
    6362    this->setAbsCoor2D(100, 100);
     
    9897        this->color -= 360.0;
    9998      Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
    100       this->background().setDiffuse(color.x, color.y, color.z);
     99      //this->setBackgroundColor(color.x, color.y, color.z);
     100      /// FIXME
     101
    101102    }
    102103    //if (this->movement != Vector2D())
  • branches/gui/src/lib/gui/gl/glgui_widget.cc

    r8604 r8605  
    1414*/
    1515
    16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
     16#define DEBUG_SPECIAL_MODULE 4//DEBUG_MODULE_GUI
    1717
    1818#include "glgui_widget.h"
     
    4141
    4242  /**
     43   * @brief loads Parameters for a Style from XML
     44   * @param root the XML-Element to load from.
     45   */
     46  void GLGuiWidget::loadParams(const TiXmlElement* root)
     47  {
     48
     49    /// STYLE
     50    LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);
     51    LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);
     52    LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);
     53    LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);
     54
     55    LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);
     56    LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);
     57    LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);
     58
     59    //    LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);
     60    //    LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);
     61
     62    LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);
     63    LoadParam(root, "Font", this, GLGuiWidget, setFont);
     64
     65    LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);
     66  }
     67
     68
     69  /**
    4370   * @brief standard deconstructor
    4471   */
     
    4774    if (this == GLGuiWidget::_focused)
    4875      GLGuiWidget::_focused = NULL;
    49 
    50     if (this->_toFrontColor)
    51       delete this->_toFrontColor;
    5276  }
    5377
     
    6993    this->_pushed = false;
    7094    this->_state = OrxGui::Normal;
    71     this->_toFrontColor = NULL;
    7295
    7396
     
    7598    this->resetStyle();
    7699
    77     this->_animationCycle = -1.0;
     100    this->_animating = false;
     101    this->_animationCycle = 0.0;
    78102    this->_animationDuration = 1.0;
    79103
    80104
    81105    this->setBackgroundColor(Color(0, 0, 0, 1));
     106    this->_style[0]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     107    this->_style[1]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     108    this->_style[2]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     109    this->_style[3]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    82110
    83111    this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal);
     
    136164  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
    137165  {
    138     if (instantaniously)
     166/*    if (instantaniously)
    139167    {
    140168      this->setForegroundColor(frontColor);
     
    150178      *this->_toFrontColor = frontColor;
    151179    //this->_frontColor = frontColor;
    152     //this->updateFrontColor();
     180    //this->updateFrontColor();*/
    153181  };
    154182
     
    265293    this->setFont(NULL);
    266294
    267     this->setAnimated(true);
    268295    this->setAnimatedStateChanges(true);
    269296  }
    270297
    271   /**
    272    * @brief loads Parameters for a Style from XML
    273    * @param root the XML-Element to load from.
    274    */
    275   void GLGuiWidget::loadParams(const TiXmlElement* root)
    276   {
    277     LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);
    278     LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);
    279     LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);
    280     LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);
    281 
    282     LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);
    283     LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);
    284     LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);
    285 
    286     //    LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);
    287     //    LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);
    288 
    289     LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);
    290     LoadParam(root, "Font", this, GLGuiWidget, setFont);
    291 
    292     LoadParam(root, "animated", this, GLGuiWidget, setAnimated);
    293     LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);
    294   }
    295298
    296299  /**
     
    674677
    675678  /**
    676    * @brief if Animation should be turned on.
    677    * @param animated true if on, false otherwise.
    678    */
    679   void GLGuiWidget::setAnimated(bool animated)
    680   {
    681     this->_animated = animated;
    682   }
    683 
    684   /**
    685679   * @brief sets the AnimatedState.
    686680   * @param animated: it states-changes should animate true, otherwise false.
     
    694688  void GLGuiWidget::switchState(OrxGui::State state)
    695689  {
    696     this->_currentStyle = this->_style[state];
     690    //this->_currentStyle = this->_style[state];
    697691    this->_state = state;
    698     printf("Switching to state %s\n", OrxGui::StateString[state].c_str());
     692    PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
     693
     694    this->animateBack();
    699695  }
    700696
     
    716712  }
    717713
     714  void GLGuiWidget::animateBack()
     715  {
     716    this->_animating = true;
     717    this->_animationCycle = 0.0f;
     718  }
     719
    718720
    719721  void GLGuiWidget::tick(float dt)
    720722  {
    721     if (this->_toFrontColor)
     723    if (this->_animating)
    722724    {
    723       this->foregroundColor(_state).slerp(*_toFrontColor, dt*3.0);
     725      this->foregroundColor();
     726
     727      _animationCycle += dt / _animationDuration;
     728      if (_animationCycle >= 1.0)
     729      {
     730        _currentStyle._foreground.diffuseColor() = this->foregroundColor(_state);
     731        _animating = false;
     732      }
     733      else
     734        _currentStyle._foreground.diffuseColor().slerp(this->foregroundColor(_state), _animationCycle);
     735
    724736      this->updateFrontColor();
    725       if (this->foregroundColor(_state).dist(*_toFrontColor) < .1)
    726       {
    727         delete _toFrontColor;
    728         _toFrontColor = NULL;
    729       }
    730737    }
    731738  }
     
    779786    /// TODO    PRINT(0)("");    Font*               _font;                 //!< The Font used in the current Widget.
    780787
    781     if (_animated)
    782       PRINT(0)("- Animated ");
    783788    if (_animatedStateChanges)
    784789      PRINT(0)("- AnimatedStateChanges");
     
    786791
    787792    /*
     793    if (_animating)
     794      PRINT(0)("- Animated ");
     795
     796    //
    788797    float               _animationCycle;
    789798    float               _animationDuration;
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8604 r8605  
    7979    void setWidgetSize(float x, float y);
    8080
    81 
     81    void animateBack();
    8282
    8383    /// STYLE
     
    114114    inline const Font* const font() const { return _font; }
    115115    /** @returns true if the Element is Animated */
    116     inline bool animated() const { return _animated; }
     116    inline bool animating() const { return _animating; }
    117117    /** @returns true if State-Changes are animated */
    118118    inline bool animatedStateChanges() const { return _animatedStateChanges; }
     
    182182    void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName);
    183183
    184     inline Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._foreground.diffuseColor(); }
    185     inline Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._background.diffuseColor(); }
    186     inline Material& background(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._background; }
    187     inline Material& foreground(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._foreground; }
    188 
    189184    void loadBackgroundMaterial(const Material& material);
    190185    void loadBackgroundMaterial(const Material& material, OrxGui::State state);
     
    204199    void setFont(const std::string& fontName);
    205200
    206     void setAnimated(bool animated);
    207201    void setAnimatedStateChanges(bool animated);
    208202    void switchState(OrxGui::State state);
     
    261255
    262256
    263 
     257    /// WIDGET
    264258    GLGuiWidget*                   _parent;           //!< The parent of this Widget.
    265259
    266260    /// LOOKS
    267261    Rect2D                         _backRect;
    268 
    269     Color*                         _toFrontColor;
    270 
    271262    Vector2D                       _minSize;
    272263
     
    306297
    307298    /// ANIMATION STUFF:
    308     bool                _animated;             //!< If the Widget is animated (Texture might be an AnimatedTexture.)
    309299    bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
    310300
     301    bool                _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
    311302    float               _animationCycle;
    312303    float               _animationDuration;
  • branches/gui/src/util/hud.cc

    r8598 r8605  
    8989  {
    9090    this->energyWidget->show();
    91     this->energyWidget->background().setDiffuseMap("hud_energy_background.png");
    92     this->energyWidget->background().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     91    this->energyWidget->setBackgroundTexture( "hud_energy_background.png");
    9392    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    9493        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    143142      {
    144143        weapon->getEnergyWidget()->show();
    145         weapon->getEnergyWidget()->background().setDiffuse( .8,.2,.11);
    146         weapon->getEnergyWidget()->background().setTransparency(.1);
     144        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
    147145        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    148146        //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
Note: See TracChangeset for help on using the changeset viewer.