Changeset 7882 in orxonox.OLD for branches/gui
- Timestamp:
- May 27, 2006, 1:24:03 AM (19 years ago)
- Location:
- branches/gui/src/lib/gui/gl_gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl_gui/glgui_button.cc
r7875 r7882 51 51 { 52 52 this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton"); 53 this->setFocusable(true); 54 this->setClickable(true); 53 55 54 56 this->label.setParent2D(this); -
branches/gui/src/lib/gui/gl_gui/glgui_handler.cc
r7881 r7882 107 107 { 108 108 GLGuiWidget* widget = dynamic_cast<GLGuiWidget*>(*it); 109 if (widget->isVisible() && widget->focusOverWidget(this->cursor->getAbsCoor2D().x, this->cursor->getAbsCoor2D().y)) 109 110 if (widget->isVisible() && 111 widget->focusable() && 112 widget->focusOverWidget(this->cursor)) 110 113 { 111 114 // receiving Focus … … 113 116 { 114 117 widget->giveFocus(); 115 printf("%s\n", widget->getClassName());116 118 } 119 return ; 117 120 } 118 121 } 122 if (GLGuiWidget::focused() != NULL) 123 GLGuiWidget::focused()->breakFocus(); 119 124 } 120 125 } -
branches/gui/src/lib/gui/gl_gui/glgui_widget.cc
r7880 r7882 17 17 18 18 #include "glgui_widget.h" 19 20 #include "glgui_cursor.h" 19 21 20 22 #include "material.h" … … 53 55 this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget"); 54 56 55 this-> focusable = true;56 this-> clickable = true;57 this->_focusable = false; 58 this->_clickable = false; 57 59 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 58 60 … … 65 67 66 68 67 bool GLGuiWidget::focusOverWidget( float x, float y) const69 bool GLGuiWidget::focusOverWidget(const Vector2D& position) const 68 70 { 69 if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x && 70 this->getAbsCoor2D().y < y && this->getAbsCoor2D().y + this->getSizeY2D() > y) 71 return true; 72 else 73 return false; 71 return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x && 72 this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y); 74 73 } 74 75 bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const 76 { 77 return this->focusOverWidget(cursor->getAbsCoor2D()); 78 } 79 75 80 76 81 /** -
branches/gui/src/lib/gui/gl_gui/glgui_widget.h
r7880 r7882 19 19 namespace OrxGui 20 20 { 21 22 21 typedef enum 23 22 { … … 34 33 35 34 35 class GLGuiCursor; 36 36 37 //! if the Element should be visible by default. 37 38 #define GLGUI_WIDGET_DEFAULT_VISIBLE false … … 43 44 class GLGuiWidget : public Element2D 44 45 { 46 45 47 private: 46 48 … … 52 54 void hide(); 53 55 54 void giveFocus() { GLGuiWidget::_focused = this; this->receivedFocus(); }; 55 56 /// INTERCONNECTIVITY 56 57 void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal); 57 58 void disconnectSignal(SignalType signalType); 58 bool focusOverWidget(float x, float y) const; 59 60 61 /// FOCUS 62 /** @brief gives focus to this widget */ 63 void giveFocus() { GLGuiWidget::_focused = this; this->receivedFocus(); }; 64 void breakFocus() { GLGuiWidget::_focused = NULL; this->removedFocus(); }; 65 /** @returns true if the widget is focusable */ 66 bool focusable() const { return this->_focusable; }; 67 /** @param focusable sets if the Widget should be focusable */ 68 void setFocusable(bool focusable = true) { this->_focusable = focusable; }; 69 /** @returns true if the position is inside of the Widget. @param position the position to check */ 70 bool focusOverWidget(const Vector2D& position) const; 71 /** @brief overloaded function, that returns true if the cursor is on top of the Widget */ 72 bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const; 73 74 /** @returns the currently focused Widget (NULL if none is selected) */ 75 static GLGuiWidget* focused() { return GLGuiWidget::_focused; }; 76 77 78 /// CLICK 79 bool clickable() const { return this->_clickable; }; 80 void setClickable(bool clickable = true) { this->_clickable = clickable; }; 59 81 60 82 … … 62 84 virtual void draw() const; 63 85 86 87 /// MATERIAL (looks) 64 88 Material& backMaterial() { return this->backMat; }; 65 89 const Material& backMaterial() const { return this->backMat; }; … … 70 94 71 95 72 static const GLGuiWidget* const focused() { return GLGuiWidget::_focused; };73 96 74 97 … … 91 114 92 115 93 94 95 116 protected: 96 117 Material backMat; … … 103 124 std::vector<SignalConnector> widgetSignals; 104 125 105 bool focusable; //!< If this widget can receive focus.106 bool clickable; //!< if this widget can be clicked upon.126 bool _focusable; //!< If this widget can receive focus. 127 bool _clickable; //!< if this widget can be clicked upon. 107 128 108 129 static GLGuiWidget* _focused;
Note: See TracChangeset
for help on using the changeset viewer.