Changeset 8035 in orxonox.OLD for trunk/src/lib
- Timestamp:
- May 31, 2006, 4:20:51 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r7919 r8035 337 337 else 338 338 { 339 SDL_WM_GrabInput(SDL_GRAB_ON);339 //SDL_WM_GrabInput(SDL_GRAB_ON); 340 340 SDL_ShowCursor(SDL_DISABLE); 341 341 } … … 380 380 case SDL_MOUSEBUTTONUP: 381 381 ev.bPressed = false; 382 ev.x = event.motion.x; 383 ev.y = event.motion.y; 382 384 ev.type = event.button.button + SDLK_LAST; 383 385 break; 384 386 case SDL_MOUSEBUTTONDOWN: 385 387 ev.bPressed = true; 388 ev.x = event.motion.x; 389 ev.y = event.motion.y; 386 390 ev.type = event.button.button + SDLK_LAST; 387 391 break; … … 474 478 { 475 479 EventHandler::getInstance()->grabEvents( true); 476 return 0;480 return 1; 477 481 } 478 482 } -
trunk/src/lib/graphics/importer/model.h
r7193 r8035 25 25 #include "base_object.h" 26 26 #include "vector.h" 27 28 using namespace std;29 27 30 28 -
trunk/src/lib/graphics/render2D/element_2d.cc
r7919 r8035 299 299 300 300 /** 301 * @brief updates the Rel - Coordinate in x-direction 302 * @param x the x coordinate 303 */ 304 void Element2D::setRelCoorX2D(float x) 305 { 306 this->setRelCoor2D(Vector2D(x, this->relCoordinate.y)); 307 } 308 309 /** 310 * @brief updates the Rel - Coordinate in y-direction 311 * @param y the y coordinate 312 */ 313 void Element2D::setRelCoorY2D(float y) 314 { 315 this->setRelCoor2D(Vector2D(this->relCoordinate.x, y)); 316 } 317 318 319 /** 301 320 * @brief sets the Relative coordinate to the parent in Pixels 302 321 * @param x the relCoord X … … 388 407 this->setAbsCoor2D(Vector2D(x, y)); 389 408 } 409 410 /** 411 * @brief updates the Abs - Coordinate in x-direction 412 * @param x the x coordinate 413 */ 414 void Element2D::setAbsCoorX2D(float x) 415 { 416 this->setAbsCoor2D(x, this->getAbsCoor2D().y); 417 } 418 419 /** 420 * @brief updates the Abs - Coordinate in y-direction 421 * @param y the y coordinate 422 */ 423 void Element2D::setAbsCoorY2D(float y) 424 { 425 this->setAbsCoor2D(this->getAbsCoor2D().x, y); 426 } 427 390 428 391 429 /** -
trunk/src/lib/graphics/render2D/element_2d.h
r7919 r8035 143 143 public: 144 144 void setRelCoor2D (const Vector2D& relCoord); 145 void setRelCoorX2D(float x); 146 void setRelCoorY2D(float y); 145 147 void setRelCoor2D (float x, float y); 146 148 void setRelCoor2Dpx (int x, int y); … … 155 157 void setAbsCoor2D (const Vector2D& absCoord); 156 158 void setAbsCoor2D (float x, float y); 159 void setAbsCoorX2D(float x); 160 void setAbsCoorY2D(float y); 157 161 void setAbsCoor2Dpx (int x, int y); 158 162 void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0); -
trunk/src/lib/gui/gl_gui/Makefile.am
r7919 r8035 25 25 glgui_inputline.cc \ 26 26 glgui_textfield.cc \ 27 glgui_image.cc \ 27 28 glgui_window.cc \ 28 29 glgui_cursor.cc … … 47 48 glgui_inputline.h \ 48 49 glgui_textfield.h \ 50 glgui_image.h \ 49 51 glgui_window.h \ 50 52 glgui_cursor.h -
trunk/src/lib/gui/gl_gui/glgui.h
r7919 r8035 7 7 #define _GLGUI_H 8 8 9 #include "glgui_defs.h" 9 10 #include "glgui_handler.h" 10 11 … … 17 18 //#include "glgui_colorselector.h" 18 19 #include "glgui_pushbutton.h" 20 #include "glgui_slider.h" 19 21 #include "glgui_cursor.h" 20 22 #include "glgui_inputline.h" 21 23 #include "glgui_textfield.h" 24 #include "glgui_image.h" 22 25 23 26 -
trunk/src/lib/gui/gl_gui/glgui_bar.cc
r7919 r8035 60 60 void GLGuiBar::draw() const 61 61 { 62 this-> startDraw();62 this->beginDraw(); 63 63 64 64 GLGuiWidget::draw(); -
trunk/src/lib/gui/gl_gui/glgui_box.cc
r7779 r8035 23 23 * standard constructor 24 24 */ 25 GLGuiBox::GLGuiBox ( BoxType type)25 GLGuiBox::GLGuiBox (OrxGui::Orientation orientation) 26 26 { 27 27 this->init(); 28 28 29 this->set Type (type);29 this->setOrientation(orientation); 30 30 } 31 31 … … 47 47 void GLGuiBox::pack(GLGuiWidget* widget) 48 48 { 49 if (widget == NULL) 50 return; 49 assert (widget != NULL); 51 50 52 51 this->children.push_back(widget); 52 widget->setParentWidget(this); 53 54 this->resize(); 53 55 } 54 56 … … 56 58 void GLGuiBox::unpack(GLGuiWidget* widget) 57 59 { 58 if (widget == NULL) 60 assert(widget == NULL); 61 62 std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget); 63 if (delWidget != this->children.end()) 59 64 { 60 this->children.clear(); 65 (*delWidget)->setParentWidget(NULL); 66 this->children.erase(delWidget); 61 67 } 62 else 63 { 64 this->children.remove(widget); 65 } 68 this->resize(); 69 } 70 71 void GLGuiBox::clear() 72 { 73 this->children.clear(); 74 this->resize(); 66 75 } 67 76 68 77 void GLGuiBox::showAll() 69 78 { 70 std:: list<GLGuiWidget*>::iterator itC = this->children.begin();79 std::vector<GLGuiWidget*>::iterator itC = this->children.begin(); 71 80 while (itC != this->children.end()) 72 81 { … … 79 88 80 89 this->show(); 81 82 90 } 83 91 84 92 void GLGuiBox::hideAll() 85 93 { 86 std:: list<GLGuiWidget*>::iterator itC = this->children.begin();94 std::vector<GLGuiWidget*>::iterator itC = this->children.begin(); 87 95 while (itC != this->children.end()) 88 96 { … … 97 105 } 98 106 107 void GLGuiBox::resize() 108 { 109 if (orientation() == OrxGui::Vertical) 110 { 111 float height = this->borderSize(); 112 float width = 0.0f; 113 std::vector<GLGuiWidget*>::iterator widget; 114 115 // find out how big the Widgets are. 116 for (widget = this->children.begin(); widget != this->children.end(); ++widget) 117 { 118 (*widget)->setRelCoor2D(this->borderSize(), height); 119 height += (*widget)->getSizeY2D(); 120 width = fmax(width, (*widget)->getSizeX2D()); 121 } 122 123 width += this->borderSize() * 2.0; 124 height += this->borderSize(); /* *2 done further up */ 125 126 printf("%f %f\n", width, height); 127 this->setSize2D(width, height); 128 } 129 else 130 { 131 float height = this->borderSize(); 132 float width = this->borderSize(); 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, this->borderSize()); 139 height = fmax(height, (*widget)->getSizeY2D()); 140 width += (*widget)->getSizeX2D(); 141 } 142 143 width += this->borderSize() ; 144 height += this->borderSize(); /* *2 done further up */ 145 146 printf("%f %f\n", width, height); 147 this->setSize2D(width, height); 148 } 149 GLGuiWidget::resize(); 150 151 // resize everything. 152 //for (widget = this->children.begin(); widget != this->children.end(); ++widget) 153 //{} 154 } 99 155 100 156 /** 101 * draws the GLGuiBox157 * @brief draws the GLGuiBox 102 158 */ 103 159 void GLGuiBox::draw() const 104 160 { 161 this->beginDraw(); 162 GLGuiWidget::draw(); 163 this->endDraw(); 105 164 } 106 165 } -
trunk/src/lib/gui/gl_gui/glgui_box.h
r7779 r8035 9 9 10 10 #include "glgui_container.h" 11 11 #include "glgui_defs.h" 12 12 13 13 namespace OrxGui 14 14 { 15 typedef enum16 {17 Box_H,18 Box_V,19 } BoxType;20 21 15 //! This is BOX part of the openglGUI class 22 16 /** … … 27 21 28 22 public: 29 GLGuiBox( BoxType type = Box_H);23 GLGuiBox(OrxGui::Orientation orientation = OrxGui::Vertical); 30 24 virtual ~GLGuiBox(); 31 25 32 void init(); 33 void setType(BoxType type) { this->type = type; }; 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; }; 34 30 35 31 virtual void pack(GLGuiWidget* widget); 36 32 virtual void unpack(GLGuiWidget* widget); 33 virtual void clear(); 34 37 35 virtual void showAll(); 38 36 virtual void hideAll(); … … 40 38 virtual void draw() const; 41 39 40 protected: 41 virtual void resize(); 42 42 43 private: 43 BoxType type; 44 std::list<GLGuiWidget*> children; 44 void init(); 45 46 Orientation _orientation; 47 std::vector<GLGuiWidget*> children; 45 48 }; 46 49 } -
trunk/src/lib/gui/gl_gui/glgui_button.cc
r7919 r8035 67 67 } 68 68 69 70 71 void GLGuiButton::clicking(const Vector2D& pos) 72 { 73 emit(clicked()); 74 } 75 void GLGuiButton::releasing(const Vector2D& pos) 76 { 77 emit(released()); 78 } 79 69 80 /** 70 81 * @brief draws the GLGuiButton -
trunk/src/lib/gui/gl_gui/glgui_button.h
r7919 r8035 32 32 { 33 33 34 public:35 GLGuiButton(const std::string& label);36 virtual ~GLGuiButton();34 public: 35 GLGuiButton(const std::string& label); 36 virtual ~GLGuiButton(); 37 37 38 const std::string& getLabel() const { return this->label.getText(); };39 void setLabel(const std::string& label);38 const std::string& getLabel() const { return this->label.getText(); }; 39 void setLabel(const std::string& label); 40 40 41 virtual void resize() = 0;41 virtual void draw() const; 42 42 43 virtual void draw() const; 43 DeclareSignal0(released); 44 DeclareSignal0(clicked); 45 46 protected: 47 virtual void clicking(const Vector2D& pos); 48 virtual void releasing(const Vector2D& pos); 44 49 45 50 private: … … 47 52 48 53 49 protected:50 54 51 Text label;55 protected: 52 56 53 private: 54 ButtonState state; 57 Text label; 58 59 private: 60 ButtonState state; 55 61 }; 56 62 } -
trunk/src/lib/gui/gl_gui/glgui_checkbutton.cc
r7919 r8035 52 52 } 53 53 54 void GLGuiCheckButton::setActivity(bool bActive) 55 { 56 this->bActive = bActive; 57 emit(this->toggled(this->bActive)); 58 } 54 59 55 60 void GLGuiCheckButton::toggleActiveState() 56 61 { 57 this-> bActive = !this->bActive;62 this->setActivity(!this->isActive()); 58 63 } 59 64 … … 62 67 this->label.setRelCoor2D(25, 5); 63 68 this->setSize2D(this->label.getSizeX2D() + 30, this->label.getSizeY2D() + 10); 69 GLGuiWidget::resize(); 70 this->frontRect().setTopLeft(borderSize(), borderSize()); 71 this->frontRect().setSize(this->getSizeX2D() -2.0*borderSize(), this->getSizeY2D() -2.0*borderSize()); 64 72 } 65 73 66 74 67 void GLGuiCheckButton::releas ed()75 void GLGuiCheckButton::releasing(const Vector2D& pos) 68 76 { 69 printf("%s released\n", this->getLabel().c_str()); 70 GLGuiWidget::released(); 77 GLGuiButton::releasing(pos); 71 78 this->toggleActiveState(); 72 79 } 80 81 73 82 74 83 /** … … 77 86 void GLGuiCheckButton::draw() const 78 87 { 79 this-> startDraw();88 this->beginDraw(); 80 89 GLGuiButton::draw(); 81 90 82 91 this->frontMaterial().select(); 83 glBegin(GL_QUADS); 84 85 glTexCoord2i(0,0); glVertex2d(1, 1); 86 glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1); 87 glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1); 88 glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1); 92 this->drawRect(this->frontRect()); 89 93 90 94 if (this->bActive) 91 95 { 96 glBegin(GL_QUADS); 92 97 glColor3f( 1, 1 ,1); 93 98 glTexCoord2i(0,0); glVertex2d(8, 8); … … 117 122 else 118 123 { 124 glBegin(GL_QUADS); 119 125 glColor3f(0, 0, 0); 120 126 glTexCoord2i(0,0); glVertex2d(8, 8); … … 125 131 } 126 132 127 128 133 this->endDraw(); 129 // this->label->draw();130 // printf("test");131 134 } 132 135 } -
trunk/src/lib/gui/gl_gui/glgui_checkbutton.h
r7919 r8035 26 26 virtual ~GLGuiCheckButton(); 27 27 28 virtual void resize();29 virtual void released();30 28 31 29 bool isActive() { return this->bActive; }; … … 35 33 virtual void draw() const; 36 34 virtual void update() {}; 35 36 DeclareSignal1(toggled, bool); 37 38 protected: 39 virtual void resize(); 40 virtual void releasing(const Vector2D& pos); 37 41 38 42 private: -
trunk/src/lib/gui/gl_gui/glgui_container.h
r7779 r8035 25 25 virtual ~GLGuiContainer(); 26 26 27 void init(); 28 29 30 void setBorderWidth(float borderwidth); 31 32 27 /** @brief packs a widget into this one. */ 33 28 virtual void pack(GLGuiWidget* widget) = 0; 34 29 /** unpacks a Widget from this container. @param widget the GLGuiWidget to unpack, if NULL all subwidgets will be unpackt. */ 35 30 virtual void unpack(GLGuiWidget* widget) = 0; 31 /** @brief clears all Widgets out. */ 32 virtual void clear() = 0; 33 36 34 virtual void hideAll() = 0; 37 35 virtual void showAll() = 0; … … 41 39 42 40 private: 43 41 void init(); 44 42 }; 45 43 } -
trunk/src/lib/gui/gl_gui/glgui_cursor.cc
r7919 r8035 59 59 this->backMaterial().setDiffuse(1.0,0.0,0.0); 60 60 this->backMaterial().setDiffuseMap("cursor.png"); 61 this->setSize2D(10, 20); 61 this->backMaterial().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 62 this->setSize2D(20, 30); 62 63 this->setAbsCoor2D(100, 100); 63 64 this->setLayer(E2D_LAYER_ABOVE_ALL); 64 65 this->color = 0.0f; 65 66 67 this->resize(); 66 68 } 67 69 … … 74 76 this->backMaterial().setDiffuse(color.x, color.y, color.z); 75 77 76 if (this->movement != Vector2D())78 //if (this->movement != Vector2D()) 77 79 { 78 80 newPos += movement; … … 88 90 89 91 90 this->setAbsCoorSoft2D(newPos, 10);91 92 movement = Vector2D(); 92 93 } 94 this->setAbsCoor2D(newPos); 93 95 } 94 96 … … 98 100 void GLGuiCursor::draw() const 99 101 { 100 this-> startDraw();102 this->beginDraw(); 101 103 GLGuiWidget::draw(); 102 104 this->endDraw(); -
trunk/src/lib/gui/gl_gui/glgui_handler.cc
r7919 r8035 107 107 { 108 108 if (GLGuiWidget::focused()->clickable()) 109 GLGuiWidget::focused()->click(); 109 { 110 Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 111 GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D()); 112 } 110 113 } 111 114 else 112 115 { 113 116 if (GLGuiWidget::focused()->clickable()) 114 GLGuiWidget::focused()->release(); 117 { 118 Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 119 GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D()); 120 } 115 121 } 116 122 } … … 137 143 138 144 } 145 146 147 Vector2D GLGuiHandler::cursorPositionOverFocusedWidget() const 148 { 149 return (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(0,0); 150 } 151 152 const Vector2D& GLGuiHandler::cursorPositionAbs() const 153 { 154 if (this->cursor) 155 return this->cursor->getAbsCoor2D(); 156 else 157 return Vector2D::nullVector(); 158 } 159 Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const 160 { 161 assert (widget != NULL); 162 if (this->cursor) 163 return this->cursor->getAbsCoor2D() - widget->getAbsCoor2D(); 164 else 165 return Vector2D::nullVector(); 166 } 167 139 168 140 169 void GLGuiHandler::draw() -
trunk/src/lib/gui/gl_gui/glgui_handler.h
r7919 r8035 30 30 GLGuiCursor* getCursor() const { return this->cursor; } 31 31 32 Vector2D cursorPositionOverFocusedWidget() const; 33 const Vector2D& cursorPositionAbs() const; 34 Vector2D cursorPositionRel(const GLGuiWidget* const widget) const; 35 32 36 void activate(); 33 37 void deactivate(); -
trunk/src/lib/gui/gl_gui/glgui_image.cc
r7779 r8035 43 43 void GLGuiImage::init() 44 44 { 45 this->setClassID(CL_GLGUI_ , "GLGuiImage");45 this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage"); 46 46 47 this->frontMaterial().setDiffuseMap(this->texture); 48 this->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 49 50 this->resize(); 47 51 } 48 52 53 54 void GLGuiImage::loadImageFromTexture(const Texture& texture) 55 { 56 this->frontMaterial().setDiffuseMap(texture); 57 this->frontMaterial().setDiffuse(1,1,1); 58 } 59 60 void GLGuiImage::loadImageFromFile(const std::string& fileName) 61 { 62 this->texture.loadImage(fileName); 63 } 64 65 void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface) 66 { 67 //this->texture.loadSurface(surface); 68 } 69 70 void GLGuiImage::loadImageFromDisplayList(GLuint texture) 71 { 72 // this->texture.setTexture(texture); 73 } 74 75 void GLGuiImage::resize() 76 { 77 this->frontRect().setTopLeft(this->borderSize(), this->borderSize()); 78 this->frontRect().setSize(this->getSizeX2D() -2.0*this->borderSize(), this->getSizeY2D() - 2.0* this->borderSize() ); 79 GLGuiWidget::resize(); 80 } 81 82 49 83 /** 50 * draws the GLGuiImage84 * @brief draws the GLGuiImage 51 85 */ 52 void GLGuiImage::draw() 86 void GLGuiImage::draw() const 53 87 { 88 this->beginDraw(); 89 GLGuiWidget::draw(); 90 91 this->frontMaterial().select(); 92 this->drawRect(this->frontRect()); 93 this->endDraw(); 54 94 } 55 95 } -
trunk/src/lib/gui/gl_gui/glgui_image.h
r7779 r8035 8 8 #define _GLGUI_IMAGE_H 9 9 10 #include " base_object.h"10 #include "glgui_widget.h" 11 11 12 12 // FORWARD DECLARATION … … 26 26 virtual ~GLGuiImage(); 27 27 28 void init(); 29 void loadImageFromFile(const char* fileName); 28 void loadImageFromTexture(const Texture& texture); 29 30 void loadImageFromFile(const std::string& fileName); 30 31 void loadImageFromSDLSurface(SDL_Surface* surface); 31 void loadImageFromDisplayList(GLuint displayList);32 void loadImageFromDisplayList(GLuint texture); 32 33 33 virtual void draw(); 34 virtual void draw() const; 35 36 DeclareSignal0(imageChanged); 34 37 35 38 private: 39 void init(); 40 virtual void resize(); 36 41 42 private: 43 Texture texture; 37 44 }; 38 45 } -
trunk/src/lib/gui/gl_gui/glgui_inputline.cc
r7919 r8035 21 21 { 22 22 /** 23 * standard constructor23 * @brief standard constructor 24 24 */ 25 25 GLGuiInputLine::GLGuiInputLine () 26 26 { 27 27 this->init(); 28 29 } 30 31 32 /** 33 * standard deconstructor 34 */ 28 } 29 30 31 /** 32 * @brief standard deconstructor 33 */ 35 34 GLGuiInputLine::~GLGuiInputLine() 36 35 {} … … 41 40 42 41 /** 43 * initializes the GUI-element42 * @brief initializes the GUI-element 44 43 */ 45 44 void GLGuiInputLine::init() … … 52 51 this->text.setRelCoor2D(4,4); 53 52 this->text.setFont("fonts/final_frontier.ttf", 20); 54 } 55 53 this->resize(); 54 } 55 56 57 /** 58 * @brief sets the Text of the InputLine 59 * @param text The new Text. 60 */ 56 61 void GLGuiInputLine::setText(const std::string& text) 57 62 { 58 63 this->text.setText(text); 59 64 this->resize(); 60 } 61 65 66 emit(this->textChanged(this->getText())); 67 } 68 69 /** 70 * @brief appends text to the InputLine 71 * @param appendText the Text to append 72 */ 62 73 void GLGuiInputLine::append(const std::string& appendText) 63 74 { 64 75 this->text.append(appendText); 65 76 this->resize(); 66 } 67 77 emit(this->textChanged(this->text.getText())); 78 } 79 80 81 /** 82 * @brief appends a Character to the InputLine 83 * @param character the Character to append. 84 */ 68 85 void GLGuiInputLine::appendCharacter(char character) 69 86 { 70 87 this->text.appendCharacter(character); 71 88 this->resize(); 72 } 73 74 89 emit(this->textChanged(this->text.getText())); 90 } 91 92 93 /** 94 * @brief Removes Characters from the InputLine 95 * @param chars The count of characters to remove 96 */ 75 97 void GLGuiInputLine::removeCharacters(unsigned int chars) 76 98 { 77 99 this->text.removeCharacters(chars); 78 100 this->resize(); 79 } 80 81 101 emit(this->textChanged(this->text.getText())); 102 } 103 104 105 /** 106 * removes the focus from this Widget. 107 */ 82 108 void GLGuiInputLine::removedFocus() 83 109 { … … 88 114 89 115 116 /** 117 * Processes an Event. 118 * @param event The event to be processed 119 * @return true if the event was catched. 120 */ 90 121 bool GLGuiInputLine::processEvent(const Event& event) 91 122 { … … 126 157 127 158 159 /** 160 * @brief Resizes the Widget to the new Size-constraints. 161 */ 128 162 void GLGuiInputLine::resize() 129 163 { 130 164 this->setSize2D( this->text.getSize2D() + Vector2D(8, 8)); 131 } 132 133 165 GLGuiWidget::resize(); 166 this->frontRect().setTopLeft(borderSize(), borderSize()); 167 this->frontRect().setSize(this->getSize2D() - Vector2D(borderSize(), borderSize())); 168 } 169 170 171 /** 172 * ticks the InputLine 173 * @param dt the time passed. 174 */ 134 175 void GLGuiInputLine::tick(float dt) 135 176 { … … 156 197 157 198 /** 158 * draws the GLGuiInputLine199 * @brief draws the GLGuiInputLine 159 200 */ 160 201 void GLGuiInputLine::draw() const 161 202 { 162 this-> startDraw();203 this->beginDraw(); 163 204 GLGuiWidget::draw(); 164 205 165 206 this->frontMaterial().select(); 166 glBegin(GL_QUADS); 167 168 glTexCoord2i(0,0); glVertex2d(3, 3); 169 glTexCoord2i(0,1); glVertex2d(3, this->getSizeY2D() - 3); 170 glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 3, this->getSizeY2D() -3); 171 glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 3, 3); 172 173 glEnd(); 207 GLGuiWidget::drawRect(this->frontRect()); 208 174 209 this->endDraw(); 175 210 } -
trunk/src/lib/gui/gl_gui/glgui_inputline.h
r7919 r8035 16 16 { 17 17 18 //! This is part of the openglGUI class18 //! This is InputLine part of the openglGUI class 19 19 /** 20 * The InputLine is a Widget, that displays a Line, that can be manipulated through 21 * Writing Text on it. 20 22 * 23 * Whenever the Text is changed the textChanged signal is emitted. 21 24 */ 22 25 class GLGuiInputLine : public OrxGui::GLGuiWidget … … 27 30 virtual ~GLGuiInputLine(); 28 31 29 void init(); 32 33 /** @returns the text of the inputLine */ 34 const std::string& getText() const { return this->text.getText(); }; 30 35 31 36 void setText(const std::string& text); … … 33 38 void appendCharacter(char character); 34 39 void removeCharacters(unsigned int chars); 35 const std::string& getName() const { return this->text.getText(); };36 37 40 38 41 virtual void removedFocus(); … … 43 46 virtual bool processEvent(const Event& event); 44 47 45 private: 46 void resize(); 48 DeclareSignal1(textChanged, const std::string&); 47 49 50 private: 51 void init(); 52 void resize(); 48 53 49 54 private: … … 55 60 float delayNext; //!< How much time must pass before next output. 56 61 57 static float repeatDelay; 58 static float repeatRate; 59 60 62 static float repeatDelay; //!< Repead Delay. 63 static float repeatRate; //!< Repeat Rate. 61 64 }; 62 65 } -
trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc
r7919 r8035 47 47 this->label.setRelCoor2D(5, 5); 48 48 this->setSize2D(this->label.getSizeX2D() + 10, this->label.getSizeY2D() + 10); 49 50 GLGuiWidget::resize(); 51 this->frontRect().setTopLeft(1, 1); 52 this->frontRect().setSize(this->getSizeX2D() -2, this->getSizeY2D() -2); 49 53 } 50 54 … … 70 74 } 71 75 72 void GLGuiPushButton::click ed()76 void GLGuiPushButton::clicking(const Vector2D& pos) 73 77 { 74 78 printf("%s clicked\n", this->getLabel().c_str()); 75 GLGui Widget::clicked();79 GLGuiButton::clicking(pos); 76 80 } 77 81 78 82 79 void GLGuiPushButton::releas ed()83 void GLGuiPushButton::releasing(const Vector2D& pos) 80 84 { 81 85 printf("%s released\n", this->getLabel().c_str()); 82 GLGui Widget::released();86 GLGuiButton::releasing(pos); 83 87 } 84 88 … … 90 94 void GLGuiPushButton::draw() const 91 95 { 92 this-> startDraw();96 this->beginDraw(); 93 97 GLGuiButton::draw(); 94 98 95 99 this->frontMaterial().select(); 96 glBegin(GL_QUADS); 97 98 glTexCoord2i(0,0); glVertex2d(1, 1); 99 glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1); 100 glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1); 101 glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1); 102 103 glEnd(); 100 this->drawRect(this->frontRect()); 104 101 this->endDraw(); 105 102 // this->label->draw(); -
trunk/src/lib/gui/gl_gui/glgui_pushbutton.h
r7919 r8035 27 27 28 28 29 virtual void resize();30 31 virtual void receivedFocus();32 virtual void removedFocus();33 virtual void clicked();34 virtual void released();35 29 36 30 37 31 virtual void draw() const; 38 32 virtual void update(); 33 protected: 34 virtual void resize(); 35 virtual void clicking(const Vector2D& pos); 36 virtual void releasing(const Vector2D& pos); 37 virtual void receivedFocus(); 38 virtual void removedFocus(); 39 40 41 39 42 private: 40 43 void init(); -
trunk/src/lib/gui/gl_gui/glgui_slider.cc
r7919 r8035 17 17 18 18 #include "glgui_slider.h" 19 #include "event_def.h" 20 21 #include "glgui_handler.h" 19 22 20 23 namespace OrxGui … … 22 25 23 26 /** 24 * standard constructor25 */27 * @brief standard constructor 28 */ 26 29 GLGuiSlider::GLGuiSlider () 27 30 { … … 32 35 33 36 /** 34 * standard deconstructor35 */37 * @brief standard deconstructor 38 */ 36 39 GLGuiSlider::~GLGuiSlider() 37 { 38 } 39 40 /** 41 * initializes the GUI-element 40 {} 41 42 /** 43 * @brief initializes the GUI-element 42 44 */ 43 45 void GLGuiSlider::init() 44 46 { 47 45 48 this->setClassID(CL_GLGUI_SLIDER, "GLGuiSlider"); 46 49 47 } 48 49 /** 50 * draws the GLGuiSlider 50 this->setClickable( ); 51 this->setFocusable( ); 52 53 this->_value = 0.0; 54 this->_minValue = 0.0; 55 this->_maxValue = 1.0; 56 this->_step = 0.1; 57 this->_sliderWidth = 5.0; 58 this->grabbed = false; 59 60 this->setSize2D(100, 30); 61 this->resize(); 62 } 63 64 /** 65 * @param value the new Value. 66 * @note will automatically be set between max() and min() 67 */ 68 void GLGuiSlider::setValue(float value) 69 { 70 if (value < this->min()) 71 this->_value = min(); 72 else if (value > max()) 73 this->_value = max(); 74 else 75 this->_value = value; 76 emit(valueChanged(this->_value)); 77 } 78 79 /** 80 * @param minimum the minumum of the range. 81 * 82 * @note will rearange value if necessary and will not be made bigger than max() 83 */ 84 void GLGuiSlider::setMin(float minimum) 85 { 86 if (minimum <= max()) 87 { 88 this->_minValue = minimum; 89 emit(rangeChanged(this->_minValue, this->_maxValue)); 90 } 91 if (this->value() < this->min()) 92 this->setValue(this->min()); 93 } 94 95 96 /** 97 * @param maximum the maximum of the range. 98 * 99 * @note will rearange value if necessary and will not be made smaller than min() 100 */ 101 void GLGuiSlider::setMax(float maximum) 102 { 103 if (maximum >= min()) 104 { 105 this->_maxValue = maximum; 106 emit(rangeChanged(this->_minValue, this->_maxValue)); 107 } 108 if (this->value() > this->max()) 109 this->setValue(this->max()); 110 } 111 112 /** 113 * @param minimum the minimum 114 * @param maximum the maximum 115 * 116 * @see setMax 117 * @see setMin 118 */ 119 void GLGuiSlider::setRange(float minimum, float maximum) 120 { 121 if (minimum < maximum) 122 { 123 this->_minValue = minimum; 124 this->_maxValue = maximum; 125 emit(rangeChanged(this->_minValue, this->_maxValue)); 126 } 127 if (this->value() < this->min()) 128 this->setValue(this->min()); 129 else if (this->value() > this->max()) 130 this->setValue(this->max()); 131 } 132 133 /** 134 * @brief sets the stepSize 135 */ 136 void GLGuiSlider::setStep(float step) 137 { 138 this->_step = step; 139 } 140 141 /** 142 * @brief makes one step into the minus direction 143 */ 144 void GLGuiSlider::stepMinus() 145 { 146 this->setValue(value() - step()); 147 } 148 149 /** 150 * @brief makes one step into the minus direction 151 */ 152 void GLGuiSlider::stepPlus() 153 { 154 this->setValue(value() + step()); 155 } 156 157 /** 158 * @brief resizes the Slider, and through this Synchronizes the GUI-size. 159 */ 160 void GLGuiSlider::resize() 161 { 162 GLGuiWidget::resize(); 163 this->frontRect().setTopLeft(5, this->getSizeY2D()/2.0 - 2.0); 164 this->frontRect().setSize(this->getSizeX2D() - 10.0, 4.0); 165 } 166 167 /** 168 * @brief handle the clicked event. 169 * @param pos the position the Click occured (from the topleft corner out) 170 */ 171 void GLGuiSlider::clicking(const Vector2D& pos) 172 { 173 GLGuiWidget::clicking(pos); 174 175 float sliderPosition = this->sliderPosition(); 176 if (sliderPosition > pos.x + this->_sliderWidth) 177 this->setValue(this->value() - this->step()); 178 179 else if (sliderPosition < pos.x - this->_sliderWidth) 180 this->setValue(this->value() + this->step()); 181 else 182 this->grabbed = true; 183 } 184 185 void GLGuiSlider::releasing(const Vector2D& pos) 186 { 187 GLGuiWidget::releasing(pos); 188 this->grabbed = false; 189 } 190 191 void GLGuiSlider::removedFocus() 192 { 193 GLGuiWidget::removedFocus(); 194 this->grabbed = false; 195 } 196 197 /** 198 * @returns the current SliderPosition calculated from the current value and the Silders' size. 199 */ 200 float GLGuiSlider::sliderPosition() const 201 { 202 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * 203 (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) + 204 (borderSize() +_sliderWidth); 205 } 206 207 /** 208 * @param position the position relative from the left border. 209 * @returns the Value at the given position. 210 */ 211 float GLGuiSlider::sliderValue(float position) const 212 { 213 return (position - (borderSize()+_sliderWidth)) / (this->getSizeX2D() - 2.0*(borderSize() + _sliderWidth)) 214 *( this->_maxValue - this->_minValue) + 215 this->_minValue ; 216 } 217 218 void GLGuiSlider::tick(float dt) 219 { 220 } 221 222 /** 223 * @brief draws the GLGuiSlider 51 224 */ 52 225 void GLGuiSlider::draw() const 53 226 { 227 this->beginDraw(); 228 GLGuiWidget::draw(); 229 230 this->frontMaterial().select(); 231 this->drawRect(this->frontRect()); 232 233 this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, borderSize(), _sliderWidth, this->getSizeY2D() - 2 * borderSize())); 234 235 this->endDraw(); 236 } 237 238 239 bool GLGuiSlider::processEvent( const Event& event ) 240 { 241 if (this->grabbed && event.type == EV_MOUSE_MOTION) 242 { 243 this->setValue(sliderValue(GLGuiHandler::getInstance()->cursorPositionRel(this).x)); 244 return true; 245 } 246 else if (event.bPressed) 247 { 248 if (event.type == SDLK_LEFT) 249 { 250 this->stepMinus(); 251 return true; 252 } 253 else if (event.type == SDLK_RIGHT) 254 { 255 this->stepPlus(); 256 return true; 257 } 258 } 259 return false; 54 260 } 55 261 } -
trunk/src/lib/gui/gl_gui/glgui_slider.h
r7919 r8035 17 17 //! This is part of the openglGUI class 18 18 /** 19 * 19 * The Slider is a Widget, with a Range and a Value. 20 20 */ 21 21 class GLGuiSlider : public GLGuiWidget … … 26 26 virtual ~GLGuiSlider(); 27 27 28 /** @returns the Value of the Slider. */ 29 float value() const { return this->_value; } 30 /** @returns the minimum of the sliders range */ 31 float min() const { return this->_minValue; }; 32 /** @returns the maximum of the sliders range */ 33 float max() const { return this->_maxValue; }; 34 /** @returns the step size */ 35 float step() const { return this->_step; }; 36 37 void setValue(float value); 38 39 void setMin(float minimum); 40 void setMax(float maximum); 41 void setRange(float minimum, float maximum); 42 43 void setStep(float step); 44 45 void stepPlus(); 46 void stepMinus(); 47 48 49 virtual void tick(float dt); 50 virtual bool processEvent(const Event& event); 51 virtual void draw() const; 52 53 DeclareSignal1(valueChanged, float); 54 DeclareSignal2(rangeChanged, float, float); 55 56 protected: 57 virtual void resize(); 58 59 virtual void clicking(const Vector2D& pos); 60 virtual void releasing(const Vector2D& pos); 61 virtual void removedFocus(); 62 63 private: 28 64 void init(); 29 30 virtual void draw() const;65 float sliderPosition() const; 66 float sliderValue(float position) const; 31 67 32 68 private: … … 35 71 float _maxValue; 36 72 float _minValue; 73 float _step; 37 74 38 75 float _value; 76 77 float _sliderWidth; 78 79 bool grabbed; 39 80 40 81 }; -
trunk/src/lib/gui/gl_gui/glgui_text.h
r7779 r8035 26 26 virtual ~GLGuiText(); 27 27 28 void setText(); 29 30 virtual void draw(); 31 32 private: 28 33 void init(); 29 34 30 virtual void draw();31 35 32 36 private: -
trunk/src/lib/gui/gl_gui/glgui_textfield.cc
r7919 r8035 43 43 { 44 44 this->setClassID(CL_GLGUI_TEXTFIELD, "GLGuiTextfield"); 45 46 47 45 } 48 46 49 47 /** 50 * draws the GLGuiTextfield48 * @brief draws the GLGuiTextfield 51 49 */ 52 50 void GLGuiTextfield::draw() const 53 51 { 52 this->beginDraw(); 53 GLGuiWidget::draw(); 54 55 this->frontMaterial().select(); 56 this->drawRect(this->frontRect()); 57 this->endDraw(); 54 58 } 55 59 } -
trunk/src/lib/gui/gl_gui/glgui_widget.cc
r7919 r8035 28 28 29 29 /** 30 * standard constructor30 * @brief standard constructor 31 31 */ 32 GLGuiWidget::GLGuiWidget ( 32 GLGuiWidget::GLGuiWidget (GLGuiWidget* parent) 33 33 { 34 34 this->init(); 35 } 36 37 38 /** 39 * standard deconstructor 35 36 this->setParentWidget(parent); 37 } 38 39 40 /** 41 * @brief standard deconstructor 40 42 */ 41 43 GLGuiWidget::~GLGuiWidget() … … 45 47 } 46 48 49 GLGuiWidget* GLGuiWidget::_selected = NULL; 47 50 GLGuiWidget* GLGuiWidget::_focused = NULL; 48 51 GLGuiWidget* GLGuiWidget::_inputGrabber = NULL; … … 63 66 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 64 67 65 this->backMat.setDiffuse(1.0, 1.0, 1.0); 66 this->frontMat.setDiffuse(1.0, 0.0, 0.0); 67 68 this->widgetSignals.resize(SignalCount, SignalConnector()); 69 } 70 68 this->_backMat.setDiffuse(1.0, 1.0, 1.0); 69 this->_frontMat.setDiffuse(1.0, 0.0, 0.0); 70 this->_borderSize = 1.0; 71 } 72 73 74 void GLGuiWidget::setParentWidget(GLGuiWidget* parent) 75 { 76 this->_parent = parent; 77 78 if (parent != NULL) 79 parent->addChild2D(this); 80 } 71 81 72 82 /** @brief gives focus to this widget */ … … 93 103 { 94 104 return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x && 95 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);105 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y); 96 106 } 97 107 … … 101 111 } 102 112 103 void GLGuiWidget::click() 113 114 void GLGuiWidget::setBorderSize(float borderSize) 115 { 116 this->_borderSize = borderSize; 117 this->resize(); 118 } 119 120 121 void GLGuiWidget::resize() 122 { 123 this->backRect().setSize(this->getSize2D()); 124 if (this->parent() != NULL) 125 this->parent()->resize(); 126 } 127 128 129 void GLGuiWidget::click(const Vector2D& pos) 104 130 { 105 131 assert (!this->_pushed); 106 this->widgetSignals[Signal_click]("none");107 132 this->_pushed = true; 108 133 109 this->click ed();110 } 111 112 void GLGuiWidget::release( )134 this->clicking(pos); 135 } 136 137 void GLGuiWidget::release(const Vector2D& pos) 113 138 { 114 139 if (this->_pushed) 115 140 { 116 this->widgetSignals[Signal_release]("none"); 117 118 this->released(); 141 this->releasing(pos); 119 142 this->_pushed = false; 120 143 } … … 122 145 123 146 124 void GLGuiWidget::click ed()147 void GLGuiWidget::clicking(const Vector2D& pos) 125 148 { 126 149 this->frontMaterial().setDiffuse(0, 0, 1); … … 128 151 } 129 152 130 void GLGuiWidget::releas ed()131 { 132 this->frontMat .setDiffuse(0,1,0);153 void GLGuiWidget::releasing(const Vector2D& pos) 154 { 155 this->frontMaterial().setDiffuse(0,1,0); 133 156 134 157 } … … 146 169 147 170 void GLGuiWidget::destroyed() 148 { 149 }; 150 151 152 153 154 /** 155 * @brief connects a Signal to the Gui-Elements' Event. 156 * @param sinalType the Type of Signal to set. @see GLGuiSignalType 157 * @param signal the name of the Signal 171 {} 172 ; 173 174 void GLGuiWidget::setWidgetSize(const Vector2D& size) 175 { 176 this->setSize2D(size); 177 this->resize(); 178 179 } 180 181 182 void GLGuiWidget::setWidgetSize(float x, float y) 183 { 184 this->setWidgetSize(Vector2D(x, y)); 185 } 186 187 188 189 void GLGuiWidget::connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor) 190 { 191 sender->connect(signal, receiver, executor); 192 } 193 194 void GLGuiWidget::connect(Signal& signal, BaseObject* receiver, Slot executor) 195 { 196 signal.push_back(SignalConnector(receiver, executor)); 197 } 198 199 200 void GLGuiWidget::show() 201 { 202 this->setVisibility(true); 203 } 204 205 206 void GLGuiWidget::hide() 207 { 208 this->setVisibility(false); 209 } 210 211 212 /** 213 * USE THIS FUNCTION ONLY FROM DERIVED CLASS 158 214 */ 159 void GLGuiWidget::connectSignal(SignalType signalType, BaseObject* object, const Executor* signal)160 {161 if (signalType >= this->widgetSignals.size())162 return;163 164 // if (this->widgetSignals[signalType] != NULL)165 // PRINTF(2)("Already connected a Signal to '%s::%s' type %s... overwriting\n", this->getClassName(), this->getName(), "TEST");166 167 this->widgetSignals[signalType] = SignalConnector(object, signal);168 }169 170 /**171 * @brief removes a Signal from a Gui-ELements' Event172 * @param signalType the type of Signal to remove.173 */174 void GLGuiWidget::disconnectSignal(SignalType signalType)175 {176 if (signalType >= this->widgetSignals.size())177 return;178 179 this->widgetSignals[signalType] = SignalConnector();180 }181 182 183 void GLGuiWidget::show()184 {185 this->setVisibility(true);186 }187 188 void GLGuiWidget::hide()189 {190 this->setVisibility(false);191 }192 193 194 215 void GLGuiWidget::draw() const 195 216 { 196 this->backMat.select(); 197 198 glBegin(GL_QUADS); 199 glTexCoord2i(0,0); glVertex2d(0, 0); 200 glTexCoord2i(0,1); glVertex2d(0, this->getSizeY2D()); 201 glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), this->getSizeY2D()); 202 glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), 0); 203 glEnd(); 217 this->backMaterial().select(); 218 this->drawRect(this->backRect()); 204 219 } 205 220 -
trunk/src/lib/gui/gl_gui/glgui_widget.h
r7919 r8035 24 24 namespace OrxGui 25 25 { 26 typedef enum27 {28 Signal_click = 0,29 Signal_release,30 Signal_rollOn,31 Signal_rollOff,32 Signal_open,33 Signal_close,34 Signal_destroy,35 36 SignalCount,37 } SignalType;38 39 26 40 27 class GLGuiCursor; … … 49 36 class GLGuiWidget : public Element2D 50 37 { 51 52 private:53 54 38 public: 55 GLGuiWidget( );39 GLGuiWidget(GLGuiWidget* parent = NULL); 56 40 virtual ~GLGuiWidget(); 57 41 … … 59 43 void hide(); 60 44 61 /// INTERCONNECTIVITY62 void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);63 void disconnectSignal(SignalType signalType);64 45 46 void setParentWidget(GLGuiWidget* parent); 47 GLGuiWidget* parent() const { return this->_parent; } 65 48 66 49 /// FOCUS … … 82 65 83 66 /// CLICK 84 void click( );85 void release( );67 void click(const Vector2D& pos); 68 void release(const Vector2D& pos); 86 69 bool clickable() const { return this->_clickable; }; 87 70 void setClickable(bool clickable = true) { this->_clickable = clickable; }; 71 72 static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor); 73 void connect(Signal& signal, BaseObject* receiver, Slot executor); 74 75 void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver); 76 77 78 /// MATERIAL (looks) 79 Material& backMaterial() { return this->_backMat; }; 80 const Material& backMaterial() const { return this->_backMat; }; 81 Rect2D& backRect() { return this->_backRect; }; 82 const Rect2D& backRect() const { return this->_backRect; }; 83 84 Material& frontMaterial() { return this->_frontMat; }; 85 const Material& frontMaterial() const { return this->_frontMat; }; 86 Rect2D& frontRect() { return this->_frontRect; }; 87 const Rect2D& frontRect() const { return this->_frontRect; }; 88 89 float borderSize() const { return this->_borderSize; }; 90 void setBorderSize(float borderSize); 91 92 void setWidgetSize(const Vector2D& size); 93 void setWidgetSize(float x, float y); 94 95 96 void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); }; 97 98 inline void drawRect(const Rect2D& rect) const { 99 glBegin(GL_QUADS); 100 glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top()); 101 glTexCoord2i(0,1); glVertex2d(rect.left(), rect.bottom()); 102 glTexCoord2i(1,1); glVertex2d(rect.right(), rect.bottom()); 103 glTexCoord2i(1,0); glVertex2d(rect.right(), rect.top()); 104 glEnd(); 105 } 106 88 107 89 108 virtual void update() {}; 90 109 virtual void draw() const; 91 110 92 93 /// MATERIAL (looks)94 Material& backMaterial() { return this->backMat; };95 const Material& backMaterial() const { return this->backMat; };96 97 Material& frontMaterial() { return this->frontMat; };98 const Material& frontMaterial() const { return this->frontMat; };99 100 111 /** @param the Event to process. @returns true if the Event has been consumed*/ 101 112 virtual bool processEvent(const Event& event) { }; 102 113 114 protected: 103 115 104 DeclareSignal(testSignal, ()); 116 /// LOOKS 117 virtual void resize(); 105 118 106 protected: 107 // if something was clickt on the GUI-widget. 108 virtual void clicked(); 109 virtual void released(); 119 // if something was clickt on the GUI-widget. 120 virtual void clicking(const Vector2D& pos); 121 virtual void releasing(const Vector2D& pos); 110 122 virtual void receivedFocus(); 111 123 virtual void removedFocus(); … … 114 126 115 127 116 inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };128 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; 117 129 inline void endDraw() const { glPopMatrix(); }; 118 130 … … 122 134 123 135 private: 136 GLGuiWidget* _parent; //!< The parent of this Widget. 137 124 138 /// LOOKS 125 Material backMat;126 Rect2D backRect;139 Material _backMat; 140 Rect2D _backRect; 127 141 128 Material frontMat;129 Rect2D frontRect;142 Material _frontMat; 143 Rect2D _frontRect; 130 144 131 132 /// SIGNALS 133 std::vector<SignalConnector> widgetSignals; 145 float _borderSize; 134 146 135 147 /// EVENTS … … 139 151 bool _pushed; 140 152 141 static GLGuiWidget* _focused; 142 static GLGuiWidget* _inputGrabber; 153 154 static GLGuiWidget* _selected; //!< The currently selected Widget. 155 static GLGuiWidget* _focused; //!< The currently Focused Widget. 156 157 static GLGuiWidget* _inputGrabber; //!< The Widget that grabs input. 143 158 }; 144 159 } -
trunk/src/lib/gui/gl_gui/signal_connector.cc
r7855 r8035 21 21 { 22 22 23 /** 24 * @brief creates a clean SignalConnector 25 */ 23 26 SignalConnector::SignalConnector( ) 24 27 { … … 27 30 } 28 31 32 /** 33 * @brief Creates a SignalConnector out of an ObjectPointer, and an Executor. 34 * @param object the Object the Executor will apply to. 35 * @param executor the Executor that will be executed. 36 * @return a new SignalConnector. 37 */ 29 38 SignalConnector::SignalConnector(BaseObject* object, const Executor* executor) 30 39 { … … 33 42 }; 34 43 44 /** 45 * @brief Creates a SignalConnector as a copy of another one. 46 * @param signalConnector The SignalConnector to copy. 47 */ 35 48 SignalConnector::SignalConnector(const SignalConnector& signalConnector) 36 49 { … … 39 52 } 40 53 54 /** 55 * @brief deletes a SignalConnector. 56 * 57 * frees the stored executor 58 */ 41 59 SignalConnector::~SignalConnector() 42 60 { … … 44 62 } 45 63 64 /** 65 * @brief assignes a SignalConnector to the current one 66 * @param signalConnector the SignalConnector to assign to this one 67 * @return A Reference to this SignalConnector. 68 */ 46 69 SignalConnector& SignalConnector::operator=(const SignalConnector& signalConnector) 47 70 { … … 51 74 } 52 75 53 void SignalConnector::operator()(const std::string& parameters) const 76 77 /** 78 * @brief compares two SignalConnectors. 79 * @param signalConnector the SignalConnector to compare against this one. 80 * @return true if the Connectors are the same. 81 */ 82 bool SignalConnector::operator==(const SignalConnector& signalConnector) const 83 { 84 return (this->object == signalConnector.object /* && this->exec == signalConnector.exec */ ); 85 } 86 87 88 /** 89 * @brief Executes the SignalConnector. 90 */ 91 void SignalConnector::operator()() const 92 { 93 if (this->isValid()) 94 (*this->exec)(this->object, 0, NULL); 95 } 96 97 /** 98 * @brief Executes the SignalConnector. 99 * @param value0 First Value. 100 */ 101 void SignalConnector::operator()(const MultiType& value0) const 54 102 { 55 103 if (exec != NULL && object != NULL) 56 (*this->exec)(this->object, parameters);104 (*this->exec)(this->object, 1, &value0); 57 105 } 58 106 107 /** 108 * @brief Executes the SignalConnector. 109 * @param value0 First Value 110 * @param value1 Second Value 111 */ 112 void SignalConnector::operator()(const MultiType& value0, const MultiType& value1) const 113 { 114 if (exec != NULL && object != NULL) 115 { 116 MultiType mt[] = { value0, value1 }; 117 (*this->exec)(this->object, 2, mt); 118 } 119 } 120 121 /** 122 * @brief Executes the SignalConnector. 123 * @param value0 First Value 124 * @param value1 Second Value 125 * @param value2 Third Value 126 */ 127 void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const 128 { 129 if (exec != NULL && object != NULL) 130 { 131 MultiType mt[] = { value0, value1, value2 }; 132 (*this->exec)(this->object, 3, mt); 133 } 134 } 135 136 /** 137 * @brief Executes the SignalConnector. 138 * @param value0 First Value 139 * @param value1 Second Value 140 * @param value2 Third Value 141 * @param value3 Fourth Value 142 */ 143 void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const 144 { 145 if (exec != NULL && object != NULL) 146 { 147 MultiType mt[] = { value0, value1, value2, value3 }; 148 (*this->exec)(this->object, 4, mt); 149 } 150 } 151 152 /** 153 * @brief Executes the SignalConnector. 154 * @param value0 First Value 155 * @param value1 Second Value 156 * @param value2 Third Value 157 * @param value3 Fourth Value 158 * @param value3 Fifth Value 159 */ 160 void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const 161 { 162 if (exec != NULL && object != NULL) 163 { 164 MultiType mt[] = { value0, value1, value2, value3, value4 }; 165 (*this->exec)(this->object, 5, mt); 166 } 167 } 59 168 } -
trunk/src/lib/gui/gl_gui/signal_connector.h
r7919 r8035 12 12 { 13 13 14 #define DeclareSignal(name, params) \ 14 //////////////// TO BE IGNORED BY YOU ///// 15 #define DeclareSignalBegin(SignalName) \ 15 16 public: \ 16 void signal_ ##connect ##name(const SignalConnector& connector) { \ 17 name ## connected.push_back(connector); \ 17 void signal_ ## connect ## SignalName(const SignalConnector& connector) { \ 18 SignalName ## connected.push_back(connector); \ 19 }\ 20 Signal& getSignalVector_##SignalName () { return this->SignalName ## connected; }; \ 21 private: 22 23 #define DeclareSignalEnd(SignalName) \ 24 Signal SignalName ## connected 25 ///////////////////////////////////////////// 26 27 28 /** 29 * @brief declares a new Signal. 30 * @param SignalName the Name of the Signal. 31 */ 32 #define DeclareSignal0(SignalName) \ 33 DeclareSignalBegin(SignalName) \ 34 void SignalName () { \ 35 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 36 SignalName ## connected[i] (); \ 18 37 }\ 19 private: \ 20 void signal_ ## name params { \ 21 for (unsigned int i = 0; i < name ## connected . size(); i++) \ 22 name ## connected[i] ("TEST"); \ 23 }\ 24 std::vector<SignalConnector> name ## connected 38 DeclareSignalEnd(SignalName) 25 39 26 //! A class for Conncting Signals to Objects, inside of the GUI 40 41 /** 42 * @brief declares a new Signal. 43 * @param SignalName the Name of the Signal. 44 * @param param0 the first Parameter the Function takes 45 */ 46 #define DeclareSignal1(SignalName, param0) \ 47 DeclareSignalBegin(SignalName) \ 48 void SignalName (param0 val0) { \ 49 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 50 SignalName ## connected[i] (val0); \ 51 }\ 52 DeclareSignalEnd(SignalName) 53 54 /** 55 * @brief declares a new Signal. 56 * @param SignalName the Name of the Signal. 57 * @param param0 the first Parameter the Function takes 58 * @param param1 the second Parameter the Function takes 59 */ 60 #define DeclareSignal2(SignalName, param0, param1) \ 61 DeclareSignalBegin(SignalName) \ 62 void SignalName (param0 val0, param1 val1) { \ 63 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 64 SignalName ## connected[i] (val0, val1); \ 65 }\ 66 DeclareSignalEnd(SignalName) 67 68 69 70 /** 71 * @brief declares a new Signal. 72 * @param SignalName the Name of the Signal. 73 * @param param0 the first Parameter the Function takes 74 * @param param1 the second Parameter the Function takes 75 * @param param2 the third Parameter the Function takes 76 */ 77 #define DeclareSignal3(SignalName, param0, param1, param2) \ 78 DeclareSignalBegin(SignalName) \ 79 void SignalName (param0 val0, param1 val1, param2 val2) { \ 80 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 81 SignalName ## connected[i] (val0, val1, val2); \ 82 }\ 83 DeclareSignalEnd(SignalName) 84 85 /** 86 * @brief declares a new Signal. 87 * @param SignalName the Name of the Signal. 88 * @param param0 the first Parameter the Function takes 89 * @param param1 the second Parameter the Function takes 90 * @param param2 the third Parameter the Function takes 91 * @param param3 the fourth Parameter the Function takes 92 */ 93 #define DeclareSignal4(SignalName, param0, param1, param2, param3) \ 94 DeclareSignalBegin(SignalName) \ 95 void SignalName (param0 val0, param1 val1, param2 val2, param3 val3) { \ 96 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 97 SignalName ## connected[i] (val0, val1, val2, val3); \ 98 }\ 99 DeclareSignalEnd(SignalName) 100 101 102 /** 103 * @brief declares a new Signal. 104 * @param SignalName the Name of the Signal. 105 * @param param0 the first Parameter the Function takes 106 * @param param1 the second Parameter the Function takes 107 * @param param2 the third Parameter the Function takes 108 * @param param4 the fifth Parameter the Function takes 109 */ 110 #define DeclareSignal5(SignalName, param0, param1, param2, param3, param4) \ 111 DeclareSignalBegin(SignalName) \ 112 void SignalName (param0 val0, param1 val1, param2 val2, param3 val3, param4 val4) { \ 113 for (unsigned int i = 0; i < SignalName ## connected .size(); i++) \ 114 SignalName ## connected[i] (val0, val1, val2, val3, val4); \ 115 }\ 116 DeclareSignalEnd(SignalName) 117 118 119 /** 120 * @brief selects a Signal. 121 * @param SignalName the Signal to be retrieved. 122 */ 123 #define SIGNAL(Object, SignalName) \ 124 Object->getSignalVector_##SignalName() 125 126 /** 127 * @brief defines a Slot, the sink of a Signal. 128 * @param Class the Class the Slot belongs to. 129 * @param function the Function to Connect to. 130 */ 131 #define SLOT(Class, function) \ 132 createExecutor<Class>(&Class::function) 133 134 /** 135 * @brief emits function 136 */ 137 #define emit(function) function 138 139 //! A class for Conncting Signals to Objects, inside of the Graphical user interface. 140 /** 141 * The SignalConnector binds an Object to a Functional (Executor) 142 * The Usage is quite easy in the Widget for this: 143 * 144 * int the header (Class Definition) you can add a definition of a Signal with: 145 * @verbatim DeclareSignal3(my_signal, int, int, float) 146 * and a Signal with the the Parameters int,int and float will be created. 147 * 148 * now you can use the connect function of GLWidget to connect this Signal to a Slot. 149 * @see GLGuiWidget::connect 150 */ 27 151 class SignalConnector 28 152 { … … 34 158 35 159 SignalConnector& operator=(const SignalConnector& signalConnector); 160 bool operator==(const SignalConnector& signalConnector) const; 36 161 37 void operator()(const std::string& parameters) const; 38 void execute(const std::string& parameters) const { (*this)(parameters); }; 162 void operator()() const; 163 void operator()(const MultiType& value0) const; 164 void operator()(const MultiType& value0, const MultiType& value1) const; 165 void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const; 166 void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const; 167 void operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const; 39 168 169 /** checks wether the SignalConnector is valid @return true on valid. */ 170 bool isValid() const { return (this->object && this->exec); }; 171 /** @brief checks if the SignalConnector is clean, invalid @returns true if invalid */ 40 172 bool isClean() const { return (this->object == NULL || this->exec == NULL); } 41 173 … … 45 177 const Executor* exec; //!< The Executor, that will be called, on object. 46 178 }; 179 180 //! TypeDefinition for SignalLists 181 typedef std::vector<SignalConnector> Signal; 182 //! TypeDefinition for a Slot. 183 typedef Executor* Slot; 184 47 185 } 48 186 #endif /* _SIGNAL_CONNECTOR_H */ -
trunk/src/lib/lang/base_object.h
r7954 r8035 12 12 #include "class_id.h" 13 13 #include "debug.h" 14 #ifndef NULL 15 #define NULL 0 //!< NULL 16 #endif 14 #include <string> 17 15 18 #include <string>19 16 #include "stdincl.h" 20 17 -
trunk/src/lib/math/rect2D.h
r7919 r8035 83 83 inline void setRight(float right) { _bottomRight.x = right; }; 84 84 /** @param topLeft the top left corner of the Rectangle */ 85 void setTopLeft(const Vector2D& topLeft) { _topLeft = topLeft; }; 85 inline void setTopLeft(const Vector2D& topLeft) { _topLeft = topLeft; }; 86 /** @param x the left border of the Rectangle @param y the top border */ 87 inline void setTopLeft(float x, float y) { this->setTopLeft(Vector2D(x,y)); }; 86 88 /** @param bottomRight the lower right corner of the Rectangle */ 87 void setBottomRight(const Vector2D& bottomRight) { _bottomRight = bottomRight; }; 89 inline void setBottomRight(const Vector2D& bottomRight) { _bottomRight = bottomRight; }; 90 /** @param x the right border of the Rectangle @param y the bottom border */ 91 inline void setBottomRight(float x, float y) { this->setBottomRight(Vector2D(x,y)); }; 88 92 89 93 void setWidth(float width); -
trunk/src/lib/math/vector.h
r7711 r8035 32 32 //! this is a small and performant 3D vector 33 33 typedef float sVec3D[3]; 34 35 36 //! small and performant 2D vector37 typedef float sVec2D[2];38 39 34 40 35 … … 101 96 inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; }; 102 97 98 /** @returns a Null Vector */ 99 inline static const Vector& nullVector() { static Vector nullVector; return nullVector; } 103 100 void debug() const; 104 101 -
trunk/src/lib/math/vector2D.h
r7919 r8035 93 93 void slerp(const Vector2D& v, float val) { *this += (*this - v) * val; } 94 94 95 /** @returns a Vector of (0,0) */ 96 static const Vector2D& nullVector() { static Vector2D nullVector; return nullVector; }; 97 95 98 void debug() const; 96 99 -
trunk/src/lib/util/executor/executor.h
r7725 r8035 38 38 class Executor : public BaseObject 39 39 { 40 public:41 virtual ~Executor();40 public: 41 virtual ~Executor(); 42 42 43 virtual Executor* clone () const = 0; 43 virtual Executor* clone () const = 0; 44 // virtual bool operator==(const Executor* executor) const = 0; 44 45 45 // SETTING up the EXECUTOR46 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,47 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,48 const MultiType& value4 = MT_NULL);49 /** @param i the i'th defaultValue, @returns reference to the MultiType */50 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };46 // SETTING up the EXECUTOR 47 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 48 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 49 const MultiType& value4 = MT_NULL); 50 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 51 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 51 52 52 // EXECUTE 53 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 54 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 55 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/ 56 void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); }; 53 // EXECUTE 54 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 55 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0; 56 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 57 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 58 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/ 59 void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); }; 57 60 58 // RETRIEVE INFORMATION59 /** @returns the Type of this Function (either static or objective) */60 inline long getType() const { return this->functorType; };61 /** @returns the Count of Parameters this Executor takes */62 inline unsigned int getParamCount() const { return this->paramCount; };63 61 64 static void debug(); 62 // RETRIEVE INFORMATION 63 /** @returns the Type of this Function (either static or objective) */ 64 inline long getType() const { return this->functorType; }; 65 /** @returns the Count of Parameters this Executor takes */ 66 inline unsigned int getParamCount() const { return this->paramCount; }; 65 67 66 protected: 67 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 68 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 69 const MultiType& param4 = MT_NULL); 68 static void debug(); 70 69 71 void cloning(Executor* executor) const; 70 protected: 71 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 72 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 73 const MultiType& param4 = MT_NULL); 72 74 73 protected: 74 short functorType; //!< The type of Function we've got (either static or objective). 75 unsigned int paramCount; //!< the count of parameters. 76 MultiType defaultValue[5]; //!< Default Values. 75 void cloning(Executor* executor) const; 76 77 protected: 78 short functorType; //!< The type of Function we've got (either static or objective). 79 unsigned int paramCount; //!< the count of parameters. 80 MultiType defaultValue[5]; //!< Default Values. 77 81 }; 78 82 -
trunk/src/lib/util/executor/executor_functional.cc
r7728 r8035 34 34 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return ExecutorFunctional_returningString_from = isString(input, defaultValue); }; 35 35 36 37 template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); }; 38 template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); } 39 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); }; 40 template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); }; 41 template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); }; 42 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); }; 43 44 36 45 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); }; 37 46 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; … … 40 49 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); }; 41 50 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_default = defaultValues[i].getString(); }; 51 52 42 53 43 54 -
trunk/src/lib/util/executor/executor_functional.h
r7725 r8035 33 33 template<> MT_Type ExecutorParamType<const std::string&>(); 34 34 35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; }; 36 36 template<> bool fromString<bool>(const std::string& input, bool defaultValue); 37 37 template<> int fromString<int>(const std::string& input, int defaultValue); … … 40 40 template<> char fromString<char>(const std::string& input, char defaultValue); 41 41 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue); 42 43 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ }; 44 template<> bool fromMulti<bool>(const MultiType& multi); 45 template<> int fromMulti<int>(const MultiType& multi); 46 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi); 47 template<> float fromMulti<float>(const MultiType& multi); 48 template<> char fromMulti<char>(const MultiType& multi); 49 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi); 50 42 51 43 52 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; }; … … 81 90 #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */ 82 91 92 /////////// 93 //// 0 //// 94 /////////// 83 95 //! @brief ExecutorClass, that can execute Functions without any parameters. 84 96 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor … … 110 122 }; 111 123 124 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 125 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 126 { 127 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); 128 } 129 112 130 /** 113 131 * @brief copies the Executor … … 120 138 }; 121 139 140 141 142 /////////// 143 //// 1 //// 144 /////////// 122 145 //! @brief ExecutorClass, that can execute Functions with one parameter. 123 146 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor … … 139 162 }; 140 163 164 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 165 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 166 { 167 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 168 fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) ); 169 } 170 171 141 172 /** 142 173 * @brief executes the Functional … … 146 177 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 147 178 { 148 149 /* // THE VERY COOL DEBUG150 printf("SUB[0] : %s\n", sub[0].c_str());151 printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));152 printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));153 */154 179 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 155 180 fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) ); … … 166 191 }; 167 192 193 /////////// 194 //// 2 //// 195 /////////// 168 196 //! @brief ExecutorClass, that can execute Functions with two parameters. 169 197 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor … … 197 225 }; 198 226 227 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 228 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 229 { 230 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 231 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 232 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) ); 233 } 234 199 235 /** 200 236 * @brief copies the Executor … … 208 244 209 245 246 /////////// 247 //// 3 //// 248 /////////// 210 249 //! @brief ExecutorClass, that can execute Functions with three parameters. 211 250 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor … … 240 279 }; 241 280 281 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 282 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 283 { 284 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 285 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 286 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 287 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) ); 288 } 289 242 290 /** 243 291 * @brief copies the Executor … … 252 300 253 301 302 /////////// 303 //// 4 //// 304 /////////// 254 305 //! @brief ExecutorClass, that can execute Functions with four parameters. 255 306 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor … … 285 336 }; 286 337 338 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 339 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 340 { 341 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 342 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 343 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 344 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 345 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) ); 346 } 347 287 348 /** 288 349 * @brief copies the Executor … … 295 356 }; 296 357 358 359 360 /////////// 361 //// 5 //// 362 /////////// 297 363 //! @brief ExecutorClass, that can execute Functions with five parameters. 298 364 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor … … 329 395 }; 330 396 397 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 398 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 399 { 400 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 401 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 402 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 403 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 404 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]), 405 fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) ); 406 } 407 331 408 /** 332 409 * @brief copies the Executor … … 344 421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 345 422 */ 346 #define EXECUTOR_FUNCTIONAL_CREATOR0( ) \347 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \423 #define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \ 424 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ 348 425 { \ 349 426 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \ … … 354 431 * @param type0 for internal usage: the first Argument 355 432 */ 356 #define EXECUTOR_FUNCTIONAL_CREATOR1( type0) \357 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \433 #define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \ 434 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 358 435 { \ 359 436 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \ … … 365 442 * @param type1 for internal usage: the second Argument 366 443 */ 367 #define EXECUTOR_FUNCTIONAL_CREATOR2( type0, type1) \368 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \444 #define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \ 445 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 369 446 { \ 370 447 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \ … … 377 454 * @param type2 for internal usage: the third Argument 378 455 */ 379 #define EXECUTOR_FUNCTIONAL_CREATOR3( type0, type1, type2) \380 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \456 #define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \ 457 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 381 458 { \ 382 459 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ … … 390 467 * @param type3 for internal usage: the fourth Argument 391 468 */ 392 #define EXECUTOR_FUNCTIONAL_CREATOR4( type0, type1, type2, type3) \393 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \469 #define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \ 470 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 394 471 { \ 395 472 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ … … 404 481 * @param type4 for internal usage: the fifth Argument 405 482 */ 406 #define EXECUTOR_FUNCTIONAL_CREATOR5( type0, type1, type2, type3, type4) \407 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \483 #define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \ 484 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 408 485 { \ 409 486 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \ -
trunk/src/lib/util/executor/executor_specials.h
r7711 r8035 67 67 } 68 68 69 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 70 { 71 72 } 73 69 74 private: 70 75 /** -
trunk/src/lib/util/executor/functor_list.h
r7785 r8035 90 90 #ifdef FUNCTOR_LIST 91 91 92 FUNCTOR_LIST(0)( );92 FUNCTOR_LIST(0)(void); 93 93 //! makes functions with one string 94 FUNCTOR_LIST(1)( l_STRING);94 FUNCTOR_LIST(1)(void, l_STRING); 95 95 //! makes functions with two strings 96 FUNCTOR_LIST(2)( l_STRING, l_STRING);96 FUNCTOR_LIST(2)(void, l_STRING, l_STRING); 97 97 //! makes functions with three strings 98 FUNCTOR_LIST(3)( l_STRING, l_STRING, l_STRING);98 FUNCTOR_LIST(3)(void, l_STRING, l_STRING, l_STRING); 99 99 //! makes functions with four strings 100 FUNCTOR_LIST(4)( l_STRING, l_STRING, l_STRING, l_STRING);100 FUNCTOR_LIST(4)(void, l_STRING, l_STRING, l_STRING, l_STRING); 101 101 102 102 103 103 //! makes functions with one bool 104 FUNCTOR_LIST(1)( l_BOOL);104 FUNCTOR_LIST(1)(void, l_BOOL); 105 105 106 106 //! makes functions with one int 107 FUNCTOR_LIST(1)( l_INT);107 FUNCTOR_LIST(1)(void, l_INT); 108 108 //! makes functions with two ints 109 FUNCTOR_LIST(2)( l_INT, l_INT);109 FUNCTOR_LIST(2)(void, l_INT, l_INT); 110 110 //! makes functions with three ints 111 FUNCTOR_LIST(3)( l_INT, l_INT, l_INT);111 FUNCTOR_LIST(3)(void, l_INT, l_INT, l_INT); 112 112 //! makes functions with four ints 113 FUNCTOR_LIST(4)( l_INT, l_INT, l_INT, l_INT);113 FUNCTOR_LIST(4)(void, l_INT, l_INT, l_INT, l_INT); 114 114 115 115 116 116 //! makes functions with one unsigned int 117 FUNCTOR_LIST(1)( l_UINT);117 FUNCTOR_LIST(1)(void, l_UINT); 118 118 //! makes functions with two unsigned ints 119 FUNCTOR_LIST(2)( l_UINT, l_UINT);119 FUNCTOR_LIST(2)(void, l_UINT, l_UINT); 120 120 //! makes functions with three unsigned ints 121 FUNCTOR_LIST(3)( l_UINT, l_UINT, l_UINT);121 FUNCTOR_LIST(3)(void, l_UINT, l_UINT, l_UINT); 122 122 //! makes functions with four unsigned ints 123 FUNCTOR_LIST(4)( l_UINT, l_UINT, l_UINT, l_UINT);123 FUNCTOR_LIST(4)(void, l_UINT, l_UINT, l_UINT, l_UINT); 124 124 125 125 //! makes functions with one float 126 FUNCTOR_LIST(1)( l_FLOAT);126 FUNCTOR_LIST(1)(void, l_FLOAT); 127 127 //! makes functions with two floats 128 FUNCTOR_LIST(2)( l_FLOAT, l_FLOAT);128 FUNCTOR_LIST(2)(void, l_FLOAT, l_FLOAT); 129 129 //! makes functions with three floats 130 FUNCTOR_LIST(3)( l_FLOAT, l_FLOAT, l_FLOAT);130 FUNCTOR_LIST(3)(void, l_FLOAT, l_FLOAT, l_FLOAT); 131 131 //! makes functions with four floats 132 FUNCTOR_LIST(4)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);132 FUNCTOR_LIST(4)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT); 133 133 //! makes functions with four floats 134 FUNCTOR_LIST(5)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);134 FUNCTOR_LIST(5)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT); 135 135 136 136 //! mixed values: 137 FUNCTOR_LIST(2)( l_STRING, l_FLOAT);138 FUNCTOR_LIST(2)( l_UINT, l_LONG);139 FUNCTOR_LIST(2)( l_STRING, l_UINT);137 FUNCTOR_LIST(2)(void, l_STRING, l_FLOAT); 138 FUNCTOR_LIST(2)(void, l_UINT, l_LONG); 139 FUNCTOR_LIST(2)(void, l_STRING, l_UINT); 140 140 141 FUNCTOR_LIST(3)( l_STRING, l_FLOAT, l_UINT);142 FUNCTOR_LIST(4)( l_STRING, l_FLOAT, l_UINT, l_UINT);143 FUNCTOR_LIST(3)( l_STRING, l_INT, l_UINT);144 FUNCTOR_LIST(3)( l_STRING, l_UINT, l_UINT);141 FUNCTOR_LIST(3)(void, l_STRING, l_FLOAT, l_UINT); 142 FUNCTOR_LIST(4)(void, l_STRING, l_FLOAT, l_UINT, l_UINT); 143 FUNCTOR_LIST(3)(void, l_STRING, l_INT, l_UINT); 144 FUNCTOR_LIST(3)(void, l_STRING, l_UINT, l_UINT); 145 145 146 146 #endif /* FUNCTOR_LIST */ -
trunk/src/lib/util/multi_type.cc
r7401 r8035 39 39 switch (this->type) 40 40 { 41 41 default: 42 42 this->value.Float = 0.0f; 43 43 break; 44 44 case MT_BOOL: 45 45 this->value.Bool = false; 46 46 break; 47 47 case MT_INT: 48 48 this->value.Int = 0; 49 49 break; 50 50 case MT_FLOAT: 51 51 this->value.Float = 0.0f; 52 52 break; 53 53 case MT_CHAR: 54 54 this->value.Char = '\0'; 55 55 break; 56 56 case MT_STRING: 57 57 this->storedString = ""; 58 58 break; … … 148 148 switch (this->type) 149 149 { 150 150 case MT_NULL: 151 151 return true; 152 152 case MT_BOOL: 153 153 return (this->value.Bool == mt.value.Bool); 154 154 case MT_INT: 155 155 return (this->value.Int == mt.value.Int); 156 156 case MT_CHAR: 157 157 return (this->value.Char == mt.value.Char); 158 158 case MT_FLOAT: 159 159 return (this->value.Float == mt.value.Float); 160 160 case MT_STRING: 161 161 return (this->storedString == mt.storedString); 162 162 } … … 175 175 switch (type) 176 176 { 177 177 case MT_BOOL: 178 178 this->setBool(this->getBool()); 179 179 break; 180 180 case MT_INT: 181 181 this->setInt(this->getInt()); 182 182 break; 183 183 case MT_FLOAT: 184 184 this->setFloat(this->getFloat()); 185 185 break; 186 186 case MT_CHAR: 187 187 this->setChar(this->getChar()); 188 188 break; 189 189 case MT_STRING: 190 190 this->setString(this->getString()); 191 191 break; … … 382 382 383 383 /** 384 * @brief returns a Constant string (actually this is slower than getString() 385 * @returns a constant string of the stored version's one. 386 * @note this could lead to a inconsistency of data 387 */ 388 const std::string& MultiType::getConstString() const 389 { 390 391 MultiType::constString = this->getString(); 392 return MultiType::constString; 393 } 394 395 396 /** 384 397 * @returns a formated c-string of the held value 385 398 */ … … 422 435 switch ( this->type ) 423 436 { 424 437 case MT_BOOL: 425 438 this->setBool(false); 426 439 break; 427 440 case MT_INT: 428 441 this->setInt(0); 429 442 break; 430 443 case MT_FLOAT: 431 444 this->setFloat(0.0f); 432 445 break; 433 446 case MT_CHAR: 434 447 this->setChar('\0'); 435 448 break; 436 449 case MT_STRING: 437 450 this->setString(""); 438 451 break; 439 452 default: 440 453 #ifdef DEBUG 441 454 PRINTF(2)("Unknown Type not reseting\n"); … … 454 467 switch ( type ) 455 468 { 456 469 case MT_BOOL: 457 470 return MultiType::typeNames[1]; 458 471 case MT_INT: 459 472 return MultiType::typeNames[2]; 460 473 case MT_FLOAT: 461 474 return MultiType::typeNames[3]; 462 475 case MT_CHAR: 463 476 return MultiType::typeNames[4]; 464 477 case MT_STRING: 465 478 return MultiType::typeNames[5]; 466 479 } … … 490 503 491 504 505 std::string MultiType::constString = ""; 492 506 const std::string MultiType::typeNames[] = 493 507 { -
trunk/src/lib/util/multi_type.h
r7401 r8035 87 87 const char* getCString(); 88 88 std::string getString() const; 89 const std::string& getConstString() const; 89 90 90 91 void reset(); … … 107 108 MT_Type type; //!< The Type stored in this MultiType 108 109 110 111 static std::string constString; //!< A String for returning Constant strings. 112 109 113 static const std::string typeNames[]; //!< List of TypeNames for conversion. 110 114 };
Note: See TracChangeset
for help on using the changeset viewer.