Changeset 7903 in orxonox.OLD for branches/gui/src/lib
- Timestamp:
- May 27, 2006, 2:18:55 PM (19 years ago)
- Location:
- branches/gui/src/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/event/event_def.h
r7868 r7903 30 30 EV_VIDEO_RESIZE, 31 31 32 EV_LEAVE_STATE, 32 33 EV_MAIN_QUIT, 33 34 -
branches/gui/src/lib/event/event_handler.cc
r7898 r7903 93 93 void EventHandler::setState(elState state) 94 94 { 95 if (state == this->state) 96 return; 97 95 98 /// When Changing the State, all the keys will be released. 96 99 /// This is done by sending each eventListener, that still … … 107 110 if (unlikely(this->bUNICODE[this->state])) 108 111 ev.x = i; 109 this->dispachEvent( ev ); 110 } 111 } 112 112 this->dispachEvent(this->state, ev ); 113 } 114 } 115 116 // switching to the new State. 117 elState oldState = this->state; 113 118 this->state = state; 119 120 // in the End the Corresponding handler will be notified. 121 Event stateSwitchEvent; 122 stateSwitchEvent.type = EV_LEAVE_STATE; 123 this->dispachEvent(oldState, stateSwitchEvent); 124 114 125 SDL_EnableUNICODE(this->bUNICODE[state]); 115 126 }; … … 388 399 break; 389 400 } 390 this->dispachEvent( ev);401 this->dispachEvent(this->state, ev); 391 402 } 392 403 } … … 397 408 * @param event the Event to dispach. 398 409 */ 399 void EventHandler::dispachEvent( const Event& event) const410 void EventHandler::dispachEvent(elState state, const Event& event) const 400 411 { 401 412 /* small debug routine: shows all events dispatched by the event handler */ 402 413 PRINT(4)("\n==========================| EventHandler::process () |===\n"); 403 PRINT(4)("= Got Event nr %i, for state %i\n", event.type, this->state);414 PRINT(4)("= Got Event nr %i, for state %i\n", event.type, state); 404 415 405 416 /// setting a temporary state in case of an EventListener's process changes the state. 406 elState currentState = this->state; 407 for (unsigned int i = 0; i < this->listeners[currentState][event.type].size(); i++) 417 for (unsigned int i = 0; i < this->listeners[state][event.type].size(); i++) 408 418 { 409 419 PRINT(4)("= Event dispatcher msg: This event has been consumed\n"); 410 PRINT(4)("= Got Event nr %i, for state %i %s::%s\n", event.type, currentState, this->listeners[this->state][event.type][i]->getClassName(), this->listeners[currentState][event.type][i]->getName());420 PRINT(4)("= Got Event nr %i, for state %i %s::%s\n", event.type, state, this->listeners[state][event.type][i]->getClassName(), this->listeners[state][event.type][i]->getName()); 411 421 PRINT(4)("=======================================================\n"); 412 this->listeners[ currentState][event.type][i]->process(event);422 this->listeners[state][event.type][i]->process(event); 413 423 } 414 424 /* else -
branches/gui/src/lib/event/event_handler.h
r7897 r7903 47 47 48 48 void process() const; 49 void dispachEvent( const Event& event) const;49 void dispachEvent(elState state, const Event& event) const; 50 50 51 51 static int eventFilter(const SDL_Event *event); -
branches/gui/src/lib/gui/gl_gui/glgui_handler.cc
r7899 r7903 95 95 void GLGuiHandler::process(const Event &event) 96 96 { 97 if (event.type == EV_MOUSE_BUTTON_LEFT)97 switch (event.type) 98 98 { 99 case EV_MOUSE_BUTTON_LEFT: 100 if (GLGuiWidget::focused() != NULL) 101 { 102 if (event.bPressed) 103 { 104 if (GLGuiWidget::focused()->clickable()) 105 GLGuiWidget::focused()->click(); 106 } 107 else 108 { 109 if (GLGuiWidget::focused()->clickable()) 110 GLGuiWidget::focused()->release(); 111 } 112 } 113 break; 114 case EV_LEAVE_STATE: 115 if (GLGuiWidget::focused() != NULL) 116 GLGuiWidget::focused()->breakFocus(); 117 } 99 118 100 if (GLGuiWidget::focused() != NULL) 101 { 102 if (event.bPressed) 103 { 104 if (GLGuiWidget::focused()->clickable()) 105 GLGuiWidget::focused()->click(); 106 } 107 else 108 { 109 if (GLGuiWidget::focused()->clickable()) 110 GLGuiWidget::focused()->release(); 111 } 112 } 113 } 119 114 120 115 121 if (GLGuiWidget::focused()) … … 118 124 } 119 125 126 127 120 128 } 121 129 122 130 void GLGuiHandler::draw() 123 131 { 124 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);132 // GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP); 125 133 } 126 134 -
branches/gui/src/lib/gui/gl_gui/glgui_widget.cc
r7896 r7903 77 77 void GLGuiWidget::giveFocus() 78 78 { 79 if (GLGuiWidget::focused() != NULL) 80 GLGuiWidget::focused()->breakFocus(); 79 81 GLGuiWidget::_focused = this; 80 82 this->receivedFocus(); … … 83 85 void GLGuiWidget::breakFocus() 84 86 { 85 GLGuiWidget::_focused = NULL; 86 this->_pushed = false; 87 this->removedFocus(); 87 if (GLGuiWidget::_focused == this) 88 { 89 GLGuiWidget::_focused = NULL; 90 this->_pushed = false; 91 this->removedFocus(); 92 } 88 93 }; 89 94
Note: See TracChangeset
for help on using the changeset viewer.