Changeset 8598 in orxonox.OLD
- Timestamp:
- Jun 20, 2006, 1:45:44 AM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui_box.cc
r8584 r8598 110 110 if (orientation() == OrxGui::Vertical) 111 111 { 112 float height = style().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( style().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 += style().borderLeft() + style().borderRight();125 height += style().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 = style().borderTop();133 float width = style().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, style().borderTop());139 (*widget)->setRelCoor2D(width, borderTop()); 140 140 height = fmax(height, (*widget)->getSizeY2D()); 141 141 width += (*widget)->getSizeX2D(); 142 142 } 143 143 144 width += style().borderRight() ;145 height += style().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); -
branches/gui/src/lib/gui/gl/glgui_button.cc
r8584 r8598 55 55 56 56 this->_label.setFont("fonts/final_frontier.ttf", 20); 57 this->_label.setColor(this-> style().foregroundColor() );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-> style().foregroundColor());73 this->_label.setColor(this->foregroundColor()); 74 74 } 75 75 -
branches/gui/src/lib/gui/gl/glgui_checkbutton.cc
r8584 r8598 66 66 { 67 67 68 this->labelText().setRelCoor2D( style().borderLeft() + 15.0, style().borderTop() + 5);69 this->setSize2D(this->labelText().getSizeX2D() + 15.0 + style().borderLeft() + style().borderRight(), this->labelText().getSizeY2D() + 10 + style().borderTop()+style().borderBottom());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()); 70 70 GLGuiWidget::resize(); 71 71 72 72 this->_checkBox.setSize(10.0, 10.0); 73 this->_checkBox.setCenter( style().borderLeft() + _checkBox.height()/2.0, style().borderTop() + (this->getSizeY2D() - style().borderTop() - style().borderBottom()) / 2.0);73 this->_checkBox.setCenter( borderLeft() + _checkBox.height()/2.0, borderTop() + (this->getSizeY2D() - borderTop() - borderBottom()) / 2.0); 74 74 75 75 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); … … 99 99 if (this->bActive) 100 100 { 101 glColor3fv( &this-> style().foregroundColor()[0]);101 glColor3fv( &this->foregroundColor()[0]); 102 102 this->drawRect(this->_checkBox); 103 103 … … 124 124 else 125 125 { 126 glColor3fv( &this-> style().foregroundColor()[0]);126 glColor3fv( &this->foregroundColor()[0]); 127 127 this->drawRect(this->_checkBox); 128 128 } -
branches/gui/src/lib/gui/gl/glgui_cursor.cc
r8596 r8598 57 57 this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor"); 58 58 59 this-> style().background().setDiffuseColor(Color(1.0,0.0,0.0, 1.0));60 this-> style().background().setDiffuseMap("cursor.png");61 this-> style().background().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);59 this->background().setDiffuseColor(Color(1.0,0.0,0.0, 1.0)); 60 this->background().setDiffuseMap("cursor.png"); 61 this->background().setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 62 62 this->setSize2D(50, 50); 63 63 this->setAbsCoor2D(100, 100); … … 80 80 bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to) 81 81 { 82 //this-> style().background().setDiffuse(1.0, 1.0, 1.0);82 //this->background().setDiffuse(1.0, 1.0, 1.0); 83 83 return this->seq.loadImageSeries(imageNameSubstitue, from, to); 84 84 } … … 98 98 this->color -= 360.0; 99 99 Vector color = Color::HSVtoRGB(Vector(this->color, 1.0, 1.0)); 100 this-> style().background().setDiffuse(color.x, color.y, color.z);100 this->background().setDiffuse(color.x, color.y, color.z); 101 101 } 102 102 //if (this->movement != Vector2D()) … … 126 126 this->beginDraw(); 127 127 128 this-> style().background().select();128 this->background().select(); 129 129 if (!this->seq.empty()) 130 130 glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber)); -
branches/gui/src/lib/gui/gl/glgui_image.cc
r8584 r8598 76 76 void GLGuiImage::updateFrontColor() 77 77 { 78 this->_imageMaterial.setDiffuseColor( style().foregroundColor());78 this->_imageMaterial.setDiffuseColor(foregroundColor()); 79 79 } 80 80 81 81 void GLGuiImage::resize() 82 82 { 83 this->_imagePlane.setTopLeft( style().borderLeft(), style().borderTop());84 this->_imagePlane.setSize(this->getSizeX2D() - ( style().borderLeft() + style().borderRight()), this->getSizeY2D() - (style().borderTop() + style().borderBottom()) );83 this->_imagePlane.setTopLeft(borderLeft(), borderTop()); 84 this->_imagePlane.setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) ); 85 85 GLGuiWidget::resize(); 86 86 } -
branches/gui/src/lib/gui/gl/glgui_inputline.cc
r8584 r8598 54 54 this->_text.setLineWidth(400); 55 55 this->_text.setDotsPosition(LimitedWidthText::Begin); 56 this->_text.setColor( style().foregroundColor());56 this->_text.setColor(foregroundColor()); 57 57 this->_text.setVisibility(false); 58 58 this->resize(); … … 203 203 void GLGuiInputLine::resize() 204 204 { 205 this->_text.setRelCoor2D( style().borderLeft(), style().borderTop());206 this->setSize2D( this->_text.getSize2D() + Vector2D( style().borderLeft() + style().borderRight(), style().borderTop() + style().borderBottom()));205 this->_text.setRelCoor2D(borderLeft(), borderTop()); 206 this->setSize2D( this->_text.getSize2D() + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom())); 207 207 GLGuiWidget::resize(); 208 208 /* this->frontRect().setTopLeft(borderLeft(), borderTop()); … … 212 212 void GLGuiInputLine::updateFrontColor() 213 213 { 214 this->_text.setColor( style().foregroundColor());214 this->_text.setColor(foregroundColor()); 215 215 } 216 216 -
branches/gui/src/lib/gui/gl/glgui_pushbutton.cc
r8584 r8598 45 45 void GLGuiPushButton::resize() 46 46 { 47 this->labelText().setRelCoor2D( style().borderLeft(), style().borderTop());48 this->setSize2D(this->labelText().getSizeX2D() + style().borderLeft() + style().borderRight(), this->labelText().getSizeY2D() + style().borderTop() + style().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(); -
branches/gui/src/lib/gui/gl/glgui_slider.cc
r8584 r8598 74 74 else 75 75 this->_value = value; 76 this->_handle.setCenter(this->sliderPosition(), style().borderTop() + (this->getSizeY2D() - style().borderTop() - style().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( style().borderLeft(), this->getSizeY2D() / 2.0 -2.0);168 this->_slider.setSize(this->getSizeX2D() - style().borderLeft() - style().borderRight(), 4.0);169 this->_handle.setSize(this->_sliderWidth, this->getSizeY2D() - style().borderTop() - style().borderBottom());167 this->_slider.setTopLeft(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 170 } 171 171 … … 211 211 { 212 212 return (this->_value - this->_minValue)/( this->_maxValue - this->_minValue) * 213 (this->getSizeX2D() - ( style().borderLeft() + style().borderRight() + 2.0*_sliderWidth)) +214 ( style().borderLeft() +_sliderWidth);213 (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) + 214 (borderLeft() +_sliderWidth); 215 215 } 216 216 … … 221 221 float GLGuiSlider::sliderValue(float position) const 222 222 { 223 return (position - ( style().borderLeft()+_sliderWidth)) / (this->getSizeX2D() - (style().borderLeft() + style().borderRight() + 2.0*_sliderWidth))223 return (position - (borderLeft()+_sliderWidth)) / (this->getSizeX2D() - (borderLeft() + borderRight() + 2.0*_sliderWidth)) 224 224 *( this->_maxValue - this->_minValue) + 225 225 this->_minValue ; … … 239 239 GLGuiWidget::draw(); 240 240 241 glColor4fv(&this-> style().foregroundColor()[0]);241 glColor4fv(&this->foregroundColor()[0]); 242 242 this->drawRect(this->_slider); 243 243 this->drawRect(this->_handle); -
branches/gui/src/lib/gui/gl/glgui_style.cc
r8594 r8598 22 22 namespace OrxGui 23 23 { 24 25 26 /**27 * @brief standard constructor28 * @param root the XML-Element to load settings from29 */30 GLGuiStyle::GLGuiStyle (const TiXmlElement* root)31 {32 this->_font = NULL;33 this->_currentState = OrxGui::Normal;34 this->_animationCycle = -1.0;35 this->_animationDuration = 1.0;36 37 /// current-style38 this->_currentStyle._borderLeft = 1.0;39 this->_currentStyle._borderRight = 1.0;40 this->_currentStyle._borderTop = 1.0;41 this->_currentStyle._borderBottom = 1.0;42 this->_currentStyle._textSize = 20.0;43 44 this->reset();45 46 47 if (root != NULL)48 this->loadParams(root);49 50 }51 52 53 /**54 * @brief standard deconstructor55 */56 GLGuiStyle::~GLGuiStyle ()57 {58 // delete what has to be deleted here59 }60 61 /**62 * @brief resets the Style to the default Settings.63 */64 void GLGuiStyle::reset()65 {66 this->setBorderLeft(1.0);67 this->setBorderRight(1.0);68 this->setBorderTop(1.0);69 this->setBorderBottom(1.0);70 71 this->setTextSize(20.0);72 this->setBackgroundColor(1.0);73 this->setForegroundColor(1.0);74 75 this->setFeaturePosition(FeatureLeft);76 this->setFont(NULL);77 78 this->setAnimated(true);79 this->setAnimatedStateChanges(true);80 }81 82 /**83 * @brief loads Parameters for a Style from XML84 * @param root the XML-Element to load from.85 */86 void GLGuiStyle::loadParams(const TiXmlElement* root)87 {88 LoadParam(root, "border-left", this, GLGuiStyle, setBorderLeft);89 LoadParam(root, "border-right", this, GLGuiStyle, setBorderRight);90 LoadParam(root, "border-top", this, GLGuiStyle, setBorderTop);91 LoadParam(root, "border-bottom", this, GLGuiStyle, setBorderBottom);92 93 LoadParam(root, "text-size", this, GLGuiStyle, setTextSize);94 LoadParam(root, "background-color", this, GLGuiStyle, setBackgroundColorS);95 LoadParam(root, "foreground-color", this, GLGuiStyle, setForegroundColorS);96 97 // LoadParamXML(root, "backmat", this, GLGuiStyle, loadBackgroundMaterial);98 // LoadParamXML(root, "frontmat", this, GLGuiStyle, loadForegroundMaterial);99 100 LoadParam(root, "feature-position", this, GLGuiStyle, setFeaturePositionS);101 LoadParam(root, "Font", this, GLGuiStyle, setFont);102 103 LoadParam(root, "animated", this, GLGuiStyle, setAnimated);104 LoadParam(root, "animated-state-changes", this, GLGuiStyle, setAnimatedStateChanges);105 }106 107 /**108 * @brief sets the Width of the left border for all States109 * @param value the borderWidth110 */111 void GLGuiStyle::setBorderLeft(float value)112 {113 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)114 setBorderLeft(value, (OrxGui::State)i);115 }116 117 /**118 * @brief sets the Width of the left border.119 * @param value the borderWidth120 * @param state the State to set the borderwidth to121 */122 void GLGuiStyle::setBorderLeft(float value, OrxGui::State state)123 {124 _style[state]._borderLeft = value;125 }126 127 /**128 * @brief sets the Width of the left border.129 * @param value the borderWidth130 * @param stateName the State to set the borderwidth to131 */132 void GLGuiStyle::setBorderLeftS(float value, const std::string& stateName)133 {134 OrxGui::State state;135 if (getState(stateName, &state))136 this->setBorderLeft(value, state);137 else138 this->setBorderLeft(value);139 }140 141 /**142 * @brief sets the Width of the right border for all states.143 * @param value the borderWidth144 */145 void GLGuiStyle::setBorderRight(float value)146 {147 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)148 setBorderRight(value, (OrxGui::State)i);149 }150 151 /**152 * @brief sets the Width of the right border.153 * @param value the borderWidth154 * @param state the State to setup.155 */156 void GLGuiStyle::setBorderRight(float value, OrxGui::State state)157 {158 _style[state]._borderRight = value;159 }160 161 /**162 * @brief sets the Width of the right border.163 * @param value the borderWidth164 * @param stateName the State to setup.165 */166 void GLGuiStyle::setBorderRightS(float value, const std::string& stateName)167 {168 OrxGui::State state;169 if (getState(stateName, &state))170 this->setBorderRight(value, state);171 else172 this->setBorderRight(value);173 }174 175 176 /**177 * @brief sets the Width of the top border for all states.178 * @param value the borderWidth179 */180 void GLGuiStyle::setBorderTop(float value)181 {182 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)183 setBorderTop(value, (OrxGui::State)i);184 }185 186 /**187 * @brief sets the Width of the top border.188 * @param value the borderWidth189 * @param state the State to setup.190 */191 void GLGuiStyle::setBorderTop(float value, OrxGui::State state)192 {193 _style[state]._borderTop = value;194 }195 196 /**197 * @brief sets the Width of the top border.198 * @param value the borderWidth199 * @param stateName the State to setup.200 */201 void GLGuiStyle::setBorderTopS(float value, const std::string& stateName)202 {203 OrxGui::State state;204 if (getState(stateName, &state))205 this->setBorderTop(value, state);206 else207 this->setBorderTop(value);208 }209 210 211 /**212 * @brief sets the Width of the bottom border for all states.213 * @param value the borderWidth214 */215 void GLGuiStyle::setBorderBottom(float value)216 {217 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)218 setBorderBottom(value, (OrxGui::State)i);219 }220 221 /**222 * @brief sets the Width of the bottom border.223 * @param value the borderWidth224 * @param state the State to setup.225 */226 void GLGuiStyle::setBorderBottom(float value, OrxGui::State state)227 {228 _style[state]._borderBottom = value;229 }230 231 /**232 * @brief sets the Width of the bottom border for all states.233 * @param value the borderWidth234 * @param stateName the State to setup.235 */236 void GLGuiStyle::setBorderBottomS(float value, const std::string& stateName)237 {238 OrxGui::State state;239 if (getState(stateName, &state))240 this->setBorderBottom(value, state);241 else242 this->setBorderBottom(value);243 }244 245 246 /**247 * @brief sets the TextSize for all states.248 * @param value the TextSize249 */250 void GLGuiStyle::setTextSize(float value)251 {252 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)253 setTextSize(value, (OrxGui::State)i);254 }255 256 /**257 * @brief sets the TextSize.258 * @param value the TextSize.259 * @param state: the State to setup260 */261 void GLGuiStyle::setTextSize(float value, OrxGui::State state)262 {263 _style[state]._textSize = value;264 }265 266 /**267 * @brief sets the TextSize.268 * @param value the TextSize.269 * @param stateName: the State to setup270 */271 void GLGuiStyle::setTextSizeS(float value, const std::string& stateName)272 {273 OrxGui::State state;274 if (getState(stateName, &state))275 this->setTextSize(value, state);276 else277 this->setTextSize(value);278 }279 280 281 /**282 * @brief sets the Background Color for all States.283 * @param color the Color.284 */285 void GLGuiStyle::setBackgroundColor(const Color& color)286 {287 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)288 setBackgroundColor(color, (OrxGui::State)i);289 }290 291 /**292 * @brief sets the Background Color.293 * @param color the Color.294 * @param state: the State to setup295 */296 void GLGuiStyle::setBackgroundColor(const Color& color, OrxGui::State state)297 {298 _style[state]._background.setDiffuseColor(color);299 }300 301 /**302 * @brief sets the Background Color.303 * @param r the Color's red part.304 * @param g the Color's green part.305 * @param b the Color's blue part.306 * @param a the Color's alpha part.307 * @param stateName: the State to setup308 */309 void GLGuiStyle::setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName)310 {311 OrxGui::State state;312 if (getState(stateName, &state))313 this->setBackgroundColor(Color(r,g,b,a), state);314 else315 this->setBackgroundColor(Color(r,g,b,a));316 }317 318 319 /**320 * @brief sets the Background Texture for all States.321 * @param texture the Texture.322 */323 void GLGuiStyle::setBackgroundTexture(const Texture& texture)324 {325 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)326 setBackgroundTexture(texture, (OrxGui::State)i);327 }328 329 /**330 * @brief sets the Background Texture to all States.331 * @param textureName the Texture's fileName.332 */333 void GLGuiStyle::setBackgroundTexture(const std::string& textureName)334 {335 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)336 _style[i]._background.setDiffuseMap(textureName);337 }338 339 /**340 * @brief sets the Background Texture.341 * @param texture the Texture.342 * @param state the State to setup.343 */344 void GLGuiStyle::setBackgroundTexture(const Texture& texture, OrxGui::State state)345 {346 _style[state]._background.setDiffuseMap(texture);347 }348 349 350 351 /**352 * @brief sets the Background Texture.353 * @param texture the Texture.354 * @param stateName the State to setup.355 */356 void GLGuiStyle::setBackgroundTexture(const std::string& textureName, const std::string& stateName)357 {358 OrxGui::State state;359 if (getState(stateName, &state))360 ; /// FIXME this->setBackgroundTexture(textureName, state);361 else362 ; /// this->setBackgroundTexture(textureName);363 }364 365 366 /**367 * @brief sets the Foreground Color for all States.368 * @param color the Color.369 */370 void GLGuiStyle::setForegroundColor(const Color& color)371 {372 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)373 setForegroundColor(color, (OrxGui::State)i);374 }375 376 /**377 * @brief sets the Foreground Color.378 * @param color the Color.379 * @param state the State to setup380 */381 void GLGuiStyle::setForegroundColor(const Color& color, OrxGui::State state)382 {383 _style[state]._foreground.setDiffuseColor(color);384 }385 386 /**387 * @brief sets the Foreground Color.388 * @param r the Color's red part.389 * @param g the Color's green part.390 * @param b the Color's blue part.391 * @param a the Color's alpha part.392 * @param stateName: the State to setup393 */394 void GLGuiStyle::setForegroundColorS(float r, float g, float b, float a, const std::string& stateName)395 {396 OrxGui::State state;397 if (getState(stateName, &state))398 this->setForegroundColor(Color(r,g,b,a), state);399 else400 this->setForegroundColor(Color(r,g,b,a));401 }402 403 404 void GLGuiStyle::loadBackgroundMaterial(const Material& material)405 {406 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)407 this->loadForegroundMaterial(material, (OrxGui::State)i);408 }409 410 void GLGuiStyle::loadBackgroundMaterial(const Material& material, OrxGui::State state)411 {412 this->_style[state]._background = material;413 }414 415 void GLGuiStyle::loadBackgroundMaterial(const TiXmlElement* element)416 {417 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)418 this->_style[i]._background.loadParams(element);419 }420 421 void GLGuiStyle::loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state)422 {423 this->_style[state]._background.loadParams(element);424 }425 void GLGuiStyle::loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName)426 {427 OrxGui::State state;428 if (getState(stateName, &state))429 this->loadBackgroundMaterial(element, state);430 else431 this->loadBackgroundMaterial(element);432 }433 434 void GLGuiStyle::loadForegroundMaterial(const Material& material)435 {}436 void GLGuiStyle::loadForegroundMaterial(const Material& material, OrxGui::State state)437 {}438 void GLGuiStyle::loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state)439 {}440 void GLGuiStyle::loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName)441 {}442 443 444 /**445 * @brief sets the Feature-Position.446 * @param featurePosition the Feature-Position.447 */448 void GLGuiStyle::setFeaturePosition(FeaturePosition featurePosition)449 {450 this->_featurePosition = featurePosition;451 }452 453 /**454 * @brief sets the Feature-Position by converting from a String.455 * @param featurePosition the Feature-Position.456 */457 void GLGuiStyle::setFeaturePositionS(const std::string& featurePosition)458 {459 for (unsigned int i = 0; i < 4; ++i)460 {461 if (featurePosition == FeaturePositionString[i])462 {463 this->setFeaturePosition((FeaturePosition)i);464 }465 }466 }467 468 /**469 * @brief sets the Font.470 * @param font the Font.471 */472 void GLGuiStyle::setFont(Font* font)473 {474 this->_font = font;475 }476 477 /**478 * @brief sets the font from a Font-Name.479 * @param fontName the FileName of the Font.480 */481 void GLGuiStyle::setFont(const std::string& fontName)482 {483 //this->font = new Font(fontName);484 }485 486 /**487 * @brief if Animation should be turned on.488 * @param animated true if on, false otherwise.489 */490 void GLGuiStyle::setAnimated(bool animated)491 {492 this->_animated = animated;493 }494 495 /**496 * @brief sets the AnimatedState.497 * @param animated: it states-changes should animate true, otherwise false.498 */499 void GLGuiStyle::setAnimatedStateChanges(bool animated)500 {501 this->_animatedStateChanges = animated;502 }503 504 505 void GLGuiStyle::tick(float dt)506 {507 508 }509 510 void GLGuiStyle::switchState(OrxGui::State state)511 {512 this->_currentStyle = this->_style[state];513 this->_currentState = state;514 printf("Switching to state %s\n", OrxGui::StateString[state].c_str());515 }516 517 518 /**519 * @param stateName the Name of a State.520 * @param state the found State is returned here if found.521 * @returns true if String is found, false otherwise.522 */523 bool GLGuiStyle::getState(const std::string& stateName, OrxGui::State* state)524 {525 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)526 if (stateName == OrxGui::StateString[i])527 {528 *state = (OrxGui::State)i;529 return true;530 }531 return false;532 }533 24 } -
branches/gui/src/lib/gui/gl/glgui_widget.cc
r8596 r8598 23 23 24 24 #include "debug.h" 25 26 #include "loading/load_param.h" 25 27 26 28 namespace OrxGui … … 69 71 this->_toFrontColor = NULL; 70 72 71 this->style().setBackgroundColor(Color(0, 0, 0, 1)); 72 73 this->style().setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal); 74 this->style().setForegroundColor(Color(0, 1, 0, 1), OrxGui::Selected); 75 this->style().setForegroundColor(Color(0, 0, 1, 1), OrxGui::Focused); 76 this->style().setForegroundColor(Color(.1, .1, .1, 1), OrxGui::Insensitive); 73 74 this->_font = NULL; 75 this->_currentState = OrxGui::Normal; 76 this->_animationCycle = -1.0; 77 this->_animationDuration = 1.0; 78 79 80 this->setBackgroundColor(Color(0, 0, 0, 1)); 81 82 this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal); 83 this->setForegroundColor(Color(0, 1, 0, 1), OrxGui::Selected); 84 this->setForegroundColor(Color(0, 0, 1, 1), OrxGui::Focused); 85 this->setForegroundColor(Color(.1, .1, .1, 1), OrxGui::Insensitive); 77 86 78 87 this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE); 79 88 80 this->s tyle().setBackgroundTexture("gui_element_background.png");81 this->s tyle().switchState(OrxGui::Normal);89 this->setBackgroundTexture("gui_element_background.png"); 90 this->switchState(OrxGui::Normal); 82 91 } 83 92 … … 128 137 if (instantaniously) 129 138 { 130 this->s tyle().setForegroundColor(frontColor);139 this->setForegroundColor(frontColor); 131 140 if (this->_toFrontColor != NULL) 132 141 { … … 172 181 void GLGuiWidget::clicking(const Vector2D& pos) 173 182 { 174 this->s tyle().switchState(OrxGui::Selected);183 this->switchState(OrxGui::Selected); 175 184 } 176 185 177 186 void GLGuiWidget::releasing(const Vector2D& pos) 178 187 { 179 this->s tyle().switchState(OrxGui::Normal);188 this->switchState(OrxGui::Normal); 180 189 } 181 190 182 191 void GLGuiWidget::receivedFocus() 183 192 { 184 this->s tyle().switchState(OrxGui::Focused);193 this->switchState(OrxGui::Focused); 185 194 } 186 195 187 196 void GLGuiWidget::removedFocus() 188 197 { 189 this->s tyle().switchState(OrxGui::Normal);198 this->switchState(OrxGui::Normal); 190 199 191 200 } … … 236 245 } 237 246 247 248 /** 249 * @brief resets the Style to the default Settings. 250 */ 251 void GLGuiWidget::resetStyle() 252 { 253 this->setBorderLeft(1.0); 254 this->setBorderRight(1.0); 255 this->setBorderTop(1.0); 256 this->setBorderBottom(1.0); 257 258 this->setTextSize(20.0); 259 this->setBackgroundColor(1.0); 260 this->setForegroundColor(1.0); 261 262 this->setFeaturePosition(FeatureLeft); 263 this->setFont(NULL); 264 265 this->setAnimated(true); 266 this->setAnimatedStateChanges(true); 267 } 268 269 /** 270 * @brief loads Parameters for a Style from XML 271 * @param root the XML-Element to load from. 272 */ 273 void GLGuiWidget::loadParams(const TiXmlElement* root) 274 { 275 LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft); 276 LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight); 277 LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop); 278 LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom); 279 280 LoadParam(root, "text-size", this, GLGuiWidget, setTextSize); 281 LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS); 282 LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS); 283 284 // LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial); 285 // LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial); 286 287 LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS); 288 LoadParam(root, "Font", this, GLGuiWidget, setFont); 289 290 LoadParam(root, "animated", this, GLGuiWidget, setAnimated); 291 LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges); 292 } 293 294 /** 295 * @brief sets the Width of the left border for all States 296 * @param value the borderWidth 297 */ 298 void GLGuiWidget::setBorderLeft(float value) 299 { 300 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 301 setBorderLeft(value, (OrxGui::State)i); 302 } 303 304 /** 305 * @brief sets the Width of the left border. 306 * @param value the borderWidth 307 * @param state the State to set the borderwidth to 308 */ 309 void GLGuiWidget::setBorderLeft(float value, OrxGui::State state) 310 { 311 _style[state]._borderLeft = value; 312 } 313 314 /** 315 * @brief sets the Width of the left border. 316 * @param value the borderWidth 317 * @param stateName the State to set the borderwidth to 318 */ 319 void GLGuiWidget::setBorderLeftS(float value, const std::string& stateName) 320 { 321 OrxGui::State state; 322 if (getState(stateName, &state)) 323 this->setBorderLeft(value, state); 324 else 325 this->setBorderLeft(value); 326 } 327 328 /** 329 * @brief sets the Width of the right border for all states. 330 * @param value the borderWidth 331 */ 332 void GLGuiWidget::setBorderRight(float value) 333 { 334 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 335 setBorderRight(value, (OrxGui::State)i); 336 } 337 338 /** 339 * @brief sets the Width of the right border. 340 * @param value the borderWidth 341 * @param state the State to setup. 342 */ 343 void GLGuiWidget::setBorderRight(float value, OrxGui::State state) 344 { 345 _style[state]._borderRight = value; 346 } 347 348 /** 349 * @brief sets the Width of the right border. 350 * @param value the borderWidth 351 * @param stateName the State to setup. 352 */ 353 void GLGuiWidget::setBorderRightS(float value, const std::string& stateName) 354 { 355 OrxGui::State state; 356 if (getState(stateName, &state)) 357 this->setBorderRight(value, state); 358 else 359 this->setBorderRight(value); 360 } 361 362 363 /** 364 * @brief sets the Width of the top border for all states. 365 * @param value the borderWidth 366 */ 367 void GLGuiWidget::setBorderTop(float value) 368 { 369 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 370 setBorderTop(value, (OrxGui::State)i); 371 } 372 373 /** 374 * @brief sets the Width of the top border. 375 * @param value the borderWidth 376 * @param state the State to setup. 377 */ 378 void GLGuiWidget::setBorderTop(float value, OrxGui::State state) 379 { 380 _style[state]._borderTop = value; 381 } 382 383 /** 384 * @brief sets the Width of the top border. 385 * @param value the borderWidth 386 * @param stateName the State to setup. 387 */ 388 void GLGuiWidget::setBorderTopS(float value, const std::string& stateName) 389 { 390 OrxGui::State state; 391 if (getState(stateName, &state)) 392 this->setBorderTop(value, state); 393 else 394 this->setBorderTop(value); 395 } 396 397 398 /** 399 * @brief sets the Width of the bottom border for all states. 400 * @param value the borderWidth 401 */ 402 void GLGuiWidget::setBorderBottom(float value) 403 { 404 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 405 setBorderBottom(value, (OrxGui::State)i); 406 } 407 408 /** 409 * @brief sets the Width of the bottom border. 410 * @param value the borderWidth 411 * @param state the State to setup. 412 */ 413 void GLGuiWidget::setBorderBottom(float value, OrxGui::State state) 414 { 415 _style[state]._borderBottom = value; 416 } 417 418 /** 419 * @brief sets the Width of the bottom border for all states. 420 * @param value the borderWidth 421 * @param stateName the State to setup. 422 */ 423 void GLGuiWidget::setBorderBottomS(float value, const std::string& stateName) 424 { 425 OrxGui::State state; 426 if (getState(stateName, &state)) 427 this->setBorderBottom(value, state); 428 else 429 this->setBorderBottom(value); 430 } 431 432 433 /** 434 * @brief sets the TextSize for all states. 435 * @param value the TextSize 436 */ 437 void GLGuiWidget::setTextSize(float value) 438 { 439 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 440 setTextSize(value, (OrxGui::State)i); 441 } 442 443 /** 444 * @brief sets the TextSize. 445 * @param value the TextSize. 446 * @param state: the State to setup 447 */ 448 void GLGuiWidget::setTextSize(float value, OrxGui::State state) 449 { 450 _style[state]._textSize = value; 451 } 452 453 /** 454 * @brief sets the TextSize. 455 * @param value the TextSize. 456 * @param stateName: the State to setup 457 */ 458 void GLGuiWidget::setTextSizeS(float value, const std::string& stateName) 459 { 460 OrxGui::State state; 461 if (getState(stateName, &state)) 462 this->setTextSize(value, state); 463 else 464 this->setTextSize(value); 465 } 466 467 468 /** 469 * @brief sets the Background Color for all States. 470 * @param color the Color. 471 */ 472 void GLGuiWidget::setBackgroundColor(const Color& color) 473 { 474 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 475 setBackgroundColor(color, (OrxGui::State)i); 476 } 477 478 /** 479 * @brief sets the Background Color. 480 * @param color the Color. 481 * @param state: the State to setup 482 */ 483 void GLGuiWidget::setBackgroundColor(const Color& color, OrxGui::State state) 484 { 485 _style[state]._background.setDiffuseColor(color); 486 } 487 488 /** 489 * @brief sets the Background Color. 490 * @param r the Color's red part. 491 * @param g the Color's green part. 492 * @param b the Color's blue part. 493 * @param a the Color's alpha part. 494 * @param stateName: the State to setup 495 */ 496 void GLGuiWidget::setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName) 497 { 498 OrxGui::State state; 499 if (getState(stateName, &state)) 500 this->setBackgroundColor(Color(r,g,b,a), state); 501 else 502 this->setBackgroundColor(Color(r,g,b,a)); 503 } 504 505 506 /** 507 * @brief sets the Background Texture for all States. 508 * @param texture the Texture. 509 */ 510 void GLGuiWidget::setBackgroundTexture(const Texture& texture) 511 { 512 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 513 setBackgroundTexture(texture, (OrxGui::State)i); 514 } 515 516 /** 517 * @brief sets the Background Texture to all States. 518 * @param textureName the Texture's fileName. 519 */ 520 void GLGuiWidget::setBackgroundTexture(const std::string& textureName) 521 { 522 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 523 _style[i]._background.setDiffuseMap(textureName); 524 } 525 526 /** 527 * @brief sets the Background Texture. 528 * @param texture the Texture. 529 * @param state the State to setup. 530 */ 531 void GLGuiWidget::setBackgroundTexture(const Texture& texture, OrxGui::State state) 532 { 533 _style[state]._background.setDiffuseMap(texture); 534 } 535 536 537 538 /** 539 * @brief sets the Background Texture. 540 * @param texture the Texture. 541 * @param stateName the State to setup. 542 */ 543 void GLGuiWidget::setBackgroundTexture(const std::string& textureName, const std::string& stateName) 544 { 545 OrxGui::State state; 546 if (getState(stateName, &state)) 547 ; /// FIXME this->setBackgroundTexture(textureName, state); 548 else 549 ; /// this->setBackgroundTexture(textureName); 550 } 551 552 553 /** 554 * @brief sets the Foreground Color for all States. 555 * @param color the Color. 556 */ 557 void GLGuiWidget::setForegroundColor(const Color& color) 558 { 559 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 560 setForegroundColor(color, (OrxGui::State)i); 561 } 562 563 /** 564 * @brief sets the Foreground Color. 565 * @param color the Color. 566 * @param state the State to setup 567 */ 568 void GLGuiWidget::setForegroundColor(const Color& color, OrxGui::State state) 569 { 570 _style[state]._foreground.setDiffuseColor(color); 571 } 572 573 /** 574 * @brief sets the Foreground Color. 575 * @param r the Color's red part. 576 * @param g the Color's green part. 577 * @param b the Color's blue part. 578 * @param a the Color's alpha part. 579 * @param stateName: the State to setup 580 */ 581 void GLGuiWidget::setForegroundColorS(float r, float g, float b, float a, const std::string& stateName) 582 { 583 OrxGui::State state; 584 if (getState(stateName, &state)) 585 this->setForegroundColor(Color(r,g,b,a), state); 586 else 587 this->setForegroundColor(Color(r,g,b,a)); 588 } 589 590 591 void GLGuiWidget::loadBackgroundMaterial(const Material& material) 592 { 593 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 594 this->loadForegroundMaterial(material, (OrxGui::State)i); 595 } 596 597 void GLGuiWidget::loadBackgroundMaterial(const Material& material, OrxGui::State state) 598 { 599 this->_style[state]._background = material; 600 } 601 602 void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element) 603 { 604 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 605 this->_style[i]._background.loadParams(element); 606 } 607 608 void GLGuiWidget::loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state) 609 { 610 this->_style[state]._background.loadParams(element); 611 } 612 void GLGuiWidget::loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName) 613 { 614 OrxGui::State state; 615 if (getState(stateName, &state)) 616 this->loadBackgroundMaterial(element, state); 617 else 618 this->loadBackgroundMaterial(element); 619 } 620 621 void GLGuiWidget::loadForegroundMaterial(const Material& material) 622 {} 623 void GLGuiWidget::loadForegroundMaterial(const Material& material, OrxGui::State state) 624 {} 625 void GLGuiWidget::loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state) 626 {} 627 void GLGuiWidget::loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName) 628 {} 629 630 631 /** 632 * @brief sets the Feature-Position. 633 * @param featurePosition the Feature-Position. 634 */ 635 void GLGuiWidget::setFeaturePosition(FeaturePosition featurePosition) 636 { 637 this->_featurePosition = featurePosition; 638 } 639 640 /** 641 * @brief sets the Feature-Position by converting from a String. 642 * @param featurePosition the Feature-Position. 643 */ 644 void GLGuiWidget::setFeaturePositionS(const std::string& featurePosition) 645 { 646 for (unsigned int i = 0; i < 4; ++i) 647 { 648 if (featurePosition == FeaturePositionString[i]) 649 { 650 this->setFeaturePosition((FeaturePosition)i); 651 } 652 } 653 } 654 655 /** 656 * @brief sets the Font. 657 * @param font the Font. 658 */ 659 void GLGuiWidget::setFont(Font* font) 660 { 661 this->_font = font; 662 } 663 664 /** 665 * @brief sets the font from a Font-Name. 666 * @param fontName the FileName of the Font. 667 */ 668 void GLGuiWidget::setFont(const std::string& fontName) 669 { 670 //this->font = new Font(fontName); 671 } 672 673 /** 674 * @brief if Animation should be turned on. 675 * @param animated true if on, false otherwise. 676 */ 677 void GLGuiWidget::setAnimated(bool animated) 678 { 679 this->_animated = animated; 680 } 681 682 /** 683 * @brief sets the AnimatedState. 684 * @param animated: it states-changes should animate true, otherwise false. 685 */ 686 void GLGuiWidget::setAnimatedStateChanges(bool animated) 687 { 688 this->_animatedStateChanges = animated; 689 } 690 691 692 void GLGuiWidget::switchState(OrxGui::State state) 693 { 694 this->_currentStyle = this->_style[state]; 695 this->_currentState = state; 696 printf("Switching to state %s\n", OrxGui::StateString[state].c_str()); 697 } 698 699 700 /** 701 * @param stateName the Name of a State. 702 * @param state the found State is returned here if found. 703 * @returns true if String is found, false otherwise. 704 */ 705 bool GLGuiWidget::getState(const std::string& stateName, OrxGui::State* state) 706 { 707 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 708 if (stateName == OrxGui::StateString[i]) 709 { 710 *state = (OrxGui::State)i; 711 return true; 712 } 713 return false; 714 } 715 716 238 717 void GLGuiWidget::tick(float dt) 239 718 { 240 719 if (this->_toFrontColor) 241 720 { 242 this-> _style.foregroundColor(_state).slerp(*_toFrontColor, dt*3.0);721 this->foregroundColor(_state).slerp(*_toFrontColor, dt*3.0); 243 722 this->updateFrontColor(); 244 if (this-> style().foregroundColor(_state).dist(*_toFrontColor) < .1)723 if (this->foregroundColor(_state).dist(*_toFrontColor) < .1) 245 724 { 246 725 delete _toFrontColor; … … 256 735 void GLGuiWidget::draw() const 257 736 { 258 this-> style().background().select();737 this->background().select(); 259 738 this->drawRect(this->backRect()); 260 this-> style().background().unselect();739 this->background().unselect(); 261 740 } 262 741 -
branches/gui/src/lib/gui/gl/glgui_widget.h
r8584 r8598 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 … … 68 71 OrxGui::State state() const { return this->_state; }; 69 72 70 GLGuiStyle& style() { return this->_style; };71 const GLGuiStyle style() const { return this->_style; };72 73 73 Rect2D& backRect() { return this->_backRect; }; 74 74 const Rect2D& backRect() const { return this->_backRect; }; … … 78 78 void setWidgetSize(const Vector2D& size); 79 79 void setWidgetSize(float x, float y); 80 81 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 animated() const { return _animated; } 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 inline Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._foreground.diffuseColor(); } 185 inline Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) { return _style[state]._background.diffuseColor(); } 186 inline Material& background(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._background; } 187 inline Material& foreground(OrxGui::State state = GLGUI_DEFAULT_STYLE) { return _style[state]._foreground; } 188 189 void loadBackgroundMaterial(const Material& material); 190 void loadBackgroundMaterial(const Material& material, OrxGui::State state); 191 void loadBackgroundMaterial(const TiXmlElement* element); 192 void loadBackgroundMaterial(const TiXmlElement* element, OrxGui::State state); 193 void loadBackgroundMaterialS(const TiXmlElement* element, const std::string& stateName); 194 195 void loadForegroundMaterial(const Material& material); 196 void loadForegroundMaterial(const Material& material, OrxGui::State state); 197 void loadForegroundMaterial(const TiXmlElement* element, OrxGui::State state); 198 void loadForegroundMaterialS(const TiXmlElement* element, const std::string& stateName); 199 200 void setFeaturePosition(FeaturePosition featurePosition); 201 void setFeaturePositionS(const std::string& featurePosition); 202 203 void setFont(Font* font); 204 void setFont(const std::string& fontName); 205 206 void setAnimated(bool animated); 207 void setAnimatedStateChanges(bool animated); 208 void switchState(OrxGui::State state); 209 80 210 81 211 … … 98 228 virtual bool processEvent(const Event& event) { return false; }; 99 229 230 bool getState(const std::string& stateName, OrxGui::State* state); 100 231 101 232 protected: … … 119 250 virtual void destroyed(); 120 251 252 121 253 private: 122 254 void init(); 123 255 124 256 private: 257 static GLGuiWidget* _selected; //!< The currently selected Widget. 258 static GLGuiWidget* _focused; //!< The currently Focused Widget. 259 static GLGuiWidget* _inputGrabber; //!< The Widget that grabs input. 260 261 262 125 263 GLGuiWidget* _parent; //!< The parent of this Widget. 126 264 127 265 /// LOOKS 128 GLGuiStyle _style;129 266 Rect2D _backRect; 130 267 … … 143 280 144 281 145 static GLGuiWidget* _selected; //!< The currently selected Widget. 146 static GLGuiWidget* _focused; //!< The currently Focused Widget. 147 148 static GLGuiWidget* _inputGrabber; //!< The Widget that grabs input. 282 283 /// STYLE - Variables. 284 typedef struct 285 { 286 float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. 287 float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. 288 float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts 289 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts 290 291 float _textSize; //!< The TextSize of the Widget. 292 293 Material _background; //!< The Background Material of the Widget. 294 295 Material _foreground; //!< The foreground Material of the Widget. 296 } 297 StatedStyle; 298 299 300 StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States 301 302 FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...) 303 Font* _font; //!< The Font used in the current Widget. 304 305 306 /// ANIMATION STUFF: 307 bool _animated; //!< If the Widget is animated (Texture might be an AnimatedTexture.) 308 bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. 309 310 float _animationCycle; 311 float _animationDuration; 312 StatedStyle _currentStyle; 313 OrxGui::State _currentState; 314 149 315 }; 150 316 } -
branches/gui/src/lib/gui/gl/specials/glgui_notifier.cc
r8584 r8598 148 148 void GLGuiNotifier::applyTextSettings(MultiLineText* text) 149 149 { 150 text->setSize(this-> style().textSize());150 text->setSize(this->textSize()); 151 151 text->setLineWidth( 300 ); 152 text->setFont("fonts/final_frontier.ttf", (int)this-> style().textSize());153 154 text->setColor(this-> style().foregroundColor() );152 text->setFont("fonts/final_frontier.ttf", (int)this->textSize()); 153 154 text->setColor(this->foregroundColor() ); 155 155 if (text->getParent2D() != this) 156 156 text->setParent2D(this); … … 200 200 this->beginDraw(); 201 201 202 this-> style().background().select();202 this->background().select(); 203 203 this->drawRect(this->backRect()); 204 204 this->endDraw(); … … 216 216 Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber) 217 217 { 218 return Vector2D(0.0f, (float)( 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)); 219 219 } 220 220 -
branches/gui/src/util/hud.cc
r8583 r8598 89 89 { 90 90 this->energyWidget->show(); 91 this->energyWidget-> style().background().setDiffuseMap("hud_energy_background.png");92 this->energyWidget-> style().background().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);91 this->energyWidget->background().setDiffuseMap("hud_energy_background.png"); 92 this->energyWidget->background().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 93 93 /* this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png"); 94 94 this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ … … 143 143 { 144 144 weapon->getEnergyWidget()->show(); 145 weapon->getEnergyWidget()-> style().background().setDiffuse( .8,.2,.11);146 weapon->getEnergyWidget()-> style().background().setTransparency(.1);145 weapon->getEnergyWidget()->background().setDiffuse( .8,.2,.11); 146 weapon->getEnergyWidget()->background().setTransparency(.1); 147 147 weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6)); 148 148 // weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
Note: See TracChangeset
for help on using the changeset viewer.