Changeset 8419 in orxonox.OLD for branches/gui/src
- Timestamp:
- Jun 14, 2006, 11:07:48 PM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/graphics/text_engine/multi_line_text.cc
r8059 r8419 76 76 glActiveTexture(GL_TEXTURE0); 77 77 78 glColor4f (this->getColor().x, this->getColor().y, this->getColor().z, this->getBlending());78 glColor4fv(&this->getColor()[0]); 79 79 glEnable(GL_BLEND); 80 80 glEnable(GL_TEXTURE_2D); 81 glBlendFunc(GL_SRC_ALPHA, GL_ONE );81 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 82 82 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 83 83 -
branches/gui/src/lib/graphics/text_engine/text.cc
r8037 r8419 37 37 this->size = textSize; 38 38 this->setSizeY2D(size); 39 this->blending = TEXT_DEFAULT_BLENDING;40 39 this->color = TEXT_DEFAULT_COLOR; 41 40 … … 73 72 this->size == text.size && 74 73 this->font == text.font && 75 this->color == text.color && 76 this->blending == text.blending); 74 this->color == text.color); 77 75 } 78 76 … … 95 93 { 96 94 this->size = text.size; 97 this->blending = text.blending;98 95 this->color = text.color; 99 96 this->setAlignment(text.getAlignment()); … … 224 221 // drawing this Text. 225 222 // setting the Blending effects 226 glColor4f (this->color.x, this->color.y, this->color.z, this->blending);223 glColor4fv(&this->color[0]); 227 224 228 225 … … 231 228 glEnable(GL_BLEND); 232 229 glEnable(GL_TEXTURE_2D); 233 glBlendFunc(GL_SRC_ALPHA, GL_ONE );230 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 234 231 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 235 232 … … 285 282 { 286 283 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->font->getName(), this->text.c_str()); 287 PRINT(0)("Color: %0.2f %0.2f %0.2f\n", this->color.x, this->color.y, this->color.z);288 } 289 284 PRINT(0)("Color: r=%0.2f g=%0.2f b=%0.2f a=%0.2f\n", this->color.r(), this->color.g(), this->color.b(), this->color.a()); 285 } 286 -
branches/gui/src/lib/graphics/text_engine/text.h
r7919 r8419 8 8 9 9 #include "element_2d.h" 10 #include "color.h" 10 11 11 12 #define TEXT_ALIGN_LEFT E2D_ALIGN_LEFT … … 13 14 #define TEXT_ALIGN_CENTER E2D_ALIGN_CENTER 14 15 #define TEXT_ALIGN_SCREEN_CENTER E2D_ALIGN_SCREEN_CENTER 15 #define TEXT_DEFAULT_COLOR Vector(1.0, 1.0, 1.0) //!< the default Color (white) 16 #define TEXT_DEFAULT_BLENDING 1.0f //!< the default blending of the text, (no blending at all) 16 #define TEXT_DEFAULT_COLOR Color(1.0, 1.0, 1.0, 1.0f) //!< the default Color (white, fully visible) 17 17 18 18 #define TEXT_DEFAULT_ALIGNMENT TEXT_ALIGN_LEFT //!< default alignment … … 44 44 void setFont(const std::string& fontFile, unsigned int renderSize); 45 45 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 46 inline void setBlending(float blending) { this-> blending= blending; };46 inline void setBlending(float blending) { this->color.a() = blending; }; 47 47 /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */ 48 void setColor(float r, float g, float b) { this->color = Vector(r, g, b); }; 48 void setColor(float r, float g, float b) { this->color = Color(r, g, b, this->color.a()); }; 49 void setColor(float r, float g, float b, float a) { this->color = Color(r, g, b, a); }; 50 void setColor(const Color& color) { this->color = color; }; 49 51 void setSize(float size); 50 52 … … 57 59 inline const Font* const getFont() const { return this->font; }; 58 60 /** @returns the Blending Value [0 invisible 1.0 full visible */ 59 inline float getBlending() const { return this-> blending; };61 inline float getBlending() const { return this->color.a(); }; 60 62 /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */ 61 inline const Vector& getColor() const { return this->color; };63 inline const Color& getColor() const { return this->color; }; 62 64 /** @returns the Size of the Text */ 63 65 inline float getSize() const { return this->size; }; … … 76 78 77 79 std::string text; //!< The text to display 78 Vector color; //!< The color of the font. 79 float blending; //!< The blending intensity. 80 Color color; //!< The color of the font. 80 81 float size; //!< The size of the Text. 81 82 }; -
branches/gui/src/lib/gui/gl/glgui_bar.cc
r8378 r8419 46 46 this->setClassID(CL_GLGUI_BAR, "GLGuiBar"); 47 47 48 this-> frontColor().setColor(1,1,1);48 this->setFrontColor(Color(1,1,1)); 49 49 50 50 this->setSize2D(50, 10); -
branches/gui/src/lib/gui/gl/glgui_button.cc
r8378 r8419 55 55 56 56 this->_label.setFont("fonts/final_frontier.ttf", 20); 57 this-> frontColor().setColor(1, 0, 0, 1.0);57 this->setFrontColor(Color(1, 0, 0, 1.0)); 58 58 59 59 this->_label.setParent2D(this); … … 69 69 70 70 71 void GLGuiButton::updateFrontColor() 72 { 73 this->_label.setColor(this->frontColor()); 74 printf("TEST Color is "); this->frontColor().debug(); 75 } 71 76 72 77 void GLGuiButton::clicking(const Vector2D& pos) 73 78 { 79 GLGuiWidget::clicking(pos); 74 80 emit(clicked()); 75 81 } 76 82 void GLGuiButton::releasing(const Vector2D& pos) 77 83 { 84 GLGuiWidget::releasing(pos); 78 85 emit(released()); 79 86 } -
branches/gui/src/lib/gui/gl/glgui_button.h
r8145 r8419 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); -
branches/gui/src/lib/gui/gl/glgui_inputline.cc
r8378 r8419 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.setVisibility(false); 54 54 this->resize(); 55 55 … … 63 63 void GLGuiInputLine::setText(const std::string& text) 64 64 { 65 this-> text.setText(text);66 this->resize(); 67 68 emit(this->textChanged(this-> getText()));65 this->_text.setText(text); 66 this->resize(); 67 68 emit(this->textChanged(this->_text.getText())); 69 69 } 70 70 … … 75 75 void GLGuiInputLine::append(const std::string& appendText) 76 76 { 77 this-> text.append(appendText);78 this->resize(); 79 emit(this->textChanged(this-> text.getText()));77 this->_text.append(appendText); 78 this->resize(); 79 emit(this->textChanged(this->_text.getText())); 80 80 } 81 81 … … 87 87 void GLGuiInputLine::appendCharacter(char character) 88 88 { 89 this-> text.appendCharacter(character);90 this->resize(); 91 emit(this->textChanged(this-> text.getText()));89 this->_text.appendCharacter(character); 90 this->resize(); 91 emit(this->textChanged(this->_text.getText())); 92 92 } 93 93 … … 99 99 void GLGuiInputLine::removeCharacters(unsigned int chars) 100 100 { 101 this-> text.removeCharacters(chars);102 this->resize(); 103 emit(this->textChanged(this-> text.getText()));101 this->_text.removeCharacters(chars); 102 this->resize(); 103 emit(this->textChanged(this->_text.getText())); 104 104 } 105 105 … … 164 164 void GLGuiInputLine::resize() 165 165 { 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));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)); 168 168 GLGuiWidget::resize(); 169 169 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); … … 171 171 } 172 172 173 void GLGuiInputLine::updateFrontColor() 174 { 175 this->_text.setColor(this->frontColor()); 176 } 173 177 174 178 void GLGuiInputLine::hiding() 175 179 { 176 this-> text.setVisibility(false);180 this->_text.setVisibility(false); 177 181 } 178 182 179 183 void GLGuiInputLine::showing() 180 184 { 181 this-> text.setVisibility(true);185 this->_text.setVisibility(true); 182 186 } 183 187 -
branches/gui/src/lib/gui/gl/glgui_inputline.h
r8145 r8419 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 55 50 56 private: 51 57 void init(); 52 58 void resize(); 53 virtual void hiding();54 virtual void showing();55 59 56 60 private: 57 Text text;//!< The Text to display inside of the InputLine.61 Text _text; //!< The Text to display inside of the InputLine. 58 62 59 63 Uint16 pressedKey; //!< the pressed key that will be repeated. -
branches/gui/src/lib/gui/gl/glgui_widget.cc
r8378 r8419 66 66 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 67 67 68 this->_backMat.setDiffuse( 1.0, 1.0, 1.0);68 this->_backMat.setDiffuse(0.0, 0.0, 0.0); 69 69 this->_frontColor.setColor(1.0, 0.0, 0.0); 70 70 … … 176 176 void GLGuiWidget::clicking(const Vector2D& pos) 177 177 { 178 this-> frontColor().setColor(0, 0, 1);178 this->setFrontColor(Color(0, 0, 1)); 179 179 180 180 } … … 182 182 void GLGuiWidget::releasing(const Vector2D& pos) 183 183 { 184 this-> frontColor().setColor(0,1,0);184 this->setFrontColor(Color(0,1,0)); 185 185 186 186 } … … 188 188 void GLGuiWidget::receivedFocus() 189 189 { 190 this-> frontColor().setColor(0, 1, 0);190 this->setFrontColor(Color(0, 1, 0)); 191 191 } 192 192 193 193 void GLGuiWidget::removedFocus() 194 194 { 195 this-> frontColor().setColor(1, 0, 0);195 this->setFrontColor(Color(1, 0, 0)); 196 196 197 197 } 198 198 199 199 void GLGuiWidget::destroyed() 200 {} 201 ; 200 { 201 }; 202 202 203 203 204 void GLGuiWidget::setWidgetSize(const Vector2D& size) -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8378 r8419 35 35 */ 36 36 class GLGuiWidget : public Element2D 37 {37 { 38 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;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 46 47 47 … … 92 92 const Rect2D& backRect() const { return this->_backRect; }; 93 93 94 Color& frontColor() { return this->_frontColor; };94 void setFrontColor(const Color& frontColor) { this->_frontColor = frontColor; this->updateFrontColor(); }; 95 95 const Color& frontColor() const { return this->_frontColor; }; 96 96 … … 114 114 void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); }; 115 115 116 inline void drawRect(const Rect2D& rect) const { 116 inline void drawRect(const Rect2D& rect) const 117 { 117 118 glBegin(GL_QUADS); 118 119 glTexCoord2i(0,0); glVertex2d(rect.left(), rect.top()); … … 130 131 virtual bool processEvent(const Event& event) { return false; }; 131 132 133 132 134 protected: 133 134 135 /// LOOKS 135 136 virtual void resize(); … … 137 138 virtual void hiding() {}; 138 139 virtual void showing() {}; 140 virtual void updateFrontColor() {}; 141 142 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; 143 inline void endDraw() const { glPopMatrix(); }; 144 145 /// EVENTS 139 146 // if something was clickt on the GUI-widget. 140 147 virtual void clicking(const Vector2D& pos); … … 145 152 virtual void destroyed(); 146 153 147 148 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };149 inline void endDraw() const { glPopMatrix(); };150 151 154 private: 152 155 void init(); 153 154 156 155 157 private: -
branches/gui/src/lib/util/color.cc
r8376 r8419 18 18 #include "color.h" 19 19 #include <stdio.h> 20 21 22 void Color::debug() const 23 { 24 printf("r:%0.2f g:%0.2f, b:%0.2f, a:%0.2f\n", r(), g(), b(), a()); 25 } 20 26 21 27 /** -
branches/gui/src/lib/util/color.h
r8378 r8419 19 19 Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); } 20 20 21 const Color& operator=(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); return *this; }; 22 bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); }; 23 21 24 inline float& operator[](unsigned int i) { return _rgba[i]; } 22 25 inline const float& operator[](unsigned int i) const { return _rgba[i]; } … … 31 34 inline float& a() { return _rgba[3]; } 32 35 36 37 33 38 void setColor(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; }; 34 39 40 void debug() const; 35 41 36 42 /// STATIC TRANSFORMATIONS -
branches/gui/src/util/hud.cc
r8378 r8419 132 132 weapon->getEnergyWidget()->backMaterial().setDiffuse( .8,.2,.11); 133 133 weapon->getEnergyWidget()->backMaterial().setTransparency(.1); 134 weapon->getEnergyWidget()-> frontColor().setColor( .2,.5,.7,.6);134 weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6)); 135 135 // weapon->getEnergyWidget()->frontMaterial().setTransparency(.6); 136 136 this->weaponsWidgets.push_back(weapon->getEnergyWidget());
Note: See TracChangeset
for help on using the changeset viewer.