Preserve the ScrollBar alpha value from the stylesheet 21/49921/3
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 21 Oct 2015 13:26:47 +0000 (14:26 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 21 Oct 2015 13:48:42 +0000 (14:48 +0100)
The alpha value from stylesheet was lost when the indicator was shown
(it was hard-coded to 1.0f)

Change-Id: I67a063ff5f9dad3393ad494c44b75138fb55901f

dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h

index d2b699b..f92f721 100755 (executable)
@@ -152,6 +152,7 @@ const char* INDICATOR_HEIGHT_POLICY_NAME[] = {"Variable", "Fixed"};
 
 ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+  mIndicatorShowAlpha(1.0f),
   mDirection(direction),
   mScrollableObject(WeakHandleBase()),
   mPropertyScrollPosition(Property::INVALID_INDEX),
@@ -161,10 +162,11 @@ ScrollBar::ScrollBar(Toolkit::ScrollBar::Direction direction)
   mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION),
   mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
   mScrollStart(0.0f),
-  mIsPanning(false),
   mCurrentScrollPosition(0.0f),
   mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable),
-  mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT)
+  mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT),
+  mIsPanning(false),
+  mIndicatorFirstShow(true)
 {
 }
 
@@ -218,6 +220,7 @@ void ScrollBar::SetScrollIndicator( Actor indicator )
   if( indicator )
   {
     mIndicator = indicator;
+    mIndicatorFirstShow = true;
     Self().Add(mIndicator);
 
     EnableGestureDetection(Gesture::Type(Gesture::Pan));
@@ -328,15 +331,22 @@ void ScrollBar::ShowIndicator()
     mAnimation.Reset();
   }
 
+  if( mIndicatorFirstShow )
+  {
+    // Preserve the alpha value from the stylesheet
+    mIndicatorShowAlpha = Self().GetCurrentColor().a;
+    mIndicatorFirstShow = false;
+  }
+
   if(mIndicatorShowDuration > 0.0f)
   {
     mAnimation = Animation::New( mIndicatorShowDuration );
-    mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN );
+    mAnimation.AnimateTo( Property( mIndicator, Actor::Property::COLOR_ALPHA ), mIndicatorShowAlpha, AlphaFunction::EASE_IN );
     mAnimation.Play();
   }
   else
   {
-    mIndicator.SetOpacity(1.0f);
+    mIndicator.SetOpacity(mIndicatorShowAlpha);
   }
 }
 
index 23d3fa7..1f9691d 100755 (executable)
@@ -265,6 +265,7 @@ private:
 private:
 
   Actor mIndicator;                                                  ///< Image of scroll indicator.
+  float mIndicatorShowAlpha;                                         ///< The alpha value when the indicator is fully shown
   Animation mAnimation;                                              ///< Scroll indicator Show/Hide Animation.
 
   Toolkit::ScrollBar::Direction mDirection;                          ///< The direction of scroll bar (vertical or horizontal)
@@ -282,7 +283,6 @@ private:
   float mScrollStart;                                                ///< Scroll Start position (start of drag)
   Vector3 mGestureDisplacement;                                      ///< Gesture Displacement.
 
-  bool mIsPanning;                                                  ///< Whether the scroll bar is being panned.
   float mCurrentScrollPosition;                                     ///< The current scroll position updated by the pan gesture
 
   Toolkit::ScrollBar::IndicatorHeightPolicy mIndicatorHeightPolicy;  ///< The height policy of scroll indicator (variable or fixed)
@@ -300,6 +300,9 @@ private:
   Constraint mIndicatorPositionConstraint;
   Constraint mIndicatorSizeConstraint;
   Constraint mScrollPositionInCurrentAxisConstraint;
+
+  bool mIsPanning          : 1;                                      ///< Whether the scroll bar is being panned.
+  bool mIndicatorFirstShow : 1;                                      ///< True if the indicator has never been shown
 };
 
 } // namespace Internal