From a1143092d6f139734fdc39aec5d9da680eb1be57 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Thu, 9 Mar 2017 19:39:58 +0000 Subject: [PATCH] [3.0] Avoid showing unnecessary scroll-indicator Change-Id: I434f5ea4e7cc49cbc51e28266db61b06ab2f598a --- .../scrollable/scroll-view/scroll-view-impl.cpp | 48 +++++++++++++++++++++- .../scrollable/scroll-view/scroll-view-impl.h | 7 ++++ .../text-controls/text-selection-toolbar-impl.cpp | 21 +++++++++- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 622a934..6d37417 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -77,6 +77,17 @@ const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f ); ///< Default const std::string INTERNAL_MAX_POSITION_PROPERTY_NAME( "internalMaxPosition" ); +// The following properties are not in the public-api yet. +enum +{ + /** + * @brief True if scroll-bar should be automatically show/hidden during/after panning. + * @details name "transientScrollBar", type bool. + */ + TRANSIENT_SCROLL_BAR = Toolkit::ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP + 1 +}; + + // Helpers //////////////////////////////////////////////////////////////////////////////////////// /** @@ -250,6 +261,9 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "panningEnabled", B DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "axisAutoLockEnabled", BOOLEAN, AXIS_AUTO_LOCK_ENABLED ) DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "wheelScrollDistanceStep", VECTOR2, WHEEL_SCROLL_DISTANCE_STEP ) +Dali::PropertyRegistration manualProperty1( typeRegistration, "transientScrollBar", TRANSIENT_SCROLL_BAR, + Property::BOOLEAN, Dali::Toolkit::Internal::ScrollView::SetProperty, Dali::Toolkit::Internal::ScrollView::GetProperty ); + DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollPosition", VECTOR2, SCROLL_POSITION) DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollPrePosition", VECTOR2, SCROLL_PRE_POSITION) DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, ScrollView, "scrollPrePositionX", SCROLL_PRE_POSITION_X, SCROLL_PRE_POSITION, 0) @@ -660,7 +674,7 @@ ScrollView::ScrollView() mDefaultMaxOvershoot(true), mCanScrollHorizontal(true), mCanScrollVertical(true), - mTransientScrollBar(true) + mTransientScrollBar(false) { } @@ -1155,6 +1169,22 @@ Vector2 ScrollView::GetWheelScrollDistanceStep() const return mWheelScrollDistanceStep; } +void ScrollView::SetTransientScrollBar( bool transient ) +{ + if( transient != mTransientScrollBar ) + { + mTransientScrollBar = transient; + + Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); + if( mTransientScrollBar && scrollBar ) + { + // Show the scroll-indicator for a brief period + scrollBar.SetVisible( true ); + GetImpl(scrollBar).ShowTransientIndicator(); + } + } +} + unsigned int ScrollView::GetCurrentPage() const { // in case animation is currently taking place. @@ -1987,6 +2017,11 @@ void ScrollView::OnChildAdd(Actor& child) // Show the scroll-indicator for a brief period GetImpl(scrollBar).ShowTransientIndicator(); } + else + { + scrollBar.SetVisible( false ); + scrollBar.HideIndicator(); + } } else if(mAlterChild) { @@ -2493,6 +2528,7 @@ void ScrollView::OnPan( const PanGesture& gesture ) if( ( rulerDomainX.max > size.width ) || ( rulerDomainY.max > size.height ) ) { + scrollBar.SetVisible( true ); scrollBar.ShowIndicator(); } } @@ -2901,6 +2937,11 @@ void ScrollView::SetProperty( BaseObject* object, Property::Index index, const P scrollViewImpl.SetWheelScrollDistanceStep( value.Get() ); break; } + case TRANSIENT_SCROLL_BAR: + { + scrollViewImpl.SetTransientScrollBar( value.Get() ); + break; + } } } } @@ -2936,6 +2977,11 @@ Property::Value ScrollView::GetProperty( BaseObject* object, Property::Index ind value = scrollViewImpl.GetWheelScrollDistanceStep(); break; } + case TRANSIENT_SCROLL_BAR: + { + value = scrollViewImpl.mTransientScrollBar; + break; + } } } diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h index 485d508..29a81bf 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h @@ -356,6 +356,13 @@ public: void SetWheelScrollDistanceStep(Vector2 step); /** + * @brief Enables or disables the transient scroll-bar + * + * @param[in] transient True if scroll-bar should be automatically show/hidden during/after panning + */ + void SetTransientScrollBar( bool transient ); + + /** * @copydoc Toolkit::ScrollView::GetCurrentPage */ unsigned int GetCurrentPage() const; diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp index d0c8d85..765b8ab 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp @@ -45,6 +45,16 @@ namespace const Dali::Vector2 DEFAULT_SCROLL_BAR_PADDING( 8.0f, 6.0f ); +// The following properties are not in the public-api yet. +enum +{ + /** + * @brief True if scroll-bar should be automatically show/hidden during/after panning. + * @details name "transientScrollBar", type bool. + */ + TRANSIENT_SCROLL_BAR = Dali::Toolkit::ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP + 1 +}; + BaseHandle Create() { return Toolkit::TextSelectionToolbar::New(); @@ -172,8 +182,15 @@ void TextSelectionToolbar::OnInitialize() void TextSelectionToolbar::OnRelayout( const Vector2& size, RelayoutContainer& container ) { float width = std::max ( mTableOfButtons.GetNaturalSize().width, size.width ); - mRulerX->SetDomain( RulerDomain( 0.0, width, true ) ); - mScrollView.SetRulerX( mRulerX ); + + if( mScrollView ) + { + mRulerX->SetDomain( RulerDomain( 0.0, width, true ) ); + mScrollView.SetRulerX( mRulerX ); + + bool showTransient( width > size.width ); + mScrollView.SetProperty( TRANSIENT_SCROLL_BAR, showTransient ); + } if( mScrollBar ) { -- 2.7.4