X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fitem-view%2Fitem-view-impl.cpp;h=27054bd59a6ecd7bbaf5a1a7811959f81dd240cd;hp=c70b7927e74fd40dc06a921d343cd5b489e742b7;hb=9e56847af25f4bddb5a2484b724d1f9b6f401538;hpb=a8bc013df97fad9f1cc2d95c37248464ac553e6e diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index c70b792..27054bd 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -71,7 +71,6 @@ const float DEFAULT_ANCHORING_DURATION = 1.0f; // 1 second const float MILLISECONDS_PER_SECONDS = 1000.0f; -const Vector2 OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE( 720.0f, 42.0f ); const float OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD = 180.0f; const Vector4 OVERSHOOT_OVERLAY_NINE_PATCH_BORDER(0.0f, 0.0f, 1.0f, 12.0f); const float DEFAULT_KEYBOARD_FOCUS_SCROLL_DURATION = 0.2f; @@ -90,23 +89,33 @@ float CalculateScrollDistance(Vector2 panDistance, Toolkit::ItemLayout& layout) } // Overshoot overlay constraints -void OvershootOverlaySizeConstraint( Vector3& current, const PropertyInputContainer& inputs ) +struct OvershootOverlaySizeConstraint { - const Vector2& parentScrollDirection = inputs[0]->GetVector2(); - const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast(inputs[1]->GetInteger()); - const Vector3& parentSize = inputs[2]->GetVector3(); - - if(Toolkit::IsVertical(layoutOrientation)) + OvershootOverlaySizeConstraint( float height ) + : mOvershootHeight( height ) { - current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y; } - else + + void operator()( Vector3& current, const PropertyInputContainer& inputs ) { - current.width = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x; + const Vector2& parentScrollDirection = inputs[0]->GetVector2(); + const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast(inputs[1]->GetInteger()); + const Vector3& parentSize = inputs[2]->GetVector3(); + + if(Toolkit::IsVertical(layoutOrientation)) + { + current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y; + } + else + { + current.width = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x; + } + + current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? mOvershootHeight : mOvershootHeight*0.5f; } - current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f; -} + float mOvershootHeight; +}; void OvershootOverlayRotationConstraint( Quaternion& current, const PropertyInputContainer& inputs ) { @@ -307,8 +316,6 @@ void ItemView::OnInitialize() { Actor self = Self(); - SetOvershootEnabled(true); - Vector2 stageSize = Stage::GetCurrent().GetSize(); mWheelScrollDistanceStep = stageSize.y * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; @@ -457,11 +464,14 @@ void ItemView::DeactivateCurrentLayout() void ItemView::OnRefreshNotification(PropertyNotification& source) { - if(mRefreshEnabled || mScrollAnimation) + // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll. + if(!mRefreshEnabled && mScrollAnimation) { - // Only refresh the cache during normal scrolling - DoRefresh(GetCurrentLayoutPosition(0), true); + RemoveAnimation(mScrollAnimation); } + + // Only cache extra items when it is not a fast scroll + DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation); } void ItemView::Refresh() @@ -957,7 +967,6 @@ void ItemView::OnChildAdd(Actor& child) Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX_Y, Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE); - scrollBar.ScrollPositionIntervalReachedSignal().Connect( this, &ItemView::OnScrollPositionChanged ); } } } @@ -1175,7 +1184,10 @@ void ItemView::OnPan( const PanGesture& gesture ) self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition ); - if( (firstItemScrollPosition >= 0.0f && currentOvershoot < 1.0f) || (firstItemScrollPosition >= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && currentOvershoot > -1.0f) ) + if( ( firstItemScrollPosition >= 0.0f && + currentOvershoot < 1.0f ) || + ( firstItemScrollPosition <= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && + currentOvershoot > -1.0f ) ) { mTotalPanDisplacement += gesture.displacement; } @@ -1425,6 +1437,7 @@ Vector2 ItemView::GetCurrentScrollPosition() const void ItemView::AddOverlay(Actor actor) { + actor.SetDrawMode( DrawMode::OVERLAY_2D ); Self().Add(actor); } @@ -1477,15 +1490,16 @@ void ItemView::EnableScrollOvershoot( bool enable ) mOvershootOverlay.SetColor(mOvershootEffectColor); mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT); mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT); + mOvershootOverlay.SetDrawMode( DrawMode::OVERLAY_2D ); self.Add(mOvershootOverlay); - Constraint constraint = Constraint::New( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint ); + Constraint constraint = Constraint::New( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint(mOvershootSize.height) ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) ); constraint.AddSource( ParentSource( Actor::Property::SIZE ) ); constraint.Apply(); - mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height); + mOvershootOverlay.SetSize(mOvershootSize.width, mOvershootSize.height); constraint = Constraint::New( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) ); @@ -1625,18 +1639,6 @@ void ItemView::GetItemsRange(ItemRange& range) } } -void ItemView::OnScrollPositionChanged( float position ) -{ - // Cancel scroll animation to prevent any fighting of setting the scroll position property. - if(!mRefreshEnabled) - { - RemoveAnimation(mScrollAnimation); - } - - // Refresh the cache immediately when the scroll position is changed. - DoRefresh(position, false); // No need to cache extra items. -} - bool ItemView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { Dali::BaseHandle handle( object );