From bbfb0898938f4b314a315d923c152698cfef6d59 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Wed, 21 Oct 2015 14:26:47 +0100
Subject: [PATCH] Preserve the ScrollBar alpha value from the stylesheet
The alpha value from stylesheet was lost when the indicator was shown
(it was hard-coded to 1.0f)
Change-Id: I67a063ff5f9dad3393ad494c44b75138fb55901f
---
.../internal/controls/scroll-bar/scroll-bar-impl.cpp | 18 ++++++++++++++----
.../internal/controls/scroll-bar/scroll-bar-impl.h | 5 ++++-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
index d2b699b..f92f721 100755
--- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
+++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
@@ -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);
}
}
diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h
index 23d3fa7..1f9691d 100755
--- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h
+++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h
@@ -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
--
2.7.4