From c0c5757663eb6ebbed43e0a3de8933f6b90a0c6a Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Tue, 30 Aug 2016 12:51:25 +0100 Subject: [PATCH] Patch to synchronize with bug fixes done in Tizen 2.4 MCD branch. Patches applied: *Update scroll-view constraints before it's animated *Disable refresh during Pinch Change-Id: I90536978512eeac863f3d40d33a8ba24c53984a9 --- .../src/dali-toolkit/utc-Dali-ItemView.cpp | 47 ++++++++++++++++++++++ .../src/dali-toolkit/utc-Dali-ScrollView.cpp | 4 +- .../scrollable/item-view/item-view-impl.cpp | 32 ++++++++++++--- .../controls/scrollable/item-view/item-view-impl.h | 7 ++++ .../scrollable/scroll-view/scroll-view-impl.cpp | 1 + 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index d5c6af5..fdef315 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -50,6 +50,7 @@ const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each static bool gObjectCreatedCallBackCalled; static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked. +static bool gOnScrollUpdateCalled; static void TestCallback(BaseHandle handle) { @@ -61,6 +62,11 @@ static void OnLayoutActivated() gOnLayoutActivatedCalled = true; } +static void OnScrollUpdate( const Vector2& position ) +{ + gOnScrollUpdateCalled = true; +} + // Generate a PanGestureEvent to send to Core Integration::PanGestureEvent GeneratePan( Gesture::State state, @@ -1102,3 +1108,44 @@ int UtcDaliItemViewOvershootHorizontal(void) END_TEST; } + +int UtcDaliItemEnableDisableRefresh(void) +{ + ToolkitTestApplication application; + Dali::Stage stage = Dali::Stage::GetCurrent(); + + // Create the ItemView actor + TestItemFactory factory; + ItemView view = ItemView::New(factory); + + // Create a grid layout and add it to ItemView + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + view.AddLayout(*gridLayout); + stage.Add(view); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(stage.GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + //Connect to signal scroll updated + view.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); + + Property::Map attributes; + view.DoAction("enableRefresh", attributes ); + gOnScrollUpdateCalled = true; + view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f ); + application.SendNotification(); + application.Render(1000); + DALI_TEST_EQUALS( gOnScrollUpdateCalled, true, TEST_LOCATION ); + + + view.DoAction("disableRefresh", attributes ); + gOnScrollUpdateCalled = false; + view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f ); + application.SendNotification(); + application.Render(1000); + + DALI_TEST_EQUALS( gOnScrollUpdateCalled, false, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 3b4038e..883aacc 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -439,7 +439,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); @@ -508,7 +508,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(v scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); 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 b7c1e57..c8bb12f 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 @@ -262,6 +262,9 @@ DALI_SIGNAL_REGISTRATION( Toolkit, ItemView, "layoutActivated", DALI_ACTION_REGISTRATION( Toolkit, ItemView, "stopScrolling", ACTION_STOP_SCROLLING ) +DALI_ACTION_REGISTRATION( Toolkit, ItemView, "enableRefresh", ACTION_ENABLE_REFRESH ) +DALI_ACTION_REGISTRATION( Toolkit, ItemView, "disableRefresh", ACTION_DISABLE_REFRESH ) + DALI_TYPE_REGISTRATION_END() bool FindById( const ItemContainer& items, ItemId id ) @@ -317,6 +320,7 @@ ItemView::ItemView(ItemFactory& factory) mIsFlicking(false), mAddingItems(false), mRefreshEnabled(true), + mRefreshNotificationEnabled(true), mInAnimation(false) { } @@ -474,14 +478,17 @@ void ItemView::DeactivateCurrentLayout() void ItemView::OnRefreshNotification(PropertyNotification& source) { - // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll. - if(!mRefreshEnabled && mScrollAnimation) + if( mRefreshNotificationEnabled ) { - RemoveAnimation(mScrollAnimation); - } + // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll. + if(!mRefreshEnabled && mScrollAnimation) + { + RemoveAnimation(mScrollAnimation); + } - // Only cache extra items when it is not a fast scroll - DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation); + // Only cache extra items when it is not a fast scroll + DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation); + } } void ItemView::Refresh() @@ -1783,6 +1790,14 @@ bool ItemView::DoAction( BaseObject* object, const std::string& actionName, cons { GetImpl( itemView ).DoStopScrolling(); } + else if ( 0 == strcmp( actionName.c_str(), ACTION_ENABLE_REFRESH ) ) + { + GetImpl( itemView ).SetRefreshNotificationEnabled( true ); + } + else if ( 0 == strcmp( actionName.c_str(), ACTION_DISABLE_REFRESH ) ) + { + GetImpl( itemView ).SetRefreshNotificationEnabled( false ); + } return true; } @@ -1796,6 +1811,11 @@ void ItemView::DoStopScrolling() } } +void ItemView::SetRefreshNotificationEnabled( bool enabled ) +{ + mRefreshNotificationEnabled = enabled; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h index 5ae0112..6ed616d 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -335,6 +335,12 @@ public: */ void DoStopScrolling(); + /** + * Helper for DoAction( ACTION_ENABLE/DISABLE_REFRESH_NOTIFICATIONS ). + * @param[in] enabled Whether to disable refresh notifications or not. + */ + void SetRefreshNotificationEnabled( bool enabled ); + private: /** @@ -619,6 +625,7 @@ private: bool mIsFlicking : 1; bool mAddingItems : 1; bool mRefreshEnabled : 1; ///< Whether to refresh the cache automatically + bool mRefreshNotificationEnabled : 1; ///< Whether to disable refresh notifications or not. bool mInAnimation : 1; ///< Keeps track of whether an animation is controlling the overshoot property. }; 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 1d53111..67ce127 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 @@ -1693,6 +1693,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... -- 2.7.4