Index: branches/gui/src/lib/gui/gl/glgui_widget.cc
===================================================================
--- branches/gui/src/lib/gui/gl/glgui_widget.cc	(revision 8604)
+++ branches/gui/src/lib/gui/gl/glgui_widget.cc	(revision 8605)
@@ -14,5 +14,5 @@
 */
 
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
+#define DEBUG_SPECIAL_MODULE 4//DEBUG_MODULE_GUI
 
 #include "glgui_widget.h"
@@ -41,4 +41,31 @@
 
   /**
+   * @brief loads Parameters for a Style from XML
+   * @param root the XML-Element to load from.
+   */
+  void GLGuiWidget::loadParams(const TiXmlElement* root)
+  {
+
+    /// STYLE
+    LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);
+    LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);
+    LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);
+    LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);
+
+    LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);
+    LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);
+    LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);
+
+    //    LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);
+    //    LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);
+
+    LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);
+    LoadParam(root, "Font", this, GLGuiWidget, setFont);
+
+    LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);
+  }
+
+
+  /**
    * @brief standard deconstructor
    */
@@ -47,7 +74,4 @@
     if (this == GLGuiWidget::_focused)
       GLGuiWidget::_focused = NULL;
-
-    if (this->_toFrontColor)
-      delete this->_toFrontColor;
   }
 
@@ -69,5 +93,4 @@
     this->_pushed = false;
     this->_state = OrxGui::Normal;
-    this->_toFrontColor = NULL;
 
 
@@ -75,9 +98,14 @@
     this->resetStyle();
 
-    this->_animationCycle = -1.0;
+    this->_animating = false;
+    this->_animationCycle = 0.0;
     this->_animationDuration = 1.0;
 
 
     this->setBackgroundColor(Color(0, 0, 0, 1));
+    this->_style[0]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    this->_style[1]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    this->_style[2]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    this->_style[3]._background.setBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
     this->setForegroundColor(Color(1, 0, 0, 1), OrxGui::Normal);
@@ -136,5 +164,5 @@
   void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
   {
-    if (instantaniously)
+/*    if (instantaniously)
     {
       this->setForegroundColor(frontColor);
@@ -150,5 +178,5 @@
       *this->_toFrontColor = frontColor;
     //this->_frontColor = frontColor;
-    //this->updateFrontColor();
+    //this->updateFrontColor();*/
   };
 
@@ -265,32 +293,7 @@
     this->setFont(NULL);
 
-    this->setAnimated(true);
     this->setAnimatedStateChanges(true);
   }
 
-  /**
-   * @brief loads Parameters for a Style from XML
-   * @param root the XML-Element to load from.
-   */
-  void GLGuiWidget::loadParams(const TiXmlElement* root)
-  {
-    LoadParam(root, "border-left", this, GLGuiWidget, setBorderLeft);
-    LoadParam(root, "border-right", this, GLGuiWidget, setBorderRight);
-    LoadParam(root, "border-top", this, GLGuiWidget, setBorderTop);
-    LoadParam(root, "border-bottom", this, GLGuiWidget, setBorderBottom);
-
-    LoadParam(root, "text-size", this, GLGuiWidget, setTextSize);
-    LoadParam(root, "background-color", this, GLGuiWidget, setBackgroundColorS);
-    LoadParam(root, "foreground-color", this, GLGuiWidget, setForegroundColorS);
-
-    //    LoadParamXML(root, "backmat", this, GLGuiWidget, loadBackgroundMaterial);
-    //    LoadParamXML(root, "frontmat", this, GLGuiWidget, loadForegroundMaterial);
-
-    LoadParam(root, "feature-position", this, GLGuiWidget, setFeaturePositionS);
-    LoadParam(root, "Font", this, GLGuiWidget, setFont);
-
-    LoadParam(root, "animated", this, GLGuiWidget, setAnimated);
-    LoadParam(root, "animated-state-changes", this, GLGuiWidget, setAnimatedStateChanges);
-  }
 
   /**
@@ -674,13 +677,4 @@
 
   /**
-   * @brief if Animation should be turned on.
-   * @param animated true if on, false otherwise.
-   */
-  void GLGuiWidget::setAnimated(bool animated)
-  {
-    this->_animated = animated;
-  }
-
-  /**
    * @brief sets the AnimatedState.
    * @param animated: it states-changes should animate true, otherwise false.
@@ -694,7 +688,9 @@
   void GLGuiWidget::switchState(OrxGui::State state)
   {
-    this->_currentStyle = this->_style[state];
+    //this->_currentStyle = this->_style[state];
     this->_state = state;
-    printf("Switching to state %s\n", OrxGui::StateString[state].c_str());
+    PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
+
+    this->animateBack();
   }
 
@@ -716,16 +712,27 @@
   }
 
+  void GLGuiWidget::animateBack()
+  {
+    this->_animating = true;
+    this->_animationCycle = 0.0f;
+  }
+
 
   void GLGuiWidget::tick(float dt)
   {
-    if (this->_toFrontColor)
+    if (this->_animating)
     {
-      this->foregroundColor(_state).slerp(*_toFrontColor, dt*3.0);
+      this->foregroundColor();
+
+      _animationCycle += dt / _animationDuration;
+      if (_animationCycle >= 1.0)
+      {
+        _currentStyle._foreground.diffuseColor() = this->foregroundColor(_state);
+        _animating = false;
+      }
+      else
+        _currentStyle._foreground.diffuseColor().slerp(this->foregroundColor(_state), _animationCycle);
+
       this->updateFrontColor();
-      if (this->foregroundColor(_state).dist(*_toFrontColor) < .1)
-      {
-        delete _toFrontColor;
-        _toFrontColor = NULL;
-      }
     }
   }
@@ -779,6 +786,4 @@
     /// TODO    PRINT(0)("");    Font*               _font;                 //!< The Font used in the current Widget.
 
-    if (_animated)
-      PRINT(0)("- Animated ");
     if (_animatedStateChanges)
       PRINT(0)("- AnimatedStateChanges");
@@ -786,4 +791,8 @@
 
     /*
+    if (_animating)
+      PRINT(0)("- Animated ");
+
+    //
     float               _animationCycle;
     float               _animationDuration;
