From cf3829e07db4fe95b8ccc0e684b66441cfe694d9 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Tue, 26 Aug 2014 13:34:00 +0100 Subject: [PATCH] Allow configurable duration to show or hide scroll indicator Change-Id: I2494a448bc6c257c2b1779f7dcb102db19c5e2c2 --- .../controls/scroll-bar/scroll-bar-impl.cpp | 78 +++++++++++++++++++--- .../internal/controls/scroll-bar/scroll-bar-impl.h | 23 +++++++ .../public-api/controls/scroll-bar/scroll-bar.cpp | 20 ++++++ .../public-api/controls/scroll-bar/scroll-bar.h | 36 +++++++++- 4 files changed, 146 insertions(+), 11 deletions(-) diff --git a/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index dc33722..d7c6d8e 100755 --- a/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -27,8 +27,8 @@ const char* DEFAULT_INDICATOR_IMAGE_PATH = DALI_IMAGE_DIR "popup_scroll.png"; const Vector4 DEFAULT_INDICATOR_NINE_PATCH_BORDER(4.0f, 9.0f, 7.0f, 11.0f); const float MINIMUM_INDICATOR_HEIGHT(20.0f); // The minimum indicator height for the nine patch border const float DEFAULT_SLIDER_DEPTH(1.0f); -const float INDICATOR_SHOW_TIME(0.5f); -const float INDICATOR_HIDE_TIME(0.5f); +const float DEFAULT_INDICATOR_SHOW_DURATION(0.5f); +const float DEFAULT_INDICATOR_HIDE_DURATION(0.5f); const float DEFAULT_PAN_GESTURE_PROCESS_TIME(16.7f); // 16.7 milliseconds, i.e. one frame const float DEFAULT_INDICATOR_FIXED_HEIGHT(80.0f); @@ -115,6 +115,8 @@ namespace Toolkit const Property::Index ScrollBar::PROPERTY_INDICATOR_HEIGHT_POLICY( Internal::ScrollBar::SCROLLBAR_PROPERTY_START_INDEX ); const Property::Index ScrollBar::PROPERTY_INDICATOR_FIXED_HEIGHT( Internal::ScrollBar::SCROLLBAR_PROPERTY_START_INDEX + 1 ); +const Property::Index ScrollBar::PROPERTY_INDICATOR_SHOW_DURATION( Internal::ScrollBar::SCROLLBAR_PROPERTY_START_INDEX + 2 ); +const Property::Index ScrollBar::PROPERTY_INDICATOR_HIDE_DURATION( Internal::ScrollBar::SCROLLBAR_PROPERTY_START_INDEX + 3 ); namespace Internal { @@ -135,10 +137,14 @@ TypeRegistration typeRegistration( typeid(Toolkit::ScrollBar), typeid(Toolkit::S PropertyRegistration property1( typeRegistration, "indicator-height-policy", Toolkit::ScrollBar::PROPERTY_INDICATOR_HEIGHT_POLICY, Property::STRING, &ScrollBar::SetProperty, &ScrollBar::GetProperty ); PropertyRegistration property2( typeRegistration, "indicator-fixed-height", Toolkit::ScrollBar::PROPERTY_INDICATOR_FIXED_HEIGHT, Property::FLOAT, &ScrollBar::SetProperty, &ScrollBar::GetProperty ); +PropertyRegistration property3( typeRegistration, "indicator-show-duration", Toolkit::ScrollBar::PROPERTY_INDICATOR_SHOW_DURATION, Property::FLOAT, &ScrollBar::SetProperty, &ScrollBar::GetProperty ); +PropertyRegistration property4( typeRegistration, "indicator-hide-duration", Toolkit::ScrollBar::PROPERTY_INDICATOR_HIDE_DURATION, Property::FLOAT, &ScrollBar::SetProperty, &ScrollBar::GetProperty ); } ScrollBar::ScrollBar() -: mScrollStart(0.0f), +: mIndicatorShowDuration(DEFAULT_INDICATOR_SHOW_DURATION), + mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION), + mScrollStart(0.0f), mIsPanning(false), mCurrentScrollPosition(0.0f), mIndicatorHeightPolicy(Toolkit::ScrollBar::Variable), @@ -272,9 +278,16 @@ void ScrollBar::Show() mAnimation.Reset(); } - mAnimation = Animation::New( INDICATOR_SHOW_TIME ); - mAnimation.OpacityTo( Self(), 1.0f, AlphaFunctions::EaseIn ); - mAnimation.Play(); + if(mIndicatorShowDuration > 0.0f) + { + mAnimation = Animation::New( mIndicatorShowDuration ); + mAnimation.OpacityTo( Self(), 1.0f, AlphaFunctions::EaseIn ); + mAnimation.Play(); + } + else + { + Self().SetOpacity(1.0f); + } } void ScrollBar::Hide() @@ -286,9 +299,16 @@ void ScrollBar::Hide() mAnimation.Reset(); } - mAnimation = Animation::New( INDICATOR_HIDE_TIME ); - mAnimation.OpacityTo( Self(), 0.0f, AlphaFunctions::EaseIn ); - mAnimation.Play(); + if(mIndicatorHideDuration > 0.0f) + { + mAnimation = Animation::New( mIndicatorHideDuration ); + mAnimation.OpacityTo( Self(), 0.0f, AlphaFunctions::EaseIn ); + mAnimation.Play(); + } + else + { + Self().SetOpacity(0.0f); + } } bool ScrollBar::OnPanGestureProcessTick() @@ -397,6 +417,26 @@ float ScrollBar::GetIndicatorFixedHeight() return mIndicatorFixedHeight; } +void ScrollBar::SetIndicatorShowDuration( float durationSeconds ) +{ + mIndicatorShowDuration = durationSeconds; +} + +float ScrollBar::GetIndicatorShowDuration() +{ + return mIndicatorShowDuration; +} + +void ScrollBar::SetIndicatorHideDuration( float durationSeconds ) +{ + mIndicatorHideDuration = durationSeconds; +} + +float ScrollBar::GetIndicatorHideDuration() +{ + return mIndicatorHideDuration; +} + void ScrollBar::OnIndicatorHeightPolicyPropertySet( Property::Value propertyValue ) { std::string policyName( propertyValue.Get() ); @@ -433,6 +473,16 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr scrollBarImpl.SetIndicatorFixedHeight(value.Get()); break; } + case Toolkit::ScrollBar::PROPERTY_INDICATOR_SHOW_DURATION: + { + scrollBarImpl.SetIndicatorShowDuration(value.Get()); + break; + } + case Toolkit::ScrollBar::PROPERTY_INDICATOR_HIDE_DURATION: + { + scrollBarImpl.SetIndicatorHideDuration(value.Get()); + break; + } } } } @@ -458,6 +508,16 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde value = scrollBarImpl.GetIndicatorFixedHeight(); break; } + case Toolkit::ScrollBar::PROPERTY_INDICATOR_SHOW_DURATION: + { + value = scrollBarImpl.GetIndicatorShowDuration(); + break; + } + case Toolkit::ScrollBar::PROPERTY_INDICATOR_HIDE_DURATION: + { + value = scrollBarImpl.GetIndicatorHideDuration(); + break; + } } } return value; diff --git a/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h b/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h index dee5479..0ceaf44 100755 --- a/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h +++ b/base/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h @@ -113,6 +113,26 @@ public: float GetIndicatorFixedHeight(); /** + * @copydoc Toolkit::ScrollBar::SetIndicatorShowDuration() + */ + void SetIndicatorShowDuration( float durationSeconds ); + + /** + * @copydoc Toolkit::ScrollBar::GetIndicatorShowDuration() + */ + float GetIndicatorShowDuration(); + + /** + * @copydoc Toolkit::ScrollBar::SetIndicatorHideDuration() + */ + void SetIndicatorHideDuration( float durationSeconds ); + + /** + * @copydoc Toolkit::ScrollBar::GetIndicatorHideDuration() + */ + float GetIndicatorHideDuration(); + + /** * @copydoc Toolkit::ScrollBar::Show() */ void Show(); @@ -203,6 +223,9 @@ private: ImageActor mIndicator; ///< Image of scroll indicator. Animation mAnimation; ///< Scroll indicator Show/Hide Animation. + float mIndicatorShowDuration; ///< The duration of scroll indicator show animation + float mIndicatorHideDuration; ///< The duration of scroll indicator hide animation + float mScrollStart; ///< Scroll Start position (start of drag) Vector3 mGestureDisplacement; ///< Gesture Displacement. diff --git a/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp b/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp index ed08541..367e7e4 100755 --- a/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp +++ b/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.cpp @@ -104,6 +104,26 @@ float ScrollBar::GetIndicatorFixedHeight() return GetImpl(*this).GetIndicatorFixedHeight(); } +void ScrollBar::SetIndicatorShowDuration( float durationSeconds ) +{ + GetImpl(*this).SetIndicatorShowDuration(durationSeconds); +} + +float ScrollBar::GetIndicatorShowDuration() +{ + return GetImpl(*this).GetIndicatorShowDuration(); +} + +void ScrollBar::SetIndicatorHideDuration( float durationSeconds ) +{ + GetImpl(*this).SetIndicatorHideDuration(durationSeconds); +} + +float ScrollBar::GetIndicatorHideDuration() +{ + return GetImpl(*this).GetIndicatorHideDuration(); +} + void ScrollBar::Show() { GetImpl(*this).Show(); diff --git a/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h b/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h index ad13fee..372e3c3 100755 --- a/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h +++ b/base/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h @@ -51,8 +51,10 @@ public: typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType; // Properties - static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", type STRING - static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", type FLOAT + static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING + static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type FLOAT + static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION; ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT + static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION; ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT public: @@ -170,6 +172,36 @@ public: float GetIndicatorFixedHeight(); /** + * @brief Sets the duration in second for the scroll indicator to become fully visible + * + * @pre The scroll bar actor has been initialised. + * + * @param[in] durationSeconds The duration for the scroll indicator to become fully visible + */ + void SetIndicatorShowDuration( float durationSeconds ); + + /** + * @brief Gets the duration in second for the scroll indicator to become fully visible + * @return The duration for the scroll indicator to become fully visible + */ + float GetIndicatorShowDuration(); + + /** + * @brief Sets the duration in second for the scroll indicator to become fully invisible + * + * @pre The scroll bar actor has been initialised. + * + * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible + */ + void SetIndicatorHideDuration( float durationSeconds ); + + /** + * @brief Gets the duration in second for the scroll indicator to become fully invisible + * @return The duration for the scroll indicator to become fully invisible + */ + float GetIndicatorHideDuration(); + + /** * @brief Shows the scroll indicator */ void Show(); -- 2.7.4