Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8448 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 12:48:26 PM (18 years ago)
Author:
bensch
Message:

merged gui back to the trunk
merged with command
merge -r8377:HEAD https://svn.orxonox.net/orxonox/branches/gui .

Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.am

    r4976 r8448  
    2828include doc/documentation.am
    2929endif
     30
     31
     32version:
     33        echo VERSION: $(PACKAGE_VERSION)
  • trunk/configure.ac

    r8367 r8448  
    560560#----#
    561561if test x$osX = xyes ; then
    562         PKG_CONFIG_PATH="$prefix"
    563         PKG_CHECK_MODULES( QT, QtOpenGL >= 4.01 QtCore >= 4.01 QtGui >= 4.0.1 )
    564         QT_INCLUDE_DIR=`$PKG_CONFIG --variable=includedir QtOpenGL QtCore QtGui`
     562#       PKG_CONFIG_PATH="$prefix"
     563#       PKG_CHECK_MODULES( QT, QtOpenGL >= 4.01 QtCore >= 4.01 QtGui >= 4.0.1 )
     564#       QT_INCLUDE_DIR=`$PKG_CONFIG --variable=includedir QtOpenGL QtCore QtGui`
    565565#----------#
    566566            AC_PATH_PROG([QT_MOC], [moc], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
  • trunk/src/lib/event/event_handler.cc

    r8340 r8448  
    355355  else
    356356  {
    357     SDL_WM_GrabInput(SDL_GRAB_ON);
     357//    SDL_WM_GrabInput(SDL_GRAB_ON);
    358358    SDL_ShowCursor(SDL_DISABLE);
    359359  }
  • trunk/src/lib/graphics/importer/material.h

    r8376 r8448  
    3838
    3939    void setDiffuse (float r, float g, float b);
     40    void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; };
    4041    void setAmbient (float r, float g, float b);
    4142    void setSpecular (float r, float g, float b);
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r8059 r8448  
    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
  • trunk/src/lib/graphics/text_engine/text.cc

    r8037 r8448  
    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
  • trunk/src/lib/graphics/text_engine/text.h

    r7919 r8448  
    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};
  • trunk/src/lib/gui/gl/glgui_bar.cc

    r8145 r8448  
    4646    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
    4747
    48     this->frontMaterial().setDiffuse(1,1,1);
     48    this->setFrontColor(Color(1,1,1));
    4949
    5050    this->setSize2D(50, 10);
     
    6464    GLGuiWidget::draw();
    6565
    66     this->frontMaterial().select();
     66    //this->frontMaterial().select();
    6767    glBegin(GL_QUADS);
    6868
  • trunk/src/lib/gui/gl/glgui_button.cc

    r8145 r8448  
    5555
    5656    this->_label.setFont("fonts/final_frontier.ttf", 20);
    57     this->frontMaterial().setDiffuse(1, 0, 0);
     57    this->_label.setColor(this->frontColor());
    5858
    5959    this->_label.setParent2D(this);
     
    6969
    7070
     71  void GLGuiButton::updateFrontColor()
     72  {
     73    this->_label.setColor(this->frontColor());
     74  }
    7175
    7276  void GLGuiButton::clicking(const Vector2D& pos)
    7377  {
     78    GLGuiWidget::clicking(pos);
    7479    emit(clicked());
    7580  }
    7681  void GLGuiButton::releasing(const Vector2D& pos)
    7782  {
     83    GLGuiWidget::releasing(pos);
    7884    emit(released());
    7985  }
  • trunk/src/lib/gui/gl/glgui_button.h

    r8145 r8448  
    4141      virtual void draw() const;
    4242
     43      DeclareSignal0(clicked);
    4344      DeclareSignal0(released);
    44       DeclareSignal0(clicked);
    4545
    4646    protected:
     47      virtual void updateFrontColor();
     48
    4749      virtual void clicking(const Vector2D& pos);
    4850      virtual void releasing(const Vector2D& pos);
  • trunk/src/lib/gui/gl/glgui_checkbutton.cc

    r8145 r8448  
    6565  void GLGuiCheckButton::resize()
    6666  {
    67     this->labelText().setRelCoor2D(borderLeft() + 25, borderTop() + 5);
    68     this->setSize2D(this->labelText().getSizeX2D() + 30 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom());
     67
     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());
    6970    GLGuiWidget::resize();
    70     this->frontRect().setTopLeft(borderLeft(), borderTop());
    71     this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));
     71
     72    this->_checkBox.setSize(10.0, 10.0);
     73    this->_checkBox.setCenter( borderLeft() + _checkBox.height()/2.0, borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0);
     74
     75/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     76    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));*/
    7277  }
    7378
     
    8994    GLGuiButton::draw();
    9095
    91     this->frontMaterial().select();
    92     this->drawRect(this->frontRect());
     96//     this->frontMaterial().select();
     97//     this->drawRect(this->frontRect());
    9398
    9499    if (this->bActive)
    95100    {
    96       glBegin(GL_QUADS);
    97       glColor3f( 1, 1 ,1);
    98       glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8);
    99       glTexCoord2i(0,1); glVertex2d(borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
    100       glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
    101       glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8);
    102       glEnd();
     101      glColor3fv( &this->frontColor()[0]);
     102      this->drawRect(this->_checkBox);
    103103
    104104
    105105      // DRAW a cross :)
    106       glColor3f(0,0,0);
     106      Vector2D center = this->_checkBox.center();
     107      glColor4f(1,1,1, 1.0);
    107108      glLineWidth(3.0);
     109
    108110      glBegin(GL_LINE_LOOP);
    109       glVertex2d(borderLeft()+8,borderTop() +8);
    110       glVertex2d(this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2 - 1);
     111      glVertex2d(_checkBox.left(), _checkBox.top());
     112      glVertex2d(center.x, center.y);
    111113
    112       glVertex2d(this->getSizeY2D()-8 + borderLeft(), borderTop()+8);
    113       glVertex2d(this->getSizeY2D()/2 +1 + borderLeft(), this->getSizeY2D()/2);
     114      glVertex2d(_checkBox.right(), _checkBox.top());
     115      glVertex2d(center.x, center.y);
    114116
    115       glVertex2d(this->getSizeY2D()-8 + borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
    116       glVertex2d(this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2+1);
     117      glVertex2d(_checkBox.right(), _checkBox.bottom());
     118      glVertex2d(center.x, center.y);
    117119
    118       glVertex2d(borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
    119       glVertex2d(this->getSizeY2D()/2 -1 + borderLeft(), this->getSizeY2D()/2);
     120      glVertex2d(_checkBox.left(), _checkBox.bottom());
     121      glVertex2d(center.x, center.y);
    120122      glEnd();
    121123    }
    122124    else
    123125    {
    124       glBegin(GL_QUADS);
    125       glColor3f(0, 0, 0);
    126       glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8);
    127       glTexCoord2i(0,1); glVertex2d(borderLeft()+ 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));
    128       glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));
    129       glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8);
    130       glEnd();
     126      glColor3fv( &this->frontColor()[0]);
     127      this->drawRect(this->_checkBox);
    131128    }
    132129
  • trunk/src/lib/gui/gl/glgui_checkbutton.h

    r8145 r8448  
    4646  private:
    4747    bool             bActive;
    48 
     48    Rect2D           _checkBox;
    4949  };
    5050}
  • trunk/src/lib/gui/gl/glgui_defs.h

    r8145 r8448  
    77#define _GLGUI_DEFS_H
    88
     9#include <string>
     10
    911/// TODO MOVE TO ORXGUI_TYPES
    1012namespace OrxGui
    1113{
     14  //! if the Element should be visible by default.
     15#define GLGUI_WIDGET_DEFAULT_VISIBLE       false
     16
     17
    1218  //! An enumeration for the Orientation of an Element.
    1319  typedef enum {
    14     Horizontal,    //!< Horizontal Orientation.
    15     Vertical       //!< Vertical Orientation.
     20    Horizontal,       //!< Horizontal Orientation.
     21    Vertical          //!< Vertical Orientation.
    1622  } Orientation;
     23
     24  const std::string OrientationString[] = {
     25    "Horizontal",
     26    "Vertical"
     27  };
     28
     29  //! An enumerator that defines the different states Widgets may be in.
     30  typedef enum {
     31    Normal,           //!< Normal state of the GUI's Widgets.
     32    Active,           //!< If the widget is Active.
     33    Selected,         //!< If the Widget is Selected.
     34    Insensitive       //!< If the Widget is insensitive.
     35  } State;
     36  //! The count of States a GUI-Element can be in.
     37#define GLGUI_STATE_COUNT   4
     38#define GLGUI_DEFAULT_STYLE OrxGui::Normal
     39
     40  const std::string StateString[] =
     41    {
     42      "Normal",
     43      "Active",
     44      "Selected",
     45      "Insensitive"
     46    };
     47
     48    //! Where a Certain feature will be positioned at.
     49    typedef enum {
     50      FeatureLeft,          //!< On the Left side.
     51      FeatureRight,         //!< On the Right side.
     52      FeatureTop,           //!< On Top of the rest of the Widget.
     53      FeatureBottom,        //!< At the Bottom of the rest of the Widget.
     54    } FeaturePosition;
     55
     56    const std::string FeaturePositionString[] =
     57    {
     58      "Left",
     59      "Right",
     60      "Top",
     61      "Bottom"
     62    };
     63
     64
     65
    1766};
    1867
  • trunk/src/lib/gui/gl/glgui_handler.cc

    r8324 r8448  
    4040
    4141
    42     EventHandler::getInstance()->withUNICODE(ES_ALL, true );
     42    EventHandler::getInstance()->withUNICODE(ES_MENU, true );
    4343
    4444    this->_cursor = NULL;
  • trunk/src/lib/gui/gl/glgui_image.cc

    r8145 r8448  
    1717
    1818#include "glgui_image.h"
     19
     20#include "debug.h"
    1921
    2022namespace OrxGui
     
    4547    this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage");
    4648
    47     this->frontMaterial().setDiffuseMap(this->texture);
    48     this->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     49    this->_imageMaterial.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    4950
    5051    this->resize();
     
    5455  void GLGuiImage::loadImageFromTexture(const Texture& texture)
    5556  {
    56     this->frontMaterial().setDiffuseMap(texture);
    57     this->frontMaterial().setDiffuse(1,1,1);
     57    this->_imageMaterial.setDiffuseMap(texture);
    5858  }
    5959
    6060  void GLGuiImage::loadImageFromFile(const std::string& fileName)
    6161  {
    62     this->texture.loadImage(fileName);
     62    this->_imageMaterial.setDiffuseMap(fileName);
    6363  }
    6464
    6565  void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface)
    6666  {
    67     //this->texture.loadSurface(surface);
     67    this->_imageMaterial.setDiffuseMap(Texture(surface));
    6868  }
    6969
    7070  void GLGuiImage::loadImageFromDisplayList(GLuint texture)
    7171  {
    72 //    this->texture.setTexture(texture);
     72    PRINTF(2)("SORRY NOT IMPLEMENTED\n");
     73//    this->_imageMaterial.setTexture(texture);
     74  }
     75
     76  void GLGuiImage::updateFrontColor()
     77  {
     78    this->_imageMaterial.setDiffuseColor(this->frontColor());
    7379  }
    7480
    7581  void GLGuiImage::resize()
    7682  {
    77     this->frontRect().setTopLeft(this->borderLeft(), this->borderTop());
    78     this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );
     83    this->_imagePlane.setTopLeft(this->borderLeft(), this->borderTop());
     84    this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );
    7985    GLGuiWidget::resize();
    8086  }
     
    8995    GLGuiWidget::draw();
    9096
    91     this->frontMaterial().select();
    92     this->drawRect(this->frontRect());
     97    this->_imageMaterial.select();
     98    this->drawRect(this->_imagePlane);
    9399    this->endDraw();
    94100  }
  • trunk/src/lib/gui/gl/glgui_image.h

    r8145 r8448  
    3636    DeclareSignal0(imageChanged);
    3737
     38  protected:
     39    virtual void updateFrontColor();
     40    virtual void resize();
     41
     42
    3843  private:
    3944    void init();
    40     virtual void resize();
    4145
    4246  private:
    43     Texture       texture;
     47    Rect2D        _imagePlane;
     48    Material      _imageMaterial;
    4449  };
    4550}
  • trunk/src/lib/gui/gl/glgui_inputline.cc

    r8145 r8448  
    2222  /**
    2323   * @brief standard constructor
    24   */
     24   */
    2525  GLGuiInputLine::GLGuiInputLine ()
    2626  {
     
    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.setColor(this->frontColor());
     54    this->_text.setVisibility(false);
    5455    this->resize();
    5556
     
    6364  void GLGuiInputLine::setText(const std::string& text)
    6465  {
    65     this->text.setText(text);
    66     this->resize();
    67 
    68     emit(this->textChanged(this->getText()));
     66    this->_text.setText(text);
     67    this->changedText();
    6968  }
    7069
     
    7574  void GLGuiInputLine::append(const std::string& appendText)
    7675  {
    77     this->text.append(appendText);
    78     this->resize();
    79     emit(this->textChanged(this->text.getText()));
     76    this->_text.append(appendText);
     77    this->changedText();
    8078  }
    8179
     
    8785  void GLGuiInputLine::appendCharacter(char character)
    8886  {
    89     this->text.appendCharacter(character);
    90     this->resize();
    91     emit(this->textChanged(this->text.getText()));
     87    this->_text.appendCharacter(character);
     88    this->changedText();
    9289  }
    9390
     
    9996  void GLGuiInputLine::removeCharacters(unsigned int chars)
    10097  {
    101     this->text.removeCharacters(chars);
     98    this->_text.removeCharacters(chars);
     99    this->changedText();
     100  }
     101
     102  /**
     103   * @brief If the Text has been changed this function is called.
     104   *
     105   * This Function also emits the Signal textChanged.
     106   */
     107  void GLGuiInputLine::changedText()
     108  {
    102109    this->resize();
    103     emit(this->textChanged(this->text.getText()));
     110    this->setFrontColor(Color(1,1,1,1), true);
     111    this->setFrontColor(Color(0,1,0,1));
     112    emit(this->textChanged(this->_text.getText()));
    104113  }
    105114
     
    117126
    118127  /**
    119    * Processes an Event.
     128   * @brief Processes an Event.
    120129   * @param event The event to be processed
    121130   * @return true if the event was catched.
     
    154163      }
    155164    }
    156 
    157165    return false;
    158166  }
     
    164172  void GLGuiInputLine::resize()
    165173  {
    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));
     174    this->_text.setRelCoor2D(this->borderLeft(), this->borderTop());
     175    this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
    168176    GLGuiWidget::resize();
    169     this->frontRect().setTopLeft(borderLeft(), borderTop());
    170     this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
    171   }
    172 
     177/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     178    this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/
     179  }
     180
     181  void GLGuiInputLine::updateFrontColor()
     182  {
     183    this->_text.setColor(this->frontColor());
     184  }
    173185
    174186  void GLGuiInputLine::hiding()
    175187  {
    176     this->text.setVisibility(false);
     188    this->_text.setVisibility(false);
    177189  }
    178190
    179191  void GLGuiInputLine::showing()
    180192  {
    181     this->text.setVisibility(true);
    182   }
    183 
    184 
    185   /**
    186    * ticks the InputLine
     193    this->_text.setVisibility(true);
     194  }
     195
     196  /**
     197   * @brief ticks the InputLine
    187198   * @param dt the time passed.
    188199   */
    189200  void GLGuiInputLine::tick(float dt)
    190201  {
     202    GLGuiWidget::tick(dt);
    191203    if (this->delayNext > 0.0)
    192204      this->delayNext -= dt;
     
    218230    GLGuiWidget::draw();
    219231
    220     this->frontMaterial().select();
    221     GLGuiWidget::drawRect(this->frontRect());
     232//     this->frontMaterial().select();
     233//     GLGuiWidget::drawRect(this->frontRect());
    222234
    223235    this->endDraw();
  • trunk/src/lib/gui/gl/glgui_inputline.h

    r8145 r8448  
    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    virtual void resize();
     55
     56
    5057  private:
    5158    void init();
    52     void resize();
    53     virtual void hiding();
    54     virtual void showing();
     59    void changedText();
    5560
    5661  private:
    57     Text                    text;             //!< The Text to display inside of the InputLine.
     62    Text                    _text;            //!< The Text to display inside of the InputLine.
    5863
    5964    Uint16                  pressedKey;       //!< the pressed key that will be repeated.
  • trunk/src/lib/gui/gl/glgui_pushbutton.cc

    r8145 r8448  
    4545  void GLGuiPushButton::resize()
    4646  {
    47     this->labelText().setRelCoor2D(borderLeft() + 5, borderTop() + 5);
    48     this->setSize2D(this->labelText().getSizeX2D() + 10 + borderLeft()+borderRight(), this->labelText().getSizeY2D() + 10 + borderTop() + borderBottom() );
     47    this->labelText().setRelCoor2D(borderLeft(), borderTop());
     48    this->setSize2D(this->labelText().getSizeX2D() + borderLeft() + borderRight(), this->labelText().getSizeY2D() + borderTop() + borderBottom() );
    4949
    5050    GLGuiWidget::resize();
    51     this->frontRect().setTopLeft(borderLeft(), borderTop());
    52     this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()));
     51/*    this->frontRect().setTopLeft(borderLeft(), borderTop());
     52    this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()));*/
    5353  }
    5454
     
    9797    GLGuiButton::draw();
    9898
    99     this->frontMaterial().select();
    100     this->drawRect(this->frontRect());
    10199    this->endDraw();
    102     //   this->label->draw();
    103     //  printf("test");
    104100  }
    105101
  • trunk/src/lib/gui/gl/glgui_slider.cc

    r8335 r8448  
    7474    else
    7575      this->_value = value;
     76    this->_handle.setCenter(this->sliderPosition(), this->borderTop() + (this->getSizeY2D() - this->borderTop() - borderBottom()) / 2.0);
     77
    7678    emit(valueChanged(this->_value));
    7779  }
     
    161163  {
    162164    GLGuiWidget::resize();
    163     this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0);
    164     this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0);
     165//    this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0);
     166//    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());
     170  }
     171
     172  void GLGuiSlider::updateFrontColor()
     173  {
     174
    165175  }
    166176
     
    218228  void GLGuiSlider::tick(float dt)
    219229  {
     230    GLGuiWidget::tick(dt);
    220231  }
    221232
     
    228239    GLGuiWidget::draw();
    229240
    230     this->frontMaterial().select();
    231     this->drawRect(this->frontRect());
    232 
    233     this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, 0*this->borderTop(), _sliderWidth, this->getSizeY2D() - (borderTop() + borderBottom()) ));
     241    glColor4fv(&this->frontColor()[0]);
     242    this->drawRect(this->_slider);
     243    this->drawRect(this->_handle);
     244    //this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, 0*this->borderTop(), _sliderWidth, this->getSizeY2D() - (borderTop() + borderBottom()) ));
    234245
    235246    this->endDraw();
  • trunk/src/lib/gui/gl/glgui_slider.h

    r8145 r8448  
    5656  protected:
    5757    virtual void resize();
     58    virtual void updateFrontColor();
    5859
    5960    virtual void clicking(const Vector2D& pos);
     
    6869  private:
    6970    Orientation      orientation;
     71
     72    Rect2D           _slider;
     73    Rect2D           _handle;
    7074
    7175    float            _maxValue;
  • trunk/src/lib/gui/gl/glgui_style.cc

    r8145 r8448  
    1818#include "glgui_style.h"
    1919
     20#include "loading/load_param.h"
     21
    2022namespace OrxGui
    2123{
     
    2527   * @brief standard constructor
    2628  */
    27   GLGuiStyle::GLGuiStyle ()
     29  GLGuiStyle::GLGuiStyle (const TiXmlElement* root)
    2830  {
     31    if (root != NULL)
     32      this->loadParams(root);
     33
     34    this->
    2935  }
    3036
     
    3743    // delete what has to be deleted here
    3844  }
     45
     46  void GLGuiStyle::loadParams(const TiXmlElement* root)
     47  {
     48  }
     49
     50  void GLGuiStyle::setBorderLeft(float value)
     51  {
     52    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     53      setBorderLeft(value, (OrxGui::State)i);
     54  }
     55
     56  void GLGuiStyle::setBorderLeft(float value, OrxGui::State state)
     57{}
     58
     59  void GLGuiStyle::setBorderLeftS(float value, const std::string& state)
     60  {}
     61
     62
     63  void GLGuiStyle::setBorderRight(float value)
     64  {
     65    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     66      setBorderRight(value, (OrxGui::State)i);
     67  }
     68
     69  void GLGuiStyle::setBorderRight(float value, OrxGui::State state)
     70{}
     71
     72  void GLGuiStyle::setBorderRightS(float value, const std::string& state)
     73  {}
     74
     75
     76  void GLGuiStyle::setBorderTop(float value)
     77  {
     78    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     79      setBorderTop(value, (OrxGui::State)i);
     80  }
     81
     82  void GLGuiStyle::setBorderTop(float value, OrxGui::State state)
     83{}
     84
     85  void GLGuiStyle::setBorderTopS(float value, const std::string& state)
     86  {}
     87
     88
     89  void GLGuiStyle::setBorderBottom(float value)
     90  {
     91    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     92      setBorderBottom(value, (OrxGui::State)i);
     93  }
     94
     95  void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)
     96{}
     97
     98  void GLGuiStyle::setBorderBottomS(float value, const std::string& state)
     99  {}
     100
     101
     102  void GLGuiStyle::setTextSize(float value)
     103  {
     104    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     105      setTextSize(value, (OrxGui::State)i);
     106  }
     107
     108  void GLGuiStyle::setTextSize(float value, OrxGui::State state)
     109{}
     110
     111  void GLGuiStyle::setTextSizeS(float value, const std::string& state)
     112  {}
     113
     114
     115  void GLGuiStyle::setBackgroundColor(const Color& color)
     116  {
     117    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     118      setBackgroundColor(color, (OrxGui::State)i);
     119  }
     120
     121  void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)
     122{}
     123
     124  void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state)
     125  {}
     126
     127
     128  void GLGuiStyle::setBackgroundTexture(const Texture& texture)
     129  {
     130    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     131      setBackgroundTexture(texture, (OrxGui::State)i);
     132  }
     133
     134  void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)
     135{}
     136
     137  void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state)
     138  {}
     139
     140
     141  void GLGuiStyle::setForegroundColor(const Color& color)
     142  {
     143    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
     144      setForegroundColor(color, (OrxGui::State)i);
     145  }
     146
     147  void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)
     148  {}
     149
     150  void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state)
     151  {}
     152
     153
     154
     155  void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition)
     156  {
     157    this->_featurePosition = featurePosition;
     158  }
     159
     160  void GLGuiStyle::setFeaturePosition(const std::string& featurePosition)
     161  {
     162
     163  }
     164
     165
     166  void GLGuiStyle::setFont(Font* font)
     167  {
     168    this->_font = font;
     169  }
     170
     171  void GLGuiStyle::setFont(const std::string& fontName)
     172  {
     173    //this->font = new Font(fontName);
     174  }
     175
     176
     177  void GLGuiStyle::setAnimated(bool animated)
     178  {
     179    this->_animated = animated;
     180  }
     181
     182  void GLGuiStyle::animatedStateChanges(bool animated)
     183  {
     184    this->_animatedStateChanges = animated;
     185  }
     186
    39187}
  • trunk/src/lib/gui/gl/glgui_style.h

    r8276 r8448  
    77#define _GLGUI_STYLE_H
    88
    9 // FORWARD DECLARATION
     9#include "glgui_defs.h"
    1010
    1111#include "font.h"
    1212#include "texture.h"
    1313#include "color.h"
     14
     15class TiXmlElement;
    1416
    1517namespace OrxGui
     
    1921  {
    2022  public:
     23    GLGuiStyle(const TiXmlElement* root = NULL);
     24    virtual ~GLGuiStyle();
    2125
    22     //! Where a Certain feature will be positioned at.
    23     typedef enum {
    24       FeatureLeft,          //!< On the Left side.
    25       FeatureRight,         //!< On the Right side.
    26       FeatureTop,           //!< On Top of the rest of the Widget.
    27       FeatureBottom,        //!< At the Bottom of the rest of the Widget.
    28     } FeaturePosition;
     26
     27    /// Retrieve
     28    inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; }
     29    inline float borderRight(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderRight; }
     30    inline float borderTop(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderTop; }
     31    inline float borderBottom(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderBottom; }
     32    inline float textSize(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._textSize; }
     33    inline const Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundColor; }
     34    inline const Texture& backgrorundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundTexture; }
     35    inline const Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._foregroundColor; }
     36
     37    inline FeaturePosition featurePosition() const { return _featurePosition; }
     38    inline const Font* const font() const { return _font; }
     39    inline bool animated() const { return _animated; }
     40    inline bool animatedStateChanges() const { return _animatedStateChanges; }
    2941
    3042
    3143
    32   public:
    33     GLGuiStyle();
    34     virtual ~GLGuiStyle();
     44    /// SETUP
     45    void loadParams(const TiXmlElement* root);
     46
     47    void setBorderLeft(float value);
     48    void setBorderLeft(float value, OrxGui::State state);
     49    void setBorderLeftS(float value, const std::string& state);
     50
     51    void setBorderRight(float value);
     52    void setBorderRight(float value, OrxGui::State state);
     53    void setBorderRightS(float value, const std::string& state);
     54
     55    void setBorderTop(float value);
     56    void setBorderTop(float value, OrxGui::State state);
     57    void setBorderTopS(float value, const std::string& state);
     58
     59    void setBorderBottom(float value);
     60    void setBorderBottom(float value, OrxGui::State state);
     61    void setBorderBottomS(float value, const std::string& state);
     62
     63    void setTextSize(float value);
     64    void setTextSize(float value, OrxGui::State state);
     65    void setTextSizeS(float value, const std::string& state);
     66
     67    void setBackgroundColor(const Color& color);
     68    void setBackgroundColor(const Color& color, OrxGui::State state);
     69    void setBackgroundColorS(float r, float g, float b, float a, const std::string& state);
     70
     71    void setBackgroundTexture(const Texture& texture);
     72    void setBackgroundTexture(const Texture& texture, OrxGui::State state);
     73    void setBackgroundTexture(const std::string& textureName, const std::string& state);
     74
     75    void setForegroundColor(const Color& color);
     76    void setForegroundColor(const Color& color, OrxGui::State state);
     77    void setForegroundColorS(float r, float g, float b, float a, const std::string& state);
     78
     79
     80    void setFeaturePosition(FeaturePosition featurePosition);
     81    void setFeaturePosition(const std::string& featurePosition);
     82
     83    void setFont(Font* font);
     84    void setFont(const std::string& fontName);
     85
     86    void setAnimated(bool animated);
     87    void animatedStateChanges(bool animated);
    3588
    3689  private:
    37     float             _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
    38     float             _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
    39     float             _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
    40     float             _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
     90    typedef struct
     91    {
     92      float             _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
     93      float             _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
     94      float             _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
     95      float             _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
    4196
    42     Font*             _font;                 //!< The Font used in the current Widget.
    43     float             _textSize;             //!< The TextSize of the Widget.
    44     float             _textColor;            //!< The TextColor of the Widget.
     97      float             _textSize;             //!< The TextSize of the Widget.
    4598
    46     float             _backgroundColor;      //!< The BackgroundColor of the Widget.
    47     Texture           _backgorundTexture;    //!< The BackgroundTexture of the Widget.
     99      Color             _backgroundColor;      //!< The BackgroundColor of the Widget.
     100      Texture           _backgroundTexture;    //!< The BackgroundTexture of the Widget.
    48101
    49     float             _foregroundColor;      //!< The foregroundColor of the Widget.
    50     Texture           _foregorundTexture;    //!< The ForegroundTexture of the Widget
     102      Color             _foregroundColor;      //!< The foregroundColor of the Widget.
     103    }
     104    StatedStyle;
    51105
    52     FeaturePosition   _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
    53106
    54     bool              _animated;             //!< If the Widget is animated (Texture might be an AnimatedTexture.)
    55     bool              _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
     107    StatedStyle         _style[GLGUI_STATE_COUNT];
     108
     109    FeaturePosition     _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
     110    Font*               _font;                 //!< The Font used in the current Widget.
     111
     112
     113    bool                _animated;             //!< If the Widget is animated (Texture might be an AnimatedTexture.)
     114    bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
    56115  };
    57116}
  • trunk/src/lib/gui/gl/glgui_textfield.cc

    r8145 r8448  
    5353    GLGuiWidget::draw();
    5454
    55     this->frontMaterial().select();
    56     this->drawRect(this->frontRect());
     55/*    this->frontMaterial().select();
     56    this->drawRect(this->frontRect());*/
    5757    this->endDraw();
    5858  }
  • trunk/src/lib/gui/gl/glgui_widget.cc

    r8335 r8448  
    4545    if (this == GLGuiWidget::_focused)
    4646      GLGuiWidget::_focused = NULL;
     47
     48    if (this->_toFrontColor)
     49      delete this->_toFrontColor;
    4750  }
    4851
     
    6669    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    6770
    68     this->_backMat.setDiffuse(1.0, 1.0, 1.0);
    69     this->_frontMat.setDiffuse(1.0, 0.0, 0.0);
    70 
    71     this->_borderLeft = 1.0;
     71    this->_backMat.setDiffuseColor(Color(1.0, 0.5, 0.4, 1.0));
     72    this->_backMat.setDiffuseMap("gui_element_background.png");
     73    this->_frontColor = Color(1.0, 0.0, 0.0);
     74    this->_toFrontColor = NULL;
     75
     76
     77    this->_borderLeft = 15.0;
    7278    this->_borderRight = 1.0;
    7379    this->_borderTop = 1.0;
     
    115121  }
    116122
     123  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
     124  {
     125    if (instantaniously)
     126    {
     127      this->_frontColor = frontColor;
     128      if (this->_toFrontColor != NULL)
     129      {
     130        delete this->_toFrontColor;
     131        this->_toFrontColor = NULL;
     132      }
     133    }
     134    else if (!this->_toFrontColor)
     135      this->_toFrontColor = new Color(frontColor);
     136    else
     137      *this->_toFrontColor = frontColor;
     138    //this->_frontColor = frontColor;
     139    //this->updateFrontColor();
     140  };
     141
    117142
    118143  void GLGuiWidget::setBorderSize(float borderSize)
     
    176201  void GLGuiWidget::clicking(const Vector2D& pos)
    177202  {
    178     this->frontMaterial().setDiffuse(0, 0, 1);
     203    this->setFrontColor(Color(0, 0, 1));
    179204
    180205  }
     
    182207  void GLGuiWidget::releasing(const Vector2D& pos)
    183208  {
    184     this->frontMaterial().setDiffuse(0,1,0);
     209    this->setFrontColor(Color(0,1,0));
    185210
    186211  }
     
    188213  void GLGuiWidget::receivedFocus()
    189214  {
    190     this->frontMaterial().setDiffuse(0, 1, 0);
     215    this->setFrontColor(Color(0, 1, 0));
    191216  }
    192217
    193218  void GLGuiWidget::removedFocus()
    194219  {
    195     this->frontMaterial().setDiffuse(1, 0, 0);
     220    this->setFrontColor(Color(1, 0, 0));
    196221
    197222  }
     
    201226  ;
    202227
     228
    203229  void GLGuiWidget::setWidgetSize(const Vector2D& size)
    204230  {
     
    239265    this->setVisibility(false);
    240266    this->hiding();
     267  }
     268
     269  void GLGuiWidget::tick(float dt)
     270  {
     271    if (this->_toFrontColor)
     272    {
     273      this->_frontColor.slerp(*_toFrontColor, dt*3.0);
     274      this->updateFrontColor();
     275      if (this->_frontColor.dist(*_toFrontColor) < .1)
     276      {
     277        delete _toFrontColor;
     278        _toFrontColor = NULL;
     279      }
     280    }
    241281  }
    242282
     
    249289    this->backMaterial().select();
    250290    this->drawRect(this->backRect());
     291    this->backMaterial().unselect();
    251292  }
    252293
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8312 r8448  
    88
    99#include "element_2d.h"
     10
     11#include "glgui_style.h"
     12#include "material.h"
    1013#include "rect2D.h"
    11 
    12 #include "material.h"
    1314
    1415#include "event.h"
    1516#include "signal_connector.h"
    16 
    17 #include "glincl.h"
    18 
    19 #include <vector>
    20 
    21 // FORWARD DECLARATION
    22 class Material;
    2317
    2418namespace OrxGui
     
    2721  class GLGuiCursor;
    2822
    29   //! if the Element should be visible by default.
    30 #define GLGUI_WIDGET_DEFAULT_VISIBLE       false
    3123
    3224  //! This is widget part of the openglGUI class
     
    3527   */
    3628  class GLGuiWidget : public Element2D
    37 {
    38   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;
    46 
    47 
    48 
     29  {
    4930  public:
    5031    GLGuiWidget(GLGuiWidget* parent = NULL);
     
    9273    const Rect2D& backRect() const { return this->_backRect; };
    9374
    94     Material& frontMaterial() { return this->_frontMat; };
    95     const Material& frontMaterial() const { return this->_frontMat; };
    96     Rect2D& frontRect() { return this->_frontRect; };
    97     const Rect2D& frontRect() const { return this->_frontRect; };
     75    void setFrontColor(const Color& frontColor, bool instantaniously = false);
     76    const Color& frontColor() const { return this->_frontColor; };
    9877
    9978    /** @brief sets all borders to the same value. */
     
    11695    void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); };
    11796
    118     inline void drawRect(const Rect2D& rect) const {
     97    inline void drawRect(const Rect2D& rect) const
     98    {
    11999      glBegin(GL_QUADS);
    120100      glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top());
     
    127107
    128108    virtual void update() {};
     109    virtual void tick(float dt);
    129110    virtual void draw() const;
    130111
     
    132113    virtual bool processEvent(const Event& event) { return false; };
    133114
     115
    134116  protected:
    135 
    136117    /// LOOKS
    137118    virtual void resize();
     
    139120    virtual void hiding() {};
    140121    virtual void showing() {};
     122    virtual void updateFrontColor() {};
     123
     124    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
     125    inline void endDraw() const { glPopMatrix(); };
     126
     127    /// EVENTS
    141128    // if something was clickt on the GUI-widget.
    142129    virtual void clicking(const Vector2D& pos);
     
    147134    virtual void destroyed();
    148135
    149 
    150     inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
    151     inline void endDraw() const { glPopMatrix(); };
    152 
    153136  private:
    154137    void init();
    155 
    156138
    157139  private:
     
    162144    Rect2D                         _backRect;
    163145
    164     Material                       _frontMat;
    165     Rect2D                         _frontRect;
     146    Color                          _frontColor;
     147    Color*                         _toFrontColor;
    166148
    167149    float                          _borderLeft;
     
    171153
    172154    Vector2D                       _minSize;
     155
     156    GLGuiStyle                     _style;
    173157
    174158    /// EVENTS
  • trunk/src/lib/math/rect2D.cc

    r8145 r8448  
    232232
    233233/**
     234 * @brief sets the new Center
     235 * @param x the center's X to move the Rectangle to.
     236 * @param y the center's Y to move the Rectangle to.
     237 * moves the Rectangle from its current center to the new Center
     238 */
     239void Rect2D::setCenter(float x, float y)
     240{
     241  this->setCenter(Vector2D(x, y));
     242}
     243
     244/**
     245 * @brief sets the new Center
     246 * @param center the center to move the Rectangle to.
     247 * moves the Rectangle from its current center to the new Center
     248 */
     249void Rect2D::setCenterX(float x)
     250{
     251#warning implement this
     252}
     253
     254/**
     255 * @brief sets the new Center
     256 * @param center the center to move the Rectangle to.
     257 * moves the Rectangle from its current center to the new Center
     258 */
     259void Rect2D::setCenterY(float y)
     260{
     261#warning implement this
     262}
     263
     264/**
    234265 * @brief scales the Rectangle from topLeft out.
    235266 * @param x: the scale factor in x direction
  • trunk/src/lib/math/rect2D.h

    r8035 r8448  
    9696  void setSize(const Vector2D& size);
    9797  void setCenter(const Vector2D& center);
     98  void setCenter(float x, float y);
     99  void setCenterX(float x);
     100  void setCenterY(float y);
     101
    98102
    99103  void scaleX(float x);
  • trunk/src/lib/util/color.cc

    r8376 r8448  
    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/**
  • trunk/src/lib/util/color.h

    r8376 r8448  
    1616{
    1717public:
    18   Color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 0.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     18  Color(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; };
    1919  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2020
    21   float& operator[](unsigned int i) { return _rgba[i]; }
    22   const float& operator[](unsigned int i) const { return _rgba[i]; }
     21  inline 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  inline bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); };
    2323
    24   float r() const { return _rgba[0]; }
    25   float& r() { return _rgba[0]; }
    26   float g() const { return _rgba[1]; }
    27   float& g() { return _rgba[1]; }
    28   float b() const { return _rgba[2]; }
    29   float& b() { return _rgba[2]; }
    30   float a() const { return _rgba[3]; }
    31   float& a() { return _rgba[3]; }
     24  inline float& operator[](unsigned int i) { return _rgba[i]; }
     25  inline const float& operator[](unsigned int i) const { return _rgba[i]; }
    3226
     27  inline float r() const { return _rgba[0]; }
     28  inline float& r() { return _rgba[0]; }
     29  inline float g() const { return _rgba[1]; }
     30  inline float& g() { return _rgba[1]; }
     31  inline float b() const { return _rgba[2]; }
     32  inline float& b() { return _rgba[2]; }
     33  inline float a() const { return _rgba[3]; }
     34  inline float& a() { return _rgba[3]; }
     35
     36
     37
     38
     39  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; };
     40  void setColor(const Color& c) { r() = c.r();  g()= c.g(); b() = c.b(); a() = c.a(); };
     41
     42  inline float dist(const Color& c) const { return (sqrt((r()-c.r())*(r()-c.r()) + (g()-c.g())*(g()-c.g()) + (b()-c.b())*(b()-c.b()) + (a()-c.a())*(a()-c.a()))); }
     43  /// Maths
     44  inline const Color& operator+=(const Color& c) { r()+=c.r(); g()+=c.g(); b()+=c.b(); a()+=c.a(); return *this; };
     45  inline Color operator+(const Color& c) const { return Color(r()+c.r(), g()+c.g(), b()+c.b(), a()+c.a()); };
     46  inline const Color& operator-=(const Color& c) { r()-=c.r(); g()-=c.g(); b()-=c.b(); a()-=c.a(); return *this; };
     47  inline Color operator-(const Color& c) const { return Color(r()-c.r(), g()-c.g(), b()-c.b(), a()-c.a()); };
     48  inline Color operator*(float v) const { return Color(r()*v, g()*v, b()*v, a()*v); };
     49
     50  void slerp(const Color& c, float v) { *this += (c - *this) * v; };
     51
     52  void debug() const;
    3353
    3454  /// STATIC TRANSFORMATIONS
  • trunk/src/util/hud.cc

    r8145 r8448  
    2121
    2222#include "world_entities/weapons/weapon_manager.h"
    23 
    24 using namespace std;
    25 
     23#include "glgui_widget.h"
    2624
    2725/**
     
    7674    this->energyWidget->backMaterial().setDiffuseMap("hud_energy_background.png");
    7775    this->energyWidget->backMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    78     this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    79     this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     76/*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     77    this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
    8078  }
    8179
     
    132130      weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11);
    133131      weapon->getEnergyWidget()->backMaterial().setTransparency(.1);
    134       weapon->getEnergyWidget()->frontMaterial().setDiffuse( .2,.5,.7);
    135       weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     132      weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
     133//      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
    136134      this->weaponsWidgets.push_back(weapon->getEnergyWidget());
    137135    }
  • trunk/src/util/hud.h

    r8145 r8448  
    77#define _HUD_H
    88
    9 #include "glgui_widget.h"
    10 #include <list>
    11 
     9#include "element_2d.h"
    1210// FORWARD DECLARATION
    1311class TiXmlElement;
    1412class WeaponManager;
     13namespace OrxGui { class GLGuiWidget; }
    1514
    1615//! A class that renders a HUD.
Note: See TracChangeset for help on using the changeset viewer.