Changeset 7919 in orxonox.OLD for trunk/src/lib/gui/gl_gui/glgui_widget.cc
- Timestamp:
- May 28, 2006, 3:48:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.