X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.cpp;h=9c05d79751e2ece403323ed35f241410e895b0aa;hb=a8d60282f49c906206c1ffb2f2425800b914d109;hp=690704de64194cd90bae0c19359f7289b65757e2;hpb=761122f3e8ff2b224d2329a911a78dc35177c5ea;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 690704d..9c05d79 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include // INTERNAL INCLUDES @@ -624,7 +626,7 @@ Dali::Toolkit::ScrollView ScrollView::New() } ScrollView::ScrollView() -: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS ) ), // Enable size negotiation +: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS | DISABLE_STYLE_CHANGE_SIGNALS ) ), // Enable size negotiation mTouchDownTime(0u), mGestureStackDepth(0), mScrollStateFlags(0), @@ -658,7 +660,8 @@ ScrollView::ScrollView() mAlterChild(false), mDefaultMaxOvershoot(true), mCanScrollHorizontal(true), - mCanScrollVertical(true) + mCanScrollVertical(true), + mTransientScrollBar(true) { } @@ -701,8 +704,6 @@ void ScrollView::OnInitialize() void ScrollView::OnStageConnection( int depth ) { - ScrollBase::OnStageConnection( depth ); - DALI_LOG_SCROLL_STATE("[0x%X]", this); if ( mSensitive ) @@ -710,11 +711,14 @@ void ScrollView::OnStageConnection( int depth ) SetScrollSensitive( false ); SetScrollSensitive( true ); } + if(IsOvershootEnabled()) { // try and make sure property notifications are set EnableScrollOvershoot(true); } + + ScrollBase::OnStageConnection( depth ); } void ScrollView::OnStageDisconnection() @@ -1176,19 +1180,6 @@ Vector2 ScrollView::GetCurrentScrollPosition() const return -GetPropertyPosition(); } -Vector2 ScrollView::GetDomainSize() const -{ - Vector3 size = Self().GetCurrentSize(); - - const RulerDomain& xDomain = GetRulerX()->GetDomain(); - const RulerDomain& yDomain = GetRulerY()->GetDomain(); - - Vector2 domainSize; - domainSize.x = xDomain.max - xDomain.min - size.x; - domainSize.y = yDomain.max - yDomain.min - size.y; - return domainSize; -} - void ScrollView::TransformTo(const Vector2& position, DirectionBias horizontalBias, DirectionBias verticalBias) { @@ -1543,7 +1534,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) if(child) { - Vector2 position = Self().GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION); + Vector2 position = DevelHandle::GetCurrentProperty( Self(), Toolkit::ScrollView::Property::SCROLL_POSITION ); // Get center-point of the Actor. Vector3 childPosition = GetPositionOfAnchor(child, AnchorPoint::CENTER); @@ -1706,6 +1697,7 @@ bool ScrollView::AnimateTo(const Vector2& position, const Vector2& positionDurat // Position Delta /////////////////////////////////////////////////////// if(positionChanged) { + UpdateMainInternalConstraint(); if(mWrapMode && findShortcuts) { // In Wrap Mode, the shortest distance is a little less intuitive... @@ -1740,7 +1732,7 @@ bool ScrollView::AnimateTo(const Vector2& position, const Vector2& positionDurat } DALI_LOG_SCROLL_STATE("[0x%X] position-changed, mScrollTargetPosition[%.2f, %.2f], mScrollPrePosition[%.2f, %.2f], mScrollPostPosition[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y, mScrollPrePosition.x, mScrollPrePosition.y, mScrollPostPosition.x, mScrollPostPosition.y ); - DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().y, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().y ); + DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().x, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().y, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().x, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().y ); } SetScrollUpdateNotification(true); @@ -1792,6 +1784,15 @@ void ScrollView::RemoveOverlay(Actor actor) mInternalActor.Remove( actor ); } +void ScrollView::SetOvershootSize( const Vector2& size ) +{ + mOvershootSize = size; + if( IsOvershootEnabled() && mOvershootIndicator ) + { + mOvershootIndicator->AttachToScrollable(*this); + } +} + void ScrollView::SetOvershootEffectColor( const Vector4& color ) { mOvershootEffectColor = color; @@ -1828,14 +1829,14 @@ void ScrollView::FindAndUnbindActor(Actor child) Vector2 ScrollView::GetPropertyPrePosition() const { - Vector2 position = Self().GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION); + Vector2 position = DevelHandle::GetCurrentProperty< Vector2 >( Self(), Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ); WrapPosition(position); return position; } Vector2 ScrollView::GetPropertyPosition() const { - Vector2 position = Self().GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION); + Vector2 position = DevelHandle::GetCurrentProperty< Vector2 >( Self(), Toolkit::ScrollView::Property::SCROLL_POSITION ); WrapPosition(position); return position; @@ -1953,6 +1954,8 @@ void ScrollView::OnSizeSet( const Vector3& size ) { mOvershootIndicator->Reset(); } + + ScrollBase::OnSizeSet( size ); } void ScrollView::OnChildAdd(Actor& child) @@ -1960,24 +1963,34 @@ void ScrollView::OnChildAdd(Actor& child) ScrollBase::OnChildAdd( child ); Dali::Toolkit::ScrollBar scrollBar = Dali::Toolkit::ScrollBar::DownCast(child); - if(scrollBar) + if( scrollBar ) { - mInternalActor.Add(scrollBar); - if(scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal) + mScrollBar = scrollBar; + scrollBar.SetName("ScrollBar"); + + mInternalActor.Add( scrollBar ); + if( scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal ) { - scrollBar.SetScrollPropertySource(Self(), - Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X, - Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_X, - Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, - Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_X); + scrollBar.SetScrollPropertySource( Self(), + Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X, + Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_X, + Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, + Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_X ); } else { - scrollBar.SetScrollPropertySource(Self(), - Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_Y, - Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y, - Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, - Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_Y); + scrollBar.SetScrollPropertySource( Self(), + Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_Y, + Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y, + Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, + Toolkit::ScrollView::Property::SCROLL_DOMAIN_SIZE_Y ); + } + + if( mTransientScrollBar ) + { + // Show the scroll-indicator for a brief period + Property::Map emptyMap; + scrollBar.DoAction( "ShowTransientIndicator", emptyMap ); } } else if(mAlterChild) @@ -2162,7 +2175,7 @@ bool ScrollView::OnWheelEvent(const WheelEvent& event) void ScrollView::ResetScrolling() { Actor self = Self(); - self.GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION).Get(mScrollPostPosition); + DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); mScrollPrePosition = mScrollPostPosition; DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPostPosition.x, mScrollPostPosition.y ); self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPostPosition); @@ -2171,8 +2184,8 @@ void ScrollView::ResetScrolling() void ScrollView::UpdateLocalScrollProperties() { Actor self = Self(); - self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get(mScrollPrePosition); - self.GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION).Get(mScrollPostPosition); + DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get( mScrollPrePosition ); + DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); } // private functions @@ -2218,7 +2231,7 @@ void ScrollView::AnimateInternalXTo( float position, float duration, AlphaFuncti if( duration > Math::MACHINE_EPSILON_10 ) { Actor self = Self(); - DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get().x, position ); + DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().x, position ); mInternalXAnimation = Animation::New(duration); DALI_LOG_SCROLL_STATE("[0x%X], mInternalXAnimation[0x%X]", this, mInternalXAnimation.GetObjectPtr() ); mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished); @@ -2239,7 +2252,7 @@ void ScrollView::AnimateInternalYTo( float position, float duration, AlphaFuncti if( duration > Math::MACHINE_EPSILON_10 ) { Actor self = Self(); - DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get().y, position ); + DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().y, position ); mInternalYAnimation = Animation::New(duration); DALI_LOG_SCROLL_STATE("[0x%X], mInternalYAnimation[0x%X]", this, mInternalYAnimation.GetObjectPtr() ); mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished); @@ -2266,7 +2279,7 @@ void ScrollView::OnScrollAnimationFinished( Animation& source ) if( source == mInternalXAnimation ) { - DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(SCROLL_PRE_POSITION).Get().x, mScrollPostPosition.x ); + DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, DevelHandle::GetCurrentProperty( Self(), SCROLL_PRE_POSITION ).Get< Vector2 >().x, mScrollPostPosition.x ); if( !(mScrollStateFlags & AnimatingInternalY) ) { @@ -2286,7 +2299,7 @@ void ScrollView::OnScrollAnimationFinished( Animation& source ) if( source == mInternalYAnimation ) { - DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(SCROLL_PRE_POSITION).Get().y, mScrollPostPosition.y ); + DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, DevelHandle::GetProperty( Self(), SCROLL_PRE_POSITION ).Get< Vector2 >().y, mScrollPostPosition.y ); if( !(mScrollStateFlags & AnimatingInternalX) ) { @@ -2476,6 +2489,18 @@ 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.ShowIndicator(); + } + } break; } @@ -2510,6 +2535,12 @@ void ScrollView::OnPan( const PanGesture& gesture ) { mScrollMainInternalPrePositionConstraint.Remove(); } + + Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); + if( scrollBar && mTransientScrollBar ) + { + scrollBar.HideIndicator(); + } } else {