Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9656 in orxonox.OLD for trunk/src/lib/gui


Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

Location:
trunk/src/lib/gui/gl
Files:
13 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/Makefile.am

    r9406 r9656  
    1313                \
    1414                glgui_handler.cc \
     15                glgui_widget.cc \
    1516                glgui_mainwidget.cc \
    16                 glgui_widget.cc \
    1717                glgui_button.cc \
    1818                glgui_pushbutton.cc \
     
    2222                glgui_bar.cc \
    2323                glgui_box.cc \
     24                glgui_fixedposition_box.cc \
    2425                glgui_frame.cc \
    2526                glgui_text.cc \
     
    4041                glgui_defs.h \
    4142                glgui_handler.h \
     43                glgui_widget.h \
    4244                glgui_mainwidget.h \
    43                 glgui_widget.h \
    4445                glgui_button.h \
    4546                glgui_pushbutton.h \
     
    4950                glgui_bar.h \
    5051                glgui_box.h \
     52                glgui_fixedposition_box.h \
    5153                glgui_frame.h \
    5254                glgui_text.h \
  • trunk/src/lib/gui/gl/glgui.h

    r9015 r9656  
    1414#include "glgui_bar.h"
    1515#include "glgui_box.h"
     16#include "glgui_fixedposition_box.h"
    1617#include "glgui_button.h"
    1718#include "glgui_checkbutton.h"
  • trunk/src/lib/gui/gl/glgui_box.cc

    r9110 r9656  
    1818#include "glgui_box.h"
    1919#include <cassert>
     20#include "debug.h"
    2021
    2122namespace OrxGui
     
    3637  */
    3738  GLGuiBox::~GLGuiBox()
    38   {}
     39  {
     40    // unpack all the widgets.
     41    while(!this->_children.empty())
     42    {
     43      /// not deleting children here.
     44      this->_children.front()->setParentWidget(NULL);
     45      this->_children.pop_front();
     46    }
     47  }
    3948
    4049  /**
     
    4958  {
    5059    assert (widget != NULL);
    51 
    52     this->children.push_back(widget);
     60    this->_children.push_back(widget);
     61
     62    this->packing(widget);
     63  }
     64
     65
     66  void GLGuiBox::pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos)
     67  {
     68    this->_children.insert(pos, widget);
     69    this->packing(widget);
     70  }
     71
     72  void GLGuiBox::pack(GLGuiWidget* widget, unsigned int position)
     73  {
     74    if (this->_children.empty())
     75      this->pack(widget);
     76
     77    unsigned int pos = 0;
     78    std::list<GLGuiWidget*>::iterator it = this->_children.begin();
     79
     80    for (; pos < position; ++pos)
     81    {
     82      if (this->_children.end() == ++it)
     83      {
     84        PRINTF(2)("Reached end of packing list, without getting to the designated position %d (i am at %d)\n", position, pos);
     85        this->pack(widget);
     86      }
     87    }
     88    this->_children.insert(it, widget);
     89    this->packing(widget);
     90  }
     91
     92  void GLGuiBox::pack(GLGuiWidget* widget, const GLGuiWidget* widgetPointer)
     93  {
     94    assert (widget != NULL && widgetPointer != NULL);
     95
     96    std::list<GLGuiWidget*>::iterator it = this->_children.begin();
     97    for (; it != this->_children.end(); ++it)
     98    {
     99      if (widgetPointer == *it)
     100      {
     101        this->_children.insert(it, widget);
     102        this->packing(widget);
     103        return;
     104      }
     105    }
     106    PRINTF(2)("WidgetPointer %p not found, inserting at the end\n", widgetPointer);
     107    this->pack(widget);
     108  }
     109
     110  void GLGuiBox::packFront(GLGuiWidget* widget)
     111  {
     112    this->_children.push_front(widget);
     113    this->packing(widget);
     114  }
     115
     116  void GLGuiBox::packBack(GLGuiWidget* widget)
     117  {
     118    this->pack(widget);
     119  }
     120
     121  void GLGuiBox::packing(GLGuiWidget* widget)
     122  {
    53123    widget->setParentWidget(this);
    54 
    55124    this->resize();
    56125  }
    57126
    58 
    59127  void GLGuiBox::unpack(GLGuiWidget* widget)
    60128  {
    61129    assert(widget != NULL);
    62130
    63     std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
    64     if (delWidget != this->children.end())
     131    std::list<GLGuiWidget*>::iterator delWidget = std::find(this->_children.begin(), this->_children.end(), widget);
     132    if (delWidget != this->_children.end())
    65133    {
    66134      (*delWidget)->setParentWidget(NULL);
    67       this->children.erase(delWidget);
     135      this->_children.erase(delWidget);
    68136    }
    69137    this->resize();
     
    72140  void GLGuiBox::clear()
    73141  {
    74     this->children.clear();
     142    this->_children.clear();
    75143    this->resize();
    76144  }
     
    78146  void GLGuiBox::showAll()
    79147  {
    80     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    81     while (itC != this->children.end())
     148    std::list<GLGuiWidget*>::iterator itC = this->_children.begin();
     149    while (itC != this->_children.end())
    82150    {
    83151      if ((*itC)->isA(CL_GLGUI_CONTAINER))
     
    93161  void GLGuiBox::hideAll()
    94162  {
    95     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    96     while (itC != this->children.end())
     163    std::list<GLGuiWidget*>::iterator itC = this->_children.begin();
     164    while (itC != this->_children.end())
    97165    {
    98166      if ((*itC)->isA(CL_GLGUI_CONTAINER))
     
    112180      float height = borderTop();
    113181      float width = 0.0f;
    114       std::vector<GLGuiWidget*>::iterator widget;
     182      std::list<GLGuiWidget*>::iterator widget;
    115183
    116184      // find out how big the Widgets are.
    117       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     185      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    118186      {
    119187        (*widget)->setRelCoor2D(borderLeft(), height);
     
    131199      float height = borderTop();
    132200      float width = borderLeft();
    133       std::vector<GLGuiWidget*>::iterator widget;
     201      std::list<GLGuiWidget*>::iterator widget;
    134202
    135203      // find out how big the Widgets are.
    136       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     204      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    137205      {
    138206        (*widget)->setRelCoor2D(width, borderTop());
     
    149217
    150218    // resize everything.
    151     //for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     219    //for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    152220    //{}
    153221  }
  • trunk/src/lib/gui/gl/glgui_box.h

    r8145 r9656  
    11/*!
    2  * @file glgui_.h
     2 * @file glgui_box.h
    33 * The gl_box widget of th openglGUI
    44 *
     
    3030
    3131    virtual void pack(GLGuiWidget* widget);
     32    void pack(GLGuiWidget* widget, unsigned int position);
     33    void pack(GLGuiWidget* widget, const GLGuiWidget* widgetPointer);
     34    void packFront(GLGuiWidget* widget);
     35    void packBack(GLGuiWidget* widget);
    3236    virtual void unpack(GLGuiWidget* widget);
     37
    3338    virtual void clear();
    3439
     
    4348  private:
    4449    void init();
     50    void packing(GLGuiWidget* widget); // the action executing when packing a widget.
     51    void pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos);
     52
     53  private:
     54
    4555
    4656    Orientation                _orientation;
    47     std::vector<GLGuiWidget*>  children;
     57    std::list<GLGuiWidget*>    _children;
    4858  };
    4959}
  • trunk/src/lib/gui/gl/glgui_container.cc

    r8619 r9656  
    4848
    4949
     50  void GLGuiContainer::removeChildWidget(GLGuiWidget* widget)
     51  {
     52    this->unpack(widget);
     53  }
     54
     55
    5056  /**
    5157   * draws the GLGuiContainer
  • trunk/src/lib/gui/gl/glgui_container.h

    r8145 r9656  
    3838    virtual void draw();
    3939
     40  protected:
     41    virtual void removeChildWidget(GLGuiWidget* widget);
     42
    4043  private:
    4144    void init();
  • trunk/src/lib/gui/gl/glgui_defs.h

    r8619 r9656  
    2323
    2424  //! Names of Orientations
    25   const std::string OrientationString[] = {
    26     "Horizontal",
    27     "Vertical"
    28   };
     25  const std::string OrientationString[] =
     26    {
     27      "Horizontal",
     28      "Vertical"
     29    };
     30
     31  //! An enumeration for the Positions of some Elements (FixedPositionBox as an example).
     32  typedef enum {
     33    Left,               //!< Left
     34    Right,              //!< Right
     35    Top,                //!< Top
     36    Bottom,             //!< Bottom
     37    TopLeft,            //!< TopLeft
     38    TopRight,           //!< TopRight
     39    BottomLeft,         //!< BottomLeft
     40    BottomRight,        //!< BottomRight
     41    Center,             //!< Centered
     42  } Position;
     43
     44  //! Names of Positions
     45  const std::string PositionString[] =
     46    {
     47      "Left",
     48      "Right",
     49      "Top",
     50      "Bottom",
     51      "TopLeft",
     52      "TopRight",
     53      "BottomLeft",
     54      "BottomRight",
     55      "Center"
     56    };
     57
    2958
    3059  //! An enumerator that defines the different states Widgets may be in.
     
    3968#define GLGUI_DEFAULT_STYLE OrxGui::Normal
    4069
    41 //! names of the States.
     70  //! names of the States.
    4271  const std::string StateString[] =
    4372    {
     
    4877    };
    4978
    50     //! Where a Certain feature will be positioned at.
    51     typedef enum {
    52       FeatureLeft,          //!< On the Left side.
    53       FeatureRight,         //!< On the Right side.
    54       FeatureTop,           //!< On Top of the rest of the Widget.
    55       FeatureBottom,        //!< At the Bottom of the rest of the Widget.
    56     } FeaturePosition;
     79  //! Where a Certain feature will be positioned at.
     80  typedef enum {
     81    FeatureLeft,          //!< On the Left side.
     82    FeatureRight,         //!< On the Right side.
     83    FeatureTop,           //!< On Top of the rest of the Widget.
     84    FeatureBottom,        //!< At the Bottom of the rest of the Widget.
     85  } FeaturePosition;
    5786
    58     //! Names of Feature-Positions
    59     const std::string FeaturePositionString[] =
     87  //! Names of Feature-Positions
     88  const std::string FeaturePositionString[] =
    6089    {
    6190      "Left",
  • trunk/src/lib/gui/gl/glgui_handler.cc

    r9240 r9656  
    2828#include "debug.h"
    2929
    30 #include <cassert>
    31 
    3230
    3331/// TAKE THIS OUT OF HERE.
     
    4644    this->setName("GLGuiHandler");
    4745
     46    this->_resolution = Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY());
    4847
    4948    EventHandler::getInstance()->withUNICODE(ES_MENU, true );
     
    5251    for (unsigned int i = 0; i < EV_NUMBER; i++)
    5352    {
    54       this->subscribeEvent(ES_ALL, i);
     53      this->subscribeEvent(ES_GAME, i);
     54      this->subscribeEvent(ES_GAME_MENU, i);
     55      this->subscribeEvent(ES_MENU, i);
    5556    }
    5657  }
     
    8889      this->_cursor = NULL;
    8990    }
     91  }
     92
     93  const Vector2D& GLGuiHandler::resolution()
     94  {
     95    if (this->_resolution == Vector2D::nullVector())
     96      this->_resolution = Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY());
     97    return _resolution;
    9098  }
    9199
     
    244252        if (this->_cursor != NULL)
    245253          this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
    246         break;
     254        this->_resolution = Vector2D(event.resize.w, event.resize.h);
     255        break;
     256
    247257      case SDLK_TAB:
    248258        if (event.bPressed)
  • trunk/src/lib/gui/gl/glgui_handler.h

    r9240 r9656  
    1212namespace OrxGui
    1313{
    14 
     14 // FORWARD DECLARATION
    1515  class GLGuiCursor;
    1616
    17   // FORWARD DECLARATION
    1817
    1918  //! A singleton class for the GLGui-Handler
     
    2221
    2322  public:
    24     virtual ~GLGuiHandler(void);
    2523    /** @returns a Pointer to the only object of this Class */
    2624    inline static GLGuiHandler* getInstance(void) { if (!GLGuiHandler::singletonRef) GLGuiHandler::singletonRef = new GLGuiHandler();  return GLGuiHandler::singletonRef; };
     25    /** @brief deletes the instance if it exists */
     26    inline static void deleteInstance() { if (GLGuiHandler::singletonRef) delete GLGuiHandler::singletonRef; };
    2727
    2828    void activateCursor();
     
    3333    const Vector2D& cursorPositionAbs() const;
    3434    Vector2D cursorPositionRel(const GLGuiWidget* const widget) const;
     35
     36    const Vector2D& resolution();
    3537
    3638    void selectNext();
     
    4850  private:
    4951    GLGuiHandler(void);
     52    virtual ~GLGuiHandler(void);
    5053    static GLGuiHandler* singletonRef;
    5154
     
    5356    bool                 isActive;
    5457    GLGuiCursor*         _cursor;
     58    Vector2D             _resolution;
    5559
    5660  };
  • trunk/src/lib/gui/gl/glgui_text.cc

    r9406 r9656  
    101101  {
    102102    this->_text.clear();
    103     this->changedText();
     103    this->resize();
    104104  }
     105
    105106
    106107  /**
     
    114115    this->setFrontColor(_changedTextColor, true);
    115116    this->textChanged.emit(this->_text.text());
     117  }
     118
     119  void GLGuiText::setTextSize(float size)
     120  {
     121    this->_text.setSize(size);
     122    this->changedText();
     123  }
     124
     125  void GLGuiText::setFont(const Font& font)
     126  {
     127    GLGuiWidget::setFont(font);
     128    this->_text.setFont(font);
    116129  }
    117130
  • trunk/src/lib/gui/gl/glgui_text.h

    r9406 r9656  
    3131    void clear();
    3232
     33    void setTextSize(float size);
     34    virtual void setFont(const Font& font);
    3335    void setChangedTextColor(const Color& color);
    3436
  • trunk/src/lib/gui/gl/glgui_widget.cc

    r9406 r9656  
    7979    if (this == GLGuiWidget::selected())
    8080      this->unselect();
     81
     82    if (this->_parent != NULL)
     83      this->_parent->removeChildWidget(this);
    8184  }
    8285
     
    8487  GLGuiWidget* GLGuiWidget::_mouseFocused = NULL;
    8588  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
    86 
     89  Font* GLGuiWidget::_defaultFont = NULL;
    8790
    8891
     
    100103    this->_state = OrxGui::Normal;
    101104
    102 
    103     this->_font = Font(ResourceManager::getInstance()->getDataDir() + "/fonts/final_frontier.ttf", 20);
     105    if(GLGuiWidget::_defaultFont == NULL)
     106      GLGuiWidget::_defaultFont = new Font(ResourceManager::getInstance()->getDataDir() + "/fonts/final_frontier.ttf", 20);
     107
     108    this->_font = *GLGuiWidget::_defaultFont;
    104109    this->resetStyle();
    105110
     
    776781  void GLGuiWidget::setFont(const std::string& fontName, unsigned int renderSize)
    777782  {
    778     this->_font = Font(fontName, renderSize);
     783    this->setFont(Font(fontName, renderSize));
    779784  }
    780785
  • trunk/src/lib/gui/gl/glgui_widget.h

    r9406 r9656  
    206206    void setFeaturePositionS(const std::string& featurePosition);
    207207
    208     void setFont(const Font& font);
    209     void setFont(const std::string& fontName, unsigned int renderSize);
     208    virtual void setFont(const Font& font);
     209    void setFont(const std::string& fontName, unsigned int renderSize = FONT_DEFAULT_RENDER_SIZE);
    210210
    211211    void setAnimatedStateChanges(bool animated);
     
    270270    virtual void destroying();
    271271
     272    // unparent the widget and from this widget seen as parent
     273    virtual void removeChildWidget(GLGuiWidget* widget) {};
     274
    272275
    273276    virtual void debug(unsigned int level) const;
     
    323326    Font                           _font;                 //!< The Font used in the current Widget.
    324327
     328    static Font*                   _defaultFont;          //!< The default Font.
    325329
    326330    /// ANIMATION STUFF:
Note: See TracChangeset for help on using the changeset viewer.