Changeset 8605 in orxonox.OLD for branches/gui/src/lib/gui/gl/glgui_widget.cc
- Timestamp:
- Jun 20, 2006, 9:59:53 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui_widget.cc
r8604 r8605 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" … … 41 41 42 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 /** 43 70 * @brief standard deconstructor 44 71 */ … … 47 74 if (this == GLGuiWidget::_focused) 48 75 GLGuiWidget::_focused = NULL; 49 50 if (this->_toFrontColor)51 delete this->_toFrontColor;52 76 } 53 77 … … 69 93 this->_pushed = false; 70 94 this->_state = OrxGui::Normal; 71 this->_toFrontColor = NULL;72 95 73 96 … … 75 98 this->resetStyle(); 76 99 77 this->_animationCycle = -1.0; 100 this->_animating = false; 101 this->_animationCycle = 0.0; 78 102 this->_animationDuration = 1.0; 79 103 80 104 81 105 this->setBackgroundColor(Color(0, 0, 0, 1)); 106 this->_style[0]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 107 this->_style[1]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 108 this->_style[2]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 109 this->_style[3]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 82 110 83 111 this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal); … … 136 164 void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously) 137 165 { 138 if (instantaniously)166 /* if (instantaniously) 139 167 { 140 168 this->setForegroundColor(frontColor); … … 150 178 *this->_toFrontColor = frontColor; 151 179 //this->_frontColor = frontColor; 152 //this->updateFrontColor(); 180 //this->updateFrontColor();*/ 153 181 }; 154 182 … … 265 293 this->setFont(NULL); 266 294 267 this->setAnimated(true);268 295 this->setAnimatedStateChanges(true); 269 296 } 270 297 271 /**272 * @brief loads Parameters for a Style from XML273 * @param root the XML-Element to load from.274 */275 void GLGuiWidget::loadParams(const TiXmlElement* root)276 {277 LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);278 LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);279 LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);280 LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);281 282 LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);283 LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);284 LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);285 286 // LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);287 // LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);288 289 LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);290 LoadParam(root, "Font", this, GLGuiWidget, setFont);291 292 LoadParam(root, "animated", this, GLGuiWidget, setAnimated);293 LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);294 }295 298 296 299 /** … … 674 677 675 678 /** 676 * @brief if Animation should be turned on.677 * @param animated true if on, false otherwise.678 */679 void GLGuiWidget::setAnimated(bool animated)680 {681 this->_animated = animated;682 }683 684 /**685 679 * @brief sets the AnimatedState. 686 680 * @param animated: it states-changes should animate true, otherwise false. … … 694 688 void GLGuiWidget::switchState(OrxGui::State state) 695 689 { 696 this->_currentStyle = this->_style[state];690 //this->_currentStyle = this->_style[state]; 697 691 this->_state = state; 698 printf("Switching to state %s\n", OrxGui::StateString[state].c_str()); 692 PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str()); 693 694 this->animateBack(); 699 695 } 700 696 … … 716 712 } 717 713 714 void GLGuiWidget::animateBack() 715 { 716 this->_animating = true; 717 this->_animationCycle = 0.0f; 718 } 719 718 720 719 721 void GLGuiWidget::tick(float dt) 720 722 { 721 if (this->_ toFrontColor)723 if (this->_animating) 722 724 { 723 this->foregroundColor(_state).slerp(*_toFrontColor, dt*3.0); 725 this->foregroundColor(); 726 727 _animationCycle += dt / _animationDuration; 728 if (_animationCycle >= 1.0) 729 { 730 _currentStyle._foreground.diffuseColor() = this->foregroundColor(_state); 731 _animating = false; 732 } 733 else 734 _currentStyle._foreground.diffuseColor().slerp(this->foregroundColor(_state), _animationCycle); 735 724 736 this->updateFrontColor(); 725 if (this->foregroundColor(_state).dist(*_toFrontColor) < .1)726 {727 delete _toFrontColor;728 _toFrontColor = NULL;729 }730 737 } 731 738 } … … 779 786 /// TODO PRINT(0)(""); Font* _font; //!< The Font used in the current Widget. 780 787 781 if (_animated)782 PRINT(0)("- Animated ");783 788 if (_animatedStateChanges) 784 789 PRINT(0)("- AnimatedStateChanges"); … … 786 791 787 792 /* 793 if (_animating) 794 PRINT(0)("- Animated "); 795 796 // 788 797 float _animationCycle; 789 798 float _animationDuration;
Note: See TracChangeset
for help on using the changeset viewer.