Changeset 9656 in orxonox.OLD for trunk/src/lib/gui
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- Location:
- trunk/src/lib/gui/gl
- Files:
-
- 13 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/Makefile.am
r9406 r9656 13 13 \ 14 14 glgui_handler.cc \ 15 glgui_widget.cc \ 15 16 glgui_mainwidget.cc \ 16 glgui_widget.cc \17 17 glgui_button.cc \ 18 18 glgui_pushbutton.cc \ … … 22 22 glgui_bar.cc \ 23 23 glgui_box.cc \ 24 glgui_fixedposition_box.cc \ 24 25 glgui_frame.cc \ 25 26 glgui_text.cc \ … … 40 41 glgui_defs.h \ 41 42 glgui_handler.h \ 43 glgui_widget.h \ 42 44 glgui_mainwidget.h \ 43 glgui_widget.h \44 45 glgui_button.h \ 45 46 glgui_pushbutton.h \ … … 49 50 glgui_bar.h \ 50 51 glgui_box.h \ 52 glgui_fixedposition_box.h \ 51 53 glgui_frame.h \ 52 54 glgui_text.h \ -
trunk/src/lib/gui/gl/glgui.h
r9015 r9656 14 14 #include "glgui_bar.h" 15 15 #include "glgui_box.h" 16 #include "glgui_fixedposition_box.h" 16 17 #include "glgui_button.h" 17 18 #include "glgui_checkbutton.h" -
trunk/src/lib/gui/gl/glgui_box.cc
r9110 r9656 18 18 #include "glgui_box.h" 19 19 #include <cassert> 20 #include "debug.h" 20 21 21 22 namespace OrxGui … … 36 37 */ 37 38 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 } 39 48 40 49 /** … … 49 58 { 50 59 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 { 53 123 widget->setParentWidget(this); 54 55 124 this->resize(); 56 125 } 57 126 58 59 127 void GLGuiBox::unpack(GLGuiWidget* widget) 60 128 { 61 129 assert(widget != NULL); 62 130 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()) 65 133 { 66 134 (*delWidget)->setParentWidget(NULL); 67 this-> children.erase(delWidget);135 this->_children.erase(delWidget); 68 136 } 69 137 this->resize(); … … 72 140 void GLGuiBox::clear() 73 141 { 74 this-> children.clear();142 this->_children.clear(); 75 143 this->resize(); 76 144 } … … 78 146 void GLGuiBox::showAll() 79 147 { 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()) 82 150 { 83 151 if ((*itC)->isA(CL_GLGUI_CONTAINER)) … … 93 161 void GLGuiBox::hideAll() 94 162 { 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()) 97 165 { 98 166 if ((*itC)->isA(CL_GLGUI_CONTAINER)) … … 112 180 float height = borderTop(); 113 181 float width = 0.0f; 114 std:: vector<GLGuiWidget*>::iterator widget;182 std::list<GLGuiWidget*>::iterator widget; 115 183 116 184 // 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) 118 186 { 119 187 (*widget)->setRelCoor2D(borderLeft(), height); … … 131 199 float height = borderTop(); 132 200 float width = borderLeft(); 133 std:: vector<GLGuiWidget*>::iterator widget;201 std::list<GLGuiWidget*>::iterator widget; 134 202 135 203 // 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) 137 205 { 138 206 (*widget)->setRelCoor2D(width, borderTop()); … … 149 217 150 218 // resize everything. 151 //for (widget = this-> children.begin(); widget != this->children.end(); ++widget)219 //for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 152 220 //{} 153 221 } -
trunk/src/lib/gui/gl/glgui_box.h
r8145 r9656 1 1 /*! 2 * @file glgui_ .h2 * @file glgui_box.h 3 3 * The gl_box widget of th openglGUI 4 4 * … … 30 30 31 31 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); 32 36 virtual void unpack(GLGuiWidget* widget); 37 33 38 virtual void clear(); 34 39 … … 43 48 private: 44 49 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 45 55 46 56 Orientation _orientation; 47 std:: vector<GLGuiWidget*>children;57 std::list<GLGuiWidget*> _children; 48 58 }; 49 59 } -
trunk/src/lib/gui/gl/glgui_container.cc
r8619 r9656 48 48 49 49 50 void GLGuiContainer::removeChildWidget(GLGuiWidget* widget) 51 { 52 this->unpack(widget); 53 } 54 55 50 56 /** 51 57 * draws the GLGuiContainer -
trunk/src/lib/gui/gl/glgui_container.h
r8145 r9656 38 38 virtual void draw(); 39 39 40 protected: 41 virtual void removeChildWidget(GLGuiWidget* widget); 42 40 43 private: 41 44 void init(); -
trunk/src/lib/gui/gl/glgui_defs.h
r8619 r9656 23 23 24 24 //! 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 29 58 30 59 //! An enumerator that defines the different states Widgets may be in. … … 39 68 #define GLGUI_DEFAULT_STYLE OrxGui::Normal 40 69 41 //! names of the States.70 //! names of the States. 42 71 const std::string StateString[] = 43 72 { … … 48 77 }; 49 78 50 51 52 53 54 55 56 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; 57 86 58 59 87 //! Names of Feature-Positions 88 const std::string FeaturePositionString[] = 60 89 { 61 90 "Left", -
trunk/src/lib/gui/gl/glgui_handler.cc
r9240 r9656 28 28 #include "debug.h" 29 29 30 #include <cassert>31 32 30 33 31 /// TAKE THIS OUT OF HERE. … … 46 44 this->setName("GLGuiHandler"); 47 45 46 this->_resolution = Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY()); 48 47 49 48 EventHandler::getInstance()->withUNICODE(ES_MENU, true ); … … 52 51 for (unsigned int i = 0; i < EV_NUMBER; i++) 53 52 { 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); 55 56 } 56 57 } … … 88 89 this->_cursor = NULL; 89 90 } 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; 90 98 } 91 99 … … 244 252 if (this->_cursor != NULL) 245 253 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 247 257 case SDLK_TAB: 248 258 if (event.bPressed) -
trunk/src/lib/gui/gl/glgui_handler.h
r9240 r9656 12 12 namespace OrxGui 13 13 { 14 14 // FORWARD DECLARATION 15 15 class GLGuiCursor; 16 16 17 // FORWARD DECLARATION18 17 19 18 //! A singleton class for the GLGui-Handler … … 22 21 23 22 public: 24 virtual ~GLGuiHandler(void);25 23 /** @returns a Pointer to the only object of this Class */ 26 24 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; }; 27 27 28 28 void activateCursor(); … … 33 33 const Vector2D& cursorPositionAbs() const; 34 34 Vector2D cursorPositionRel(const GLGuiWidget* const widget) const; 35 36 const Vector2D& resolution(); 35 37 36 38 void selectNext(); … … 48 50 private: 49 51 GLGuiHandler(void); 52 virtual ~GLGuiHandler(void); 50 53 static GLGuiHandler* singletonRef; 51 54 … … 53 56 bool isActive; 54 57 GLGuiCursor* _cursor; 58 Vector2D _resolution; 55 59 56 60 }; -
trunk/src/lib/gui/gl/glgui_text.cc
r9406 r9656 101 101 { 102 102 this->_text.clear(); 103 this-> changedText();103 this->resize(); 104 104 } 105 105 106 106 107 /** … … 114 115 this->setFrontColor(_changedTextColor, true); 115 116 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); 116 129 } 117 130 -
trunk/src/lib/gui/gl/glgui_text.h
r9406 r9656 31 31 void clear(); 32 32 33 void setTextSize(float size); 34 virtual void setFont(const Font& font); 33 35 void setChangedTextColor(const Color& color); 34 36 -
trunk/src/lib/gui/gl/glgui_widget.cc
r9406 r9656 79 79 if (this == GLGuiWidget::selected()) 80 80 this->unselect(); 81 82 if (this->_parent != NULL) 83 this->_parent->removeChildWidget(this); 81 84 } 82 85 … … 84 87 GLGuiWidget* GLGuiWidget::_mouseFocused = NULL; 85 88 GLGuiWidget* GLGuiWidget::_inputGrabber = NULL; 86 89 Font* GLGuiWidget::_defaultFont = NULL; 87 90 88 91 … … 100 103 this->_state = OrxGui::Normal; 101 104 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; 104 109 this->resetStyle(); 105 110 … … 776 781 void GLGuiWidget::setFont(const std::string& fontName, unsigned int renderSize) 777 782 { 778 this-> _font = Font(fontName, renderSize);783 this->setFont(Font(fontName, renderSize)); 779 784 } 780 785 -
trunk/src/lib/gui/gl/glgui_widget.h
r9406 r9656 206 206 void setFeaturePositionS(const std::string& featurePosition); 207 207 208 v oid 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); 210 210 211 211 void setAnimatedStateChanges(bool animated); … … 270 270 virtual void destroying(); 271 271 272 // unparent the widget and from this widget seen as parent 273 virtual void removeChildWidget(GLGuiWidget* widget) {}; 274 272 275 273 276 virtual void debug(unsigned int level) const; … … 323 326 Font _font; //!< The Font used in the current Widget. 324 327 328 static Font* _defaultFont; //!< The default Font. 325 329 326 330 /// ANIMATION STUFF:
Note: See TracChangeset
for help on using the changeset viewer.