Changeset 8619 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Jun 20, 2006, 1:24:11 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 2 deleted
- 34 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r8490 r8619 355 355 else 356 356 { 357 SDL_WM_GrabInput(SDL_GRAB_ON);357 //SDL_WM_GrabInput(SDL_GRAB_ON); 358 358 SDL_ShowCursor(SDL_DISABLE); 359 359 } -
trunk/src/lib/graphics/Makefile.am
r8293 r8619 4 4 noinst_LIBRARIES = libORXgraphics.a 5 5 6 libORXgraphics_a_SOURCES = graphics_engine.cc \ 7 light.cc \ 8 shader.cc \ 9 \ 10 render2D/render_2d.cc \ 11 render2D/element_2d.cc \ 12 render2D/image_plane.cc \ 13 \ 14 text_engine/text_engine.cc \ 15 text_engine/text.cc \ 16 text_engine/multi_line_text.cc \ 17 text_engine/font.cc \ 18 \ 19 effects/graphics_effect.cc \ 20 effects/atmospheric_engine.cc \ 21 effects/weather_effect.cc \ 22 effects/sun_effect.cc \ 23 effects/fog_effect.cc \ 24 effects/volfog_effect.cc \ 25 effects/rain_effect.cc \ 26 effects/snow_effect.cc \ 27 effects/cloud_effect.cc \ 28 effects/lightening_effect.cc \ 29 effects/lense_flare.cc 6 libORXgraphics_a_SOURCES = \ 7 graphics_engine.cc \ 8 light.cc \ 9 shader.cc \ 10 \ 11 render2D/render_2d.cc \ 12 render2D/element_2d.cc \ 13 render2D/image_plane.cc \ 14 \ 15 text_engine/text_engine.cc \ 16 text_engine/text.cc \ 17 text_engine/multi_line_text.cc \ 18 text_engine/limited_width_text.cc \ 19 text_engine/font.cc \ 20 \ 21 effects/graphics_effect.cc \ 22 effects/atmospheric_engine.cc \ 23 effects/weather_effect.cc \ 24 effects/sun_effect.cc \ 25 effects/fog_effect.cc \ 26 effects/volfog_effect.cc \ 27 effects/rain_effect.cc \ 28 effects/snow_effect.cc \ 29 effects/cloud_effect.cc \ 30 effects/lightening_effect.cc \ 31 effects/lense_flare.cc 30 32 31 33 noinst_HEADERS = graphics_engine.h \ … … 40 42 text_engine/text.h \ 41 43 text_engine/multi_line_text.h \ 44 text_engine/limited_width_text.h \ 42 45 text_engine/font.h \ 43 46 text_engine/default_font.xpm \ -
trunk/src/lib/graphics/effects/lense_flare.cc
r8495 r8619 47 47 this->setClassID(CL_LENSE_FLARE, "LenseFlare"); 48 48 49 this->flareMatrix = new float[14];50 49 /* length image scale */ 51 50 this->flareMatrix[0] = 1.0f; -
trunk/src/lib/graphics/effects/lense_flare.h
r8495 r8619 51 51 bool bVisible; //!< Checks visibility 52 52 Light* lightSource; //!< reference to the sun (or primary light source) 53 std::vector<ImagePlane*> 53 std::vector<ImagePlane*> flares; //!< the flares array 54 54 55 55 Vector2D flareVector; //!< the axis to draw the flares on … … 57 57 Vector2D screenCenter; //!< the vector marking the center of the screen 58 58 59 float * flareMatrix;59 float flareMatrix[14]; 60 60 Plane frustumPlane; //!< plane that marks the view frustum 61 61 }; -
trunk/src/lib/graphics/importer/material.cc
r8376 r8619 22 22 #include "debug.h" 23 23 #include "compiler.h" 24 25 #include "loading/load_param.h" 26 24 27 #include "util/loading/resource_manager.h" 25 28 … … 47 50 } 48 51 52 Material& Material::operator=(const Material& material) 53 { 54 this->illumModel = material.illumModel; 55 this->diffuse = material.diffuse; 56 this->specular = material.specular; 57 this->ambient = material.ambient; 58 this->shininess = material.shininess; 59 60 this->textures = material.textures; 61 this->sFactor = material.sFactor; 62 this->tFactor = material.tFactor; 63 this->setName(material.getName()); 64 65 return *this; 66 } 67 68 69 70 void Material::loadParams(const TiXmlElement* root) 71 { 72 LoadParam(root, "illum", this, Material, setIllum); 73 74 LoadParam(root, "diffuse-color", this, Material , setDiffuse); 75 LoadParam(root, "ambient-color", this, Material , setAmbient); 76 LoadParam(root, "specular-color", this, Material , setSpecular); 77 LoadParam(root, "transparency", this, Material , setTransparency); 78 79 LoadParam(root, "tex", this, Material, setDiffuseMap); 80 LoadParam(root, "blendfunc", this, Material, setBlendFuncS) 81 .defaultValues("ZERO", "ZERO"); 82 } 83 84 49 85 /** 50 86 * @brief deletes a Material … … 65 101 66 102 const Material* Material::selectedMaterial = NULL; 67 68 const GLenum Material::glTextureArbs[] =69 {70 GL_TEXTURE0,71 GL_TEXTURE1,72 GL_TEXTURE2,73 GL_TEXTURE3,74 GL_TEXTURE4,75 GL_TEXTURE5,76 GL_TEXTURE6,77 GL_TEXTURE778 };79 103 80 104 … … 104 128 * @brief sets the material with which the following Faces will be painted 105 129 */ 106 130 bool Material::select() const 107 131 { 108 132 if (unlikely(this == Material::selectedMaterial)) 109 110 111 /// !! HACK !!! FIX THIS IN MODEL ///133 return true; 134 135 /// !! HACK !!! FIX THIS IN MODEL /// 112 136 else if (likely(Material::selectedMaterial != NULL)) 113 137 { 114 Material::unselect();115 // for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)116 // {117 // glActiveTexture(Material::glTextureArbs[i]);118 // glBindTexture(GL_TEXTURE_2D, 0);119 // glDisable(GL_TEXTURE_2D);120 // }138 Material::unselect(); 139 // for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i) 140 // { 141 // glActiveTexture(Material::glTextureArbs[i]); 142 // glBindTexture(GL_TEXTURE_2D, 0); 143 // glDisable(GL_TEXTURE_2D); 144 // } 121 145 } 122 146 … … 125 149 for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i) 126 150 { 127 128 129 151 glActiveTexture(Material::glTextureArbs[i]); 152 //glBindTexture(GL_TEXTURE_2D, 0); 153 glDisable(GL_TEXTURE_2D); 130 154 } 131 155 } 132 156 133 157 // setting diffuse color 134 158 glColor4f (diffuse.r(), diffuse.g(), diffuse.b(), diffuse.a()); 135 159 // setting ambient color … … 161 185 for(unsigned int i = 0; i < this->textures.size(); ++i) 162 186 { 163 164 165 166 167 168 169 187 glActiveTexture(Material::glTextureArbs[i]); 188 glEnable(GL_TEXTURE_2D); 189 if(this->textures[i].hasAlpha()) 190 { 191 glEnable(GL_BLEND); 192 } 193 glBindTexture(GL_TEXTURE_2D, this->textures[i].getTexture()); 170 194 } 171 195 Material::selectedMaterial = this; … … 179 203 { 180 204 Material::selectedMaterial = NULL; 181 182 183 184 185 186 205 for(unsigned int i = 0; i < 8; ++i) 206 { 207 glActiveTexture(Material::glTextureArbs[i]); 208 glBindTexture(GL_TEXTURE_2D, 0); 209 glDisable(GL_TEXTURE_2D); 210 } 187 211 } 188 212 … … 252 276 this->diffuse.a() = trans; 253 277 } 278 279 /** 280 * @brief sets the Blend-Function Parameters 281 * @param sFactor the Source Parameter. 282 * @param tFactor the Desitnation Parameter. 283 */ 284 void Material::setBlendFuncS(const std::string& sFactor, const std::string& tFactor) 285 { 286 this->setBlendFunc(Material::stringToBlendFunc(sFactor), Material::stringToBlendFunc(tFactor)); 287 } 288 289 254 290 255 291 /** … … 354 390 // HACK 355 391 glActiveTexture(textureNumber); 356 357 392 glEnable(GL_TEXTURE_2D); 393 glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture()); 358 394 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 359 395 … … 387 423 */ 388 424 void Material::setBump(const std::string& bump) 389 { 390 } 425 {} 391 426 392 427 … … 400 435 return maxTexUnits; 401 436 } 437 438 const GLenum Material::glTextureArbs[] = 439 { 440 GL_TEXTURE0, 441 GL_TEXTURE1, 442 GL_TEXTURE2, 443 GL_TEXTURE3, 444 GL_TEXTURE4, 445 GL_TEXTURE5, 446 GL_TEXTURE6, 447 GL_TEXTURE7 448 }; 449 450 451 /** 452 * @param blendFunc the Enumerator to convert to a String. 453 * @returns the matching String if found 454 */ 455 const std::string& Material::blendFuncToString(GLenum blendFunc) 456 { 457 for (unsigned int i = 0; i < 9; ++i) 458 if (blendFunc == Material::glBlendFuncParams[i]) 459 return Material::blendFuncNames[i]; 460 PRINTF(2)("Supplied an Invalid Enumerator to blendfunc %d\n", blendFunc); 461 return Material::blendFuncNames[0]; 462 } 463 464 /** 465 * @param blendFuncString the String to convert into a gl-enumeration 466 * @returns the matching GL-enumeration if found. 467 */ 468 GLenum Material::stringToBlendFunc(const std::string& blendFuncString) 469 { 470 for (unsigned int i = 0; i < 9; ++i) 471 if (blendFuncString == Material::blendFuncNames[i]) 472 return Material::glBlendFuncParams[i]; 473 PRINTF(2)("BlendFunction %s not recognized using %s\n", blendFuncString.c_str(), Material::blendFuncNames[0].c_str()); 474 return Material::glBlendFuncParams[0]; 475 } 476 477 478 const GLenum Material::glBlendFuncParams[] = 479 { 480 GL_ZERO, 481 GL_ONE, 482 GL_DST_COLOR, 483 GL_ONE_MINUS_DST_COLOR, 484 GL_SRC_ALPHA, 485 GL_ONE_MINUS_SRC_ALPHA, 486 GL_DST_ALPHA, 487 GL_ONE_MINUS_DST_ALPHA, 488 GL_SRC_ALPHA_SATURATE 489 }; 490 491 const std::string Material::blendFuncNames[] = 492 { 493 "ZERO", 494 "ONE", 495 "DST_COLOR", 496 "ONE_MINUS_DST_COLOR", 497 "SRC_ALPHA", 498 "ONE_MINUS_SRC_ALPHA", 499 "DST_ALPHA", 500 "ONE_MINUS_DST_ALPHA", 501 "SRC_ALPHA_SATURATE" 502 503 }; -
trunk/src/lib/graphics/importer/material.h
r8448 r8619 24 24 class Material : public BaseObject 25 25 { 26 27 28 26 public: 27 Material (const std::string& mtlName = ""); 28 virtual ~Material (); 29 29 30 Material& operator=(const Material& material);30 void loadParams(const TiXmlElement* root); 31 31 32 bool select () const; 33 bool activateTextureUnit(unsigned int textureNumber); 34 static void unselect(); 32 Material& operator=(const Material& material); 35 33 36 void setIllum (int illum); 37 int getIllumModel() const { return this->illumModel; }; 34 bool select () const; 35 bool activateTextureUnit(unsigned int textureNumber); 36 static void unselect(); 38 37 39 void setDiffuse (float r, float g, float b); 40 void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; }; 41 void setAmbient (float r, float g, float b); 42 void setSpecular (float r, float g, float b); 43 void setShininess (float shini); 44 void setTransparency (float trans); 45 void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; 38 void setIllum (int illum); 39 int getIllumModel() const { return this->illumModel; }; 46 40 47 const Color& getDiffuseColor() const { return diffuse; }; 41 void setDiffuse (float r, float g, float b); 42 void setDiffuseColor(const Color& diffuseColor) { this->diffuse = diffuseColor; }; 43 void setAmbient (float r, float g, float b); 44 void setSpecular (float r, float g, float b); 45 void setShininess (float shini); 46 void setTransparency (float trans); 47 void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; }; 48 void setBlendFuncS(const std::string& sFactor, const std::string& tFactor); 48 49 49 // MAPPING // 50 void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0); 51 void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); 52 void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); 53 void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); 50 Color& diffuseColor() { return diffuse; }; 51 const Color& diffuseColor() const { return diffuse; }; 54 52 55 void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D); 56 void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D); 57 void setBump(const std::string& bump); 58 GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; }; 53 // MAPPING // 54 void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0); 55 void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); 56 void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0); 57 void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); 59 58 60 static void addTexturePath(const std::string& pathName); 59 void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D); 60 void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D); 61 void setBump(const std::string& bump); 61 62 62 public: 63 static const GLenum glTextureArbs[]; //!< The Texture ARB's 63 GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; }; 64 64 65 static unsigned int getMaxTextureUnits();65 const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; }; 66 66 67 private: 68 static const Material* selectedMaterial; //!< The currently selected material. 67 static void addTexturePath(const std::string& pathName); 69 68 70 int illumModel; //!< The IlluminationModel is either flat or smooth. 71 Color diffuse; //!< The diffuse color of the Material. (also transparency.) 72 Color ambient; //!< The ambient color of the Material. 73 Color specular; //!< The specular color of the Material. 74 float shininess; //!< The shininess of the Material. 75 GLenum sFactor; //!< The Blending Factor for the Source. 76 GLenum tFactor; //!< The Blending Factor for the Destination. 69 const std::string& blendFuncToString(GLenum blendFunc); 70 GLenum stringToBlendFunc(const std::string& blendFuncString); 77 71 78 std::vector<Texture> textures; //!< An Array of Textures.79 72 80 Texture* ambientTexture; //!< The ambient texture of the Material. 81 Texture* specularTexture; //!< The specular texture of the Material. 73 public: 74 static const GLenum glTextureArbs[]; //!< The Texture ARB's 75 76 static const GLenum glBlendFuncParams[]; 77 static const std::string blendFuncNames[]; 78 79 static unsigned int getMaxTextureUnits(); 80 81 private: 82 static const Material* selectedMaterial; //!< The currently selected material. 83 84 int illumModel; //!< The IlluminationModel is either flat or smooth. 85 Color diffuse; //!< The diffuse color of the Material. (also transparency.) 86 Color ambient; //!< The ambient color of the Material. 87 Color specular; //!< The specular color of the Material. 88 float shininess; //!< The shininess of the Material. 89 GLenum sFactor; //!< The Blending Factor for the Source. 90 GLenum tFactor; //!< The Blending Factor for the Destination. 91 92 std::vector<Texture> textures; //!< An Array of Textures. 93 94 Texture* ambientTexture; //!< The ambient texture of the Material. 95 Texture* specularTexture; //!< The specular texture of the Material. 82 96 }; 83 97 -
trunk/src/lib/graphics/importer/texture_sequence.cc
r8324 r8619 180 180 } 181 181 bool success = this->addFrame(addSurface); 182 delete addSurface;182 SDL_FreeSurface(addSurface); 183 183 184 184 return success; -
trunk/src/lib/graphics/text_engine/multi_line_text.cc
r8448 r8619 61 61 void MultiLineText::draw() const 62 62 { 63 if (unlikely(this-> getText().empty()))63 if (unlikely(this->text().empty())) 64 64 return; 65 65 glPushMatrix(); … … 76 76 glActiveTexture(GL_TEXTURE0); 77 77 78 glColor4fv(&this-> getColor()[0]);78 glColor4fv(&this->color()[0]); 79 79 glEnable(GL_BLEND); 80 80 glEnable(GL_TEXTURE_2D); … … 82 82 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 83 83 84 glBindTexture(GL_TEXTURE_2D, this-> getFont()->getTexture());84 glBindTexture(GL_TEXTURE_2D, this->font()->getTexture()); 85 85 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 86 86 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 92 92 93 93 glBegin(GL_QUADS); 94 for (unsigned int i = 0; i < this-> getText().size(); ++i)94 for (unsigned int i = 0; i < this->text().size(); ++i) 95 95 { 96 96 if (unlikely(this->lineEnds.size() > lineNumber && i == this->lineEnds[lineNumber])) … … 99 99 ++lineNumber; 100 100 posX = 0.0f; 101 posY += this->lineSpacing + this-> getSize(); //this->getFont()->getMaxHeight();101 posY += this->lineSpacing + this->size(); //this->font()->getMaxHeight(); 102 102 } 103 103 104 if(likely((tmpGlyph = this-> getFont()->getGlyphArray()[this->getText()[i]]) != NULL))104 if(likely((tmpGlyph = this->font()->getGlyphArray()[this->text()[i]]) != NULL)) 105 105 { 106 106 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 107 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), posY);107 glVertex2d(posX+tmpGlyph->maxX*this->size(), posY); 108 108 109 109 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 110 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), posY + this->getSize());110 glVertex2d(posX+tmpGlyph->maxX*this->size(), posY + this->size()); 111 111 112 112 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 113 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), posY+ this->getSize());113 glVertex2d(posX+tmpGlyph->minX*this->size(), posY+ this->size()); 114 114 115 115 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 116 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), posY);116 glVertex2d(posX+tmpGlyph->minX*this->size(), posY); 117 117 118 posX += tmpGlyph->advance * this-> getSize();118 posX += tmpGlyph->advance * this->size(); 119 119 } 120 120 } … … 132 132 this->lineEnds.clear(); 133 133 float width = 0.0f; 134 float maxWidth = this->lineWidth / this-> getSize();134 float maxWidth = this->lineWidth / this->size(); 135 135 136 for (unsigned int i = 0; i < this-> getText().size(); i++)136 for (unsigned int i = 0; i < this->text().size(); i++) 137 137 { 138 if (width > maxWidth || this-> getText()[i] == '\n')138 if (width > maxWidth || this->text()[i] == '\n') 139 139 { 140 140 if (likely(i > 0)) 141 141 { 142 142 this->lineEnds.push_back( i -1 ); 143 width = this-> getFont()->getGlyphArray()[this->getText()[i-1]]->advance;143 width = this->font()->getGlyphArray()[this->text()[i-1]]->advance; 144 144 } 145 145 else … … 148 148 149 149 // Advance the Text. 150 if(this-> getFont()->getGlyphArray()[this->getText()[i]] != NULL)151 width += this-> getFont()->getGlyphArray()[this->getText()[i]]->advance;150 if(this->font()->getGlyphArray()[this->text()[i]] != NULL) 151 width += this->font()->getGlyphArray()[this->text()[i]]->advance; 152 152 } 153 153 this->lineCount = lineEnds.size() + 1; 154 this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this-> getFont()->getMaxHeight()));154 this->setSizeY2D((this->lineEnds.size()+1) * (this->lineSpacing + this->font()->getMaxHeight())); 155 155 } 156 156 … … 162 162 printf("Debug %s::%s: %d lines\n", this->getClassName(), this->getName(), this->getLineCount()); 163 163 164 std::string tmpText = this-> getText();164 std::string tmpText = this->text(); 165 165 std::vector<unsigned int> ends = this->lineEnds; 166 166 ends.push_back(tmpText.size()); -
trunk/src/lib/graphics/text_engine/text.cc
r8518 r8619 22 22 #include "debug.h" 23 23 24 using namespace std;25 26 24 /** 27 25 * @brief creates a new Text Element … … 34 32 35 33 // initialize this Text 36 this-> font = NULL;37 this-> size = textSize;38 this->setSizeY2D( size);39 this-> color = TEXT_DEFAULT_COLOR;34 this->_font = NULL; 35 this->_size = textSize; 36 this->setSizeY2D(textSize); 37 this->_color = TEXT_DEFAULT_COLOR; 40 38 41 39 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); … … 47 45 { 48 46 this->setClassID(CL_TEXT, "Text"); 49 this-> font = NULL;47 this->_font = NULL; 50 48 51 49 *this = text; … … 58 56 Text::~Text() 59 57 { 60 if (this-> font != NULL && this->font != Font::getDefaultFont())61 ResourceManager::getInstance()->unload(this-> font);58 if (this->_font != NULL && this->_font != Font::getDefaultFont()) 59 ResourceManager::getInstance()->unload(this->_font); 62 60 } 63 61 … … 69 67 bool Text::operator==(const Text& text) const 70 68 { 71 return (this-> text == text.text &&72 this-> size == text.size &&73 this-> font == text.font &&74 this-> color == text.color);69 return (this->_text == text._text && 70 this->_size == text._size && 71 this->_font == text._font && 72 this->_color == text._color); 75 73 } 76 74 … … 82 80 bool Text::operator==(const std::string& text) const 83 81 { 84 return (this-> text == text);82 return (this->_text == text); 85 83 } 86 84 … … 92 90 Text& Text::operator=(const Text& text) 93 91 { 94 this-> size = text.size;95 this-> color = text.color;92 this->_size = text._size; 93 this->_color = text._color; 96 94 this->setAlignment(text.getAlignment()); 97 if (this-> font != NULL)98 ResourceManager::getInstance()->unload(this-> font);99 100 this-> font = (Font*)ResourceManager::getInstance()->copy( text.font ); //!< HACK101 102 this-> text = text.text;95 if (this->_font != NULL) 96 ResourceManager::getInstance()->unload(this->_font); 97 98 this->_font = (Font*)ResourceManager::getInstance()->copy( text._font ); //!< HACK 99 100 this->_text = text._text; 103 101 return *this; 104 102 } … … 110 108 void Text::setText(const std::string& text) 111 109 { 112 this-> text = text;110 this->_text = text; 113 111 this->setupTextWidth(); 114 112 } … … 120 118 void Text::append(const std::string& appendText) 121 119 { 122 this-> text += appendText;120 this->_text += appendText; 123 121 this->setupTextWidth(); 124 122 } … … 129 127 void Text::appendCharacter(char character) 130 128 { 131 this-> text += character;129 this->_text += character; 132 130 this->setupTextWidth(); 133 131 } … … 141 139 { 142 140 this->append(appendText); 143 return this-> text;141 return this->_text; 144 142 } 145 143 … … 152 150 void Text::removeCharacters(unsigned int chars) 153 151 { 154 if (t ext.size() > chars)155 this-> text.resize(this->text.size()-chars);156 else if (!t ext.empty())157 t ext.clear();152 if (this->_text.size() > chars) 153 this->_text.resize(this->_text.size()-chars); 154 else if (!this->_text.empty()) 155 this->_text.clear(); 158 156 this->setupTextWidth(); 159 157 } … … 165 163 void Text::clear() 166 164 { 167 t ext.clear();165 this->_text.clear(); 168 166 this->setupTextWidth(); 169 167 } … … 177 175 { 178 176 Font* newFont = NULL; 179 Font* oldFont = this-> font;177 Font* oldFont = this->_font; 180 178 181 179 // load a new Font … … 194 192 195 193 // unloading the Font if we alrady have one loaded. 196 this-> font = newFont;194 this->_font = newFont; 197 195 if (oldFont != NULL && oldFont != Font::getDefaultFont()) 198 196 ResourceManager::getInstance()->unload(oldFont); … … 207 205 void Text::setSize(float size) 208 206 { 209 this-> size = size;207 this->_size = size; 210 208 this->setSizeY2D(size); 211 209 this->setupTextWidth(); … … 218 216 void Text::draw() const 219 217 { 220 if (unlikely(this-> text.empty()))218 if (unlikely(this->_text.empty())) 221 219 return; 222 220 glPushMatrix(); … … 230 228 // drawing this Text. 231 229 // setting the Blending effects 232 glColor4fv(&this-> color[0]);230 glColor4fv(&this->_color[0]); 233 231 234 232 … … 240 238 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, GL_MODULATE ); 241 239 242 glBindTexture(GL_TEXTURE_2D, font->getTexture());240 glBindTexture(GL_TEXTURE_2D, this->_font->getTexture()); 243 241 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); 244 242 glRotatef(this->getAbsDir2D(), 0, 0, 1); … … 247 245 float posX = 0.0f; 248 246 glBegin(GL_QUADS); 249 for (unsigned int i = 0; i < this-> text.size(); i++)247 for (unsigned int i = 0; i < this->_text.size(); i++) 250 248 { 251 if(likely((tmpGlyph = this-> getFont()->getGlyphArray()[this->text[i]]) != NULL))249 if(likely((tmpGlyph = this->font()->getGlyphArray()[this->_text[i]]) != NULL)) 252 250 { 253 251 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 254 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), 0);252 glVertex2d(posX+tmpGlyph->maxX*this->size(), 0); 255 253 256 254 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 257 glVertex2d(posX+tmpGlyph->maxX*this-> getSize(), this->getSize());255 glVertex2d(posX+tmpGlyph->maxX*this->size(), this->size()); 258 256 259 257 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 260 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), this->getSize());258 glVertex2d(posX+tmpGlyph->minX*this->size(), this->size()); 261 259 262 260 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 263 glVertex2d(posX+tmpGlyph->minX*this-> getSize(), 0);264 265 posX += tmpGlyph->advance * this-> getSize();261 glVertex2d(posX+tmpGlyph->minX*this->size(), 0); 262 263 posX += tmpGlyph->advance * this->size(); 266 264 } 267 265 } … … 278 276 { 279 277 float width = 0; 280 for (unsigned int i = 0; i < this-> text.size(); i++)281 if(this-> font->getGlyphArray()[this->text[i]] != NULL)282 width += this-> font->getGlyphArray()[this->text[i]]->advance;283 this->setSizeX2D(width * this-> getSize());278 for (unsigned int i = 0; i < this->_text.size(); i++) 279 if(this->_font->getGlyphArray()[this->_text[i]] != NULL) 280 width += this->_font->getGlyphArray()[this->_text[i]]->advance; 281 this->setSizeX2D(width * this->size()); 284 282 } 285 283 … … 290 288 void Text::debug() const 291 289 { 292 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this-> font->getName(), this->text.c_str());293 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());294 } 295 290 PRINT(0)("=== TEXT: %s (with Font:'%s') displaying %s ===\n", this->getName(), this->_font->getName(), this->_text.c_str()); 291 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()); 292 } 293 -
trunk/src/lib/graphics/text_engine/text.h
r8518 r8619 45 45 void setFont(const std::string& fontFile, unsigned int renderSize); 46 46 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 47 inline void setBlending(float blending) { this-> color.a() = blending; };47 inline void setBlending(float blending) { this->_color.a() = blending; }; 48 48 /** @param r red @param g green @param b blue @brief sets the Color of the Text to render (values in [0-1]) */ 49 void setColor(float r, float g, float b) { this-> color = Color(r, g, b, this->color.a()); };50 void setColor(float r, float g, float b, float a) { this-> color = Color(r, g, b, a); };51 void setColor(const Color& color) { this-> color = color; };49 void setColor(float r, float g, float b) { this->_color = Color(r, g, b, this->_color.a()); }; 50 void setColor(float r, float g, float b, float a) { this->_color = Color(r, g, b, a); }; 51 void setColor(const Color& color) { this->_color = color; }; 52 52 void setSize(float size); 53 53 … … 55 55 /// RETRIEVE 56 56 /** @returns the String this Text displays */ 57 inline const std::string& getText() const { return this->text; };57 inline const std::string& text() const { return this->_text; }; 58 58 59 59 /** @returns the pointer to the stored Font (not changeable) */ 60 inline const Font* const getFont() const { return this->font; };60 inline const Font* const font() const { return this->_font; }; 61 61 /** @returns the Blending Value [0 invisible 1.0 full visible */ 62 inline float getBlending() const { return this->color.a(); };62 inline float blending() const { return this->_color.a(); }; 63 63 /** @returns: a Vector(r,g,b) @brief: retrieve a Vector holding the Color of the Text */ 64 inline const Color& getColor() const { return this->color; };64 inline const Color& color() const { return this->_color; }; 65 65 /** @returns the Size of the Text */ 66 inline float getSize() const { return this->size; };66 inline float size() const { return this->_size; }; 67 67 68 68 virtual void draw() const; … … 76 76 77 77 private: 78 Font* font; //!< Font of this text78 Font* _font; //!< Font of this text 79 79 80 std::string text; //!< The text to display81 Color color; //!< The color of the font.82 float size; //!< The size of the Text.80 std::string _text; //!< The text to display 81 Color _color; //!< The color of the font. 82 float _size; //!< The size of the Text. 83 83 }; 84 84 -
trunk/src/lib/gui/gl/Makefile.am
r8518 r8619 12 12 glmenu/glmenu_imagescreen.cc \ 13 13 \ 14 glgui_style.cc \15 14 glgui_handler.cc \ 16 15 signal_connector.cc \ … … 27 26 glgui_inputline.cc \ 28 27 glgui_textfield.cc \ 28 glgui_table.cc \ 29 29 glgui_image.cc \ 30 30 glgui_window.cc \ … … 37 37 glmenu/glmenu_imagescreen.h \ 38 38 \ 39 glgui_style.h \40 39 signal_connector.h \ 41 40 glgui.h \ … … 54 53 glgui_inputline.h \ 55 54 glgui_textfield.h \ 55 glgui_table.h \ 56 56 glgui_image.h \ 57 57 glgui_window.h \ -
trunk/src/lib/gui/gl/glgui.h
r8145 r8619 16 16 #include "glgui_button.h" 17 17 #include "glgui_checkbutton.h" 18 //#include "glgui_colorselector.h"19 18 #include "glgui_pushbutton.h" 20 19 #include "glgui_slider.h" … … 22 21 #include "glgui_inputline.h" 23 22 #include "glgui_textfield.h" 23 #include "glgui_table.h" 24 24 #include "glgui_image.h" 25 25 -
trunk/src/lib/gui/gl/glgui_box.cc
r8450 r8619 110 110 if (orientation() == OrxGui::Vertical) 111 111 { 112 float height = this->borderTop();112 float height = borderTop(); 113 113 float width = 0.0f; 114 114 std::vector<GLGuiWidget*>::iterator widget; … … 117 117 for (widget = this->children.begin(); widget != this->children.end(); ++widget) 118 118 { 119 (*widget)->setRelCoor2D( this->borderLeft(), height);119 (*widget)->setRelCoor2D(borderLeft(), height); 120 120 height += (*widget)->getSizeY2D(); 121 121 width = fmax(width, (*widget)->getSizeX2D()); 122 122 } 123 123 124 width += this->borderLeft() + this->borderRight();125 height += this->borderBottom(); /* *2 done further up */124 width += borderLeft() + borderRight(); 125 height += borderBottom(); /* *2 done further up */ 126 126 127 127 printf("%f %f\n", width, height); … … 130 130 else 131 131 { 132 float height = this->borderTop();133 float width = this->borderLeft();132 float height = borderTop(); 133 float width = borderLeft(); 134 134 std::vector<GLGuiWidget*>::iterator widget; 135 135 … … 137 137 for (widget = this->children.begin(); widget != this->children.end(); ++widget) 138 138 { 139 (*widget)->setRelCoor2D(width, this->borderTop());139 (*widget)->setRelCoor2D(width, borderTop()); 140 140 height = fmax(height, (*widget)->getSizeY2D()); 141 141 width += (*widget)->getSizeX2D(); 142 142 } 143 143 144 width += this->borderRight() ;145 height += this->borderBottom(); /* *2 done further up */144 width += borderRight() ; 145 height += borderBottom(); /* *2 done further up */ 146 146 147 147 printf("%f %f\n", width, height); -
trunk/src/lib/gui/gl/glgui_button.cc
r8448 r8619 55 55 56 56 this->_label.setFont("fonts/final_frontier.ttf", 20); 57 this->_label.setColor(this->f rontColor());57 this->_label.setColor(this->foregroundColor() ); 58 58 59 59 this->_label.setParent2D(this); … … 71 71 void GLGuiButton::updateFrontColor() 72 72 { 73 this->_label.setColor(this->f rontColor());73 this->_label.setColor(this->foregroundColor()); 74 74 } 75 75 -
trunk/src/lib/gui/gl/glgui_button.h
r8448 r8619 36 36 virtual ~GLGuiButton(); 37 37 38 const std::string& label() const { return this->_label. getText(); };38 const std::string& label() const { return this->_label.text(); }; 39 39 void setLabel(const std::string& label); 40 40 -
trunk/src/lib/gui/gl/glgui_checkbutton.cc
r8448 r8619 96 96 // this->frontMaterial().select(); 97 97 // this->drawRect(this->frontRect()); 98 99 98 if (this->bActive) 100 99 { 101 glColor3fv( &this->f rontColor()[0]);100 glColor3fv( &this->foregroundColor()[0]); 102 101 this->drawRect(this->_checkBox); 103 102 … … 124 123 else 125 124 { 126 glColor3fv( &this->f rontColor()[0]);125 glColor3fv( &this->foregroundColor()[0]); 127 126 this->drawRect(this->_checkBox); 128 127 } -
trunk/src/lib/gui/gl/glgui_container.cc
r8145 r8619 43 43 this->setClassID(CL_GLGUI_CONTAINER, "GLGuiContainer"); 44 44 45 this->setBackgroundTexture("gui_container_background.png"); 46 45 47 } 46 48 -
trunk/src/lib/gui/gl/glgui_cursor.cc
r8324 r8619 57 57 this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor"); 58 58 59 this->backMaterial().setDiffuse(1.0,0.0,0.0); 60 this->backMaterial().setDiffuseMap("cursor.png"); 61 this->backMaterial().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 59 this->setBackgroundColor(Color(1.0, 1.0, 1.0, 1.0)); 60 this->setBackgroundTexture("cursor.png"); 62 61 this->setSize2D(50, 50); 63 62 this->setAbsCoor2D(100, 100); 64 63 this->setLayer(E2D_LAYER_ABOVE_ALL); 65 64 this->color = 0.0f; 65 this->frameNumber = 0.0f; 66 66 67 67 this->resize(); … … 79 79 bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to) 80 80 { 81 this->backMaterial().setDiffuse(1.0, 1.0, 1.0);81 //this->background().setDiffuse(1.0, 1.0, 1.0); 82 82 return this->seq.loadImageSeries(imageNameSubstitue, from, to); 83 83 } … … 97 97 this->color -= 360.0; 98 98 Vector color = Color::HSVtoRGB(Vector(this->color, 1.0, 1.0)); 99 this->backMaterial().setDiffuse(color.x, color.y, color.z); 99 //this->setBackgroundColor(color.x, color.y, color.z); 100 /// FIXME 101 100 102 } 101 103 //if (this->movement != Vector2D()) … … 125 127 this->beginDraw(); 126 128 127 this->back Material().select();129 this->background().select(); 128 130 if (!this->seq.empty()) 129 131 glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber)); -
trunk/src/lib/gui/gl/glgui_defs.h
r8448 r8619 22 22 } Orientation; 23 23 24 //! Names of Orientations 24 25 const std::string OrientationString[] = { 25 26 "Horizontal", … … 30 31 typedef enum { 31 32 Normal, //!< Normal state of the GUI's Widgets. 32 Active, //!< If the widget is Active.33 Focused, //!< If the widget is Active. 33 34 Selected, //!< If the Widget is Selected. 34 35 Insensitive //!< If the Widget is insensitive. … … 38 39 #define GLGUI_DEFAULT_STYLE OrxGui::Normal 39 40 41 //! names of the States. 40 42 const std::string StateString[] = 41 43 { 42 44 "Normal", 43 " Active",45 "Focused", 44 46 "Selected", 45 47 "Insensitive" … … 54 56 } FeaturePosition; 55 57 58 //! Names of Feature-Positions 56 59 const std::string FeaturePositionString[] = 57 60 { -
trunk/src/lib/gui/gl/glgui_image.cc
r8448 r8619 47 47 this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage"); 48 48 49 this->setForegroundColor(Color(1,1,1,1)); 49 50 this->_imageMaterial.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 50 51 … … 76 77 void GLGuiImage::updateFrontColor() 77 78 { 78 this->_imageMaterial.setDiffuseColor( this->frontColor());79 this->_imageMaterial.setDiffuseColor(foregroundColor()); 79 80 } 80 81 81 82 void GLGuiImage::resize() 82 83 { 83 this->_imagePlane.setTopLeft( this->borderLeft(), this->borderTop());84 this->_imagePlane.setTopLeft(borderLeft(), borderTop()); 84 85 this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) ); 85 86 GLGuiWidget::resize(); -
trunk/src/lib/gui/gl/glgui_inputline.cc
r8518 r8619 52 52 this->_text.setRelCoor2D(4,4); 53 53 this->_text.setFont("fonts/final_frontier.ttf", 20); 54 this->_text.setColor(this->frontColor()); 54 this->_text.setLineWidth(400); 55 this->_text.setDotsPosition(LimitedWidthText::Begin); 56 this->_text.setColor(foregroundColor()); 55 57 this->_text.setVisibility(false); 56 58 this->resize(); 59 60 this->delayNext = 0.0; 61 this->pressedKey = SDLK_FIRST; 62 this->pressedKeyName = SDLK_FIRST; 57 63 58 64 } … … 116 122 this->resize(); 117 123 this->setFrontColor(Color(1,1,1,1), true); 118 this->setFrontColor(Color(0,1,0,1)); 119 emit(this->textChanged(this->_text.getText())); 124 emit(this->textChanged(this->_text.text())); 120 125 } 121 126 … … 139 144 void GLGuiInputLine::pushEnter() 140 145 { 141 emit(this->enterPushed(this->_text. getText()));146 emit(this->enterPushed(this->_text.text())); 142 147 if (this->_clearOnEnter) 143 148 this->clear(); … … 197 202 void GLGuiInputLine::resize() 198 203 { 199 this->_text.setRelCoor2D( this->borderLeft(), this->borderTop());204 this->_text.setRelCoor2D(borderLeft(), borderTop()); 200 205 this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom())); 201 206 GLGuiWidget::resize(); 202 /* this->frontRect().setTopLeft(borderLeft(), borderTop());203 this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/207 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); 208 this->frontRect().setSize(this->getSize2D() - Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));*/ 204 209 } 205 210 206 211 void GLGuiInputLine::updateFrontColor() 207 212 { 208 this->_text.setColor( this->frontColor());213 this->_text.setColor(foregroundColor()); 209 214 } 210 215 … … 228 233 if (this->delayNext > 0.0) 229 234 this->delayNext -= dt; 230 235 else if (this->pressedKey != SDLK_FIRST ) 231 236 { 232 237 this->delayNext = GLGuiInputLine::repeatRate; … … 237 242 break; 238 243 default: 239 {240 if (likely(this->pressedKey < 127))241 this->appendCharacter(this->pressedKeyName);242 }244 { 245 if (likely(this->pressedKey < 127)) 246 this->appendCharacter(this->pressedKeyName); 247 } 243 248 } 244 249 } … … 255 260 GLGuiWidget::draw(); 256 261 257 // this->frontMaterial().select();258 // GLGuiWidget::drawRect(this->frontRect());262 // this->frontMaterial().select(); 263 // GLGuiWidget::drawRect(this->frontRect()); 259 264 260 265 this->endDraw(); -
trunk/src/lib/gui/gl/glgui_inputline.h
r8518 r8619 9 9 10 10 #include "glgui_widget.h" 11 #include " text.h"11 #include "limited_width_text.h" 12 12 #include "event.h" 13 13 … … 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.text(); }; 35 35 36 36 void setText(const std::string& text); … … 66 66 67 67 private: 68 Text_text; //!< The Text to display inside of the InputLine.68 LimitedWidthText _text; //!< The Text to display inside of the InputLine. 69 69 bool _clearOnEnter; //!< Clear on Enter 70 70 -
trunk/src/lib/gui/gl/glgui_slider.cc
r8448 r8619 74 74 else 75 75 this->_value = value; 76 this->_handle.setCenter(this->sliderPosition(), this->borderTop() + (this->getSizeY2D() - this->borderTop() - borderBottom()) / 2.0);76 this->_handle.setCenter(this->sliderPosition(), borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0); 77 77 78 78 emit(valueChanged(this->_value)); … … 165 165 // this->frontRect().setTopLeft(this->borderLeft(), this->getSizeY2D()/2.0 - 2.0); 166 166 // this->frontRect().setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0); 167 this->_slider.setTopLeft( this->borderLeft(), this->getSizeY2D() / 2.0 -2.0);167 this->_slider.setTopLeft(borderLeft(), this->getSizeY2D() / 2.0 -2.0); 168 168 this->_slider.setSize(this->getSizeX2D() - borderLeft() - borderRight(), 4.0); 169 169 this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - borderTop() - borderBottom()); … … 211 211 { 212 212 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * 213 214 213 (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) + 214 (borderLeft() +_sliderWidth); 215 215 } 216 216 … … 239 239 GLGuiWidget::draw(); 240 240 241 glColor4fv(&this->f rontColor()[0]);241 glColor4fv(&this->foregroundColor()[0]); 242 242 this->drawRect(this->_slider); 243 243 this->drawRect(this->_handle); -
trunk/src/lib/gui/gl/glgui_widget.cc
r8448 r8619 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI16 #define DEBUG_SPECIAL_MODULE 4//DEBUG_MODULE_GUI 17 17 18 18 #include "glgui_widget.h" … … 23 23 24 24 #include "debug.h" 25 26 #include "loading/load_param.h" 25 27 26 28 namespace OrxGui … … 39 41 40 42 /** 43 * @brief loads Parameters for a Style from XML 44 * @param root the XML-Element to load from. 45 */ 46 void GLGuiWidget::loadParams(const TiXmlElement* root) 47 { 48 49 /// STYLE 50 LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft); 51 LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight); 52 LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop); 53 LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom); 54 55 LoadParam(root, "text-size", this, GLGuiWidget, setTextSize); 56 LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS); 57 LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS); 58 59 // LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial); 60 // LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial); 61 62 LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS); 63 LoadParam(root, "Font", this, GLGuiWidget, setFont); 64 65 LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges); 66 } 67 68 69 /** 41 70 * @brief standard deconstructor 42 71 */ … … 45 74 if (this == GLGuiWidget::_focused) 46 75 GLGuiWidget::_focused = NULL; 47 48 if (this->_toFrontColor)49 delete this->_toFrontColor;50 76 } 51 77 … … 66 92 this->_clickable = false; 67 93 this->_pushed = false; 94 this->_state = OrxGui::Normal; 95 96 97 this->_font = NULL; 98 this->resetStyle(); 99 100 this->_animating = false; 101 this->_animationCycle = 0.0; 102 this->_animationDuration = 1.0; 103 104 105 this->setBackgroundColor(Color(.51, .3, .3, .5)); 106 this->setBackgroundColor(Color(.3, .5, .3, 1), OrxGui::Selected); 107 this->_style[0]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 108 this->_style[1]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 109 this->_style[2]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 110 this->_style[3]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 111 112 this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal); 113 this->setForegroundColor(Color(0, 0, 1, 1), OrxGui::Selected); 114 this->setForegroundColor(Color(0, 1, 0, 1), OrxGui::Focused); 115 this->setForegroundColor(Color(.1, .1, .1, 1), OrxGui::Insensitive); 68 116 69 117 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 70 118 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; 78 this->_borderRight = 1.0; 79 this->_borderTop = 1.0; 80 this->_borderBottom = 1.0; 119 this->setBorderLeft(15); 120 this->setBackgroundTexture("gui_element_background.png"); 121 122 this->switchState(_state); 123 this->_currentStyle = this->_style[_state]; 81 124 } 82 125 … … 121 164 } 122 165 166 167 123 168 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously) 124 169 { 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(); 170 this->_currentStyle._foreground.setDiffuseColor(frontColor); 171 this->animateBack(); 140 172 }; 141 142 143 void GLGuiWidget::setBorderSize(float borderSize)144 {145 this->_borderLeft = borderSize;146 this->_borderRight = borderSize;147 this->_borderTop = borderSize;148 this->_borderBottom = borderSize;149 this->resize();150 }151 152 void GLGuiWidget::setBorderLeft(float borderLeft)153 {154 this->_borderLeft = borderLeft;155 this->resize();156 }157 void GLGuiWidget::setBorderRight(float borderRight)158 {159 this->_borderRight = borderRight;160 this->resize();161 }162 void GLGuiWidget::setBorderTop(float borderTop)163 {164 this->_borderTop = borderTop;165 this->resize();166 }167 void GLGuiWidget::setBorderBottom(float borderBottom)168 {169 this->_borderBottom = borderBottom;170 this->resize();171 }172 173 173 174 174 … … 201 201 void GLGuiWidget::clicking(const Vector2D& pos) 202 202 { 203 this->setFrontColor(Color(0, 0, 1)); 204 203 this->switchState(OrxGui::Selected); 205 204 } 206 205 207 206 void GLGuiWidget::releasing(const Vector2D& pos) 208 207 { 209 this->setFrontColor(Color(0,1,0)); 210 208 this->switchState(OrxGui::Normal); 211 209 } 212 210 213 211 void GLGuiWidget::receivedFocus() 214 212 { 215 this->s etFrontColor(Color(0, 1, 0));213 this->switchState(OrxGui::Focused); 216 214 } 217 215 218 216 void GLGuiWidget::removedFocus() 219 217 { 220 this->s etFrontColor(Color(1, 0, 0));218 this->switchState(OrxGui::Normal); 221 219 222 220 } … … 267 265 } 268 266 269 void GLGuiWidget::tick(float dt) 270 { 271 if (this->_toFrontColor) 267 268 /** 269 * @brief resets the Style to the default Settings. 270 */ 271 void GLGuiWidget::resetStyle() 272 { 273 this->setBorderLeft(1.0); 274 this->setBorderRight(1.0); 275 this->setBorderTop(1.0); 276 this->setBorderBottom(1.0); 277 278 this->setTextSize(20.0); 279 this->setBackgroundColor(1.0); 280 this->setForegroundColor(1.0); 281 282 this->setFeaturePosition(FeatureLeft); 283 this->setFont(NULL); 284 285 this->setAnimatedStateChanges(true); 286 } 287 288 289 /** 290 * @brief sets the Width of the left border for all States 291 * @param value the borderWidth 292 */ 293 void GLGuiWidget::setBorderLeft(float value) 294 { 295 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 296 setBorderLeft(value, (OrxGui::State)i); 297 } 298 299 /** 300 * @brief sets the Width of the left border. 301 * @param value the borderWidth 302 * @param state the State to set the borderwidth to 303 */ 304 void GLGuiWidget::setBorderLeft(float value, OrxGui::State state) 305 { 306 _style[state]._borderLeft = value; 307 if (state == _state) 308 _currentStyle._borderLeft = value; 309 } 310 311 /** 312 * @brief sets the Width of the left border. 313 * @param value the borderWidth 314 * @param stateName the State to set the borderwidth to 315 */ 316 void GLGuiWidget::setBorderLeftS(float value, const std::string& stateName) 317 { 318 OrxGui::State state; 319 if (getState(stateName, &state)) 320 this->setBorderLeft(value, state); 321 else 322 this->setBorderLeft(value); 323 } 324 325 /** 326 * @brief sets the Width of the right border for all states. 327 * @param value the borderWidth 328 */ 329 void GLGuiWidget::setBorderRight(float value) 330 { 331 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 332 setBorderRight(value, (OrxGui::State)i); 333 } 334 335 /** 336 * @brief sets the Width of the right border. 337 * @param value the borderWidth 338 * @param state the State to setup. 339 */ 340 void GLGuiWidget::setBorderRight(float value, OrxGui::State state) 341 { 342 _style[state]._borderRight = value; 343 if (state == _state) 344 _currentStyle._borderRight = value; 345 } 346 347 /** 348 * @brief sets the Width of the right border. 349 * @param value the borderWidth 350 * @param stateName the State to setup. 351 */ 352 void GLGuiWidget::setBorderRightS(float value, const std::string& stateName) 353 { 354 OrxGui::State state; 355 if (getState(stateName, &state)) 356 this->setBorderRight(value, state); 357 else 358 this->setBorderRight(value); 359 } 360 361 362 /** 363 * @brief sets the Width of the top border for all states. 364 * @param value the borderWidth 365 */ 366 void GLGuiWidget::setBorderTop(float value) 367 { 368 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 369 setBorderTop(value, (OrxGui::State)i); 370 } 371 372 /** 373 * @brief sets the Width of the top border. 374 * @param value the borderWidth 375 * @param state the State to setup. 376 */ 377 void GLGuiWidget::setBorderTop(float value, OrxGui::State state) 378 { 379 _style[state]._borderTop = value; 380 if (state == _state) 381 _currentStyle._borderTop = value; 382 } 383 384 /** 385 * @brief sets the Width of the top border. 386 * @param value the borderWidth 387 * @param stateName the State to setup. 388 */ 389 void GLGuiWidget::setBorderTopS(float value, const std::string& stateName) 390 { 391 OrxGui::State state; 392 if (getState(stateName, &state)) 393 this->setBorderTop(value, state); 394 else 395 this->setBorderTop(value); 396 } 397 398 399 /** 400 * @brief sets the Width of the bottom border for all states. 401 * @param value the borderWidth 402 */ 403 void GLGuiWidget::setBorderBottom(float value) 404 { 405 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 406 setBorderBottom(value, (OrxGui::State)i); 407 } 408 409 /** 410 * @brief sets the Width of the bottom border. 411 * @param value the borderWidth 412 * @param state the State to setup. 413 */ 414 void GLGuiWidget::setBorderBottom(float value, OrxGui::State state) 415 { 416 _style[state]._borderBottom = value; 417 if (state == _state) 418 _currentStyle._borderBottom = value; 419 420 } 421 422 /** 423 * @brief sets the Width of the bottom border for all states. 424 * @param value the borderWidth 425 * @param stateName the State to setup. 426 */ 427 void GLGuiWidget::setBorderBottomS(float value, const std::string& stateName) 428 { 429 OrxGui::State state; 430 if (getState(stateName, &state)) 431 this->setBorderBottom(value, state); 432 else 433 this->setBorderBottom(value); 434 } 435 436 437 /** 438 * @brief sets the TextSize for all states. 439 * @param value the TextSize 440 */ 441 void GLGuiWidget::setTextSize(float value) 442 { 443 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 444 setTextSize(value, (OrxGui::State)i); 445 } 446 447 /** 448 * @brief sets the TextSize. 449 * @param value the TextSize. 450 * @param state: the State to setup 451 */ 452 void GLGuiWidget::setTextSize(float value, OrxGui::State state) 453 { 454 _style[state]._textSize = value; 455 if (state == _state) 456 _currentStyle._textSize = value; 457 } 458 459 /** 460 * @brief sets the TextSize. 461 * @param value the TextSize. 462 * @param stateName: the State to setup 463 */ 464 void GLGuiWidget::setTextSizeS(float value, const std::string& stateName) 465 { 466 OrxGui::State state; 467 if (getState(stateName, &state)) 468 this->setTextSize(value, state); 469 else 470 this->setTextSize(value); 471 } 472 473 474 /** 475 * @brief sets the Background Color for all States. 476 * @param color the Color. 477 */ 478 void GLGuiWidget::setBackgroundColor(const Color& color) 479 { 480 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 481 setBackgroundColor(color, (OrxGui::State)i); 482 } 483 484 /** 485 * @brief sets the Background Color. 486 * @param color the Color. 487 * @param state: the State to setup 488 */ 489 void GLGuiWidget::setBackgroundColor(const Color& color, OrxGui::State state) 490 { 491 _style[state]._background.setDiffuseColor(color); 492 if (state == _state) 493 _currentStyle._background.setDiffuseColor(color); 494 495 } 496 497 /** 498 * @brief sets the Background Color. 499 * @param r the Color's red part. 500 * @param g the Color's green part. 501 * @param b the Color's blue part. 502 * @param a the Color's alpha part. 503 * @param stateName: the State to setup 504 */ 505 void GLGuiWidget::setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName) 506 { 507 OrxGui::State state; 508 if (getState(stateName, &state)) 509 this->setBackgroundColor(Color(r,g,b,a), state); 510 else 511 this->setBackgroundColor(Color(r,g,b,a)); 512 } 513 514 515 /** 516 * @brief sets the Background Texture for all States. 517 * @param texture the Texture. 518 */ 519 void GLGuiWidget::setBackgroundTexture(const Texture& texture) 520 { 521 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 522 setBackgroundTexture(texture, (OrxGui::State)i); 523 } 524 525 /** 526 * @brief sets the Background Texture to all States. 527 * @param textureName the Texture's fileName. 528 */ 529 void GLGuiWidget::setBackgroundTexture(const std::string& textureName) 530 { 531 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 532 _style[i]._background.setDiffuseMap(textureName); 533 this->_currentStyle._background.setDiffuseMap(textureName); 534 } 535 536 /** 537 * @brief sets the Background Texture. 538 * @param texture the Texture. 539 * @param state the State to setup. 540 */ 541 void GLGuiWidget::setBackgroundTexture(const Texture& texture, OrxGui::State state) 542 { 543 _style[state]._background.setDiffuseMap(texture); 544 if (state == _state) 545 _currentStyle._background.setDiffuseMap(texture); 546 } 547 548 549 550 /** 551 * @brief sets the Background Texture. 552 * @param texture the Texture. 553 * @param stateName the State to setup. 554 */ 555 void GLGuiWidget::setBackgroundTexture(const std::string& textureName, const std::string& stateName) 556 { 557 OrxGui::State state; 558 if (getState(stateName, &state)) 559 ; /// FIXME this->setBackgroundTexture(textureName, state); 560 else 561 ; /// this->setBackgroundTexture(textureName); 562 } 563 564 565 /** 566 * @brief sets the Foreground Color for all States. 567 * @param color the Color. 568 */ 569 void GLGuiWidget::setForegroundColor(const Color& color) 570 { 571 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 572 setForegroundColor(color, (OrxGui::State)i); 573 } 574 575 /** 576 * @brief sets the Foreground Color. 577 * @param color the Color. 578 * @param state the State to setup 579 */ 580 void GLGuiWidget::setForegroundColor(const Color& color, OrxGui::State state) 581 { 582 _style[state]._foreground.setDiffuseColor(color); 583 if (state == _state) 584 _currentStyle._foreground.setDiffuseColor(color); 585 586 } 587 588 /** 589 * @brief sets the Foreground Color. 590 * @param r the Color's red part. 591 * @param g the Color's green part. 592 * @param b the Color's blue part. 593 * @param a the Color's alpha part. 594 * @param stateName: the State to setup 595 */ 596 void GLGuiWidget::setForegroundColorS(float r, float g, float b, float a, const std::string& stateName) 597 { 598 OrxGui::State state; 599 if (getState(stateName, &state)) 600 this->setForegroundColor(Color(r,g,b,a), state); 601 else 602 this->setForegroundColor(Color(r,g,b,a)); 603 } 604 605 606 void GLGuiWidget::loadBackgroundMaterial(const Material& material) 607 { 608 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 609 this->loadForegroundMaterial(material, (OrxGui::State)i); 610 } 611 612 void GLGuiWidget::loadBackgroundMaterial(const Material& material, OrxGui::State state) 613 { 614 this->_style[state]._background = material; 615 if (state == _state) 616 _currentStyle._background = material; 617 618 } 619 620 void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element) 621 { 622 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 623 this->loadBackgroundMaterial(element, (OrxGui::State)i); 624 } 625 626 void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state) 627 { 628 this->_style[state]._background.loadParams(element); 629 if (state == _state) 630 this->_currentStyle._background = _style[state]._background; 631 } 632 633 void GLGuiWidget::loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName) 634 { 635 OrxGui::State state; 636 if (getState(stateName, &state)) 637 this->loadBackgroundMaterial(element, state); 638 else 639 this->loadBackgroundMaterial(element); 640 } 641 642 void GLGuiWidget::loadForegroundMaterial(const Material& material) 643 {} 644 void GLGuiWidget::loadForegroundMaterial(const Material& material, OrxGui::State state) 645 {} 646 void GLGuiWidget::loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state) 647 {} 648 void GLGuiWidget::loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName) 649 {} 650 651 652 /** 653 * @brief sets the Feature-Position. 654 * @param featurePosition the Feature-Position. 655 */ 656 void GLGuiWidget::setFeaturePosition(FeaturePosition featurePosition) 657 { 658 this->_featurePosition = featurePosition; 659 } 660 661 /** 662 * @brief sets the Feature-Position by converting from a String. 663 * @param featurePosition the Feature-Position. 664 */ 665 void GLGuiWidget::setFeaturePositionS(const std::string& featurePosition) 666 { 667 for (unsigned int i = 0; i < 4; ++i) 272 668 { 273 this->_frontColor.slerp(*_toFrontColor, dt*3.0); 274 this->updateFrontColor(); 275 if (this->_frontColor.dist(*_toFrontColor) < .1) 669 if (featurePosition == FeaturePositionString[i]) 276 670 { 277 delete _toFrontColor; 278 _toFrontColor = NULL; 671 this->setFeaturePosition((FeaturePosition)i); 279 672 } 280 673 } 281 674 } 282 675 676 /** 677 * @brief sets the Font. 678 * @param font the Font. 679 */ 680 void GLGuiWidget::setFont(Font* font) 681 { 682 this->_font = font; 683 } 684 685 /** 686 * @brief sets the font from a Font-Name. 687 * @param fontName the FileName of the Font. 688 */ 689 void GLGuiWidget::setFont(const std::string& fontName) 690 { 691 //this->font = new Font(fontName); 692 } 693 694 /** 695 * @brief sets the AnimatedState. 696 * @param animated: it states-changes should animate true, otherwise false. 697 */ 698 void GLGuiWidget::setAnimatedStateChanges(bool animated) 699 { 700 this->_animatedStateChanges = animated; 701 } 702 703 704 void GLGuiWidget::switchState(OrxGui::State state) 705 { 706 //this->_currentStyle = this->_style[state]; 707 this->_state = state; 708 PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str()); 709 710 this->animateBack(); 711 } 712 713 714 void GLGuiWidget::animateBack() 715 { 716 this->_animating = true; 717 this->_animationCycle = 0.0f; 718 } 719 720 721 void GLGuiWidget::tick(float dt) 722 { 723 if (this->_animating) 724 { 725 this->foregroundColor(); 726 727 _animationCycle += dt / _animationDuration; 728 if (_animationCycle >= 1.0) 729 { 730 _currentStyle._foreground.diffuseColor() = this->foregroundColor(_state); 731 _currentStyle._background.diffuseColor() = this->backgroundColor(_state); 732 _animating = false; 733 } 734 else 735 { 736 _currentStyle._foreground.diffuseColor().slerp(this->foregroundColor(_state), _animationCycle); 737 _currentStyle._background.diffuseColor().slerp(this->backgroundColor(_state), _animationCycle); 738 } 739 this->updateFrontColor(); 740 } 741 } 742 283 743 284 744 /** … … 287 747 void GLGuiWidget::draw() const 288 748 { 289 this->back Material().select();749 this->background().select(); 290 750 this->drawRect(this->backRect()); 291 this->backMaterial().unselect(); 292 } 751 this->background().unselect(); 752 } 753 754 755 /** 756 * @param stateName the Name of a State. 757 * @param state the found State is returned here if found. 758 * @returns true if String is found, false otherwise. 759 */ 760 bool GLGuiWidget::getState(const std::string& stateName, OrxGui::State* state) 761 { 762 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 763 if (stateName == OrxGui::StateString[i]) 764 { 765 *state = (OrxGui::State)i; 766 return true; 767 } 768 return false; 769 } 770 771 /** 772 * @brief print out some nice debug output about the Widget. 773 */ 774 void GLGuiWidget::debug() const 775 { 776 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName()); 777 if (_parent != NULL) 778 PRINT(0)("- Parent %s::%s ", _parent->getClassName(), _parent->getName()); 779 PRINT(0)("- State: %s", StateString[_state].c_str()); 780 781 if (_focusable) 782 PRINT(0)("- focusable "); 783 if (_clickable) 784 PRINT(0)("- Clickable "); 785 if (_pushed) 786 PRINT(0)("- Pushed "); 787 PRINT(0)("\n"); 788 789 790 PRINT(0)("Minimum Size %0.2f %0.2f ", _minSize.x, _minSize.y); 791 PRINT(0)("Back Rect: "); 792 _backRect.debug(); 793 PRINT(0)("Style:\n"); 794 795 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 796 { 797 PRINT(0)("In State %s: \n", StateString[i].c_str()); 798 799 PRINT(0)(" Borders: Left: %0.2f, Right: %0.2f, Top: %0.2f, Bottom %0.2f\n", 800 _style[i]._borderLeft, _style[i]._borderRight, _style[i]._borderTop, _style[i]._borderBottom); 801 PRINT(0)(" TextSize %0.2f\n", _style[i]._textSize); 802 PRINT(0)(" BackgroundColor: "); _style[i]._background.diffuseColor().debug(); 803 PRINT(0)(" ForegroundColor: "); _style[i]._foreground.diffuseColor().debug(); 804 PRINT(0)("\n"); 805 } 806 807 808 PRINT(0)(" Feature at %s ", FeaturePositionString[_featurePosition].c_str()); 809 /// TODO PRINT(0)(""); Font* _font; //!< The Font used in the current Widget. 810 811 if (_animatedStateChanges) 812 PRINT(0)("- AnimatedStateChanges"); 813 PRINT(0)("\n"); 814 815 /* 816 if (_animating) 817 PRINT(0)("- Animated "); 818 819 // 820 float _animationCycle; 821 float _animationDuration; 822 StatedStyle _currentStyle; 823 OrxGui::State _currentState; 824 */ 825 } 826 293 827 294 828 } -
trunk/src/lib/gui/gl/glgui_widget.h
r8518 r8619 9 9 #include "element_2d.h" 10 10 11 #include "glgui_style.h" 11 #include "glgui_defs.h" 12 12 13 #include "material.h" 13 14 #include "rect2D.h" … … 15 16 #include "event.h" 16 17 #include "signal_connector.h" 18 19 class Font; 17 20 18 21 namespace OrxGui … … 66 69 void disconnect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver); 67 70 68 69 GLGuiStyle& style() { return this->_style; }; 70 const GLGuiStyle style() const { return this->_style; }; 71 72 /// MATERIAL (looks) 73 Material& backMaterial() { return this->_backMat; }; 74 const Material& backMaterial() const { return this->_backMat; }; 71 OrxGui::State state() const { return this->_state; }; 72 75 73 Rect2D& backRect() { return this->_backRect; }; 76 74 const Rect2D& backRect() const { return this->_backRect; }; 77 75 78 76 void setFrontColor(const Color& frontColor, bool instantaniously = false); 79 const Color& frontColor() const { return this->_frontColor; };80 81 /** @brief sets all borders to the same value. */82 void setBorderSize(float borderSize);83 void setBorderLeft(float borderLeft);84 void setBorderRight(float borderRight);85 void setBorderTop(float borderTop);86 void setBorderBottom(float borderBottom);87 88 float borderLeft() const { return this->_borderLeft; };89 float borderRight() const { return this->_borderRight; };90 float borderTop() const { return this->_borderTop; };91 float borderBottom() const { return this->_borderBottom; };92 93 77 94 78 void setWidgetSize(const Vector2D& size); 95 79 void setWidgetSize(float x, float y); 96 80 97 98 void setBackgroundColor(float x, float y, float z) { this->backMaterial().setDiffuse(x,y,z); }; 81 void animateBack(); 82 83 /// STYLE 84 //////////////////////////////// 85 /// Retrieve Current Values. /// 86 //////////////////////////////// 87 /** @returns current left borderWidth */ 88 inline float borderLeft() const { return _currentStyle._borderLeft; } 89 /** @returns current right borderWidth */ 90 inline float borderRight() const { return _currentStyle._borderRight; } 91 /** @returns current top borderWidth */ 92 inline float borderTop() const { return _currentStyle._borderTop; } 93 /** @returns burrent bottom borderWidth */ 94 inline float borderBottom() const { return _currentStyle._borderBottom; } 95 96 97 /** @returns current textSize */ 98 inline float textSize() const { return _currentStyle._textSize; } 99 /** @returns the Background Color */ 100 inline const Color& backgroundColor() const { return _currentStyle._background.diffuseColor(); } 101 /** @returns the current Background Material. */ 102 inline const Material& background() const { return _currentStyle._background; } 103 /** @returns the current background Texture. */ 104 inline const Texture& backgroundTexture() const { return _currentStyle._background.diffuseTexture(); } 105 /** @returns the current foreground Color */ 106 inline const Color& foregroundColor() const { return _currentStyle._foreground.diffuseColor(); } 107 /** @returns the current ForeGroung Material. */ 108 inline const Material& foreground() const { return _currentStyle._foreground; } 109 110 111 /** @returns FeaturePosition */ 112 inline FeaturePosition featurePosition() const { return _featurePosition; } 113 /** @returns the font */ 114 inline const Font* const font() const { return _font; } 115 /** @returns true if the Element is Animated */ 116 inline bool animating() const { return _animating; } 117 /** @returns true if State-Changes are animated */ 118 inline bool animatedStateChanges() const { return _animatedStateChanges; } 119 120 121 /////////////////////////////////////////////////////////////// 122 /// Retrieve Values for the Saved Values inside the States. /// 123 /////////////////////////////////////////////////////////////// 124 /** @returns left borderWidth @param state the State to retrieve from */ 125 inline float borderLeft(OrxGui::State state) const { return _style[state]._borderLeft; } 126 /** @returns right borderWidth @param state the State to retrieve from */ 127 inline float borderRight(OrxGui::State state) const { return _style[state]._borderRight; } 128 /** @returns top borderWidth @param state the State to retrieve from */ 129 inline float borderTop(OrxGui::State state) const { return _style[state]._borderTop; } 130 /** @returns bottom borderWidth @param state the State to retrieve from */ 131 inline float borderBottom(OrxGui::State state) const { return _style[state]._borderBottom; } 132 133 /** @returns textSize @param state the State to retrieve from */ 134 inline float textSize(OrxGui::State state) const { return _style[state]._textSize; } 135 /** @returns the Background Color @param state the State to retrieve from */ 136 inline const Color& backgroundColor(OrxGui::State state) const { return _style[state]._background.diffuseColor(); } 137 /** @returns the Background Material. @param state the state to retrieve from */ 138 inline const Material& background(OrxGui::State state) const { return _style[state]._background; } 139 /** @returns background Texture. @param state the State to retrieve from */ 140 inline const Texture& backgroundTexture(OrxGui::State state) const { return _style[state]._background.diffuseTexture(); } 141 /** @returns the foreground Color @param state the State to retrieve from */ 142 inline const Color& foregroundColor(OrxGui::State state) const { return _style[state]._foreground.diffuseColor(); } 143 /** @returns the ForeGroung Material. @param state the state to retrieve from */ 144 inline const Material& foreground(OrxGui::State state) const { return _style[state]._foreground; } 145 146 147 /// SETUP 148 void resetStyle(); 149 void loadParams(const TiXmlElement* root); 150 151 void setBorderLeft(float value); 152 void setBorderLeft(float value, OrxGui::State state); 153 void setBorderLeftS(float value, const std::string& stateName); 154 155 void setBorderRight(float value); 156 void setBorderRight(float value, OrxGui::State state); 157 void setBorderRightS(float value, const std::string& stateName); 158 159 void setBorderTop(float value); 160 void setBorderTop(float value, OrxGui::State state); 161 void setBorderTopS(float value, const std::string& stateName); 162 163 void setBorderBottom(float value); 164 void setBorderBottom(float value, OrxGui::State state); 165 void setBorderBottomS(float value, const std::string& stateName); 166 167 void setTextSize(float value); 168 void setTextSize(float value, OrxGui::State state); 169 void setTextSizeS(float value, const std::string& stateName); 170 171 void setBackgroundColor(const Color& color); 172 void setBackgroundColor(const Color& color, OrxGui::State state); 173 void setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName); 174 175 void setBackgroundTexture(const Texture& texture); 176 void setBackgroundTexture(const std::string& textureName); 177 void setBackgroundTexture(const Texture& texture, OrxGui::State state); 178 void setBackgroundTexture(const std::string& textureName, const std::string& stateName); 179 180 void setForegroundColor(const Color& color); 181 void setForegroundColor(const Color& color, OrxGui::State state); 182 void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName); 183 184 void loadBackgroundMaterial(const Material& material); 185 void loadBackgroundMaterial(const Material& material, OrxGui::State state); 186 void loadBackgroundMaterial(const TiXmlElement* element); 187 void loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state); 188 void loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName); 189 190 void loadForegroundMaterial(const Material& material); 191 void loadForegroundMaterial(const Material& material, OrxGui::State state); 192 void loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state); 193 void loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName); 194 195 void setFeaturePosition(FeaturePosition featurePosition); 196 void setFeaturePositionS(const std::string& featurePosition); 197 198 void setFont(Font* font); 199 void setFont(const std::string& fontName); 200 201 void setAnimatedStateChanges(bool animated); 202 void switchState(OrxGui::State state); 203 204 99 205 100 206 inline void drawRect(const Rect2D& rect) const … … 116 222 virtual bool processEvent(const Event& event) { return false; }; 117 223 224 bool getState(const std::string& stateName, OrxGui::State* state); 118 225 119 226 protected: … … 137 244 virtual void destroyed(); 138 245 246 virtual void debug() const; 247 139 248 private: 140 249 void init(); 141 250 142 251 private: 252 static GLGuiWidget* _selected; //!< The currently selected Widget. 253 static GLGuiWidget* _focused; //!< The currently Focused Widget. 254 static GLGuiWidget* _inputGrabber; //!< The Widget that grabs input. 255 256 257 /// WIDGET 143 258 GLGuiWidget* _parent; //!< The parent of this Widget. 144 259 145 260 /// LOOKS 146 Material _backMat;147 261 Rect2D _backRect; 148 149 Color _frontColor;150 Color* _toFrontColor;151 152 float _borderLeft;153 float _borderRight;154 float _borderTop;155 float _borderBottom;156 157 262 Vector2D _minSize; 158 263 159 GLGuiStyle _style;160 264 161 265 /// EVENTS 266 OrxGui::State _state; 267 162 268 bool _focusable; //!< If this widget can receive focus. 163 269 bool _clickable; //!< if this widget can be clicked upon. … … 166 272 167 273 168 static GLGuiWidget* _selected; //!< The currently selected Widget. 169 static GLGuiWidget* _focused; //!< The currently Focused Widget. 170 171 static GLGuiWidget* _inputGrabber; //!< The Widget that grabs input. 274 275 /// STYLE - Variables. 276 typedef struct 277 { 278 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. 279 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. 280 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts 281 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts 282 283 float _textSize; //!< The TextSize of the Widget. 284 285 Material _background; //!< The Background Material of the Widget. 286 287 Material _foreground; //!< The foreground Material of the Widget. 288 } 289 StatedStyle; 290 291 292 StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States 293 294 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...) 295 Font* _font; //!< The Font used in the current Widget. 296 297 298 /// ANIMATION STUFF: 299 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. 300 301 bool _animating; //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.) 302 float _animationCycle; 303 float _animationDuration; 304 StatedStyle _currentStyle; 305 172 306 }; 173 307 } -
trunk/src/lib/gui/gl/specials/glgui_notifier.cc
r8518 r8619 25 25 26 26 /** 27 * standard constructor27 * @brief standard constructor 28 28 */ 29 29 GLGuiNotifier::GLGuiNotifier () … … 34 34 this->lineSpacing = 0; 35 35 this->linesProcessed = 0; 36 this->_fadeAge = 3.0; 37 this->setHideAge(4.0); 36 38 37 39 this->setDisplayLineCount(10); … … 57 59 } 58 60 61 /** 62 * @brief push a message onto the notifier. 63 * @param message the message to be pushed. 64 * 65 * @note it is not guaranteed, that the message is delivered instantaniously 66 * The possibility may arise, that the DisplayLines are all in use, then one 67 * has to wait until a line gets hidden, until a new one can be pushed to be 68 * displayed. 69 */ 59 70 void GLGuiNotifier::pushNotifyMessage(const std::string& message) 60 71 { 61 72 if (!this->hiddenText.empty()) 62 73 { 63 printf("%s\n", message.c_str()); 64 DisplayLine dl; 74 DisplayLine dl; // put everything in here, and then display it 75 76 // retrieve a Text. 65 77 dl.text = this->hiddenText.top(); 66 78 this->hiddenText.pop(); 79 80 // setup Text 67 81 dl.text->setBlending(1.0f); 68 82 dl.text->setText(message); 69 this->hiddenText.pop(); 83 dl.text->setVisibility(true); 84 dl.text->setRelCoor2D(this->calculateLinePosition(0)); 85 70 86 dl.age = 0.0f; 71 87 this->displayLines.push_front(dl); 72 73 dl.text->setVisibility(true);74 dl.text->setRelCoor2D(this->calculateLinePosition(0));75 88 this->repositionText(); 76 89 } 77 90 else 78 91 { 92 // push it onto the List of messages we still need. 79 93 this->inputBuffer.push_front(message); 80 //printf("grumble... must be fixed\n"); 81 } 82 } 83 84 94 } 95 } 96 97 98 /** 99 * @brief sets the Dipsplay Line Count of the Notifier. 100 * @param coun the count of displayLines. 101 */ 85 102 void GLGuiNotifier::setDisplayLineCount(unsigned int count) 86 103 { … … 96 113 } 97 114 115 void GLGuiNotifier::setFadeAge(float fadeAge) 116 { 117 this->_fadeAge = fadeAge; 118 this->_transformAge = hideAge() - this->fadeAge(); 119 } 120 121 void GLGuiNotifier::setHideAge(float hideAge) 122 { 123 this->_hideAge = hideAge; 124 this->_transformAge = this->hideAge() - fadeAge(); 125 } 126 98 127 99 128 /** … … 119 148 void GLGuiNotifier::applyTextSettings(MultiLineText* text) 120 149 { 121 text->setSize(this-> style().textSize());150 text->setSize(this->textSize()); 122 151 text->setLineWidth( 300 ); 123 text->setFont("fonts/final_frontier.ttf", (int)this-> style().textSize());124 125 text->setColor(this-> style().foregroundColor() );152 text->setFont("fonts/final_frontier.ttf", (int)this->textSize()); 153 154 text->setColor(this->foregroundColor() ); 126 155 if (text->getParent2D() != this) 127 156 text->setParent2D(this); … … 129 158 130 159 160 /** 161 * @brief ticks the entire Notifier. 162 * @param dt the time passed since the last Tick 163 */ 131 164 void GLGuiNotifier::tick(float dt) 132 165 { … … 135 168 { 136 169 (*line).age+=dt; 137 if ((*line).age > 3.0f)170 if ((*line).age > this->fadeAge()) 138 171 { 139 (*line).text->setBlending( 4.0 - (*line).age);140 if ((*line).age > 4.0f)172 (*line).text->setBlending((hideAge() - (*line).age)/_transformAge); 173 if ((*line).age > hideAge()) 141 174 { 142 175 std::list<DisplayLine>::iterator tmp = line; … … 167 200 this->beginDraw(); 168 201 169 this->back Material().select();202 this->background().select(); 170 203 this->drawRect(this->backRect()); 171 204 this->endDraw(); … … 183 216 Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber) 184 217 { 185 return Vector2D(0.0f, (float)(t his->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));218 return Vector2D(0.0f, (float)(textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1)); 186 219 } 187 220 -
trunk/src/lib/gui/gl/specials/glgui_notifier.h
r8518 r8619 30 30 void pushNotifyMessage(const std::string& message); 31 31 32 // BUFFERS32 /// Setup 33 33 void setDisplayLineCount(unsigned int count); 34 void setFadeAge(float fadeAge); 35 void setHideAge(float hideAge); 36 37 /** @returns the beginning of the Hiding process */ 38 inline float fadeAge() const { return _fadeAge; }; 39 /** @returns at what age elements should be fully hidden */ 40 inline float hideAge() const { return _hideAge; }; 34 41 35 42 void clear(); … … 54 61 55 62 private: 63 //! structure that defines a Displayed line. 56 64 typedef struct 57 65 { … … 59 67 MultiLineText* text; 60 68 61 } 62 DisplayLine; 69 } DisplayLine; 70 71 72 float _fadeAge; 73 float _hideAge; 74 float _transformAge; 63 75 64 76 unsigned int lineSpacing; //!< The Spacing between lines. … … 72 84 73 85 unsigned long linesProcessed; //!< How many Lines have been processed so far. 74 std::list<std::string> inputBuffer; //!< 86 std::list<std::string> inputBuffer; //!< The input buffer for lines that were not yet printet out, because there is too much input. 75 87 76 88 }; -
trunk/src/lib/math/rect2D.cc
r8448 r8619 475 475 } 476 476 477 /** 478 * @brief print debug output for the Rect 479 */ 480 void Rect2D::debug() const 481 { 482 PRINT(0)("Top: %0.2f Left: %0.2f; Bottom %0.2f Right:%0.2f; Size: %0.2fx%0.2f\n", top(), left(), bottom(), right(), size().x, size().y); 483 } -
trunk/src/lib/math/rect2D.h
r8448 r8619 127 127 const Rect2D& slerp(const Rect2D& rect, float value); 128 128 129 void debug() const; 130 129 131 private: 130 132 Vector2D _topLeft; -
trunk/src/lib/sound/sound_buffer.cc
r8362 r8619 114 114 else if (stereo && !is16Bit) 115 115 return AL_FORMAT_STEREO8; 116 else if (stereo && is16Bit)116 else /* if (stereo && is16Bit) */ 117 117 return AL_FORMAT_STEREO16; 118 118 } -
trunk/src/lib/util/color.cc
r8448 r8619 24 24 printf("r:%0.2f g:%0.2f, b:%0.2f, a:%0.2f\n", r(), g(), b(), a()); 25 25 } 26 27 26 28 27 29 /** -
trunk/src/lib/util/executor/functor_list.h
r8048 r8619 144 144 FUNCTOR_LIST(3)(l_STRING, l_UINT, l_UINT); 145 145 146 FUNCTOR_LIST(5)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_STRING); 147 146 148 #endif /* FUNCTOR_LIST */ -
trunk/src/lib/util/filesys/file.cc
r8333 r8619 205 205 206 206 /// FIXME NEXT THREE FUNCTIONS 207 bool File::isRead eable() const207 bool File::isReadable() const 208 208 { 209 209 #ifndef __WIN32__ -
trunk/src/lib/util/filesys/file.h
r8333 r8619 51 51 bool isFile() const; 52 52 bool isDirectory() const; 53 bool isRead eable() const;53 bool isReadable() const; 54 54 bool isWriteable() const; 55 55 bool isExecutable() const;
Note: See TracChangeset
for help on using the changeset viewer.