Changeset 8664 in orxonox.OLD for branches/gui/src
- Timestamp:
- Jun 21, 2006, 11:04:44 AM (18 years ago)
- Location:
- branches/gui/src/lib/gui/gl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui_handler.cc
r8653 r8664 104 104 { 105 105 case EV_MOUSE_BUTTON_LEFT: 106 if (GLGuiWidget::mouseFocused() != NULL )106 if (GLGuiWidget::mouseFocused() != NULL && event.bPressed) 107 107 { 108 if (event.bPressed) 108 // if clickable select the Widget. 109 if (GLGuiWidget::mouseFocused()->clickable()) 109 110 { 110 if (GLGuiWidget::mouseFocused()->clickable()) 111 { 112 Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 113 GLGuiWidget::mouseFocused()->select(); 114 GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D()); 115 } 116 } 117 else 118 { 119 if (GLGuiWidget::mouseFocused()->clickable()) 120 { 121 Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 122 GLGuiWidget::mouseFocused()->release(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D()); 123 } 111 Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 112 GLGuiWidget::mouseFocused()->select(); 113 GLGuiWidget::selected()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D()); 124 114 } 125 115 } 116 else if (GLGuiWidget::selected != NULL && !event.bPressed) 117 { 118 if (GLGuiWidget::selected()->clickable()) 119 { 120 Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y); 121 GLGuiWidget::selected()->release(cursorPos - GLGuiWidget::selected()->getAbsCoor2D()); 122 } 123 } 124 126 125 break; 127 126 case EV_LEAVE_STATE: 127 if (GLGuiWidget::selected() != NULL) 128 GLGuiWidget::selected()->unselect(); 129 128 130 if (GLGuiWidget::mouseFocused() != NULL) 129 131 GLGuiWidget::mouseFocused()->breakMouseFocus(); … … 138 140 139 141 140 if (GLGuiWidget::selected() )142 if (GLGuiWidget::selected() != NULL) 141 143 { 142 144 GLGuiWidget::selected()->processEvent(event); … … 178 180 void GLGuiHandler::tick(float dt) 179 181 { 182 // do not change if we already clicked into a Widget. 183 if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->clicked()) 184 return ; 180 185 181 186 // CHECK THE COLLISIONS. -
branches/gui/src/lib/gui/gl/glgui_widget.cc
r8653 r8664 95 95 this->_pushed = false; 96 96 this->_state = OrxGui::Normal; 97 this->_clicked = false; 97 98 98 99 … … 167 168 168 169 170 /** 171 * @brief selects the Widget, unselecting the old one (if existing) 172 */ 169 173 void GLGuiWidget::select() 170 174 { 171 if (GLGuiWidget:: selected()!= NULL)175 if (GLGuiWidget::_selected != NULL) 172 176 GLGuiWidget::selected()->unselect(); 173 177 GLGuiWidget::_selected = this; 174 178 } 175 179 180 /** 181 * @brief unselects the current Widget. 182 * 183 * if the current Widget is not selected, nothing is done here. 184 */ 176 185 void GLGuiWidget::unselect() 177 186 { 178 if (GLGuiWidget::selected() != this) 179 _selected = NULL; 187 if (GLGuiWidget::_selected != this) 188 return; 189 190 GLGuiWidget::_selected = NULL; 180 191 } 181 192 … … 217 228 void GLGuiWidget::clicking(const Vector2D& pos) 218 229 { 230 this->_clicked = true; 219 231 this->switchState(OrxGui::Selected); 220 232 } … … 222 234 void GLGuiWidget::releasing(const Vector2D& pos) 223 235 { 236 this->_clicked = false; 224 237 this->switchState(OrxGui::Normal); 225 238 } … … 236 249 } 237 250 238 void GLGuiWidget::destroyed() 251 void GLGuiWidget::selecting() 252 { 253 this->switchState(OrxGui::Selected); 254 } 255 256 void GLGuiWidget::unselecting() 257 { 258 this->switchState(OrxGui::Normal); 259 } 260 261 262 void GLGuiWidget::destroying() 239 263 {} 240 264 ; … … 737 761 void GLGuiWidget::tick(float dt) 738 762 { 739 763 if (this->_animating) 740 764 { 741 765 this->foregroundColor(); … … 778 802 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 779 803 if (stateName == OrxGui::StateString[i]) 780 {781 *state = (OrxGui::State)i;782 return true;783 }804 { 805 *state = (OrxGui::State)i; 806 return true; 807 } 784 808 return false; 785 809 } … … 788 812 * @brief print out some nice debug output about the Widget. 789 813 */ 790 void GLGuiWidget::debug( ) const814 void GLGuiWidget::debug(unsigned int level) const 791 815 { 792 816 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName()); -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8653 r8664 42 42 43 43 /// FOCUS 44 /** @brief gives focus to this widget */44 /** @brief gives mouse - focus to this widget */ 45 45 void giveMouseFocus(); 46 46 void breakMouseFocus(); 47 47 48 /** @returns true if the widget is focusable */ 48 49 bool focusable() const { return this->_focusable; }; … … 54 55 bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const; 55 56 56 /** @returns the currently focused Widget (NULL if none is selected)*/57 /** @returns the currently mouse - focused Widget (NULL if none is focused). */ 57 58 static GLGuiWidget* mouseFocused() { return GLGuiWidget::_mouseFocused; }; 58 59 59 60 /// SELECT 60 static GLGuiWidget* selected() { return GLGuiWidget::_selected; };61 61 void select(); 62 62 void unselect(); 63 /** @returns true if the Widget is selectable */ 64 bool selectable() const { return this->_selectable; } 65 /** @param selectable true if the widget should be selectable */ 66 void setSelectable(bool selectable) { this->_selectable = selectable; } 67 68 /** @returns the currently Selected Widget (NULL if none is selected). */ 69 static GLGuiWidget* selected() { return GLGuiWidget::_selected; }; 63 70 64 71 /// CLICK 72 bool clicked() { return _clicked; }; 65 73 void click(const Vector2D& pos); 66 74 void release(const Vector2D& pos); … … 85 93 void animateBack(); 86 94 87 /// STYLE 95 /////////////////////////////////////////////////////////////////////////////////// 96 /// STYLE ///////////////////////////////////////////////////////////////////////// 88 97 //////////////////////////////// 89 98 /// Retrieve Current Values. /// … … 205 214 void setAnimatedStateChanges(bool animated); 206 215 void switchState(OrxGui::State state); 207 216 /////////////////////////////////////////////////////////////////////////////////// 208 217 209 218 … … 229 238 230 239 protected: 240 /// RENDERING 241 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; 242 inline void endDraw() const { glPopMatrix(); }; 243 244 231 245 /// LOOKS 232 246 virtual void resize(); … … 234 248 virtual void hiding() {}; 235 249 virtual void showing() {}; 250 236 251 virtual void updateFrontColor() {}; 237 252 238 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };239 inline void endDraw() const { glPopMatrix(); };240 253 241 254 /// EVENTS 242 // if something was clickt on the GUI-widget.255 // mouse clicking 243 256 virtual void clicking(const Vector2D& pos); 244 257 virtual void releasing(const Vector2D& pos); 258 // mouse focusing 245 259 virtual void receivedFocus(); 246 260 virtual void removedFocus(); 247 248 virtual void destroyed(); 249 250 virtual void debug() const; 261 // selecting either with the mouse by clicking, or by the keybord traversing to it. 262 virtual void selecting(); 263 virtual void unselecting(); 264 // destroying the Widget. 265 virtual void destroying(); 266 267 268 virtual void debug(unsigned int level) const; 251 269 252 270 private: … … 269 287 /// EVENTS 270 288 OrxGui::State _state; 289 bool _clicked; 271 290 272 291 bool _focusable; //!< If this widget can receive focus. 273 292 bool _clickable; //!< if this widget can be clicked upon. 293 bool _selectable; //!< If this widget can be selected. 274 294 275 295 bool _pushed; … … 280 300 typedef struct 281 301 { 282 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts.283 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts.284 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts285 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts286 287 float _textSize; //!< The TextSize of the Widget.288 289 Material _background; //!< The Background Material of the Widget.290 291 Material _foreground; //!< The foreground Material of the Widget.302 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. 303 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. 304 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts 305 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts 306 307 float _textSize; //!< The TextSize of the Widget. 308 309 Material _background; //!< The Background Material of the Widget. 310 311 Material _foreground; //!< The foreground Material of the Widget. 292 312 } 293 313 StatedStyle; 294 314 295 315 296 StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States297 298 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)299 Font* _font; //!< The Font used in the current Widget.316 StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States 317 318 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...) 319 Font* _font; //!< The Font used in the current Widget. 300 320 301 321 302 322 /// ANIMATION STUFF: 303 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically.304 305 bool _animating; //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)306 float _animationCycle;307 float _animationDuration;308 StatedStyle _currentStyle;323 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. 324 325 bool _animating; //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.) 326 float _animationCycle; 327 float _animationDuration; 328 StatedStyle _currentStyle; 309 329 310 330 };
Note: See TracChangeset
for help on using the changeset viewer.