Changeset 8667 in orxonox.OLD
- Timestamp:
- Jun 21, 2006, 1:50:54 PM (18 years ago)
- Location:
- branches/gui/src/lib/gui/gl
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui_button.cc
r8619 r8667 79 79 emit(clicked()); 80 80 } 81 void GLGuiButton::releasing(const Vector2D& pos )81 void GLGuiButton::releasing(const Vector2D& pos, bool focused) 82 82 { 83 GLGuiWidget::releasing(pos );83 GLGuiWidget::releasing(pos, focused); 84 84 emit(released()); 85 85 } -
branches/gui/src/lib/gui/gl/glgui_button.h
r8619 r8667 48 48 49 49 virtual void clicking(const Vector2D& pos); 50 virtual void releasing(const Vector2D& pos );50 virtual void releasing(const Vector2D& pos, bool focused); 51 51 virtual void hiding(); 52 52 virtual void showing(); -
branches/gui/src/lib/gui/gl/glgui_checkbutton.cc
r8619 r8667 78 78 79 79 80 void GLGuiCheckButton::releasing(const Vector2D& pos )80 void GLGuiCheckButton::releasing(const Vector2D& pos, bool focused) 81 81 { 82 GLGuiButton::releasing(pos );82 GLGuiButton::releasing(pos, focused); 83 83 this->toggleActiveState(); 84 84 } -
branches/gui/src/lib/gui/gl/glgui_checkbutton.h
r8448 r8667 38 38 protected: 39 39 virtual void resize(); 40 virtual void releasing(const Vector2D& pos );40 virtual void releasing(const Vector2D& pos, bool focused); 41 41 42 42 private: -
branches/gui/src/lib/gui/gl/glgui_handler.cc
r8664 r8667 111 111 Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 112 112 GLGuiWidget::mouseFocused()->select(); 113 GLGuiWidget:: selected()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());113 GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D()); 114 114 } 115 115 } 116 else if (GLGuiWidget::selected != NULL && !event.bPressed)116 else if (GLGuiWidget::selected() != NULL && !event.bPressed) 117 117 { 118 118 if (GLGuiWidget::selected()->clickable()) … … 162 162 return Vector2D::nullVector(); 163 163 } 164 164 165 Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const 165 166 { … … 172 173 173 174 174 void GLGuiHandler::draw() 175 { 176 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP); 177 } 178 179 180 void GLGuiHandler::tick(float dt) 181 { 182 // do not change if we already clicked into a Widget. 183 if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->clicked()) 184 return ; 185 186 // CHECK THE COLLISIONS. 175 void GLGuiHandler::checkFocus() 176 { 177 // CHECK THE COLLISIONS. 187 178 const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET); 188 179 … … 209 200 } 210 201 } 202 203 void GLGuiHandler::draw() 204 { 205 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP); 206 } 207 208 209 void GLGuiHandler::tick(float dt) 210 { 211 // do not change if we already clicked into a Widget. 212 if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->pushed()) 213 return ; 214 215 this->checkFocus(); 216 } 211 217 } -
branches/gui/src/lib/gui/gl/glgui_handler.h
r8324 r8667 37 37 void deactivate(); 38 38 39 void checkFocus(); 39 40 40 41 virtual void process(const Event &event); -
branches/gui/src/lib/gui/gl/glgui_pushbutton.cc
r8448 r8667 81 81 82 82 83 void GLGuiPushButton::releasing(const Vector2D& pos )83 void GLGuiPushButton::releasing(const Vector2D& pos, bool focused) 84 84 { 85 85 printf("%s released\n", this->label().c_str()); 86 GLGuiButton::releasing(pos );86 GLGuiButton::releasing(pos, focused); 87 87 } 88 88 -
branches/gui/src/lib/gui/gl/glgui_pushbutton.h
r8145 r8667 31 31 virtual void draw() const; 32 32 virtual void update(); 33 33 34 protected: 34 35 virtual void resize(); 35 36 virtual void clicking(const Vector2D& pos); 36 virtual void releasing(const Vector2D& pos );37 virtual void releasing(const Vector2D& pos, bool focused); 37 38 virtual void receivedFocus(); 38 39 virtual void removedFocus(); -
branches/gui/src/lib/gui/gl/glgui_slider.cc
r8619 r8667 193 193 } 194 194 195 void GLGuiSlider::releasing(const Vector2D& pos )196 { 197 GLGuiWidget::releasing(pos );195 void GLGuiSlider::releasing(const Vector2D& pos, bool focused) 196 { 197 GLGuiWidget::releasing(pos, focused); 198 198 this->grabbed = false; 199 199 } -
branches/gui/src/lib/gui/gl/glgui_slider.h
r8448 r8667 59 59 60 60 virtual void clicking(const Vector2D& pos); 61 virtual void releasing(const Vector2D& pos );61 virtual void releasing(const Vector2D& pos, bool focused); 62 62 virtual void removedFocus(); 63 63 -
branches/gui/src/lib/gui/gl/glgui_widget.cc
r8664 r8667 95 95 this->_pushed = false; 96 96 this->_state = OrxGui::Normal; 97 this->_ clicked = false;97 this->_pushed = false; 98 98 99 99 … … 136 136 } 137 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 138 159 /** @brief gives focus to this widget */ 139 160 void GLGuiWidget::giveMouseFocus() 140 161 { 162 if (this->_state == OrxGui::Insensitive) 163 return ; 164 141 165 if (GLGuiWidget::mouseFocused() != NULL) 142 166 GLGuiWidget::mouseFocused()->breakMouseFocus(); 143 167 GLGuiWidget::_mouseFocused = this; 168 169 this->switchState(OrxGui::Focused); 170 144 171 this->receivedFocus(); 145 172 }; … … 151 178 GLGuiWidget::_mouseFocused = NULL; 152 179 this->_pushed = false; 180 181 if (GLGuiWidget::_selected != this) 182 this->switchState(OrxGui::Normal); 183 else 184 this->switchState(OrxGui::Selected); 185 153 186 this->removedFocus(); 154 187 } 155 188 }; 156 189 157 158 bool GLGuiWidget::focusOverWidget(const Vector2D& position) const159 {160 return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&161 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);162 }163 164 bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const165 {166 return this->focusOverWidget(cursor->getAbsCoor2D());167 }168 169 170 190 /** 171 191 * @brief selects the Widget, unselecting the old one (if existing) … … 176 196 GLGuiWidget::selected()->unselect(); 177 197 GLGuiWidget::_selected = this; 198 199 this->switchState(OrxGui::Selected); 178 200 } 179 201 … … 188 210 return; 189 211 212 if (GLGuiWidget::_mouseFocused == this) 213 this->switchState(OrxGui::Focused); 214 else 215 this->switchState(OrxGui::Normal); 216 190 217 GLGuiWidget::_selected = NULL; 191 218 } 192 193 194 195 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)196 {197 this->_currentStyle._foreground.setDiffuseColor(frontColor);198 this->animateBack();199 };200 219 201 220 … … 220 239 if (this->_pushed) 221 240 { 222 this->releasing(pos );241 this->releasing(pos, GLGuiWidget::_mouseFocused == this); 223 242 this->_pushed = false; 224 243 } … … 227 246 228 247 void GLGuiWidget::clicking(const Vector2D& pos) 229 { 230 this->_clicked = true; 231 this->switchState(OrxGui::Selected); 232 } 233 234 void GLGuiWidget::releasing(const Vector2D& pos) 235 { 236 this->_clicked = false; 237 this->switchState(OrxGui::Normal); 238 } 248 {} 249 250 void GLGuiWidget::releasing(const Vector2D& pos, bool focused) 251 {} 239 252 240 253 void GLGuiWidget::receivedFocus() 241 254 { 242 this->switchState(OrxGui::Focused);243 255 } 244 256 245 257 void GLGuiWidget::removedFocus() 246 258 { 247 this->switchState(OrxGui::Normal);248 259 249 260 } … … 251 262 void GLGuiWidget::selecting() 252 263 { 253 this->switchState(OrxGui::Selected);254 264 } 255 265 256 266 void GLGuiWidget::unselecting() 257 267 { 258 this->switchState(OrxGui::Normal);259 268 } 260 269 261 270 262 271 void GLGuiWidget::destroying() 263 { }264 ;272 { 273 } 265 274 266 275 -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8664 r8667 70 70 71 71 /// CLICK 72 bool clicked() { return _clicked; };72 bool pushed() { return _pushed; }; 73 73 void click(const Vector2D& pos); 74 74 void release(const Vector2D& pos); … … 255 255 // mouse clicking 256 256 virtual void clicking(const Vector2D& pos); 257 virtual void releasing(const Vector2D& pos );257 virtual void releasing(const Vector2D& pos, bool focused); 258 258 // mouse focusing 259 259 virtual void receivedFocus(); … … 287 287 /// EVENTS 288 288 OrxGui::State _state; 289 bool _ clicked;289 bool _pushed; 290 290 291 291 bool _focusable; //!< If this widget can receive focus. … … 293 293 bool _selectable; //!< If this widget can be selected. 294 294 295 bool _pushed;296 295 297 296
Note: See TracChangeset
for help on using the changeset viewer.