Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8419 in orxonox.OLD


Ignore:
Timestamp:
Jun 14, 2006, 11:07:48 PM (18 years ago)
Author:
bensch
Message:

Better coloring sceme

Location:
branches/gui/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/graphics/text_engine/multi_line_text.cc

    r8059 r8419  
    7676  glActiveTexture(GL_TEXTURE0);
    7777
    78   glColor4f(this->getColor().x, this->getColor().y, this->getColor().z, this->getBlending());
     78  glColor4fv(&this->getColor()[0]);
    7979  glEnable(GL_BLEND);
    8080  glEnable(GL_TEXTURE_2D);
    81   glBlendFunc(GL_SRC_ALPHA, GL_ONE);
     81  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    8282  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    8383
  • branches/gui/src/lib/graphics/text_engine/text.cc

    r8037 r8419  
    3737  this->size = textSize;
    3838  this->setSizeY2D(size);
    39   this->blending = TEXT_DEFAULT_BLENDING;
    4039  this->color = TEXT_DEFAULT_COLOR;
    4140
     
    7372          this->size == text.size &&
    7473          this->font == text.font &&
    75           this->color == text.color &&
    76           this->blending == text.blending);
     74          this->color == text.color);
    7775}
    7876
     
    9593{
    9694  this->size = text.size;
    97   this->blending = text.blending;
    9895  this->color = text.color;
    9996  this->setAlignment(text.getAlignment());
     
    224221  // drawing this Text.
    225222  // setting the Blending effects
    226   glColor4f(this->color.x, this->color.y, this->color.z, this->blending);
     223  glColor4fv(&this->color[0]);
    227224
    228225
     
    231228  glEnable(GL_BLEND);
    232229  glEnable(GL_TEXTURE_2D);
    233   glBlendFunc(GL_SRC_ALPHA, GL_ONE);
     230  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    234231  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE );
    235232
     
    285282{
    286283  PRINT(0)("=== TEXT: %s (with Font:'%s')  displaying %s ===\n", this->getName(), this->font->getName(), this->text.c_str());
    287   PRINT(0)("Color: %0.2f %0.2f %0.2f\n", this->color.x, this->color.y, this->color.z);
    288 }
    289 
     284  PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->color.r(), this->color.g(), this->color.b(), this->color.a());
     285}
     286
  • branches/gui/src/lib/graphics/text_engine/text.h

    r7919 r8419  
    88
    99#include "element_2d.h"
     10#include "color.h"
    1011
    1112#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
     
    1314#define  TEXT_ALIGN_CENTER           E2D_ALIGN_CENTER
    1415#define  TEXT_ALIGN_SCREEN_CENTER    E2D_ALIGN_SCREEN_CENTER
    15 #define  TEXT_DEFAULT_COLOR          Vector(1.0, 1.0, 1.0)      //!< the default Color (white)
    16 #define  TEXT_DEFAULT_BLENDING       1.0f                       //!< the default blending of the text, (no blending at all)
     16#define  TEXT_DEFAULT_COLOR          Color(1.0, 1.0, 1.0, 1.0f) //!< the default Color (white, fully visible)
    1717
    1818#define  TEXT_DEFAULT_ALIGNMENT      TEXT_ALIGN_LEFT            //!< default alignment
     
    4444    void setFont(const std::string& fontFile, unsigned int renderSize);
    4545    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    46     inline void setBlending(float blending) { this->blending = blending; };
     46    inline void setBlending(float blending) { this->color.a() = blending; };
    4747    /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */
    48     void setColor(float r, float g, float b) { this->color = Vector(r, g, b); };
     48    void setColor(float r, float g, float b) { this->color = Color(r, g, b, this->color.a()); };
     49    void setColor(float r, float g, float b, float a) { this->color = Color(r, g, b, a); };
     50    void setColor(const Color& color) { this->color = color; };
    4951    void setSize(float size);
    5052
     
    5759    inline const Font* const getFont() const { return this->font; };
    5860    /** @returns the Blending Value [0 invisible 1.0 full visible */
    59     inline float getBlending() const { return this->blending; };
     61    inline float getBlending() const { return this->color.a(); };
    6062    /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */
    61     inline const Vector& getColor() const { return this->color; };
     63    inline const Color& getColor() const { return this->color; };
    6264    /** @returns the Size of the Text */
    6365    inline float getSize() const { return this->size; };
     
    7678
    7779    std::string       text;           //!< The text to display
    78     Vector            color;          //!< The color of the font.
    79     float             blending;       //!< The blending intensity.
     80    Color             color;          //!< The color of the font.
    8081    float             size;           //!< The size of the Text.
    8182};
  • branches/gui/src/lib/gui/gl/glgui_bar.cc

    r8378 r8419  
    4646    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
    4747
    48     this->frontColor().setColor(1,1,1);
     48    this->setFrontColor(Color(1,1,1));
    4949
    5050    this->setSize2D(50, 10);
  • branches/gui/src/lib/gui/gl/glgui_button.cc

    r8378 r8419  
    5555
    5656    this->_label.setFont("fonts/final_frontier.ttf", 20);
    57     this->frontColor().setColor(1, 0, 0, 1.0);
     57    this->setFrontColor(Color(1, 0, 0, 1.0));
    5858
    5959    this->_label.setParent2D(this);
     
    6969
    7070
     71  void GLGuiButton::updateFrontColor()
     72  {
     73    this->_label.setColor(this->frontColor());
     74    printf("TEST Color is "); this->frontColor().debug();
     75  }
    7176
    7277  void GLGuiButton::clicking(const Vector2D& pos)
    7378  {
     79    GLGuiWidget::clicking(pos);
    7480    emit(clicked());
    7581  }
    7682  void GLGuiButton::releasing(const Vector2D& pos)
    7783  {
     84    GLGuiWidget::releasing(pos);
    7885    emit(released());
    7986  }
  • branches/gui/src/lib/gui/gl/glgui_button.h

    r8145 r8419  
    4545
    4646    protected:
     47      virtual void updateFrontColor();
     48
    4749      virtual void clicking(const Vector2D& pos);
    4850      virtual void releasing(const Vector2D& pos);
  • branches/gui/src/lib/gui/gl/glgui_inputline.cc

    r8378 r8419  
    4848    this->setFocusable(true);
    4949
    50     this->text.setParent2D(this);
    51     this->text.setRelCoor2D(4,4);
    52     this->text.setFont("fonts/final_frontier.ttf", 20);
    53     this->text.setVisibility(false);
     50    this->_text.setParent2D(this);
     51    this->_text.setRelCoor2D(4,4);
     52    this->_text.setFont("fonts/final_frontier.ttf", 20);
     53    this->_text.setVisibility(false);
    5454    this->resize();
    5555
     
    6363  void GLGuiInputLine::setText(const std::string& text)
    6464  {
    65     this->text.setText(text);
    66     this->resize();
    67 
    68     emit(this->textChanged(this->getText()));
     65    this->_text.setText(text);
     66    this->resize();
     67
     68    emit(this->textChanged(this->_text.getText()));
    6969  }
    7070
     
    7575  void GLGuiInputLine::append(const std::string& appendText)
    7676  {
    77     this->text.append(appendText);
    78     this->resize();
    79     emit(this->textChanged(this->text.getText()));
     77    this->_text.append(appendText);
     78    this->resize();
     79    emit(this->textChanged(this->_text.getText()));
    8080  }
    8181
     
    8787  void GLGuiInputLine::appendCharacter(char character)
    8888  {
    89     this->text.appendCharacter(character);
    90     this->resize();
    91     emit(this->textChanged(this->text.getText()));
     89    this->_text.appendCharacter(character);
     90    this->resize();
     91    emit(this->textChanged(this->_text.getText()));
    9292  }
    9393
     
    9999  void GLGuiInputLine::removeCharacters(unsigned int chars)
    100100  {
    101     this->text.removeCharacters(chars);
    102     this->resize();
    103     emit(this->textChanged(this->text.getText()));
     101    this->_text.removeCharacters(chars);
     102    this->resize();
     103    emit(this->textChanged(this->_text.getText()));
    104104  }
    105105
     
    164164  void GLGuiInputLine::resize()
    165165  {
    166     this->text.setRelCoor2D(this->borderLeft() + 2.0,this->borderTop() + 2.0);
    167     this->setSize2D( this->text.getSize2D() + Vector2D(borderLeft() + borderRight() + 4.0, borderTop() + borderBottom() + 4.0));
     166    this->_text.setRelCoor2D(this->borderLeft() + 2.0,this->borderTop() + 2.0);
     167    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight() + 4.0, borderTop() + borderBottom() + 4.0));
    168168    GLGuiWidget::resize();
    169169/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     
    171171  }
    172172
     173  void GLGuiInputLine::updateFrontColor()
     174  {
     175    this->_text.setColor(this->frontColor());
     176  }
    173177
    174178  void GLGuiInputLine::hiding()
    175179  {
    176     this->text.setVisibility(false);
     180    this->_text.setVisibility(false);
    177181  }
    178182
    179183  void GLGuiInputLine::showing()
    180184  {
    181     this->text.setVisibility(true);
     185    this->_text.setVisibility(true);
    182186  }
    183187
  • branches/gui/src/lib/gui/gl/glgui_inputline.h

    r8145 r8419  
    3232
    3333    /** @returns the text of the inputLine */
    34     const std::string& getText() const { return this->text.getText(); };
     34    const std::string& _getText() const { return this->_text.getText(); };
    3535
    3636    void setText(const std::string& text);
     
    4848    DeclareSignal1(textChanged, const std::string&);
    4949
     50  protected:
     51    virtual void updateFrontColor();
     52    virtual void hiding();
     53    virtual void showing();
     54
     55
    5056  private:
    5157    void init();
    5258    void resize();
    53     virtual void hiding();
    54     virtual void showing();
    5559
    5660  private:
    57     Text                    text;             //!< The Text to display inside of the InputLine.
     61    Text                    _text;            //!< The Text to display inside of the InputLine.
    5862
    5963    Uint16                  pressedKey;       //!< the pressed key that will be repeated.
  • branches/gui/src/lib/gui/gl/glgui_widget.cc

    r8378 r8419  
    6666    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    6767
    68     this->_backMat.setDiffuse(1.0, 1.0, 1.0);
     68    this->_backMat.setDiffuse(0.0, 0.0, 0.0);
    6969    this->_frontColor.setColor(1.0, 0.0, 0.0);
    7070
     
    176176  void GLGuiWidget::clicking(const Vector2D& pos)
    177177  {
    178     this->frontColor().setColor(0, 0, 1);
     178    this->setFrontColor(Color(0, 0, 1));
    179179
    180180  }
     
    182182  void GLGuiWidget::releasing(const Vector2D& pos)
    183183  {
    184     this->frontColor().setColor(0,1,0);
     184    this->setFrontColor(Color(0,1,0));
    185185
    186186  }
     
    188188  void GLGuiWidget::receivedFocus()
    189189  {
    190     this->frontColor().setColor(0, 1, 0);
     190    this->setFrontColor(Color(0, 1, 0));
    191191  }
    192192
    193193  void GLGuiWidget::removedFocus()
    194194  {
    195     this->frontColor().setColor(1, 0, 0);
     195    this->setFrontColor(Color(1, 0, 0));
    196196
    197197  }
    198198
    199199  void GLGuiWidget::destroyed()
    200   {}
    201   ;
     200  {
     201  };
     202
    202203
    203204  void GLGuiWidget::setWidgetSize(const Vector2D& size)
  • branches/gui/src/lib/gui/gl/glgui_widget.h

    r8378 r8419  
    3535   */
    3636  class GLGuiWidget : public Element2D
    37 {
     37  {
    3838  public:
    39   //! An enumerator that defines the different states Widgets may be in.
    40   typedef enum {
    41     Normal,           //!< Normal state of the GUI's Widgets.
    42     Active,           //!< If the widget is Active.
    43     Selected,         //!< If the Widget is Selected.
    44     Insensitive       //!< If the Widget is insensitive.
    45   } State;
     39    //! An enumerator that defines the different states Widgets may be in.
     40    typedef enum {
     41      Normal,           //!< Normal state of the GUI's Widgets.
     42      Active,           //!< If the widget is Active.
     43      Selected,         //!< If the Widget is Selected.
     44      Insensitive       //!< If the Widget is insensitive.
     45    } State;
    4646
    4747
     
    9292    const Rect2D& backRect() const { return this->_backRect; };
    9393
    94     Color& frontColor() { return this->_frontColor; };
     94    void setFrontColor(const Color& frontColor) { this->_frontColor = frontColor; this->updateFrontColor(); };
    9595    const Color& frontColor() const { return this->_frontColor; };
    9696
     
    114114    void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); };
    115115
    116     inline void drawRect(const Rect2D& rect) const {
     116    inline void drawRect(const Rect2D& rect) const
     117    {
    117118      glBegin(GL_QUADS);
    118119      glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top());
     
    130131    virtual bool processEvent(const Event& event) { return false; };
    131132
     133
    132134  protected:
    133 
    134135    /// LOOKS
    135136    virtual void resize();
     
    137138    virtual void hiding() {};
    138139    virtual void showing() {};
     140    virtual void updateFrontColor() {};
     141
     142    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
     143    inline void endDraw() const { glPopMatrix(); };
     144
     145    /// EVENTS
    139146    // if something was clickt on the GUI-widget.
    140147    virtual void clicking(const Vector2D& pos);
     
    145152    virtual void destroyed();
    146153
    147 
    148     inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
    149     inline void endDraw() const { glPopMatrix(); };
    150 
    151154  private:
    152155    void init();
    153 
    154156
    155157  private:
  • branches/gui/src/lib/util/color.cc

    r8376 r8419  
    1818#include "color.h"
    1919#include <stdio.h>
     20
     21
     22void Color::debug() const
     23{
     24  printf("r:%0.2f g:%0.2f, b:%0.2f, a:%0.2f\n", r(), g(), b(), a());
     25}
    2026
    2127/**
  • branches/gui/src/lib/util/color.h

    r8378 r8419  
    1919  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2020
     21  const Color& operator=(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); return *this; };
     22  bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); };
     23
    2124  inline float& operator[](unsigned int i) { return _rgba[i]; }
    2225  inline const float& operator[](unsigned int i) const { return _rgba[i]; }
     
    3134  inline float& a() { return _rgba[3]; }
    3235
     36
     37
    3338  void setColor(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
    3439
     40  void debug() const;
    3541
    3642  /// STATIC TRANSFORMATIONS
  • branches/gui/src/util/hud.cc

    r8378 r8419  
    132132      weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
    133133      weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
    134       weapon->getEnergyWidget()->frontColor().setColor( .2,.5,.7,.6);
     134      weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    135135//      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
    136136      this->weaponsWidgets.push_back(weapon->getEnergyWidget());
Note: See TracChangeset for help on using the changeset viewer.