Changeset 8448 in orxonox.OLD for trunk/src/lib/gui
- Timestamp:
- Jun 15, 2006, 12:48:26 PM (19 years ago)
- Location:
- trunk/src/lib/gui/gl
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/glgui_bar.cc
r8145 r8448 46 46 this->setClassID(CL_GLGUI_BAR, "GLGuiBar"); 47 47 48 this-> frontMaterial().setDiffuse(1,1,1);48 this->setFrontColor(Color(1,1,1)); 49 49 50 50 this->setSize2D(50, 10); … … 64 64 GLGuiWidget::draw(); 65 65 66 this->frontMaterial().select();66 //this->frontMaterial().select(); 67 67 glBegin(GL_QUADS); 68 68 -
trunk/src/lib/gui/gl/glgui_button.cc
r8145 r8448 55 55 56 56 this->_label.setFont("fonts/final_frontier.ttf", 20); 57 this-> frontMaterial().setDiffuse(1, 0, 0);57 this->_label.setColor(this->frontColor()); 58 58 59 59 this->_label.setParent2D(this); … … 69 69 70 70 71 void GLGuiButton::updateFrontColor() 72 { 73 this->_label.setColor(this->frontColor()); 74 } 71 75 72 76 void GLGuiButton::clicking(const Vector2D& pos) 73 77 { 78 GLGuiWidget::clicking(pos); 74 79 emit(clicked()); 75 80 } 76 81 void GLGuiButton::releasing(const Vector2D& pos) 77 82 { 83 GLGuiWidget::releasing(pos); 78 84 emit(released()); 79 85 } -
trunk/src/lib/gui/gl/glgui_button.h
r8145 r8448 41 41 virtual void draw() const; 42 42 43 DeclareSignal0(clicked); 43 44 DeclareSignal0(released); 44 DeclareSignal0(clicked);45 45 46 46 protected: 47 virtual void updateFrontColor(); 48 47 49 virtual void clicking(const Vector2D& pos); 48 50 virtual void releasing(const Vector2D& pos); -
trunk/src/lib/gui/gl/glgui_checkbutton.cc
r8145 r8448 65 65 void GLGuiCheckButton::resize() 66 66 { 67 this->labelText().setRelCoor2D(borderLeft() + 25, borderTop() + 5); 68 this->setSize2D(this->labelText().getSizeX2D() + 30 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom()); 67 68 this->labelText().setRelCoor2D( borderLeft() + 15.0, borderTop() + 5); 69 this->setSize2D(this->labelText().getSizeX2D() + 15.0 + borderLeft() + borderRight(), this->labelText().getSizeY2D() + 10 + borderTop()+borderBottom()); 69 70 GLGuiWidget::resize(); 70 this->frontRect().setTopLeft(borderLeft(), borderTop()); 71 this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom())); 71 72 this->_checkBox.setSize(10.0, 10.0); 73 this->_checkBox.setCenter( borderLeft() + _checkBox.height()/2.0, borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0); 74 75 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); 76 this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()) , this->getSizeY2D() - (borderTop() + borderBottom()));*/ 72 77 } 73 78 … … 89 94 GLGuiButton::draw(); 90 95 91 this->frontMaterial().select();92 this->drawRect(this->frontRect());96 // this->frontMaterial().select(); 97 // this->drawRect(this->frontRect()); 93 98 94 99 if (this->bActive) 95 100 { 96 glBegin(GL_QUADS); 97 glColor3f( 1, 1 ,1); 98 glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8); 99 glTexCoord2i(0,1); glVertex2d(borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom())); 100 glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom())); 101 glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8); 102 glEnd(); 101 glColor3fv( &this->frontColor()[0]); 102 this->drawRect(this->_checkBox); 103 103 104 104 105 105 // DRAW a cross :) 106 glColor3f(0,0,0); 106 Vector2D center = this->_checkBox.center(); 107 glColor4f(1,1,1, 1.0); 107 108 glLineWidth(3.0); 109 108 110 glBegin(GL_LINE_LOOP); 109 glVertex2d( borderLeft()+8,borderTop() +8);110 glVertex2d( this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2 - 1);111 glVertex2d(_checkBox.left(), _checkBox.top()); 112 glVertex2d(center.x, center.y); 111 113 112 glVertex2d( this->getSizeY2D()-8 + borderLeft(), borderTop()+8);113 glVertex2d( this->getSizeY2D()/2 +1 + borderLeft(), this->getSizeY2D()/2);114 glVertex2d(_checkBox.right(), _checkBox.top()); 115 glVertex2d(center.x, center.y); 114 116 115 glVertex2d( this->getSizeY2D()-8 + borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom()));116 glVertex2d( this->getSizeY2D()/2 + borderLeft(), this->getSizeY2D()/2+1);117 glVertex2d(_checkBox.right(), _checkBox.bottom()); 118 glVertex2d(center.x, center.y); 117 119 118 glVertex2d( borderLeft() + 8, this->getSizeY2D()-8 - (borderTop() + borderBottom()));119 glVertex2d( this->getSizeY2D()/2 -1 + borderLeft(), this->getSizeY2D()/2);120 glVertex2d(_checkBox.left(), _checkBox.bottom()); 121 glVertex2d(center.x, center.y); 120 122 glEnd(); 121 123 } 122 124 else 123 125 { 124 glBegin(GL_QUADS); 125 glColor3f(0, 0, 0); 126 glTexCoord2i(0,0); glVertex2d(borderLeft()+8, borderTop()+8); 127 glTexCoord2i(0,1); glVertex2d(borderLeft()+ 8, this->getSizeY2D()-8 - (borderTop() + borderBottom())); 128 glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8 +borderLeft(), this->getSizeY2D()-8- (borderTop() + borderBottom())); 129 glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8 +borderLeft(), borderTop()+8); 130 glEnd(); 126 glColor3fv( &this->frontColor()[0]); 127 this->drawRect(this->_checkBox); 131 128 } 132 129 -
trunk/src/lib/gui/gl/glgui_checkbutton.h
r8145 r8448 46 46 private: 47 47 bool bActive; 48 48 Rect2D _checkBox; 49 49 }; 50 50 } -
trunk/src/lib/gui/gl/glgui_defs.h
r8145 r8448 7 7 #define _GLGUI_DEFS_H 8 8 9 #include <string> 10 9 11 /// TODO MOVE TO ORXGUI_TYPES 10 12 namespace OrxGui 11 13 { 14 //! if the Element should be visible by default. 15 #define GLGUI_WIDGET_DEFAULT_VISIBLE false 16 17 12 18 //! An enumeration for the Orientation of an Element. 13 19 typedef enum { 14 Horizontal, //!< Horizontal Orientation.15 Vertical //!< Vertical Orientation.20 Horizontal, //!< Horizontal Orientation. 21 Vertical //!< Vertical Orientation. 16 22 } Orientation; 23 24 const std::string OrientationString[] = { 25 "Horizontal", 26 "Vertical" 27 }; 28 29 //! An enumerator that defines the different states Widgets may be in. 30 typedef enum { 31 Normal, //!< Normal state of the GUI's Widgets. 32 Active, //!< If the widget is Active. 33 Selected, //!< If the Widget is Selected. 34 Insensitive //!< If the Widget is insensitive. 35 } State; 36 //! The count of States a GUI-Element can be in. 37 #define GLGUI_STATE_COUNT 4 38 #define GLGUI_DEFAULT_STYLE OrxGui::Normal 39 40 const std::string StateString[] = 41 { 42 "Normal", 43 "Active", 44 "Selected", 45 "Insensitive" 46 }; 47 48 //! Where a Certain feature will be positioned at. 49 typedef enum { 50 FeatureLeft, //!< On the Left side. 51 FeatureRight, //!< On the Right side. 52 FeatureTop, //!< On Top of the rest of the Widget. 53 FeatureBottom, //!< At the Bottom of the rest of the Widget. 54 } FeaturePosition; 55 56 const std::string FeaturePositionString[] = 57 { 58 "Left", 59 "Right", 60 "Top", 61 "Bottom" 62 }; 63 64 65 17 66 }; 18 67 -
trunk/src/lib/gui/gl/glgui_handler.cc
r8324 r8448 40 40 41 41 42 EventHandler::getInstance()->withUNICODE(ES_ ALL, true );42 EventHandler::getInstance()->withUNICODE(ES_MENU, true ); 43 43 44 44 this->_cursor = NULL; -
trunk/src/lib/gui/gl/glgui_image.cc
r8145 r8448 17 17 18 18 #include "glgui_image.h" 19 20 #include "debug.h" 19 21 20 22 namespace OrxGui … … 45 47 this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage"); 46 48 47 this->frontMaterial().setDiffuseMap(this->texture); 48 this->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 49 this->_imageMaterial.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 49 50 50 51 this->resize(); … … 54 55 void GLGuiImage::loadImageFromTexture(const Texture& texture) 55 56 { 56 this->frontMaterial().setDiffuseMap(texture); 57 this->frontMaterial().setDiffuse(1,1,1); 57 this->_imageMaterial.setDiffuseMap(texture); 58 58 } 59 59 60 60 void GLGuiImage::loadImageFromFile(const std::string& fileName) 61 61 { 62 this-> texture.loadImage(fileName);62 this->_imageMaterial.setDiffuseMap(fileName); 63 63 } 64 64 65 65 void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface) 66 66 { 67 //this->texture.loadSurface(surface);67 this->_imageMaterial.setDiffuseMap(Texture(surface)); 68 68 } 69 69 70 70 void GLGuiImage::loadImageFromDisplayList(GLuint texture) 71 71 { 72 // this->texture.setTexture(texture); 72 PRINTF(2)("SORRY NOT IMPLEMENTED\n"); 73 // this->_imageMaterial.setTexture(texture); 74 } 75 76 void GLGuiImage::updateFrontColor() 77 { 78 this->_imageMaterial.setDiffuseColor(this->frontColor()); 73 79 } 74 80 75 81 void GLGuiImage::resize() 76 82 { 77 this-> frontRect().setTopLeft(this->borderLeft(), this->borderTop());78 this-> frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) );83 this->_imagePlane.setTopLeft(this->borderLeft(), this->borderTop()); 84 this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) ); 79 85 GLGuiWidget::resize(); 80 86 } … … 89 95 GLGuiWidget::draw(); 90 96 91 this-> frontMaterial().select();92 this->drawRect(this-> frontRect());97 this->_imageMaterial.select(); 98 this->drawRect(this->_imagePlane); 93 99 this->endDraw(); 94 100 } -
trunk/src/lib/gui/gl/glgui_image.h
r8145 r8448 36 36 DeclareSignal0(imageChanged); 37 37 38 protected: 39 virtual void updateFrontColor(); 40 virtual void resize(); 41 42 38 43 private: 39 44 void init(); 40 virtual void resize();41 45 42 46 private: 43 Texture texture; 47 Rect2D _imagePlane; 48 Material _imageMaterial; 44 49 }; 45 50 } -
trunk/src/lib/gui/gl/glgui_inputline.cc
r8145 r8448 22 22 /** 23 23 * @brief standard constructor 24 */24 */ 25 25 GLGuiInputLine::GLGuiInputLine () 26 26 { … … 48 48 this->setFocusable(true); 49 49 50 this->text.setParent2D(this); 51 this->text.setRelCoor2D(4,4); 52 this->text.setFont("fonts/final_frontier.ttf", 20); 53 this->text.setVisibility(false); 50 this->_text.setParent2D(this); 51 this->_text.setRelCoor2D(4,4); 52 this->_text.setFont("fonts/final_frontier.ttf", 20); 53 this->_text.setColor(this->frontColor()); 54 this->_text.setVisibility(false); 54 55 this->resize(); 55 56 … … 63 64 void GLGuiInputLine::setText(const std::string& text) 64 65 { 65 this->text.setText(text); 66 this->resize(); 67 68 emit(this->textChanged(this->getText())); 66 this->_text.setText(text); 67 this->changedText(); 69 68 } 70 69 … … 75 74 void GLGuiInputLine::append(const std::string& appendText) 76 75 { 77 this->text.append(appendText); 78 this->resize(); 79 emit(this->textChanged(this->text.getText())); 76 this->_text.append(appendText); 77 this->changedText(); 80 78 } 81 79 … … 87 85 void GLGuiInputLine::appendCharacter(char character) 88 86 { 89 this->text.appendCharacter(character); 90 this->resize(); 91 emit(this->textChanged(this->text.getText())); 87 this->_text.appendCharacter(character); 88 this->changedText(); 92 89 } 93 90 … … 99 96 void GLGuiInputLine::removeCharacters(unsigned int chars) 100 97 { 101 this->text.removeCharacters(chars); 98 this->_text.removeCharacters(chars); 99 this->changedText(); 100 } 101 102 /** 103 * @brief If the Text has been changed this function is called. 104 * 105 * This Function also emits the Signal textChanged. 106 */ 107 void GLGuiInputLine::changedText() 108 { 102 109 this->resize(); 103 emit(this->textChanged(this->text.getText())); 110 this->setFrontColor(Color(1,1,1,1), true); 111 this->setFrontColor(Color(0,1,0,1)); 112 emit(this->textChanged(this->_text.getText())); 104 113 } 105 114 … … 117 126 118 127 /** 119 * Processes an Event.128 * @brief Processes an Event. 120 129 * @param event The event to be processed 121 130 * @return true if the event was catched. … … 154 163 } 155 164 } 156 157 165 return false; 158 166 } … … 164 172 void GLGuiInputLine::resize() 165 173 { 166 this-> text.setRelCoor2D(this->borderLeft() + 2.0,this->borderTop() + 2.0);167 this->setSize2D( this-> text.getSize2D() + Vector2D(borderLeft() + borderRight() + 4.0, borderTop() + borderBottom() + 4.0));174 this->_text.setRelCoor2D(this->borderLeft(), this->borderTop()); 175 this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom())); 168 176 GLGuiWidget::resize(); 169 this->frontRect().setTopLeft(borderLeft(), borderTop()); 170 this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom())); 171 } 172 177 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); 178 this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/ 179 } 180 181 void GLGuiInputLine::updateFrontColor() 182 { 183 this->_text.setColor(this->frontColor()); 184 } 173 185 174 186 void GLGuiInputLine::hiding() 175 187 { 176 this-> text.setVisibility(false);188 this->_text.setVisibility(false); 177 189 } 178 190 179 191 void GLGuiInputLine::showing() 180 192 { 181 this->text.setVisibility(true); 182 } 183 184 185 /** 186 * ticks the InputLine 193 this->_text.setVisibility(true); 194 } 195 196 /** 197 * @brief ticks the InputLine 187 198 * @param dt the time passed. 188 199 */ 189 200 void GLGuiInputLine::tick(float dt) 190 201 { 202 GLGuiWidget::tick(dt); 191 203 if (this->delayNext > 0.0) 192 204 this->delayNext -= dt; … … 218 230 GLGuiWidget::draw(); 219 231 220 this->frontMaterial().select();221 GLGuiWidget::drawRect(this->frontRect());232 // this->frontMaterial().select(); 233 // GLGuiWidget::drawRect(this->frontRect()); 222 234 223 235 this->endDraw(); -
trunk/src/lib/gui/gl/glgui_inputline.h
r8145 r8448 32 32 33 33 /** @returns the text of the inputLine */ 34 const std::string& getText() const { return this->text.getText(); };34 const std::string& _getText() const { return this->_text.getText(); }; 35 35 36 36 void setText(const std::string& text); … … 48 48 DeclareSignal1(textChanged, const std::string&); 49 49 50 protected: 51 virtual void updateFrontColor(); 52 virtual void hiding(); 53 virtual void showing(); 54 virtual void resize(); 55 56 50 57 private: 51 58 void init(); 52 void resize(); 53 virtual void hiding(); 54 virtual void showing(); 59 void changedText(); 55 60 56 61 private: 57 Text text;//!< The Text to display inside of the InputLine.62 Text _text; //!< The Text to display inside of the InputLine. 58 63 59 64 Uint16 pressedKey; //!< the pressed key that will be repeated. -
trunk/src/lib/gui/gl/glgui_pushbutton.cc
r8145 r8448 45 45 void GLGuiPushButton::resize() 46 46 { 47 this->labelText().setRelCoor2D(borderLeft() + 5, borderTop() + 5);48 this->setSize2D(this->labelText().getSizeX2D() + 10 + borderLeft()+borderRight(), this->labelText().getSizeY2D() + 10+ borderTop() + borderBottom() );47 this->labelText().setRelCoor2D(borderLeft(), borderTop()); 48 this->setSize2D(this->labelText().getSizeX2D() + borderLeft() + borderRight(), this->labelText().getSizeY2D() + borderTop() + borderBottom() ); 49 49 50 50 GLGuiWidget::resize(); 51 this->frontRect().setTopLeft(borderLeft(), borderTop());52 this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom())); 51 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); 52 this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()));*/ 53 53 } 54 54 … … 97 97 GLGuiButton::draw(); 98 98 99 this->frontMaterial().select();100 this->drawRect(this->frontRect());101 99 this->endDraw(); 102 // this->label->draw();103 // printf("test");104 100 } 105 101 -
trunk/src/lib/gui/gl/glgui_slider.cc
r8335 r8448 74 74 else 75 75 this->_value = value; 76 this->_handle.setCenter(this->sliderPosition(), this->borderTop() + (this->getSizeY2D() - this->borderTop() - borderBottom()) / 2.0); 77 76 78 emit(valueChanged(this->_value)); 77 79 } … … 161 163 { 162 164 GLGuiWidget::resize(); 163 this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0); 164 this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0); 165 // this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0); 166 // this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0); 167 this->_slider.setTopLeft(this->borderLeft(), this->getSizeY2D() / 2.0 -2.0); 168 this->_slider.setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0); 169 this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - borderTop() - borderBottom()); 170 } 171 172 void GLGuiSlider::updateFrontColor() 173 { 174 165 175 } 166 176 … … 218 228 void GLGuiSlider::tick(float dt) 219 229 { 230 GLGuiWidget::tick(dt); 220 231 } 221 232 … … 228 239 GLGuiWidget::draw(); 229 240 230 this->frontMaterial().select();231 this->drawRect(this-> frontRect());232 233 this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, 0*this->borderTop(), _sliderWidth, this->getSizeY2D() - (borderTop() + borderBottom()) ));241 glColor4fv(&this->frontColor()[0]); 242 this->drawRect(this->_slider); 243 this->drawRect(this->_handle); 244 //this->drawRect(Rect2D(this->sliderPosition()-_sliderWidth/2.0, 0*this->borderTop(), _sliderWidth, this->getSizeY2D() - (borderTop() + borderBottom()) )); 234 245 235 246 this->endDraw(); -
trunk/src/lib/gui/gl/glgui_slider.h
r8145 r8448 56 56 protected: 57 57 virtual void resize(); 58 virtual void updateFrontColor(); 58 59 59 60 virtual void clicking(const Vector2D& pos); … … 68 69 private: 69 70 Orientation orientation; 71 72 Rect2D _slider; 73 Rect2D _handle; 70 74 71 75 float _maxValue; -
trunk/src/lib/gui/gl/glgui_style.cc
r8145 r8448 18 18 #include "glgui_style.h" 19 19 20 #include "loading/load_param.h" 21 20 22 namespace OrxGui 21 23 { … … 25 27 * @brief standard constructor 26 28 */ 27 GLGuiStyle::GLGuiStyle ( )29 GLGuiStyle::GLGuiStyle (const TiXmlElement* root) 28 30 { 31 if (root != NULL) 32 this->loadParams(root); 33 34 this-> 29 35 } 30 36 … … 37 43 // delete what has to be deleted here 38 44 } 45 46 void GLGuiStyle::loadParams(const TiXmlElement* root) 47 { 48 } 49 50 void GLGuiStyle::setBorderLeft(float value) 51 { 52 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 53 setBorderLeft(value, (OrxGui::State)i); 54 } 55 56 void GLGuiStyle::setBorderLeft(float value, OrxGui::State state) 57 {} 58 59 void GLGuiStyle::setBorderLeftS(float value, const std::string& state) 60 {} 61 62 63 void GLGuiStyle::setBorderRight(float value) 64 { 65 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 66 setBorderRight(value, (OrxGui::State)i); 67 } 68 69 void GLGuiStyle::setBorderRight(float value, OrxGui::State state) 70 {} 71 72 void GLGuiStyle::setBorderRightS(float value, const std::string& state) 73 {} 74 75 76 void GLGuiStyle::setBorderTop(float value) 77 { 78 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 79 setBorderTop(value, (OrxGui::State)i); 80 } 81 82 void GLGuiStyle::setBorderTop(float value, OrxGui::State state) 83 {} 84 85 void GLGuiStyle::setBorderTopS(float value, const std::string& state) 86 {} 87 88 89 void GLGuiStyle::setBorderBottom(float value) 90 { 91 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 92 setBorderBottom(value, (OrxGui::State)i); 93 } 94 95 void GLGuiStyle::setBorderBottom(float value, OrxGui::State state) 96 {} 97 98 void GLGuiStyle::setBorderBottomS(float value, const std::string& state) 99 {} 100 101 102 void GLGuiStyle::setTextSize(float value) 103 { 104 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 105 setTextSize(value, (OrxGui::State)i); 106 } 107 108 void GLGuiStyle::setTextSize(float value, OrxGui::State state) 109 {} 110 111 void GLGuiStyle::setTextSizeS(float value, const std::string& state) 112 {} 113 114 115 void GLGuiStyle::setBackgroundColor(const Color& color) 116 { 117 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 118 setBackgroundColor(color, (OrxGui::State)i); 119 } 120 121 void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state) 122 {} 123 124 void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& state) 125 {} 126 127 128 void GLGuiStyle::setBackgroundTexture(const Texture& texture) 129 { 130 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 131 setBackgroundTexture(texture, (OrxGui::State)i); 132 } 133 134 void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state) 135 {} 136 137 void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& state) 138 {} 139 140 141 void GLGuiStyle::setForegroundColor(const Color& color) 142 { 143 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 144 setForegroundColor(color, (OrxGui::State)i); 145 } 146 147 void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state) 148 {} 149 150 void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& state) 151 {} 152 153 154 155 void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition) 156 { 157 this->_featurePosition = featurePosition; 158 } 159 160 void GLGuiStyle::setFeaturePosition(const std::string& featurePosition) 161 { 162 163 } 164 165 166 void GLGuiStyle::setFont(Font* font) 167 { 168 this->_font = font; 169 } 170 171 void GLGuiStyle::setFont(const std::string& fontName) 172 { 173 //this->font = new Font(fontName); 174 } 175 176 177 void GLGuiStyle::setAnimated(bool animated) 178 { 179 this->_animated = animated; 180 } 181 182 void GLGuiStyle::animatedStateChanges(bool animated) 183 { 184 this->_animatedStateChanges = animated; 185 } 186 39 187 } -
trunk/src/lib/gui/gl/glgui_style.h
r8276 r8448 7 7 #define _GLGUI_STYLE_H 8 8 9 // FORWARD DECLARATION 9 #include "glgui_defs.h" 10 10 11 11 #include "font.h" 12 12 #include "texture.h" 13 13 #include "color.h" 14 15 class TiXmlElement; 14 16 15 17 namespace OrxGui … … 19 21 { 20 22 public: 23 GLGuiStyle(const TiXmlElement* root = NULL); 24 virtual ~GLGuiStyle(); 21 25 22 //! Where a Certain feature will be positioned at. 23 typedef enum { 24 FeatureLeft, //!< On the Left side. 25 FeatureRight, //!< On the Right side. 26 FeatureTop, //!< On Top of the rest of the Widget. 27 FeatureBottom, //!< At the Bottom of the rest of the Widget. 28 } FeaturePosition; 26 27 /// Retrieve 28 inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; } 29 inline float borderRight(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderRight; } 30 inline float borderTop(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderTop; } 31 inline float borderBottom(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderBottom; } 32 inline float textSize(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._textSize; } 33 inline const Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundColor; } 34 inline const Texture& backgrorundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundTexture; } 35 inline const Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._foregroundColor; } 36 37 inline FeaturePosition featurePosition() const { return _featurePosition; } 38 inline const Font* const font() const { return _font; } 39 inline bool animated() const { return _animated; } 40 inline bool animatedStateChanges() const { return _animatedStateChanges; } 29 41 30 42 31 43 32 public: 33 GLGuiStyle(); 34 virtual ~GLGuiStyle(); 44 /// SETUP 45 void loadParams(const TiXmlElement* root); 46 47 void setBorderLeft(float value); 48 void setBorderLeft(float value, OrxGui::State state); 49 void setBorderLeftS(float value, const std::string& state); 50 51 void setBorderRight(float value); 52 void setBorderRight(float value, OrxGui::State state); 53 void setBorderRightS(float value, const std::string& state); 54 55 void setBorderTop(float value); 56 void setBorderTop(float value, OrxGui::State state); 57 void setBorderTopS(float value, const std::string& state); 58 59 void setBorderBottom(float value); 60 void setBorderBottom(float value, OrxGui::State state); 61 void setBorderBottomS(float value, const std::string& state); 62 63 void setTextSize(float value); 64 void setTextSize(float value, OrxGui::State state); 65 void setTextSizeS(float value, const std::string& state); 66 67 void setBackgroundColor(const Color& color); 68 void setBackgroundColor(const Color& color, OrxGui::State state); 69 void setBackgroundColorS(float r, float g, float b, float a, const std::string& state); 70 71 void setBackgroundTexture(const Texture& texture); 72 void setBackgroundTexture(const Texture& texture, OrxGui::State state); 73 void setBackgroundTexture(const std::string& textureName, const std::string& state); 74 75 void setForegroundColor(const Color& color); 76 void setForegroundColor(const Color& color, OrxGui::State state); 77 void setForegroundColorS(float r, float g, float b, float a, const std::string& state); 78 79 80 void setFeaturePosition(FeaturePosition featurePosition); 81 void setFeaturePosition(const std::string& featurePosition); 82 83 void setFont(Font* font); 84 void setFont(const std::string& fontName); 85 86 void setAnimated(bool animated); 87 void animatedStateChanges(bool animated); 35 88 36 89 private: 37 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. 38 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. 39 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts 40 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts 90 typedef struct 91 { 92 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. 93 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. 94 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts 95 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts 41 96 42 Font* _font; //!< The Font used in the current Widget. 43 float _textSize; //!< The TextSize of the Widget. 44 float _textColor; //!< The TextColor of the Widget. 97 float _textSize; //!< The TextSize of the Widget. 45 98 46 float_backgroundColor; //!< The BackgroundColor of the Widget.47 Texture _backgorundTexture; //!< The BackgroundTexture of the Widget.99 Color _backgroundColor; //!< The BackgroundColor of the Widget. 100 Texture _backgroundTexture; //!< The BackgroundTexture of the Widget. 48 101 49 float _foregroundColor; //!< The foregroundColor of the Widget. 50 Texture _foregorundTexture; //!< The ForegroundTexture of the Widget 102 Color _foregroundColor; //!< The foregroundColor of the Widget. 103 } 104 StatedStyle; 51 105 52 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)53 106 54 bool _animated; //!< If the Widget is animated (Texture might be an AnimatedTexture.) 55 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. 107 StatedStyle _style[GLGUI_STATE_COUNT]; 108 109 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...) 110 Font* _font; //!< The Font used in the current Widget. 111 112 113 bool _animated; //!< If the Widget is animated (Texture might be an AnimatedTexture.) 114 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. 56 115 }; 57 116 } -
trunk/src/lib/gui/gl/glgui_textfield.cc
r8145 r8448 53 53 GLGuiWidget::draw(); 54 54 55 this->frontMaterial().select();56 this->drawRect(this->frontRect()); 55 /* this->frontMaterial().select(); 56 this->drawRect(this->frontRect());*/ 57 57 this->endDraw(); 58 58 } -
trunk/src/lib/gui/gl/glgui_widget.cc
r8335 r8448 45 45 if (this == GLGuiWidget::_focused) 46 46 GLGuiWidget::_focused = NULL; 47 48 if (this->_toFrontColor) 49 delete this->_toFrontColor; 47 50 } 48 51 … … 66 69 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 67 70 68 this->_backMat.setDiffuse(1.0, 1.0, 1.0); 69 this->_frontMat.setDiffuse(1.0, 0.0, 0.0); 70 71 this->_borderLeft = 1.0; 71 this->_backMat.setDiffuseColor(Color(1.0, 0.5, 0.4, 1.0)); 72 this->_backMat.setDiffuseMap("gui_element_background.png"); 73 this->_frontColor = Color(1.0, 0.0, 0.0); 74 this->_toFrontColor = NULL; 75 76 77 this->_borderLeft = 15.0; 72 78 this->_borderRight = 1.0; 73 79 this->_borderTop = 1.0; … … 115 121 } 116 122 123 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously) 124 { 125 if (instantaniously) 126 { 127 this->_frontColor = frontColor; 128 if (this->_toFrontColor != NULL) 129 { 130 delete this->_toFrontColor; 131 this->_toFrontColor = NULL; 132 } 133 } 134 else if (!this->_toFrontColor) 135 this->_toFrontColor = new Color(frontColor); 136 else 137 *this->_toFrontColor = frontColor; 138 //this->_frontColor = frontColor; 139 //this->updateFrontColor(); 140 }; 141 117 142 118 143 void GLGuiWidget::setBorderSize(float borderSize) … … 176 201 void GLGuiWidget::clicking(const Vector2D& pos) 177 202 { 178 this-> frontMaterial().setDiffuse(0, 0, 1);203 this->setFrontColor(Color(0, 0, 1)); 179 204 180 205 } … … 182 207 void GLGuiWidget::releasing(const Vector2D& pos) 183 208 { 184 this-> frontMaterial().setDiffuse(0,1,0);209 this->setFrontColor(Color(0,1,0)); 185 210 186 211 } … … 188 213 void GLGuiWidget::receivedFocus() 189 214 { 190 this-> frontMaterial().setDiffuse(0, 1, 0);215 this->setFrontColor(Color(0, 1, 0)); 191 216 } 192 217 193 218 void GLGuiWidget::removedFocus() 194 219 { 195 this-> frontMaterial().setDiffuse(1, 0, 0);220 this->setFrontColor(Color(1, 0, 0)); 196 221 197 222 } … … 201 226 ; 202 227 228 203 229 void GLGuiWidget::setWidgetSize(const Vector2D& size) 204 230 { … … 239 265 this->setVisibility(false); 240 266 this->hiding(); 267 } 268 269 void GLGuiWidget::tick(float dt) 270 { 271 if (this->_toFrontColor) 272 { 273 this->_frontColor.slerp(*_toFrontColor, dt*3.0); 274 this->updateFrontColor(); 275 if (this->_frontColor.dist(*_toFrontColor) < .1) 276 { 277 delete _toFrontColor; 278 _toFrontColor = NULL; 279 } 280 } 241 281 } 242 282 … … 249 289 this->backMaterial().select(); 250 290 this->drawRect(this->backRect()); 291 this->backMaterial().unselect(); 251 292 } 252 293 -
trunk/src/lib/gui/gl/glgui_widget.h
r8312 r8448 8 8 9 9 #include "element_2d.h" 10 11 #include "glgui_style.h" 12 #include "material.h" 10 13 #include "rect2D.h" 11 12 #include "material.h"13 14 14 15 #include "event.h" 15 16 #include "signal_connector.h" 16 17 #include "glincl.h"18 19 #include <vector>20 21 // FORWARD DECLARATION22 class Material;23 17 24 18 namespace OrxGui … … 27 21 class GLGuiCursor; 28 22 29 //! if the Element should be visible by default.30 #define GLGUI_WIDGET_DEFAULT_VISIBLE false31 23 32 24 //! This is widget part of the openglGUI class … … 35 27 */ 36 28 class GLGuiWidget : public Element2D 37 { 38 public: 39 //! An enumerator that defines the different states Widgets may be in. 40 typedef enum { 41 Normal, //!< Normal state of the GUI's Widgets. 42 Active, //!< If the widget is Active. 43 Selected, //!< If the Widget is Selected. 44 Insensitive //!< If the Widget is insensitive. 45 } State; 46 47 48 29 { 49 30 public: 50 31 GLGuiWidget(GLGuiWidget* parent = NULL); … … 92 73 const Rect2D& backRect() const { return this->_backRect; }; 93 74 94 Material& frontMaterial() { return this->_frontMat; }; 95 const Material& frontMaterial() const { return this->_frontMat; }; 96 Rect2D& frontRect() { return this->_frontRect; }; 97 const Rect2D& frontRect() const { return this->_frontRect; }; 75 void setFrontColor(const Color& frontColor, bool instantaniously = false); 76 const Color& frontColor() const { return this->_frontColor; }; 98 77 99 78 /** @brief sets all borders to the same value. */ … … 116 95 void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); }; 117 96 118 inline void drawRect(const Rect2D& rect) const { 97 inline void drawRect(const Rect2D& rect) const 98 { 119 99 glBegin(GL_QUADS); 120 100 glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top()); … … 127 107 128 108 virtual void update() {}; 109 virtual void tick(float dt); 129 110 virtual void draw() const; 130 111 … … 132 113 virtual bool processEvent(const Event& event) { return false; }; 133 114 115 134 116 protected: 135 136 117 /// LOOKS 137 118 virtual void resize(); … … 139 120 virtual void hiding() {}; 140 121 virtual void showing() {}; 122 virtual void updateFrontColor() {}; 123 124 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; 125 inline void endDraw() const { glPopMatrix(); }; 126 127 /// EVENTS 141 128 // if something was clickt on the GUI-widget. 142 129 virtual void clicking(const Vector2D& pos); … … 147 134 virtual void destroyed(); 148 135 149 150 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };151 inline void endDraw() const { glPopMatrix(); };152 153 136 private: 154 137 void init(); 155 156 138 157 139 private: … … 162 144 Rect2D _backRect; 163 145 164 Material _frontMat;165 Rect2D _frontRect;146 Color _frontColor; 147 Color* _toFrontColor; 166 148 167 149 float _borderLeft; … … 171 153 172 154 Vector2D _minSize; 155 156 GLGuiStyle _style; 173 157 174 158 /// EVENTS
Note: See TracChangeset
for help on using the changeset viewer.