Changeset 7919 in orxonox.OLD for trunk/src/lib/gui/gl_gui/glgui_handler.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_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 }
Note: See TracChangeset
for help on using the changeset viewer.