Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8583 in orxonox.OLD


Ignore:
Timestamp:
Jun 19, 2006, 1:20:42 PM (18 years ago)
Author:
bensch
Message:

gui: using style.

Location:
branches/gui/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/graphics/importer/material.cc

    r8572 r8583  
    4949  this->setName(mtlName);
    5050}
     51
     52Material& Material::operator=(const Material& material)
     53{
     54  this->setIllum(material.illumModel);
     55  this->setDiffuseColor(material.diffuseColor());
     56  this->specular = material.specular;
     57  this->ambient = material.ambient;
     58  this->setShininess(material.shininess);
     59
     60  this->textures = material.textures;
     61  this->sFactor = material.sFactor;
     62  this->tFactor = material.tFactor;
     63  this->setName(material.getName());
     64
     65  return *this;
     66}
     67
     68
    5169
    5270void Material::loadParams(const TiXmlElement* root)
  • branches/gui/src/lib/graphics/importer/material.h

    r8575 r8583  
    4848  void setBlendFuncS(const std::string& sFactor, const std::string& tFactor);
    4949
     50  Color& diffuseColor() { return diffuse; };
    5051  const Color& diffuseColor() const { return diffuse; };
    5152
  • branches/gui/src/lib/gui/gl/glgui_button.cc

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

    r8448 r8583  
    9999    if (this->bActive)
    100100    {
    101       glColor3fv( &this->frontColor()[0]);
     101      glColor3fv( &this->foregroundColor()[0]);
    102102      this->drawRect(this->_checkBox);
    103103
     
    124124    else
    125125    {
    126       glColor3fv( &this->frontColor()[0]);
     126      glColor3fv( &this->foregroundColor()[0]);
    127127      this->drawRect(this->_checkBox);
    128128    }
  • branches/gui/src/lib/gui/gl/glgui_cursor.cc

    r8528 r8583  
    5757    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
    5858
    59     this->backMaterial().setDiffuse(1.0,0.0,0.0);
    60     this->backMaterial().setDiffuseMap("cursor.png");
    61     this->backMaterial().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     59    this->style().background().setDiffuse(1.0,0.0,0.0);
     60    this->style().background().setDiffuseMap("cursor.png");
     61    this->style().background().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    6262    this->setSize2D(50, 50);
    6363    this->setAbsCoor2D(100, 100);
     
    8080  bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
    8181  {
    82     this->backMaterial().setDiffuse(1.0, 1.0, 1.0);
     82    this->style().background().setDiffuse(1.0, 1.0, 1.0);
    8383    return this->seq.loadImageSeries(imageNameSubstitue, from, to);
    8484  }
     
    9898        this->color -= 360.0;
    9999      Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
    100       this->backMaterial().setDiffuse(color.x, color.y, color.z);
     100      this->style().background().setDiffuse(color.x, color.y, color.z);
    101101    }
    102102    //if (this->movement != Vector2D())
     
    126126    this->beginDraw();
    127127
    128     this->backMaterial().select();
     128    this->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

    r8448 r8583  
    7676  void GLGuiImage::updateFrontColor()
    7777  {
    78     this->_imageMaterial.setDiffuseColor(this->frontColor());
     78    this->_imageMaterial.setDiffuseColor(this->foregroundColor());
    7979  }
    8080
  • branches/gui/src/lib/gui/gl/glgui_inputline.cc

    r8543 r8583  
    5454    this->_text.setLineWidth(400);
    5555    this->_text.setDotsPosition(LimitedWidthText::Begin);
    56     this->_text.setColor(this->frontColor());
     56    this->_text.setColor(this->foregroundColor());
    5757    this->_text.setVisibility(false);
    5858    this->resize();
     
    212212  void GLGuiInputLine::updateFrontColor()
    213213  {
    214     this->_text.setColor(this->frontColor());
     214    this->_text.setColor(this->foregroundColor());
    215215  }
    216216
  • branches/gui/src/lib/gui/gl/glgui_slider.cc

    r8448 r8583  
    239239    GLGuiWidget::draw();
    240240
    241     glColor4fv(&this->frontColor()[0]);
     241    glColor4fv(&this->foregroundColor()[0]);
    242242    this->drawRect(this->_slider);
    243243    this->drawRect(this->_handle);
  • branches/gui/src/lib/gui/gl/glgui_style.h

    r8582 r8583  
    2626
    2727
    28     /// Retrieve
     28    /// Retrieve (ALL THESE FUNCTIONS ARE AGAIN IN THE GLGUI-WIDGET FOR EASY RETRIEVAL)
    2929    /** @returns left borderWidth @param state the State to retrieve from */
    3030    inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; }
     
    4040    /** @returns the Background Color @param state the State to retrieve from */
    4141    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; }
    4244    /** @returns background Texture. @param state the State to retrieve from */
    43     inline const Texture& backgrorundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._background.diffuseTexture(); }
     45    inline const Texture& backgroundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._background.diffuseTexture(); }
    4446    /** @returns the foreground Color @param state the State to retrieve from */
    4547    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; }
    4650
    4751    /** @returns FeaturePosition */
     
    9195    void setForegroundColor(const Color& color, OrxGui::State state);
    9296    void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName);
     97
     98    inline Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._foreground.diffuseColor(); }
     99    inline Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._background.diffuseColor(); }
     100    inline Material& background(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._background; }
     101    inline Material& foreground(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._foreground; }
    93102
    94103    void loadBackgroundMaterial(const Material& material);
  • branches/gui/src/lib/gui/gl/glgui_widget.cc

    r8448 r8583  
    6666    this->_clickable = false;
    6767    this->_pushed = false;
     68    this->_state = OrxGui::Normal;
    6869
    6970    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    7071
    71     this->_backMat.setDiffuseColor(Color(1.0, 0.5, 0.4, 1.0));
     72/*    this->_backMat.setDiffuseColor(Color(1.0, 0.5, 0.4, 1.0));
    7273    this->_backMat.setDiffuseMap("gui_element_background.png");
    73     this->_frontColor = Color(1.0, 0.0, 0.0);
     74    this->_frontColor = Color(1.0, 0.0, 0.0);*/
    7475    this->_toFrontColor = NULL;
    75 
    76 
    77     this->_borderLeft = 15.0;
    78     this->_borderRight = 1.0;
    79     this->_borderTop = 1.0;
    80     this->_borderBottom = 1.0;
    8176  }
    8277
     
    125120    if (instantaniously)
    126121    {
    127       this->_frontColor = frontColor;
     122      this->style().setForegroundColor(frontColor);
    128123      if (this->_toFrontColor != NULL)
    129124      {
     
    141136
    142137
    143   void GLGuiWidget::setBorderSize(float borderSize)
    144   {
    145     this->_borderLeft = borderSize;
    146     this->_borderRight = borderSize;
    147     this->_borderTop = borderSize;
    148     this->_borderBottom = borderSize;
    149     this->resize();
    150   }
    151 
    152   void GLGuiWidget::setBorderLeft(float borderLeft)
    153   {
    154     this->_borderLeft = borderLeft;
    155     this->resize();
    156   }
    157   void GLGuiWidget::setBorderRight(float borderRight)
    158   {
    159     this->_borderRight = borderRight;
    160     this->resize();
    161   }
    162   void GLGuiWidget::setBorderTop(float borderTop)
    163   {
    164     this->_borderTop = borderTop;
    165     this->resize();
    166   }
    167   void GLGuiWidget::setBorderBottom(float borderBottom)
    168   {
    169     this->_borderBottom = borderBottom;
    170     this->resize();
    171   }
    172 
    173 
    174 
    175138  void GLGuiWidget::resize()
    176139  {
     
    271234    if (this->_toFrontColor)
    272235    {
    273       this->_frontColor.slerp(*_toFrontColor, dt*3.0);
     236      this->_style.foregroundColor(_state).slerp(*_toFrontColor, dt*3.0);
    274237      this->updateFrontColor();
    275       if (this->_frontColor.dist(*_toFrontColor) < .1)
     238      if (this->style().foregroundColor(_state).dist(*_toFrontColor) < .1)
    276239      {
    277240        delete _toFrontColor;
     
    287250  void GLGuiWidget::draw() const
    288251  {
    289     this->backMaterial().select();
     252    this->background().select();
    290253    this->drawRect(this->backRect());
    291     this->backMaterial().unselect();
     254    this->background().unselect();
    292255  }
    293256
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8518 r8583  
    6666    void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver);
    6767
     68    OrxGui::State state() const { return this->_state; };
    6869
    6970    GLGuiStyle& style() { return this->_style; };
    7071    const GLGuiStyle style() const { return this->_style; };
    7172
    72     /// MATERIAL (looks)
    73     Material& backMaterial() { return this->_backMat; };
    74     const Material& backMaterial() const { return this->_backMat; };
     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
     107
    75108    Rect2D& backRect() { return this->_backRect; };
    76109    const Rect2D& backRect() const { return this->_backRect; };
    77110
    78111    void setFrontColor(const Color& frontColor, bool instantaniously = false);
    79     const Color& frontColor() const { return this->_frontColor; };
    80 
    81     /** @brief sets all borders to the same value. */
    82     void setBorderSize(float borderSize);
    83     void setBorderLeft(float borderLeft);
    84     void setBorderRight(float borderRight);
    85     void setBorderTop(float borderTop);
    86     void setBorderBottom(float borderBottom);
    87 
    88     float borderLeft() const { return this->_borderLeft; };
    89     float borderRight() const { return this->_borderRight; };
    90     float borderTop() const { return this->_borderTop; };
    91     float borderBottom() const { return this->_borderBottom; };
    92 
    93112
    94113    void setWidgetSize(const Vector2D& size);
    95114    void setWidgetSize(float x, float y);
    96115
    97 
    98     void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); };
    99116
    100117    inline void drawRect(const Rect2D& rect) const
     
    144161
    145162    /// LOOKS
    146     Material                       _backMat;
     163    GLGuiStyle                     _style;
    147164    Rect2D                         _backRect;
    148165
    149     Color                          _frontColor;
    150166    Color*                         _toFrontColor;
    151 
    152     float                          _borderLeft;
    153     float                          _borderRight;
    154     float                          _borderTop;
    155     float                          _borderBottom;
    156167
    157168    Vector2D                       _minSize;
    158169
    159     GLGuiStyle                     _style;
    160170
    161171    /// EVENTS
     172    OrxGui::State                  _state;
     173
    162174    bool                           _focusable;        //!< If this widget can receive focus.
    163175    bool                           _clickable;        //!< if this widget can be clicked upon.
  • branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc

    r8530 r8583  
    200200    this->beginDraw();
    201201
    202     this->backMaterial().select();
     202    this->background().select();
    203203    this->drawRect(this->backRect());
    204204    this->endDraw();
  • branches/gui/src/story_entities/simple_game_menu.cc

    r8518 r8583  
    120120    OrxGui::GLGuiSlider* slider = new OrxGui::GLGuiSlider();
    121121    slider->connect(SIGNAL(slider, valueChanged), this, SLOT(SimpleGameMenu, TEST));
    122     slider->connect(SIGNAL(slider, valueChanged), box, SLOT(OrxGui::GLGuiWidget, setBackgroundColor));
    123122    slider->setRange(0, 1);
    124123    slider->setValue(slider->min());
  • branches/gui/src/util/hud.cc

    r8518 r8583  
    8989  {
    9090    this->energyWidget->show();
    91     this->energyWidget->backMaterial().setDiffuseMap("hud_energy_background.png");
    92     this->energyWidget->backMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     91    this->energyWidget->style().background().setDiffuseMap("hud_energy_background.png");
     92    this->energyWidget->style().background().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    9393    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    9494        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    143143      {
    144144        weapon->getEnergyWidget()->show();
    145         weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
    146         weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
     145        weapon->getEnergyWidget()->style().background().setDiffuse( .8,.2,.11);
     146        weapon->getEnergyWidget()->style().background().setTransparency(.1);
    147147        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    148148        //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
Note: See TracChangeset for help on using the changeset viewer.