From: Feng Jin Date: Sun, 15 Jan 2017 23:07:40 +0000 (+0800) Subject: Fix bug that the properties of layouts are set after the call of ItemView::ActivateLa... X-Git-Tag: dali_1.2.23~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=88181548d9252ce64a07f4000da87ed032d1a306 Fix bug that the properties of layouts are set after the call of ItemView::ActivateLayout() function. Change-Id: I91e424b86c0e13125e5cd3b2b9fb0138f798b77d Signed-off-by: Feng Jin --- diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt old mode 100644 new mode 100755 index fc24948..4e3e0ff --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -22,6 +22,7 @@ SET(TC_SOURCES utc-Dali-Text-Typesetter.cpp utc-Dali-Text-ViewModel.cpp utc-Dali-DebugRendering.cpp + utc-Dali-ItemView-internal.cpp ) # Append list of test harness files (Won't get parsed for test cases) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp new file mode 100755 index 0000000..1ee8077 --- /dev/null +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +// Need to override adaptor classes for toolkit test harness, so include +// test harness headers before dali headers. +#include + +#include +#include +#include + +#include +#include + + +using namespace Dali; +using namespace Toolkit; + +namespace +{ +const unsigned int TOTAL_ITEM_NUMBER = 200; +const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg"; + + +// Implementation of ItemFactory for providing actors to ItemView +class TestItemFactory : public ItemFactory +{ +public: + + /** + * Constructor + * @param application class, stored as reference + */ + TestItemFactory() + { + } + + /** + * Virtual destructor. + */ + virtual ~TestItemFactory() + { + } + +public: // From ItemFactory + + /** + * Query the number of items available from the factory. + * The maximum available item has an ID of GetNumberOfItems() - 1. + */ + virtual unsigned int GetNumberOfItems() + { + return TOTAL_ITEM_NUMBER; + } + + /** + * Create an Actor to represent a visible item. + * @param itemId + * @return the created actor. + */ + virtual Actor NewItem(unsigned int itemId) + { + // Create a renderable actor for this item + Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME ); + Actor actor = CreateRenderableActor(image); + + return actor; + } +}; + +} + +int UtcDaliItemLayoutCheckPropertiesSetBeforeActivateLayout(void) +{ + ToolkitTestApplication application; + + TestItemFactory factory; + ItemView view = ItemView::New(factory); + + Property::Map gridLayoutProperty; + gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) ); + + //Set the column of grid-layout. + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(6) ); + + Property::Array layoutArray; + + layoutArray.PushBack(gridLayoutProperty); + + view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray); + + Dali::Toolkit::Internal::GridLayout* gridLayout = dynamic_cast(view.GetLayout(0).Get()); + + Dali::Stage stage = Dali::Stage::GetCurrent(); + Vector3 stageSize(stage.GetSize()); + + //Check if the number of columns is equals to 6 which is set before. + DALI_TEST_EQUALS(gridLayout->GetNumberOfColumns(), 6, TEST_LOCATION ); + view.ActivateLayout(0, stageSize, 0.0f); + END_TEST; + +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp index da05a53..77321db 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp @@ -601,18 +601,6 @@ int UtcDaliItemLayoutSetAndGetLayoutProperties(void) } -int UtcDaliItemLayoutSetandGetLayoutChangedFlag(void) -{ - ToolkitTestApplication application; - - TestItemLayoutPtr layout = TestItemLayout::New(); - DALI_TEST_CHECK( layout ); - layout->ResetLayoutChangedFlag(); - DALI_TEST_CHECK(layout->HasLayoutChanged() == false); - - END_TEST; -} - int UtcDaliItemRangeIntersection(void) { ToolkitTestApplication application; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp index 3b53bac..4cb2043 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp @@ -447,10 +447,6 @@ Degree DepthLayout::GetScrollDirection() const void DepthLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor ) { - if(HasLayoutChanged()) - { - SetDepthLayoutProperties(GetLayoutProperties()); - } Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor ); if( itemView ) { @@ -559,7 +555,6 @@ void DepthLayout::SetDepthLayoutProperties(const Property::Map& properties) } } } - ResetLayoutChangedFlag(); } Vector3 DepthLayout::GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const diff --git a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp index e002245..d362f05 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp @@ -534,10 +534,6 @@ Degree GridLayout::GetScrollDirection() const void GridLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor ) { - if(HasLayoutChanged()) - { - SetGridLayoutProperties(GetLayoutProperties()); - } // This just implements the default behaviour of constraint application. // Custom layouts can override this function to apply their custom constraints. Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor ); @@ -685,7 +681,6 @@ void GridLayout::SetGridLayoutProperties(const Property::Map& properties) } } } - ResetLayoutChangedFlag(); } Vector3 GridLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const 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 a5741ab..1724f83 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -1800,6 +1800,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) { Internal::DepthLayoutPtr depthLayout = Internal::DepthLayout::New(); (*depthLayout).SetLayoutProperties(*layout); + (*depthLayout).SetDepthLayoutProperties(*layout); AddLayout(*depthLayout); break; } @@ -1807,6 +1808,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) { Internal::GridLayoutPtr gridLayout = Internal::GridLayout::New(); (*gridLayout).SetLayoutProperties(*layout); + (*gridLayout).SetGridLayoutProperties(*layout); AddLayout(*gridLayout); break; } @@ -1815,6 +1817,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) Internal::GridLayoutPtr listLayout = Internal::GridLayout::New(); listLayout->SetNumberOfColumns( 1 ); (*listLayout).SetLayoutProperties(*layout); + (*listLayout).SetGridLayoutProperties(*layout); AddLayout(*listLayout); break; } @@ -1822,6 +1825,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) { Internal::SpiralLayoutPtr spiralLayout = Internal::SpiralLayout::New(); (*spiralLayout).SetLayoutProperties(*layout); + (*spiralLayout).SetSpiralLayoutProperties(*layout); AddLayout(*spiralLayout); break; } diff --git a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp index 9e8db62..e320fe1 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp @@ -426,10 +426,6 @@ Degree SpiralLayout::GetScrollDirection() const void SpiralLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor ) { - if(HasLayoutChanged()) - { - SetSpiralLayoutProperties(GetLayoutProperties()); - } // This just implements the default behaviour of constraint application. // Custom layouts can override this function to apply their custom constraints. Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor ); @@ -548,7 +544,6 @@ void SpiralLayout::SetSpiralLayoutProperties(const Property::Map& properties) } } } - ResetLayoutChangedFlag(); } Vector3 SpiralLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp index a9f2769..017ac53 100755 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp @@ -38,7 +38,6 @@ struct ItemLayout::Impl Vector3 mItemSize; ///< The size of an item in the layout ControlOrientation::Type mOrientation; ///< the orientation of the layout. Property::Map mProperties; - bool mHasLayoutChanged; }; ItemLayout::ItemLayout() @@ -156,7 +155,6 @@ void ItemLayout::SetLayoutProperties(const Property::Map& properties) } } } - mImpl->mHasLayoutChanged = true; mImpl->mProperties = properties; } @@ -165,16 +163,6 @@ Property::Map ItemLayout::GetLayoutProperties() return mImpl->mProperties; } -bool ItemLayout::HasLayoutChanged() -{ - return mImpl->mHasLayoutChanged; -} - -void ItemLayout::ResetLayoutChangedFlag() -{ - mImpl->mHasLayoutChanged = false; -} - } // namespace Toolkit } // namespace Dali diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h index 97af2df..4d91ef5 100755 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h @@ -181,19 +181,6 @@ public: Property::Map GetLayoutProperties(); /** - * @brief Check if the Property has been changed. - * @SINCE_1_2.20 - * @return whether the layout has been changed or not.if changed, return true. - */ - bool HasLayoutChanged(); - - /** - * @brief Set the layout changed flag to false. - * @SINCE_1_2.20 - */ - void ResetLayoutChangedFlag(); - - /** * @brief Retrieve the target size of an item in the layout. * * This will return the default size for the layout unless overridden by calling SetItemSize().