From a434be8fee8cb4a42f8d28d04828b6628e43e84f Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Thu, 23 Mar 2017 19:08:43 +0000 Subject: [PATCH] Fix scroll bar issue for TBT testing 1. Fixed the scroll bar visibility isue 2. Increased scroll indicator size and duration to hide indicator to make it easier to grab 3. Fixed orientation of scroll bar to match its direction Change-Id: I98d7d79ed7f83eec5733e8566ea10708e0f9768b --- .../controls/scroll-bar/scroll-bar-impl.cpp | 55 ++++++++++++ .../internal/controls/scroll-bar/scroll-bar-impl.h | 16 ++++ .../scrollable/scroll-view/scroll-view-impl.cpp | 99 +++++++++++++++------ .../scrollable/scroll-view/scroll-view-impl.h | 15 +++- .../styles/images-common/popup_scroll.9.png | Bin 485 -> 583 bytes 5 files changed, 159 insertions(+), 26 deletions(-) mode change 100644 => 100755 dali-toolkit/styles/images-common/popup_scroll.9.png 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 5a4beea..7073754 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -220,6 +220,7 @@ void ScrollBar::OnInitialize() { CreateDefaultIndicatorActor(); Self().SetDrawMode(DrawMode::OVERLAY_2D); + SetScrollDirection(mDirection); } void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize ) @@ -538,9 +539,63 @@ void ScrollBar::OnSizeSet( const Vector3& size ) } } +void ScrollBar::OnStageConnection( int depth ) +{ + Actor parent = Self().GetParent(); + if (parent && mDirection == Toolkit::ScrollBar::Horizontal) + { + parent.OnRelayoutSignal().Connect( this, &ScrollBar::OnParentRelayout ); + } + + Control::OnStageConnection( depth ); +} + +void ScrollBar::OnStageDisconnection() +{ + Actor parent = Self().GetParent(); + if (parent && mDirection == Toolkit::ScrollBar::Horizontal) + { + parent.OnRelayoutSignal().Disconnect( this, &ScrollBar::OnParentRelayout ); + } + + Control::OnStageDisconnection(); +} + +void ScrollBar::OnParentRelayout(Actor actor) +{ + // Make the height of the horizontal scroll bar to be the same as the width of its parent. + // The parent size only set during relayout. + Self().SetSize(Vector2(0.0f, actor.GetRelayoutSize( Dimension::WIDTH) )); +} + void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction ) { mDirection = direction; + + Actor self = Self(); + + if(mDirection == Toolkit::ScrollBar::Horizontal) + { + // Rotate the scroll bar and align it to the bottom of its parent + self.SetParentOrigin(ParentOrigin::BOTTOM_LEFT); + self.SetAnchorPoint(AnchorPoint::TOP_LEFT); + self.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH); + self.SetOrientation(Quaternion(Radian( 1.5f * Math::PI ), Vector3::ZAXIS)); + + Actor parent = self.GetParent(); + if (parent && mDirection == Toolkit::ScrollBar::Horizontal) + { + parent.OnRelayoutSignal().Connect( this, &ScrollBar::OnParentRelayout ); + } + } + else + { + // Align the scroll bar to the right of its parent + self.SetParentOrigin(ParentOrigin::TOP_RIGHT); + self.SetAnchorPoint(AnchorPoint::TOP_RIGHT); + self.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT); + self.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH); + } } Toolkit::ScrollBar::Direction ScrollBar::GetScrollDirection() const 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 da398b6..7f0bd18 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h @@ -215,6 +215,16 @@ private: // from Control */ virtual void OnSizeSet( const Vector3& size ); + /** + * @copydoc CustomActorImpl::OnStageConnection() + */ + virtual void OnStageConnection( int depth ); + + /** + * @copydoc CustomActorImpl::OnStageDisconnection() + */ + virtual void OnStageDisconnection(); + private: /** @@ -253,6 +263,12 @@ private: */ void OnIndicatorHeightPolicyPropertySet(Property::Value propertyValue); + /** + * Callback when the size has been set on the parent during relayout + * @param[in] actor The actor that has been relaid out. + */ + void OnParentRelayout(Actor actor); + private: /** 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 c953947..82fc206 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 @@ -1184,12 +1184,9 @@ void ScrollView::SetTransientScrollBar( bool transient ) { mTransientScrollBar = transient; - Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); - if( mTransientScrollBar && scrollBar ) + if( mTransientScrollBar ) { - // Show the scroll-indicator for a brief period - scrollBar.SetVisible( true ); - GetImpl(scrollBar).ShowTransientIndicator(); + ShowScrollIndicator(true); } } } @@ -1783,6 +1780,9 @@ bool ScrollView::AnimateTo(const Vector2& position, const Vector2& positionDurat DALI_LOG_SCROLL_STATE("[0x%X] mSnapStartedSignal [%.2f, %.2f]", this, snapEvent.position.x, snapEvent.position.y); mSnapStartedSignal.Emit( snapEvent ); + // Make indicator visible during scrolling + ShowScrollIndicator(false); + return (mScrollStateFlags & SCROLL_ANIMATION_FLAGS) != 0; } @@ -1905,6 +1905,11 @@ void ScrollView::HandleSnapAnimationFinished() mDomainOffset += deltaPosition - mScrollPostPosition; self.SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, mDomainOffset); HandleStoppedAnimation(); + + if( mTransientScrollBar ) + { + HideScrollIndicator(); + } } void ScrollView::SetScrollUpdateNotification( bool enabled ) @@ -2000,12 +2005,12 @@ void ScrollView::OnChildAdd(Actor& child) Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child); if( scrollBar ) { - mScrollBar = scrollBar; scrollBar.SetName("ScrollBar"); mInternalActor.Add( scrollBar ); if( scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal ) { + mHorizontalScrollBar = scrollBar; scrollBar.SetScrollPropertySource( Self(), Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_X, @@ -2014,6 +2019,7 @@ void ScrollView::OnChildAdd(Actor& child) } else { + mVerticalScrollBar = scrollBar; scrollBar.SetScrollPropertySource( Self(), Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_Y, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y, @@ -2028,7 +2034,7 @@ void ScrollView::OnChildAdd(Actor& child) } else { - scrollBar.SetVisible( false ); + scrollBar.SetVisible(false); scrollBar.HideIndicator(); } } @@ -2528,19 +2534,10 @@ void ScrollView::OnPan( const PanGesture& gesture ) self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(gesture.position.x, gesture.position.y, 0.0f) ); UpdateMainInternalConstraint(); - Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); - if( scrollBar && mTransientScrollBar ) - { - Vector3 size = Self().GetCurrentSize(); - const Toolkit::RulerDomain& rulerDomainX = mRulerX->GetDomain(); - const Toolkit::RulerDomain& rulerDomainY = mRulerY->GetDomain(); - if( ( rulerDomainX.max > size.width ) || ( rulerDomainY.max > size.height ) ) - { - scrollBar.SetVisible( true ); - scrollBar.ShowIndicator(); - } - } + // Make scroll indicator visible as soon as the panning starts + ShowScrollIndicator(false); + break; } @@ -2575,12 +2572,6 @@ void ScrollView::OnPan( const PanGesture& gesture ) { mScrollMainInternalPrePositionConstraint.Remove(); } - - Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); - if( scrollBar && mTransientScrollBar ) - { - scrollBar.HideIndicator(); - } } else { @@ -2940,6 +2931,64 @@ bool ScrollView::IsPanningOrScrolling() const return panningOrScrolling; } +void ScrollView::ShowScrollIndicator(bool transient) +{ + Vector3 scrollViewSize = Self().GetCurrentSize(); + + Toolkit::ScrollBar scrollBar = mHorizontalScrollBar.GetHandle(); + if( scrollBar) + { + const Toolkit::RulerDomain& rulerDomainX = mRulerX->GetDomain(); + + if( rulerDomainX.max > scrollViewSize.width ) + { + scrollBar.SetVisible(true); + if( transient ) + { + GetImpl(scrollBar).ShowTransientIndicator(); + } + else + { + scrollBar.ShowIndicator(); + } + } + } + + scrollBar = mVerticalScrollBar.GetHandle(); + if( scrollBar) + { + const Toolkit::RulerDomain& rulerDomainY = mRulerY->GetDomain(); + + if( rulerDomainY.max > scrollViewSize.height ) + { + scrollBar.SetVisible(true); + if( transient ) + { + GetImpl(scrollBar).ShowTransientIndicator(); + } + else + { + scrollBar.ShowIndicator(); + } + } + } +} + +void ScrollView::HideScrollIndicator() +{ + Toolkit::ScrollBar scrollBar = mHorizontalScrollBar.GetHandle(); + if( scrollBar ) + { + scrollBar.HideIndicator(); + } + + scrollBar = mVerticalScrollBar.GetHandle(); + if( scrollBar ) + { + scrollBar.HideIndicator(); + } +} + void ScrollView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) { Toolkit::ScrollView scrollView = Toolkit::ScrollView::DownCast( Dali::BaseHandle( object ) ); 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 d2abd05..9268e58 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 @@ -813,6 +813,18 @@ private: */ bool IsPanningOrScrolling() const; + /** + * @brief Make scroll indicator visible. + * + * @param[in] transient True if scroll-bar should be automatically show/hidden during/after panning + */ + void ShowScrollIndicator(bool transient); + + /** + * @brief Make scroll indicator invisible. + */ + void HideScrollIndicator(); + protected: /** @@ -953,7 +965,8 @@ private: Constraint mScrollMainInternalPrePositionMaxConstraint; ScrollOvershootIndicatorPtr mOvershootIndicator; - WeakHandle mScrollBar; + WeakHandle mHorizontalScrollBar; + WeakHandle mVerticalScrollBar; Toolkit::ScrollView::SnapStartedSignalType mSnapStartedSignal; diff --git a/dali-toolkit/styles/images-common/popup_scroll.9.png b/dali-toolkit/styles/images-common/popup_scroll.9.png old mode 100644 new mode 100755 index 2ffc3a71df3b56ab63c3a36c8c8f0832fd0412e5..3738eb299bd74efb3173cf664e282765a64b323a GIT binary patch literal 583 zcmV-N0=WH&P)A~9183wmv=D@I=556VT*M`#nRf_80!`UHK17SXyE z5fxZLv}x6*D7*cqj-hxpH3xn;c+dIWGvl05Ci@v;11TQKWYQXo#kS({_!)QspCAXG z5{bkyKI7?hxonQLzzVt=AI)2# V`f~Stu3!KF002ovPDHLkV1l&N1{VMT literal 485 zcmVy=fQk*aMu*1x z8^>|B>-BmE)jl;5lHVUpl7=yfO~Wvb@Hh{2YNB=}?j?PYuIszFEyv{H1!X-+)HH1k zH-oETT$IyRkr(U>bpIm6OCA(JHmx`VW>u6j#pYAEnwl)lj3Qo9Vt7L`P1&`8ZB ztJmvw#zeXVL2#ZVwpy+0(OCy#qtQ4G!|-;JD@I3DweP6)?xC4$7X@BTgl?ccsbXF@#Gx^{d+%r!~r2U!Ww4$6` z