Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9546 in orxonox.OLD for branches/proxy


Ignore:
Timestamp:
Jul 28, 2006, 11:13:00 AM (18 years ago)
Author:
bensch
Message:

added a fixed positionBox, so that everything can be centered

Location:
branches/proxy/src
Files:
9 edited
2 copied

Legend:

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

    r9406 r9546  
    2222                glgui_bar.cc \
    2323                glgui_box.cc \
     24                glgui_fixedposition_box.cc \
    2425                glgui_frame.cc \
    2526                glgui_text.cc \
     
    4950                glgui_bar.h \
    5051                glgui_box.h \
     52                glgui_fixedposition_box.h \
    5153                glgui_frame.h \
    5254                glgui_text.h \
  • branches/proxy/src/lib/gui/gl/glgui_box.h

    r8145 r9546  
    11/*!
    2  * @file glgui_.h
     2 * @file glgui_box.h
    33 * The gl_box widget of th openglGUI
    44 *
  • branches/proxy/src/lib/gui/gl/glgui_defs.h

    r8619 r9546  
    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",
  • branches/proxy/src/lib/gui/gl/glgui_fixedposition_box.cc

    r9541 r9546  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
    1717
    18 #include "glgui_box.h"
     18#include "glgui_fixedposition_box.h"
     19#include "glgui_handler.h"
    1920#include <cassert>
    2021
     
    2425   * standard constructor
    2526  */
    26   GLGuiBox::GLGuiBox (OrxGui::Orientation orientation)
     27  GLGuiFixedpositionBox::GLGuiFixedpositionBox (OrxGui::Position position, OrxGui::Orientation orientation)
     28      GLGuiBox(orientation)
    2729  {
    28     this->init();
    29 
    30     this->setOrientation(orientation);
    3130  }
    3231
     
    3534   * standard deconstructor
    3635  */
    37   GLGuiBox::~GLGuiBox()
     36  GLGuiFixedpositionBox::~GLGuiFixedpositionBox()
    3837  {}
    3938
    40   /**
    41    * initializes the GUI-element
    42    */
    43   void GLGuiBox::init()
     39
     40  void GLGuiFixedpositionBox::setPosition(OrxGui::Position position)
    4441  {
    45     this->setClassID(CL_GLGUI_BOX, "GLGuiBox");
    46   }
    47 
    48   void GLGuiBox::pack(GLGuiWidget* widget)
    49   {
    50     assert (widget != NULL);
    51 
    52     this->children.push_back(widget);
    53     widget->setParentWidget(this);
    54 
    55     this->resize();
     42    this->_position = position;
     43    this->resize;
    5644  }
    5745
    5846
    59   void GLGuiBox::unpack(GLGuiWidget* widget)
     47  void GLGuiFixedpositionBox::resize()
    6048  {
    61     assert(widget != NULL);
     49    GLGuiBox::resize();
    6250
    63     std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
    64     if (delWidget != this->children.end())
     51    switch (this->position)
    6552    {
    66       (*delWidget)->setParentWidget(NULL);
    67       this->children.erase(delWidget);
     53      case OrxGui::Center:
     54        this->setAbsCoor2D(GuiHandler::getInstance()->resolution() - this->getSize2D() / 2.0);
     55        break;
     56
    6857    }
    69     this->resize();
    70   }
    71 
    72   void GLGuiBox::clear()
    73   {
    74     this->children.clear();
    75     this->resize();
    76   }
    77 
    78   void GLGuiBox::showAll()
    79   {
    80     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    81     while (itC != this->children.end())
    82     {
    83       if ((*itC)->isA(CL_GLGUI_CONTAINER))
    84         static_cast<GLGuiContainer*>(*itC)->showAll();
    85       else
    86         (*itC)->show();
    87       itC++;
    88     }
    89 
    90     this->show();
    91   }
    92 
    93   void GLGuiBox::hideAll()
    94   {
    95     std::vector<GLGuiWidget*>::iterator itC = this->children.begin();
    96     while (itC != this->children.end())
    97     {
    98       if ((*itC)->isA(CL_GLGUI_CONTAINER))
    99         static_cast<GLGuiContainer*>(*itC)->hideAll();
    100       else
    101         (*itC)->hide();
    102       itC++;
    103     }
    104 
    105     this->hide();
    106   }
    107 
    108   void GLGuiBox::resize()
    109   {
    110     if (orientation() == OrxGui::Vertical)
    111     {
    112       float height = borderTop();
    113       float width = 0.0f;
    114       std::vector<GLGuiWidget*>::iterator widget;
    115 
    116       // find out how big the Widgets are.
    117       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    118       {
    119         (*widget)->setRelCoor2D(borderLeft(), height);
    120         height += (*widget)->getSizeY2D();
    121         width = fmax(width, (*widget)->getSizeX2D());
    122       }
    123 
    124       width += borderLeft() + borderRight();
    125       height += borderBottom(); /* *2 done further up */
    126 
    127       this->setSize2D(width, height);
    128     }
    129     else
    130     {
    131       float height = borderTop();
    132       float width = borderLeft();
    133       std::vector<GLGuiWidget*>::iterator widget;
    134 
    135       // find out how big the Widgets are.
    136       for (widget = this->children.begin(); widget != this->children.end(); ++widget)
    137       {
    138         (*widget)->setRelCoor2D(width, borderTop());
    139         height = fmax(height, (*widget)->getSizeY2D());
    140         width += (*widget)->getSizeX2D();
    141       }
    142 
    143       width += borderRight() ;
    144       height += borderBottom(); /* *2 done further up */
    145 
    146       this->setSize2D(width, height);
    147     }
    148     GLGuiWidget::resize();
    149 
    15058    // resize everything.
    15159    //for (widget = this->children.begin(); widget != this->children.end(); ++widget)
     
    15361  }
    15462
    155   /**
    156    * @brief draws the GLGuiBox
    157    */
    158   void GLGuiBox::draw() const
    159   {
    160     this->beginDraw();
    161     GLGuiWidget::draw();
    162     this->endDraw();
    163   }
    16463}
  • branches/proxy/src/lib/gui/gl/glgui_fixedposition_box.h

    r9541 r9546  
    11/*!
    2  * @file glgui_.h
    3  * The gl_box widget of th openglGUI
    4  *
     2 * @file glgui_fixedposition_box.h
     3 * The gl_fixedposition_box widget of th openglGUi
    54 */
    65
    7 #ifndef _GLGUI_BOX_H
    8 #define _GLGUI_BOX_H
     6#ifndef _GLGUI_FIXEDPOSITION_BOX_H
     7#define _GLGUI_FIXEDPOSITION_BOX_H
    98
    109#include "glgui_container.h"
     
    1716   *
    1817   */
    19   class GLGuiBox : public GLGuiContainer
     18  class GLGuiFixedpositionBox : public GLGuiBox
    2019  {
    2120
    2221  public:
    23     GLGuiBox(OrxGui::Orientation orientation = OrxGui::Vertical);
    24     virtual ~GLGuiBox();
     22    GLGuiFixedpositionBox(OrxGui::Position position = OrxGui::Center, OrxGui::Orientation orientation = OrxGui::Vertical);
     23    virtual ~GLGuiFixedpositionBox();
    2524
    26     /** @returns the Orientation of the Box */
    27     OrxGui::Orientation orientation() const { return this->_orientation; };
    28     /** @param orientation the Orientation of the Box */
    29     void setOrientation(OrxGui::Orientation orientation) { this->_orientation = orientation; };
     25    inline OrxGui::Position position() const { return _position; };
     26    void setPosition(OrxGui::Position);
    3027
    31     virtual void pack(GLGuiWidget* widget);
    32     virtual void unpack(GLGuiWidget* widget);
    33     virtual void clear();
    34 
    35     virtual void showAll();
    36     virtual void hideAll();
    37 
    38     virtual void draw() const;
    3928
    4029  protected:
    4130    virtual void resize();
    4231
     32
    4333  private:
    44     void init();
    45 
    46     Orientation                _orientation;
    47     std::vector<GLGuiWidget*>  children;
     34    OrxGui::Position     _position;     //!< The Fixed position of the Widget.
    4835  };
    4936}
    50 #endif /* _GLGUI__H */
     37#endif /* _GLGUI_FIXEDPOSITION_BOX_H */
  • branches/proxy/src/lib/gui/gl/glgui_handler.cc

    r9240 r9546  
    2828#include "debug.h"
    2929
    30 #include <cassert>
    31 
    3230
    3331/// TAKE THIS OUT OF HERE.
     
    9391  void GLGuiHandler::activate()
    9492  {
     93    this->_resolution = Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY());
    9594    //EventHandler::getInstance()->pushState(ES_MENU);
    9695
     
    244243        if (this->_cursor != NULL)
    245244          this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
    246         break;
     245        this->_resolution = Vector2D(event.resize.w, event.resize.h);
     246        break;
     247
    247248      case SDLK_TAB:
    248249        if (event.bPressed)
  • branches/proxy/src/lib/gui/gl/glgui_handler.h

    r9240 r9546  
    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() const { return this->_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  };
  • branches/proxy/src/lib/network/monitor/network_stats_widget.cc

    r9494 r9546  
    169169  this->_bar.setChangedValueColor(Color::black);
    170170  */
    171   this->pack(&this->_thisHost);
     171  this->_thisHostIs.setText(std::string("I am ") + _monitor->getLocalNode()->getPeerInfo()->getNodeTypeString());
     172
     173  this->pack(&this->_thisHostIs);
     174
     175this->pack(&this->_thisHost);
    172176
    173177  this->pack(&this->_upstreamText);
  • branches/proxy/src/lib/network/monitor/network_stats_widget.h

    r9494 r9546  
    22 * @file network_stats_widget.h
    33 * @brief Definition of an EnergyWidget, that displays a bar and a Text
    4 */
     4 */
    55
    66#ifndef _NETWORK_STATS_WIDGET_H
     
    101101    const NetworkMonitor*  _monitor;
    102102
     103    OrxGui::GLGuiText      _thisHostIs;
    103104    HostWidget             _thisHost;
    104105
  • branches/proxy/src/story_entities/menu/game_menu.cc

    r9406 r9546  
    7676  if( this->dataTank)
    7777    delete this->dataTank;
    78   delete OrxGui::GLGuiHandler::getInstance( );
     78  OrxGui::GLGuiHandler::deleteInstance( );
    7979}
    8080
  • branches/proxy/src/story_entities/multi_player_world.cc

    r9406 r9546  
    6363  if( this->dataTank)
    6464    delete this->dataTank;
    65   delete OrxGui::GLGuiHandler::getInstance( );
     65  OrxGui::GLGuiHandler::deleteInstance( );
    6666}
    6767
Note: See TracChangeset for help on using the changeset viewer.