Changeset 7919 in orxonox.OLD for trunk/src/lib/gui
- Timestamp:
- May 28, 2006, 3:48:13 PM (19 years ago)
- Location:
- trunk/src/lib/gui/gl_gui
- Files:
-
- 22 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl_gui/Makefile.am
r7855 r7919 9 9 10 10 11 libORXglgui_a_SOURCES = glmenu/glmenu_imagescreen.cc \ 12 glgui_handler.cc \ 13 signal_connector.cc \ 14 glgui_mainwidget.cc \ 15 glgui_widget.cc \ 16 glgui_button.cc \ 17 glgui_pushbutton.cc \ 18 glgui_container.cc \ 19 glgui_bar.cc \ 20 glgui_box.cc \ 21 glgui_frame.cc \ 22 glgui_window.cc 11 libORXglgui_a_SOURCES = \ 12 glmenu/glmenu_imagescreen.cc \ 13 glgui_handler.cc \ 14 signal_connector.cc \ 15 glgui_mainwidget.cc \ 16 glgui_widget.cc \ 17 glgui_button.cc \ 18 glgui_pushbutton.cc \ 19 glgui_checkbutton.cc \ 20 glgui_slider.cc \ 21 glgui_container.cc \ 22 glgui_bar.cc \ 23 glgui_box.cc \ 24 glgui_frame.cc \ 25 glgui_inputline.cc \ 26 glgui_textfield.cc \ 27 glgui_window.cc \ 28 glgui_cursor.cc 23 29 24 30 25 noinst_HEADERS= glmenu/glmenu_imagescreen.h \ 31 noinst_HEADERS= \ 32 glmenu/glmenu_imagescreen.h \ 26 33 signal_connector.h \ 27 34 glgui.h \ 35 glgui_defs.h \ 28 36 glgui_handler.h \ 29 37 glgui_mainwidget.h \ … … 31 39 glgui_button.h \ 32 40 glgui_pushbutton.h \ 41 glgui_checkbutton.h \ 42 glgui_slider.h \ 33 43 glgui_container.h \ 34 44 glgui_bar.h \ 35 45 glgui_box.h \ 36 46 glgui_frame.h \ 37 glgui_window.h 47 glgui_inputline.h \ 48 glgui_textfield.h \ 49 glgui_window.h \ 50 glgui_cursor.h 38 51 39 52 -
trunk/src/lib/gui/gl_gui/glgui.h
r7855 r7919 6 6 #ifndef _GLGUI_H 7 7 #define _GLGUI_H 8 9 #include "glgui_handler.h" 10 8 11 #include "glgui_widget.h" 9 12 … … 12 15 #include "glgui_button.h" 13 16 #include "glgui_checkbutton.h" 14 #include "glgui_colorselector.h" 15 16 namespace OrxGui 17 { 17 //#include "glgui_colorselector.h" 18 #include "glgui_pushbutton.h" 19 #include "glgui_cursor.h" 20 #include "glgui_inputline.h" 21 #include "glgui_textfield.h" 18 22 19 23 20 }; 21 22 23 24 25 26 #endif _GLGUI_H 24 #endif /* _GLGUI_H */ -
trunk/src/lib/gui/gl_gui/glgui_bar.cc
r7779 r7919 46 46 this->setClassID(CL_GLGUI_BAR, "GLGuiBar"); 47 47 48 this->frontMat .setDiffuse(1,1,1);48 this->frontMaterial().setDiffuse(1,1,1); 49 49 50 50 this->setSize2D(50, 10); … … 64 64 GLGuiWidget::draw(); 65 65 66 this->frontMat .select();66 this->frontMaterial().select(); 67 67 glBegin(GL_QUADS); 68 68 -
trunk/src/lib/gui/gl_gui/glgui_button.cc
r7779 r7919 26 26 * standard constructor 27 27 */ 28 GLGuiButton::GLGuiButton ( )28 GLGuiButton::GLGuiButton (const std::string& label) 29 29 { 30 30 this->init(); 31 31 32 this->label.setText( label ); 32 33 } 33 34 … … 45 46 46 47 /** 47 * initializes the GUI-element48 * @brief initializes the GUI-element 48 49 */ 49 50 void GLGuiButton::init() 50 51 { 51 52 this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton"); 53 this->setFocusable(true); 54 this->setClickable(true); 52 55 53 this->label = new Text(); 54 this->label->setParent2D(this); 56 this->label.setFont("fonts/final_frontier.ttf", 20); 57 this->frontMaterial().setDiffuse(1, 0, 0); 58 59 this->label.setParent2D(this); 55 60 } 61 56 62 57 63 void GLGuiButton::setLabel(const std::string& label) 58 64 { 59 this->label->setText(label); 60 this->label->setRelCoor2D(5, 5); 61 this->setSize2D(this->label->getSizeX2D()+10, this->label->getSizeY2D()+10); 65 this->label.setText(label); 66 this->resize(); 62 67 } 63 68 64 65 69 /** 66 * draws the GLGuiButton70 * @brief draws the GLGuiButton 67 71 */ 68 72 void GLGuiButton::draw() const -
trunk/src/lib/gui/gl_gui/glgui_button.h
r7779 r7919 10 10 #include "glgui_widget.h" 11 11 12 class Text; 12 #include "text.h" 13 13 14 14 namespace OrxGui … … 27 27 //! This is part of the openglGUI class 28 28 /** 29 * 29 * The Button is an Abstract class, that can be pushed to Toggle its state. 30 30 */ 31 31 class GLGuiButton : public GLGuiWidget … … 33 33 34 34 public: 35 GLGuiButton( );35 GLGuiButton(const std::string& label); 36 36 virtual ~GLGuiButton(); 37 37 38 void init();38 const std::string& getLabel() const { return this->label.getText(); }; 39 39 void setLabel(const std::string& label); 40 41 virtual void resize() = 0; 40 42 41 43 virtual void draw() const; 42 44 45 private: 46 void init(); 47 48 43 49 protected: 44 Text* label; 50 51 Text label; 45 52 46 53 private: -
trunk/src/lib/gui/gl_gui/glgui_checkbutton.cc
r7779 r7919 27 27 * standard constructor 28 28 */ 29 GLGuiCheckButton::GLGuiCheckButton () 29 GLGuiCheckButton::GLGuiCheckButton (const std::string& label, bool active) 30 : GLGuiButton(label) 30 31 { 31 32 this->init(); 33 this->bActive = active; 32 34 35 this->resize(); 33 36 } 34 37 … … 44 47 * initializes the GUI-element 45 48 */ 46 GLGuiCheckButton::init()49 void GLGuiCheckButton::init() 47 50 { 48 51 this->setClassID(CL_GLGUI_CHECKBUTTON, "GLGuiCheckButton"); 52 } 49 53 54 55 void GLGuiCheckButton::toggleActiveState() 56 { 57 this->bActive = !this->bActive; 58 } 59 60 void GLGuiCheckButton::resize() 61 { 62 this->label.setRelCoor2D(25, 5); 63 this->setSize2D(this->label.getSizeX2D() + 30, this->label.getSizeY2D() + 10); 64 } 65 66 67 void GLGuiCheckButton::released() 68 { 69 printf("%s released\n", this->getLabel().c_str()); 70 GLGuiWidget::released(); 71 this->toggleActiveState(); 50 72 } 51 73 52 74 /** 53 * draws the GLGuiCheckButton75 * @brief draws the GLGuiPushButton 54 76 */ 55 77 void GLGuiCheckButton::draw() const 56 78 { 79 this->startDraw(); 80 GLGuiButton::draw(); 81 82 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); 89 90 if (this->bActive) 91 { 92 glColor3f( 1, 1 ,1); 93 glTexCoord2i(0,0); glVertex2d(8, 8); 94 glTexCoord2i(0,1); glVertex2d(8, this->getSizeY2D()-8); 95 glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8, this->getSizeY2D()-8); 96 glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8, 8); 97 glEnd(); 98 99 100 // DRAW a cross :) 101 glColor3f(0,0,0); 102 glLineWidth(3.0); 103 glBegin(GL_LINE_LOOP); 104 glVertex2d(8,8); 105 glVertex2d(this->getSizeY2D()/2, this->getSizeY2D()/2 - 1); 106 107 glVertex2d(this->getSizeY2D() -8, 8); 108 glVertex2d(this->getSizeY2D()/2 +1, this->getSizeY2D()/2); 109 110 glVertex2d(this->getSizeY2D() -8, this->getSizeY2D() - 8); 111 glVertex2d(this->getSizeY2D()/2, this->getSizeY2D()/2+1); 112 113 glVertex2d(8, this->getSizeY2D() - 8); 114 glVertex2d(this->getSizeY2D()/2 -1, this->getSizeY2D()/2); 115 glEnd(); 116 } 117 else 118 { 119 glColor3f(0, 0, 0); 120 glTexCoord2i(0,0); glVertex2d(8, 8); 121 glTexCoord2i(0,1); glVertex2d(8, this->getSizeY2D()-8); 122 glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8, this->getSizeY2D()-8); 123 glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8, 8); 124 glEnd(); 125 } 126 127 128 this->endDraw(); 129 // this->label->draw(); 130 // printf("test"); 57 131 } 58 132 } -
trunk/src/lib/gui/gl_gui/glgui_checkbutton.h
r7779 r7919 6 6 7 7 #ifndef _GLGUI_CHECKBUTTON_H 8 #define _GLGUI_ _H8 #define _GLGUI_CHECKBUTTON_H 9 9 10 10 #include "glgui_button.h" … … 23 23 24 24 public: 25 GLGuiCheckButton( );25 GLGuiCheckButton(const std::string& label = "", bool active = false); 26 26 virtual ~GLGuiCheckButton(); 27 27 28 void init(); 28 virtual void resize(); 29 virtual void released(); 29 30 30 31 bool isActive() { return this->bActive; }; 31 32 void setActivity(bool bActive); 33 void toggleActiveState(); 32 34 33 35 virtual void draw() const; 34 36 virtual void update() {}; 37 38 private: 39 void init(); 40 35 41 36 42 private: -
trunk/src/lib/gui/gl_gui/glgui_colorselector.h
r7779 r7919 5 5 */ 6 6 7 #ifndef _GLGUI_ _H8 #define _GLGUI_ _H7 #ifndef _GLGUI_COLORSELECTOR_H 8 #define _GLGUI_COLORSELECTOR_H 9 9 10 #include " base_object.h"10 #include "glgui_widget.h" 11 11 12 12 namespace OrxGui -
trunk/src/lib/gui/gl_gui/glgui_cursor.cc
r7779 r7919 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI 17 17 18 #include "glgui_.h" 18 #include "glgui_cursor.h" 19 20 #include "glgui_handler.h" 21 #include "color.h" 22 19 23 20 24 namespace OrxGui … … 24 28 * standard constructor 25 29 */ 26 GLGui ::GLGui()30 GLGuiCursor::GLGuiCursor () 27 31 { 28 32 this->init(); 33 34 this->subscribeEvent(ES_MENU, EV_MOUSE_MOTION); 35 this->subscribeEvent(ES_MENU, EV_WINDOW_FOCUS); 36 29 37 30 38 } … … 32 40 33 41 /** 34 * standard deconstructor35 */36 GLGui ::~GLGui()42 * @brief standard deconstructor 43 */ 44 GLGuiCursor::~GLGuiCursor() 37 45 { 46 GLGuiHandler::getInstance()->deactivateCursor(false); 47 } 48 49 float GLGuiCursor::_mouseSensitivity = 1.0; 50 51 52 /** 53 * @brief initializes the GUI-element 54 */ 55 void GLGuiCursor::init() 56 { 57 this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor"); 58 59 this->backMaterial().setDiffuse(1.0,0.0,0.0); 60 this->backMaterial().setDiffuseMap("cursor.png"); 61 this->setSize2D(10, 20); 62 this->setAbsCoor2D(100, 100); 63 this->setLayer(E2D_LAYER_ABOVE_ALL); 64 this->color = 0.0f; 65 66 } 67 68 void GLGuiCursor::tick(float dt) 69 { 70 this->color += dt*10.0; 71 if (this->color > 360.0) 72 this->color -= 360.0; 73 Vector color = Color::HSVtoRGB(Vector(this->color, 1.0, 1.0)); 74 this->backMaterial().setDiffuse(color.x, color.y, color.z); 75 76 if (this->movement != Vector2D()) 77 { 78 newPos += movement; 79 // reposition the cursor. 80 if (newPos.x < 0.0f ) 81 newPos.x = 0.0f; 82 if (newPos.x > this->_maxBorders.x) 83 newPos.x = this->_maxBorders.x; 84 if (newPos.y < 0.0f ) 85 newPos.y = 0.0f; 86 if (newPos.y > this->_maxBorders.y) 87 newPos.y = this->_maxBorders.y; 88 89 90 this->setAbsCoorSoft2D(newPos, 10); 91 movement = Vector2D(); 92 } 38 93 } 39 94 40 95 /** 41 * initializes the GUI-element96 * @brief draws the GLGuiCursor 42 97 */ 43 GLGui::init()98 void GLGuiCursor::draw() const 44 99 { 45 this->setClassID(CL_GLGUI_, "GLGui"); 46 100 this->startDraw(); 101 GLGuiWidget::draw(); 102 this->endDraw(); 47 103 } 48 104 49 /** 50 * draws the GLGui 51 */ 52 void GLGui::draw() 105 void GLGuiCursor::process(const Event& event) 53 106 { 107 switch (event.type) 108 { 109 case EV_WINDOW_FOCUS: 110 if (event.bPressed) 111 { 112 int mouseX, mouseY; 113 SDL_GetMouseState(&mouseX, &mouseY); 114 newPos = Vector2D(mouseX, mouseY); 115 } 116 break; 117 case EV_MOUSE_MOTION: 118 movement += Vector2D((float)event.xRel * _mouseSensitivity, (float)event.yRel * _mouseSensitivity); 119 break; 120 121 } 54 122 } 55 123 } -
trunk/src/lib/gui/gl_gui/glgui_cursor.h
r7779 r7919 1 1 /*! 2 * @file glgui_ .h3 * The gl_ widget of th openglGUI2 * @file glgui_cursor.h 3 * The gl_cursor widget of th openglGUI 4 4 * 5 5 */ 6 6 7 #ifndef _GLGUI_ _H8 #define _GLGUI_ _H7 #ifndef _GLGUI_CURSOR_H 8 #define _GLGUI_CURSOR_H 9 9 10 #include "base_object.h" 10 #include "glgui_widget.h" 11 #include "event_listener.h" 12 #include "vector2D.h" 11 13 12 14 namespace OrxGui … … 18 20 * 19 21 */ 20 class GLGui : public GLGui22 class GLGuiCursor : public GLGuiWidget, public EventListener 21 23 { 22 24 23 25 public: 24 GLGui(); 25 virtual ~GLGui(); 26 GLGuiCursor(); 27 virtual ~GLGuiCursor(); 28 29 static void setMouseSensitivity(float mouseSensitivity); 30 static float mouseSensitivity() { return GLGuiCursor::_mouseSensitivity; }; 31 32 void setMaxBorders(const Vector2D& maxBorders) { this->_maxBorders = maxBorders; }; 26 33 27 34 void init(); 35 const Vector2D& position() const { return Element2D::getAbsCoor2D(); } 28 36 29 virtual void draw();30 37 38 virtual void tick(float dt); 39 virtual void draw() const; 40 virtual void process(const Event& event); 31 41 private: 42 43 Vector2D _maxBorders; 44 45 Vector2D newPos; 46 Vector2D movement; 47 48 float color; // so f****ing temporary... ... .... 49 50 static float _mouseSensitivity; 32 51 33 52 }; 34 53 } 35 #endif /* _GLGUI_ _H */54 #endif /* _GLGUI_CURSOR_H */ -
trunk/src/lib/gui/gl_gui/glgui_handler.cc
r7868 r7919 20 20 21 21 #include "glgui_mainwidget.h" 22 #include "glgui_cursor.h" 23 24 #include "class_list.h" 25 26 27 /// TAKE THIS OUT OF HERE. 28 #include "graphics_engine.h" 22 29 23 30 namespace OrxGui … … 32 39 this->setName("GLGuiHandler"); 33 40 34 //this->subscribeEvent()35 41 42 EventHandler::getInstance()->withUNICODE(ES_MENU, true ); 43 44 this->cursor = NULL; 45 for (unsigned int i = 0; i < EV_NUMBER; i++) 46 { 47 this->subscribeEvent(ES_MENU, i); 48 } 36 49 } 37 50 … … 49 62 } 50 63 64 void GLGuiHandler::activateCursor() 65 { 66 if (this->cursor == NULL) 67 this->cursor = new GLGuiCursor(); 68 this->cursor->show(); 69 this->cursor->setMaxBorders(Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY())); 70 } 71 72 void GLGuiHandler::deactivateCursor(bool deleteCursor) 73 { 74 if (this->cursor) 75 { 76 if (deleteCursor) 77 delete this->cursor; 78 this->cursor = NULL; 79 } 80 } 81 82 51 83 void GLGuiHandler::activate() 52 84 { 53 85 EventHandler::getInstance()->pushState(ES_MENU); 86 87 54 88 55 89 } … … 59 93 EventHandler::getInstance()->popState(); 60 94 95 61 96 } 62 97 … … 64 99 void GLGuiHandler::process(const Event &event) 65 100 { 101 switch (event.type) 102 { 103 case EV_MOUSE_BUTTON_LEFT: 104 if (GLGuiWidget::focused() != NULL) 105 { 106 if (event.bPressed) 107 { 108 if (GLGuiWidget::focused()->clickable()) 109 GLGuiWidget::focused()->click(); 110 } 111 else 112 { 113 if (GLGuiWidget::focused()->clickable()) 114 GLGuiWidget::focused()->release(); 115 } 116 } 117 break; 118 case EV_LEAVE_STATE: 119 if (GLGuiWidget::focused() != NULL) 120 GLGuiWidget::focused()->breakFocus(); 121 break; 122 123 case EV_VIDEO_RESIZE: 124 if (this->cursor != NULL) 125 this->cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h)); 126 break; 127 } 128 129 130 131 if (GLGuiWidget::focused()) 132 { 133 GLGuiWidget::focused()->processEvent(event); 134 } 135 66 136 67 137 … … 70 140 void GLGuiHandler::draw() 71 141 { 72 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);142 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP); 73 143 } 74 144 … … 76 146 void GLGuiHandler::tick(float dt) 77 147 { 148 149 // CHECK THE COLLISIONS. 150 const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET); 151 152 if (objects != NULL && this->cursor != NULL) 153 { 154 for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++) 155 { 156 GLGuiWidget* widget = dynamic_cast<GLGuiWidget*>(*it); 157 158 if (widget->isVisible() && 159 widget->focusable() && 160 widget->focusOverWidget(this->cursor)) 161 { 162 // receiving Focus 163 if (GLGuiWidget::focused() != widget) 164 { 165 widget->giveFocus(); 166 } 167 return ; 168 } 169 } 170 if (GLGuiWidget::focused() != NULL) 171 GLGuiWidget::focused()->breakFocus(); 172 } 78 173 } 79 174 } -
trunk/src/lib/gui/gl_gui/glgui_handler.h
r7779 r7919 8 8 9 9 #include "event_listener.h" 10 #include "glgui_widget.h" 10 11 11 12 namespace OrxGui 12 13 { 14 15 class GLGuiCursor; 16 13 17 // FORWARD DECLARATION 14 18 … … 21 25 /** @returns a Pointer to the only object of this Class */ 22 26 inline static GLGuiHandler* getInstance(void) { if (!GLGuiHandler::singletonRef) GLGuiHandler::singletonRef = new GLGuiHandler(); return GLGuiHandler::singletonRef; }; 27 28 void activateCursor(); 29 void deactivateCursor(/** ignore param */ bool deleteCursor = true); 30 GLGuiCursor* getCursor() const { return this->cursor; } 23 31 24 32 void activate(); … … 36 44 37 45 bool isActive; 46 GLGuiCursor* cursor; 47 38 48 }; 39 49 } -
trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc
r7779 r7919 25 25 26 26 /** 27 * standard constructor 28 */ 29 GLGuiPushButton::GLGuiPushButton () 27 * @brief standard constructor 28 */ 29 GLGuiPushButton::GLGuiPushButton (const std::string& label) 30 : GLGuiButton(label) 30 31 { 31 32 this->init(); 33 34 this->resize(); 32 35 } 33 36 34 37 35 38 /** 36 * standard deconstructor39 * @brief standard deconstructor 37 40 */ 38 41 GLGuiPushButton::~GLGuiPushButton() 39 42 { 43 } 44 45 void GLGuiPushButton::resize() 46 { 47 this->label.setRelCoor2D(5, 5); 48 this->setSize2D(this->label.getSizeX2D() + 10, this->label.getSizeY2D() + 10); 40 49 } 41 50 … … 46 55 { 47 56 this->setClassID(CL_GLGUI_PUSHBUTTON, "GLGuiPushButton"); 48 this->frontMat.setDiffuse(1,0,0);49 // this->label->setRelCoor2D(10, 10);50 57 } 51 58 59 void GLGuiPushButton::receivedFocus() 60 { 61 printf("%s received focus\n", this->getLabel().c_str()); 62 GLGuiWidget::receivedFocus(); 63 } 64 65 void GLGuiPushButton::removedFocus() 66 { 67 printf("%s removed focus\n", this->getLabel().c_str()); 68 GLGuiWidget::removedFocus(); 69 70 } 71 72 void GLGuiPushButton::clicked() 73 { 74 printf("%s clicked\n", this->getLabel().c_str()); 75 GLGuiWidget::clicked(); 76 } 77 78 79 void GLGuiPushButton::released() 80 { 81 printf("%s released\n", this->getLabel().c_str()); 82 GLGuiWidget::released(); 83 } 84 85 86 52 87 /** 53 * draws the GLGuiPushButton88 * @brief draws the GLGuiPushButton 54 89 */ 55 90 void GLGuiPushButton::draw() const 56 91 { 57 92 this->startDraw(); 93 GLGuiButton::draw(); 58 94 59 // GLGuiButton::draw(); 60 61 this->frontMat.select(); 95 this->frontMaterial().select(); 62 96 glBegin(GL_QUADS); 63 97 64 gl Vertex2d(0,0);65 gl Vertex2d(0, this->getSizeY2D());66 gl Vertex2d(this->getSizeX2D(), this->getSizeY2D());67 gl Vertex2d(this->getSizeX2D(),0);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); 68 102 69 103 glEnd(); 70 71 104 this->endDraw(); 72 105 // this->label->draw(); -
trunk/src/lib/gui/gl_gui/glgui_pushbutton.h
r7779 r7919 23 23 24 24 public: 25 GLGuiPushButton( );25 GLGuiPushButton(const std::string& label = ""); 26 26 virtual ~GLGuiPushButton(); 27 27 28 void init(); 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 virtual void draw() const; 31 38 virtual void update(); 32 39 private: 40 void init(); 33 41 34 42 }; -
trunk/src/lib/gui/gl_gui/glgui_slider.cc
r7779 r7919 50 50 * draws the GLGuiSlider 51 51 */ 52 void GLGuiSlider::draw() 52 void GLGuiSlider::draw() const 53 53 { 54 54 } -
trunk/src/lib/gui/gl_gui/glgui_slider.h
r7779 r7919 8 8 #define _GLGUI_SLIDER_H 9 9 10 #include " base_object.h"11 10 #include "glgui_widget.h" 11 #include "glgui_defs.h" 12 12 13 13 namespace OrxGui … … 19 19 * 20 20 */ 21 class GLGuiSlider : public GLGui Slider21 class GLGuiSlider : public GLGuiWidget 22 22 { 23 23 … … 28 28 void init(); 29 29 30 virtual void draw() ;30 virtual void draw() const; 31 31 32 32 private: 33 Orientation orientation; 34 35 float _maxValue; 36 float _minValue; 37 38 float _value; 33 39 34 40 }; -
trunk/src/lib/gui/gl_gui/glgui_textfield.cc
r7779 r7919 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI 17 17 18 #include "glgui_textfield _.h"18 #include "glgui_textfield.h" 19 19 namespace OrxGui 20 20 { … … 42 42 void GLGuiTextfield::init() 43 43 { 44 this->setClassID(CL_GLGUI_, "GLGuiTextfield"); 44 this->setClassID(CL_GLGUI_TEXTFIELD, "GLGuiTextfield"); 45 45 46 46 47 } … … 49 50 * draws the GLGuiTextfield 50 51 */ 51 void GLGuiTextfield::draw() 52 void GLGuiTextfield::draw() const 52 53 { 53 54 } -
trunk/src/lib/gui/gl_gui/glgui_textfield.h
r7779 r7919 9 9 10 10 #include "glgui_widget.h" 11 12 #include "text.h" 13 #include <vector> 11 14 12 15 // FORWARD DECLARATION … … 28 31 void init(); 29 32 30 virtual void draw(); 33 void process(const Event& event); 34 35 virtual void draw() const; 31 36 32 37 private: 33 std:: list<Text*>textLines;38 std::vector<Text> textLines; 34 39 35 40 }; -
trunk/src/lib/gui/gl_gui/glgui_widget.cc
r7855 r7919 18 18 #include "glgui_widget.h" 19 19 20 #include "glgui_cursor.h" 21 20 22 #include "material.h" 21 23 … … 39 41 GLGuiWidget::~GLGuiWidget() 40 42 { 41 } 43 if (this == GLGuiWidget::_focused) 44 GLGuiWidget::_focused = NULL; 45 } 46 47 GLGuiWidget* GLGuiWidget::_focused = NULL; 48 GLGuiWidget* GLGuiWidget::_inputGrabber = NULL; 49 42 50 43 51 … … 49 57 this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget"); 50 58 51 this->focusable = true; 52 this->clickable = true; 59 this->_focusable = false; 60 this->_clickable = false; 61 this->_pushed = false; 62 53 63 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 54 // this->setParent2D((Element2D*)NULL);55 64 56 65 this->backMat.setDiffuse(1.0, 1.0, 1.0); 57 58 this->frontModel = 0; 66 this->frontMat.setDiffuse(1.0, 0.0, 0.0); 59 67 60 68 this->widgetSignals.resize(SignalCount, SignalConnector()); … … 62 70 63 71 64 bool GLGuiWidget::focusOverWidget(float x, float y) 65 { 66 if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x && 67 this->getAbsCoor2D().y < y && this->getAbsCoor2D().y + this->getSizeY2D() > y) 68 return true; 69 else 70 return false; 71 } 72 /** @brief gives focus to this widget */ 73 void GLGuiWidget::giveFocus() 74 { 75 if (GLGuiWidget::focused() != NULL) 76 GLGuiWidget::focused()->breakFocus(); 77 GLGuiWidget::_focused = this; 78 this->receivedFocus(); 79 }; 80 81 void GLGuiWidget::breakFocus() 82 { 83 if (GLGuiWidget::_focused == this) 84 { 85 GLGuiWidget::_focused = NULL; 86 this->_pushed = false; 87 this->removedFocus(); 88 } 89 }; 90 91 92 bool GLGuiWidget::focusOverWidget(const Vector2D& position) const 93 { 94 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); 96 } 97 98 bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const 99 { 100 return this->focusOverWidget(cursor->getAbsCoor2D()); 101 } 102 103 void GLGuiWidget::click() 104 { 105 assert (!this->_pushed); 106 this->widgetSignals[Signal_click]("none"); 107 this->_pushed = true; 108 109 this->clicked(); 110 } 111 112 void GLGuiWidget::release() 113 { 114 if (this->_pushed) 115 { 116 this->widgetSignals[Signal_release]("none"); 117 118 this->released(); 119 this->_pushed = false; 120 } 121 } 122 123 124 void GLGuiWidget::clicked() 125 { 126 this->frontMaterial().setDiffuse(0, 0, 1); 127 128 } 129 130 void GLGuiWidget::released() 131 { 132 this->frontMat.setDiffuse(0,1,0); 133 134 } 135 136 void GLGuiWidget::receivedFocus() 137 { 138 this->frontMaterial().setDiffuse(0, 1, 0); 139 } 140 141 void GLGuiWidget::removedFocus() 142 { 143 this->frontMaterial().setDiffuse(1, 0, 0); 144 145 } 146 147 void GLGuiWidget::destroyed() 148 { 149 }; 150 151 152 72 153 73 154 /** … … 116 197 117 198 glBegin(GL_QUADS); 118 glTexCoord2i(0, 1); glVertex2d(0, 0);119 glTexCoord2i(0, 0); glVertex2d(0, this->getSizeY2D());120 glTexCoord2i(1, 0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());121 glTexCoord2i(1, 1); glVertex2d(this->getSizeX2D(), 0);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); 122 203 glEnd(); 123 204 } -
trunk/src/lib/gui/gl_gui/glgui_widget.h
r7868 r7919 8 8 9 9 #include "element_2d.h" 10 #include "event.h" 10 #include "rect2D.h" 11 11 12 #include "material.h" 12 13 14 #include "event.h" 15 #include "signal_connector.h" 16 13 17 #include "glincl.h" 14 #include "signal_connector.h" 18 19 #include <vector> 15 20 16 21 // FORWARD DECLARATION … … 19 24 namespace OrxGui 20 25 { 21 22 26 typedef enum 23 27 { … … 34 38 35 39 40 class GLGuiCursor; 41 36 42 //! if the Element should be visible by default. 37 43 #define GLGUI_WIDGET_DEFAULT_VISIBLE false … … 43 49 class GLGuiWidget : public Element2D 44 50 { 51 45 52 private: 46 53 … … 52 59 void hide(); 53 60 61 /// INTERCONNECTIVITY 54 62 void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal); 55 63 void disconnectSignal(SignalType signalType); 56 bool focusOverWidget(float x, float y);57 64 65 66 /// FOCUS 67 /** @brief gives focus to this widget */ 68 void giveFocus(); 69 void breakFocus(); 70 /** @returns true if the widget is focusable */ 71 bool focusable() const { return this->_focusable; }; 72 /** @param focusable sets if the Widget should be focusable */ 73 void setFocusable(bool focusable = true) { this->_focusable = focusable; }; 74 /** @returns true if the position is inside of the Widget. @param position the position to check */ 75 bool focusOverWidget(const Vector2D& position) const; 76 /** @brief overloaded function, that returns true if the cursor is on top of the Widget */ 77 bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const; 78 79 /** @returns the currently focused Widget (NULL if none is selected) */ 80 static GLGuiWidget* focused() { return GLGuiWidget::_focused; }; 81 82 83 /// CLICK 84 void click(); 85 void release(); 86 bool clickable() const { return this->_clickable; }; 87 void setClickable(bool clickable = true) { this->_clickable = clickable; }; 58 88 59 89 virtual void update() {}; 60 90 virtual void draw() const; 61 91 92 93 /// MATERIAL (looks) 62 94 Material& backMaterial() { return this->backMat; }; 63 95 const Material& backMaterial() const { return this->backMat; }; … … 66 98 const Material& frontMaterial() const { return this->frontMat; }; 67 99 100 /** @param the Event to process. @returns true if the Event has been consumed*/ 101 virtual bool processEvent(const Event& event) { }; 102 103 104 DeclareSignal(testSignal, ()); 105 68 106 protected: 69 107 // if something was clickt on the GUI-widget. 70 virtual void clicked(const Event& event) {}; 71 virtual void released(const Event& event) {}; 108 virtual void clicked(); 109 virtual void released(); 110 virtual void receivedFocus(); 111 virtual void removedFocus(); 72 112 73 virtual void receivedFocus() {}; 74 virtual void removedFocus() {}; 75 76 virtual void destroyed() {}; 113 virtual void destroyed(); 77 114 78 115 … … 84 121 85 122 123 private: 124 /// LOOKS 125 Material backMat; 126 Rect2D backRect; 127 128 Material frontMat; 129 Rect2D frontRect; 86 130 87 131 88 protected: 89 Material backMat; 90 GLuint backModel; 132 /// SIGNALS 133 std::vector<SignalConnector> widgetSignals; 91 134 92 Material frontMat; 93 GLuint frontModel; 135 /// EVENTS 136 bool _focusable; //!< If this widget can receive focus. 137 bool _clickable; //!< if this widget can be clicked upon. 94 138 95 private: 96 std::vector<SignalConnector> widgetSignals; 139 bool _pushed; 97 140 98 bool focusable; //!< If this widget can receive focus.99 bool clickable; //!< if this widget can be clicked upon.141 static GLGuiWidget* _focused; 142 static GLGuiWidget* _inputGrabber; 100 143 }; 101 144 } -
trunk/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc
r7221 r7919 240 240 glEnd(); 241 241 242 glDisable(GL_TEXTURE_2D);243 242 /* draw white border */ 244 243 glBegin(GL_LINE_LOOP); -
trunk/src/lib/gui/gl_gui/signal_connector.h
r7855 r7919 11 11 namespace OrxGui 12 12 { 13 14 #define DeclareSignal(name, params) \ 15 public: \ 16 void signal_ ##connect ##name(const SignalConnector& connector) { \ 17 name ## connected.push_back(connector); \ 18 }\ 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 25 13 26 //! A class for Conncting Signals to Objects, inside of the GUI 14 27 class SignalConnector
Note: See TracChangeset
for help on using the changeset viewer.