Changeset 8717 in orxonox.OLD for trunk/src/lib/gui/gl/glgui_widget.cc
- Timestamp:
- Jun 22, 2006, 2:04:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/glgui_widget.cc
r8619 r8717 72 72 GLGuiWidget::~GLGuiWidget() 73 73 { 74 if (this == GLGuiWidget::_focused) 75 GLGuiWidget::_focused = NULL; 74 if (this == GLGuiWidget::_mouseFocused) 75 GLGuiWidget::_mouseFocused = NULL; 76 if (this == GLGuiWidget::selected()) 77 this->unselect(); 76 78 } 77 79 78 80 GLGuiWidget* GLGuiWidget::_selected = NULL; 79 GLGuiWidget* GLGuiWidget::_ focused = NULL;81 GLGuiWidget* GLGuiWidget::_mouseFocused = NULL; 80 82 GLGuiWidget* GLGuiWidget::_inputGrabber = NULL; 81 83 … … 91 93 this->_focusable = false; 92 94 this->_clickable = false; 95 this->_selectable = false; 93 96 this->_pushed = false; 94 97 this->_state = OrxGui::Normal; … … 133 136 } 134 137 138 139 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously) 140 { 141 this->_currentStyle._foreground.setDiffuseColor(frontColor); 142 this->animateBack(); 143 }; 144 145 146 bool GLGuiWidget::focusOverWidget(const Vector2D& position) const 147 { 148 return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x && 149 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y); 150 } 151 152 bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const 153 { 154 return this->focusOverWidget(cursor->getAbsCoor2D()); 155 } 156 157 158 135 159 /** @brief gives focus to this widget */ 136 void GLGuiWidget::giveFocus() 137 { 138 if (GLGuiWidget::focused() != NULL) 139 GLGuiWidget::focused()->breakFocus(); 140 GLGuiWidget::_focused = this; 160 void GLGuiWidget::giveMouseFocus() 161 { 162 if (this->_state == OrxGui::Insensitive) 163 return ; 164 165 if (GLGuiWidget::mouseFocused() != NULL) 166 GLGuiWidget::mouseFocused()->breakMouseFocus(); 167 GLGuiWidget::_mouseFocused = this; 168 169 this->switchState(OrxGui::Focused); 170 141 171 this->receivedFocus(); 142 172 }; 143 173 144 void GLGuiWidget::break Focus()145 { 146 if (GLGuiWidget::_ focused == this)174 void GLGuiWidget::breakMouseFocus() 175 { 176 if (GLGuiWidget::_mouseFocused == this) 147 177 { 148 GLGuiWidget::_focused = NULL; 149 this->_pushed = false; 178 GLGuiWidget::_mouseFocused = NULL; 179 180 if (GLGuiWidget::_selected != this) 181 this->switchState(OrxGui::Normal); 182 else 183 this->switchState(OrxGui::Selected); 184 150 185 this->removedFocus(); 151 186 } 152 187 }; 153 188 154 155 bool GLGuiWidget::focusOverWidget(const Vector2D& position) const 156 { 157 return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x && 158 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y); 159 } 160 161 bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const 162 { 163 return this->focusOverWidget(cursor->getAbsCoor2D()); 164 } 165 166 167 168 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously) 169 { 170 this->_currentStyle._foreground.setDiffuseColor(frontColor); 171 this->animateBack(); 172 }; 189 /** 190 * @brief selects the Widget, unselecting the old one (if existing) 191 */ 192 void GLGuiWidget::select() 193 { 194 if (GLGuiWidget::_selected != NULL) 195 GLGuiWidget::selected()->unselect(); 196 GLGuiWidget::_selected = this; 197 198 this->switchState(OrxGui::Selected); 199 } 200 201 /** 202 * @brief unselects the current Widget. 203 * 204 * if the current Widget is not selected, nothing is done here. 205 */ 206 void GLGuiWidget::unselect() 207 { 208 if (GLGuiWidget::_selected != this) 209 return; 210 211 if (GLGuiWidget::_mouseFocused == this) 212 this->switchState(OrxGui::Focused); 213 else 214 this->switchState(OrxGui::Normal); 215 216 GLGuiWidget::_selected = NULL; 217 } 173 218 174 219 … … 193 238 if (this->_pushed) 194 239 { 195 this->releasing(pos );240 this->releasing(pos, GLGuiWidget::_mouseFocused == this); 196 241 this->_pushed = false; 197 242 } … … 200 245 201 246 void GLGuiWidget::clicking(const Vector2D& pos) 202 { 203 this->switchState(OrxGui::Selected); 204 } 205 206 void GLGuiWidget::releasing(const Vector2D& pos) 207 { 208 this->switchState(OrxGui::Normal); 209 } 247 {} 248 249 void GLGuiWidget::releasing(const Vector2D& pos, bool focused) 250 {} 210 251 211 252 void GLGuiWidget::receivedFocus() 212 253 { 213 this->switchState(OrxGui::Focused);214 254 } 215 255 216 256 void GLGuiWidget::removedFocus() 217 257 { 218 this->switchState(OrxGui::Normal); 219 220 } 221 222 void GLGuiWidget::destroyed() 223 {} 224 ; 258 259 } 260 261 void GLGuiWidget::selecting() 262 { 263 } 264 265 void GLGuiWidget::unselecting() 266 { 267 } 268 269 270 void GLGuiWidget::destroying() 271 { 272 } 225 273 226 274 … … 706 754 //this->_currentStyle = this->_style[state]; 707 755 this->_state = state; 708 PRINTF(3)(" Switching to state %s\n", OrxGui::StateString[state].c_str());756 PRINTF(3)("%s::%s Switches to state %s\n", this->getClassName(), this->getName(), OrxGui::StateString[state].c_str()); 709 757 710 758 this->animateBack(); … … 762 810 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 763 811 if (stateName == OrxGui::StateString[i]) 764 {765 *state = (OrxGui::State)i;766 return true;767 }812 { 813 *state = (OrxGui::State)i; 814 return true; 815 } 768 816 return false; 769 817 } … … 772 820 * @brief print out some nice debug output about the Widget. 773 821 */ 774 void GLGuiWidget::debug( ) const822 void GLGuiWidget::debug(unsigned int level) const 775 823 { 776 824 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
Note: See TracChangeset
for help on using the changeset viewer.