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=19d737379364997aac996414629dd94f89de9f7b;hp=575f3aa992464617369f28c082c7973ab81e7cac;hb=f546dd5d83a968e573f8f053a01ce43df32c71a0;hpb=1710c1317e96351975f49bd208314f573021ae54 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 old mode 100755 new mode 100644 index 575f3aa..19d7373 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -25,15 +25,15 @@ #include #include -#include +#include #include -#include +#include #include #include #include // INTERNAL INCLUDES -#include +#include #include #include #include @@ -333,7 +333,7 @@ Dali::Toolkit::ItemView ItemView::New(ItemFactory& factory) } ItemView::ItemView(ItemFactory& factory) -: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS | REQUIRES_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), +: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), mItemFactory(factory), mItemsParentOrigin(ParentOrigin::CENTER), mItemsAnchorPoint(AnchorPoint::CENTER), @@ -347,7 +347,7 @@ ItemView::ItemView(ItemFactory& factory) mScrollDistance(0.0f), mScrollSpeed(0.0f), mScrollOvershoot(0.0f), - mGestureState(Gesture::Clear), + mGestureState(GestureState::CLEAR), mAnimatingOvershootOn(false), mAnimateOvershootOff(false), mAnchoringEnabled(false), @@ -362,18 +362,23 @@ ItemView::ItemView(ItemFactory& factory) void ItemView::OnInitialize() { + Scrollable::OnInitialize(); + Actor self = Self(); Vector2 stageSize = Stage::GetCurrent().GetSize(); mWheelScrollDistanceStep = stageSize.y * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; - self.TouchSignal().Connect( this, &ItemView::OnTouch ); - EnableGestureDetection(Gesture::Type(Gesture::Pan)); + self.TouchedSignal().Connect( this, &ItemView::OnTouch ); + EnableGestureDetection(GestureType::Value(GestureType::PAN)); mWheelEventFinishedTimer = Timer::New( WHEEL_EVENT_FINISHED_TIME_OUT ); mWheelEventFinishedTimer.TickSignal().Connect( this, &ItemView::OnWheelEventFinished ); SetRefreshInterval(DEFAULT_REFRESH_INTERVAL_LAYOUT_POSITIONS); + + // Connect wheel event + self.WheelEventSignal().Connect( this, &ItemView::OnWheelEvent ); } ItemView::~ItemView() @@ -426,7 +431,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz Actor self = Self(); // The ItemView size should match the active layout size - self.SetSize(targetSize); + self.SetProperty( Actor::Property::SIZE, targetSize); mActiveLayoutTargetSize = targetSize; // Switch to the new layout @@ -446,7 +451,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz Vector3 size; mActiveLayout->GetItemSize( itemId, targetSize, size ); - actor.SetSize( size.GetVectorXY() ); + actor.SetProperty( Actor::Property::SIZE, size.GetVectorXY() ); } // Refresh the new layout @@ -972,7 +977,7 @@ void ItemView::SetupActor( Item item, const Vector3& layoutSize ) { Vector3 size; mActiveLayout->GetItemSize( item.first, mActiveLayoutTargetSize, size ); - item.second.SetSize( size.GetVectorXY() ); + item.second.SetProperty( Actor::Property::SIZE, size.GetVectorXY() ); mActiveLayout->ApplyConstraints( item.second, item.first, layoutSize, Self() ); } @@ -1022,14 +1027,14 @@ void ItemView::OnChildAdd(Actor& child) Scrollable::OnChildAdd( child ); } -bool ItemView::OnWheelEvent(const WheelEvent& event) +bool ItemView::OnWheelEvent(Actor actor, const WheelEvent& event) { // Respond the wheel event to scroll if (mActiveLayout) { Actor self = Self(); const Vector3 layoutSize = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); - float layoutPositionDelta = GetCurrentLayoutPosition(0) - (event.z * mWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor()); + float layoutPositionDelta = GetCurrentLayoutPosition(0) - (event.GetDelta() * mWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor()); float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout); self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition ); @@ -1114,7 +1119,7 @@ float ItemView::ClampFirstItemPosition( float targetPosition, const Vector3& tar return clamppedPosition; } -bool ItemView::OnTouch( Actor actor, const TouchData& touch ) +bool ItemView::OnTouch( Actor actor, const TouchEvent& touch ) { // Ignore events with multiple-touch points if (touch.GetPointCount() != 1) @@ -1125,7 +1130,7 @@ bool ItemView::OnTouch( Actor actor, const TouchData& touch ) if ( touch.GetState( 0 ) == PointState::DOWN ) { // Cancel ongoing scrolling etc. - mGestureState = Gesture::Clear; + mGestureState = GestureState::CLEAR; mScrollDistance = 0.0f; mScrollSpeed = 0.0f; @@ -1142,7 +1147,7 @@ bool ItemView::OnTouch( Actor actor, const TouchData& touch ) RemoveAnimation(mScrollAnimation); } - return true; // consume since we're potentially scrolling + return false; // Do not consume as we're potentially scrolling (detecting pan gestures) } void ItemView::OnPan( const PanGesture& gesture ) @@ -1155,15 +1160,15 @@ void ItemView::OnPan( const PanGesture& gesture ) // Short-circuit if there is no active layout if (!mActiveLayout) { - mGestureState = Gesture::Clear; + mGestureState = GestureState::CLEAR; return; } - mGestureState = gesture.state; + mGestureState = gesture.GetState(); switch (mGestureState) { - case Gesture::Finished: + case GestureState::FINISHED: { // Swipe Detection if (fabsf(mScrollDistance) > mMinimumSwipeDistance && @@ -1218,16 +1223,17 @@ void ItemView::OnPan( const PanGesture& gesture ) } break; - case Gesture::Started: // Fall through + case GestureState::STARTED: // Fall through { mTotalPanDisplacement = Vector2::ZERO; mScrollStartedSignal.Emit(GetCurrentScrollPosition()); mRefreshEnabled = true; } - case Gesture::Continuing: + case GestureState::CONTINUING: { - mScrollDistance = CalculateScrollDistance(gesture.displacement, *mActiveLayout); + const Vector2& displacement = gesture.GetDisplacement(); + mScrollDistance = CalculateScrollDistance(displacement, *mActiveLayout); mScrollSpeed = Clamp((gesture.GetSpeed() * gesture.GetSpeed() * mActiveLayout->GetFlickSpeedFactor() * MILLISECONDS_PER_SECONDS), 0.0f, mActiveLayout->GetMaximumSwipeSpeed()); // Refresh order depends on the direction of the scroll; negative is towards the last item. @@ -1246,7 +1252,7 @@ void ItemView::OnPan( const PanGesture& gesture ) ( firstItemScrollPosition <= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) && currentOvershoot > -1.0f ) ) { - mTotalPanDisplacement += gesture.displacement; + mTotalPanDisplacement += displacement; } mScrollOvershoot = CalculateScrollOvershoot(); @@ -1277,7 +1283,7 @@ void ItemView::OnPan( const PanGesture& gesture ) } break; - case Gesture::Cancelled: + case GestureState::CANCELLED: { mScrollAnimation = DoAnchoring(); } @@ -1815,7 +1821,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) { const Property::Value& element = layouts.GetElementAt( arrayIdx ); - Property::Map* layout = element.GetMap(); + const Property::Map* layout = element.GetMap(); if( layout != NULL ) { for( unsigned int mapIdx = 0, mapCount = (*layout).Count(); mapIdx < mapCount; ++mapIdx )