From: fengjin16 Date: Fri, 25 Nov 2016 11:22:22 +0000 (+0800) Subject: Add support for ItemView layout customisation through properties. X-Git-Tag: dali_1.2.20~9 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=06f734a391814a2972e31351604e0a34ef712ed9 Add support for ItemView layout customisation through properties. Change "SetLayoutProperties()" to non-virtual method. Change-Id: I635ec472ee459518466d6d0f67df94166d7c4d80 Signed-off-by: fengjin16 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp old mode 100644 new mode 100755 index aa51150..da05a53 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp @@ -24,6 +24,8 @@ #include #include +#include + using namespace Dali; using namespace Toolkit; @@ -349,6 +351,268 @@ int UtcDaliItemLayoutGetNextFocusItemID(void) END_TEST; } +int UtcDaliItemLayoutSetAndGetLayoutProperties(void) +{ + ToolkitTestApplication application; + + // 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 ); + + // Set the property of the grid layout + Property::Map gridLayoutProperty; + gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_SPACING, Dali::Property::Value(50.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_TOP_MARGIN, Dali::Property::Value(95.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN, Dali::Property::Value(20.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_SIDE_MARGIN, Dali::Property::Value(20.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.03f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.015f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(100.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::ORIENTATION, Dali::Property::Value((int)ControlOrientation::Up) ); + gridLayout->SetLayoutProperties(gridLayoutProperty); + + view.AddLayout(*gridLayout); + ItemLayoutPtr layout = view.GetLayout(0); + DALI_TEST_CHECK(gridLayout == layout); + Property::Map firstLayout = gridLayout->GetLayoutProperties(); + + //Check all the properties of grid layout + DALI_TEST_EQUALS( gridLayoutProperty.Count(), firstLayout.Count(), TEST_LOCATION ); + + for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) ); + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE) + { + Vector3 size = propertyPair.second.Get(); + DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING) + { + float rowSpacing = propertyPair.second.Get(); + DALI_TEST_EQUALS( rowSpacing, 50.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER) + { + int number = propertyPair.second.Get(); + DALI_TEST_EQUALS(number, 4, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_SPACING) + { + float columnSpacing = propertyPair.second.Get(); + DALI_TEST_EQUALS(columnSpacing, 50.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_TOP_MARGIN) + { + float topMargin = propertyPair.second.Get(); + DALI_TEST_EQUALS(topMargin, 95.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN) + { + float bottomMargin = propertyPair.second.Get(); + DALI_TEST_EQUALS(bottomMargin, 20.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_SIDE_MARGIN) + { + float sideMargin = propertyPair.second.Get(); + DALI_TEST_EQUALS(sideMargin, 20.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR) + { + float scrollSpeedFactor = propertyPair.second.Get(); + DALI_TEST_EQUALS(scrollSpeedFactor, 0.03f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION) + { + float animationDuration = propertyPair.second.Get(); + DALI_TEST_EQUALS(animationDuration, 0.015f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED) + { + float swipSpeed = propertyPair.second.Get(); + DALI_TEST_EQUALS(swipSpeed, 100.0f, TEST_LOCATION ); + } + } + ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + + // Set the property of the depth layout + Property::Map depthLayoutProperty; + depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_SPACING, Dali::Property::Value(55.0f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_TILT_ANGLE, Dali::Property::Value(Math::PI*0.15f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ITEM_TILT_ANGLE, Dali::Property::Value(-Math::PI*0.025f ) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.02f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.03f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(50.0f) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::ORIENTATION, Dali::Property::Value((int)ControlOrientation::Up) ); + depthLayout->SetLayoutProperties(depthLayoutProperty); + + view.AddLayout(*depthLayout); + layout = view.GetLayout(1); + DALI_TEST_CHECK(depthLayout == layout); + + Property::Map secondLayout = depthLayout->GetLayoutProperties(); + + //Check all the properties of grid layout + DALI_TEST_EQUALS( depthLayoutProperty.Count(), secondLayout.Count(), TEST_LOCATION ); + for( unsigned int mapIdx = 0, mapCount = secondLayout.Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( secondLayout.GetKeyValue( mapIdx ) ); + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::DEPTH, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ORIENTATION) + { + int orientation = propertyPair.second.Get(); + DALI_TEST_EQUALS(orientation, (int)ControlOrientation::Up, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE) + { + Vector3 size = propertyPair.second.Get(); + DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION ); + } + + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER) + { + int columnNumber = propertyPair.second.Get(); + DALI_TEST_EQUALS( columnNumber, 3, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ROW_NUMBER) + { + float rowNumber = propertyPair.second.Get(); + DALI_TEST_EQUALS(rowNumber, 26.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ROW_SPACING) + { + float rowSpacing = propertyPair.second.Get(); + DALI_TEST_EQUALS(rowSpacing, 55.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_TILT_ANGLE) + { + float tiltAngle = propertyPair.second.Get(); + DALI_TEST_EQUALS(tiltAngle, Math::PI*0.15f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ITEM_TILT_ANGLE) + { + float itemTiltAngle = propertyPair.second.Get(); + DALI_TEST_EQUALS(itemTiltAngle, -Math::PI*0.025f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_SCROLL_SPEED_FACTOR) + { + float scrollSpeedFactor = propertyPair.second.Get(); + DALI_TEST_EQUALS(scrollSpeedFactor, 0.02f, TEST_LOCATION ); + } + + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ITEM_FLICK_ANIMATION_DURATION) + { + float animationDuration = propertyPair.second.Get(); + DALI_TEST_EQUALS(animationDuration, 0.03f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_MAXIMUM_SWIPE_SPEED) + { + float swipSpeed = propertyPair.second.Get(); + DALI_TEST_EQUALS(swipSpeed, 50.0f, TEST_LOCATION ); + } + } + ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + + // Set the property of the spiral layout + Property::Map spiralLayoutPrperty; + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_REVOLUTION_DISTANCE, Dali::Property::Value(190.0f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.01f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.1f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(30.0f) ); + spiralLayout->SetLayoutProperties(spiralLayoutPrperty); + + view.AddLayout(*spiralLayout); + layout = view.GetLayout(2); + DALI_TEST_CHECK(spiralLayout == layout); + + Property::Map thridLayout = spiralLayout->GetLayoutProperties(); + + //Check all the properties of grid layout + DALI_TEST_EQUALS( spiralLayoutPrperty.Count(), thridLayout.Count(), TEST_LOCATION ); + + for( unsigned int mapIdx = 0, mapCount = thridLayout.Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( thridLayout.GetKeyValue( mapIdx ) ); + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::SPIRAL, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING) + { + float columnNumber = propertyPair.second.Get(); + DALI_TEST_EQUALS( columnNumber, (Math::PI*2.0f)/9.5f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT) + { + float rowNumber = propertyPair.second.Get(); + DALI_TEST_EQUALS(rowNumber, -0.125f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_REVOLUTION_DISTANCE) + { + float rowSpacing = propertyPair.second.Get(); + DALI_TEST_EQUALS(rowSpacing, 190.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_SCROLL_SPEED_FACTOR) + { + float scrollSpeedFactor = propertyPair.second.Get(); + DALI_TEST_EQUALS(scrollSpeedFactor, 0.01f, TEST_LOCATION ); + } + + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_ITEM_FLICK_ANIMATION_DURATION) + { + float animationDuration = propertyPair.second.Get(); + DALI_TEST_EQUALS(animationDuration, 0.1f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_MAXIMUM_SWIPE_SPEED) + { + float swipSpeed = propertyPair.second.Get(); + DALI_TEST_EQUALS(swipSpeed, 30.0f, TEST_LOCATION ); + } + } + Dali::Stage stage = Dali::Stage::GetCurrent(); + Vector3 stageSize(stage.GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + view.ActivateLayout(1, stageSize, 0.5f); + view.ActivateLayout(2, stageSize, 0.5f); + END_TEST; + +} + +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/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp old mode 100644 new mode 100755 index fdef315..3e3e303 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include using namespace Dali; @@ -938,6 +940,71 @@ int UtcDaliItemViewSetGetProperty(void) view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f ); DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get(), 11.0f, TEST_LOCATION ); + // Test "layout" property + DALI_TEST_CHECK( view.GetPropertyIndex("layout") == DevelItemView::Property::LAYOUT ); + Property::Map gridLayoutProperty; + gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) ); + gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) ); + + Property::Map depthLayoutProperty; + depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) ); + depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) ); + + Property::Map spiralLayoutPrperty; + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) ); + spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) ); + + Property::Map listLayoutPrperty; + listLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST) ); + listLayoutPrperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100,50)) ); + + + Property::Array layoutArray; + layoutArray.PushBack(gridLayoutProperty); + layoutArray.PushBack(depthLayoutProperty); + layoutArray.PushBack(spiralLayoutPrperty); + layoutArray.PushBack(listLayoutPrperty); + + view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray); + + Property::Array getLayoutArray; + DALI_TEST_CHECK( view.GetProperty(DevelItemView::Property::LAYOUT ).Get( getLayoutArray ) ); + + //Check that the result is the same as + DALI_TEST_EQUALS( layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION ); + Property::Map firstLayout = *((getLayoutArray.GetElementAt( 0 )).GetMap()); + + for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) ); + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE) + { + Vector3 size = propertyPair.second.Get(); + DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING) + { + float spacing = propertyPair.second.Get(); + DALI_TEST_EQUALS( spacing, 50.0f, TEST_LOCATION ); + } + else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER) + { + int number = propertyPair.second.Get(); + DALI_TEST_EQUALS(number, 4, TEST_LOCATION ); + } + } + view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray); + + // Test "overshootEnabled" property DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED ); DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), view.IsOvershootEnabled(), TEST_LOCATION ); diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index 4ba3e04..2b80acf 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -105,6 +105,7 @@ develapibuttonsdir = $(develapicontrolsdir)/buttons develapieffectsviewdir = $(develapicontrolsdir)/effects-view develapigaussianblurviewdir = $(develapicontrolsdir)/gaussian-blur-view develapimagnifierdir = $(develapicontrolsdir)/magnifier +develapiitemviewdir = $(develapicontrolsdir)/scrollable/item-view develapinavigationviewdir = $(develapicontrolsdir)/navigation-view develapipageturnviewdir = $(develapicontrolsdir)/page-turn-view develapipopupdir = $(develapicontrolsdir)/popup @@ -132,6 +133,7 @@ develapieffectsview_HEADERS = $(devel_api_effects_view_header_files) develapifocusmanager_HEADERS = $(devel_api_focus_manager_header_files) develapigaussianblurview_HEADERS = $(devel_api_gaussian_blur_view_header_files) develapiimageloader_HEADERS = $(devel_api_image_loader_header_files) +develapiitemview_HEADERS = $(devel_api_item_view_header_files) develapimagnifier_HEADERS = $(devel_api_magnifier_header_files) develapinavigationview_HEADERS = $(devel_api_navigation_view_header_files) develapipageturnview_HEADERS = $(devel_api_page_turn_view_header_files) diff --git a/dali-toolkit/devel-api/controls/scrollable/item-view/default-item-layout-property.h b/dali-toolkit/devel-api/controls/scrollable/item-view/default-item-layout-property.h new file mode 100755 index 0000000..65d94dd --- /dev/null +++ b/dali-toolkit/devel-api/controls/scrollable/item-view/default-item-layout-property.h @@ -0,0 +1,259 @@ +#ifndef DALI_TOOLKIT_DEFAULT_ITEM_LAYOUT_PROPERTY_H +#define DALI_TOOLKIT_DEFAULT_ITEM_LAYOUT_PROPERTY_H + +/* + * 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. + * + */ + +namespace Dali +{ + +namespace Toolkit +{ + +/** + * @brief Default item layout property. + */ +namespace DefaultItemLayoutProperty +{ + +/** + * @brief The properties of each type of item layout. + */ +enum Property +{ + /** + * @brief The type of the Layout. + * @details Name "type", type(Dali::Toolkit::DefaultItemLayout::Type),Property::INTEGER + * @note Mandatory. + */ + TYPE = 0, + + /** + * @brief The size of each item in the Layout. + * @details Name "itemSize",Property::VECTOR3 + * @note Optional. + * @note If not supplied, see ItemLayout::GetDefaultItemSize(). + */ + ITEM_SIZE, + + /** + * @brief The internal orientation of the Layout. + * @details Name "orientation",type(@ref Dali::Toolkit::ControlOrientation::Type),Property::INTEGER + * @note Optional. + * @note If not supplied, the default is ControlOrientation::Up, The contents of control are in a vertical layout, from top to bottom. + */ + ORIENTATION, + + /** + * @brief The number of columns in the GridLayout. + * @details Name "gridColumnNumber",Property::INTEGER. + * @note Optional. + * @note If not supplied, the default is 4. + */ + GRID_COLUMN_NUMBER, + + /** + * @brief The spacing between rows in the GridLayout. + * @details Name "gridRowSpacing",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 20.0f. + */ + GRID_ROW_SPACING, + + /** + * @brief The spacing between columns in the GridLayout. + * @details Name "gridColumnSpacing",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 20.0f. + */ + GRID_COLUMN_SPACING, + + /** + * @brief The margin in the top of the GridLayout. + * @details Name "gridTopMargin",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 95.0f. + */ + GRID_TOP_MARGIN, + + /** + * @brief The margin in the bottom of the GridLayout. + * @details Name "gridBottomMargin",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 20.0f. + */ + GRID_BOTTOM_MARGIN, + + /** + * @brief The margin in the left and right of the GridLayout. + * @details Name "gridSideMargin",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 20.0f. + */ + GRID_SIDE_MARGIN, + + /** + * @brief The factor used to customise the scroll speed while dragging and swiping the GridLayout. + * @details Name "gridScrollSpeedFactor",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 0.03f. + */ + GRID_SCROLL_SPEED_FACTOR, + + /** + * @brief The maximum swipe speed in pixels per second of GridLayout. + * @details Name "gridMaximumSwipSpeed",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 100.0f. + */ + GRID_MAXIMUM_SWIPE_SPEED, + + /** + * @brief The duration of the flick animation in seconds of GridLayout. + * @details Name "gridItemFlickAnimationDuration",Property::FLOAT + * @note Optional. + * @note This is the time taken to animate each item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered by a swipe gesture. + * @note Must be greater than zero;If not supplied, the default is 0.015f. + */ + GRID_ITEM_FLICK_ANIMATION_DURATION, + + /** + * @brief The number of columns in the DepthLayout. + * @details Name "depthColumnNumber",Property::INTEGER + * @note Optional. + * @note If not supplied, the default is 3. + */ + DEPTH_COLUMN_NUMBER, + + /** + * @brief The number of rows in the DepthLayout. + * @details Name "depthRowNumber",Property::INTEGER + * @note Optional. + * @note If not supplied, the default is 26. + */ + DEPTH_ROW_NUMBER, + + /** + * @brief The spacing between rows in the DepthLayout. + * @details Name "depthRowSpacing",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 55.0f. + */ + DEPTH_ROW_SPACING, + + /** + * @brief The factor used to customise the scroll speed while dragging and swiping the DepthLayout. + * @details Name "depthScrollSpeedFactor",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 0.02f. + */ + DEPTH_SCROLL_SPEED_FACTOR, + + /** + * @brief The maximumSwipSpeed of the DepthLayout. + * @details Name "depthMaximumSwipSpeed",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 50.0f. + */ + DEPTH_MAXIMUM_SWIPE_SPEED, + + /** + * @brief The duration of the flick animation in seconds of DepthLayout. + * @details Name "depthItemFlickAnimationDuration",Property::FLOAT + * @note Optional. + * @note This is the time taken to animate each item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered by a swipe gesture. + * @note Must be greater than zero; If not supplied, the default is 0.03f. + */ + DEPTH_ITEM_FLICK_ANIMATION_DURATION, + + /** + * @brief The tilt angle of DepthLayout. + * @details Name "depthTiltAngle",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is (Math::PI)*0.15f. + * @note This is clamped between -45 & 45 degrees. + */ + DEPTH_TILT_ANGLE, + + /** + * @brief The tilt angle of the individual items in the DepthLayout. + * @details Name "depthItemTiltAngle",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is -(Math::PI)*0.025f. + */ + DEPTH_ITEM_TILT_ANGLE, + + /** + * @brief The spacing angle between items in the SpiralLayout. + * @details Name "spiralItemSpacing",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 9.5f. + */ + SPIRAL_ITEM_SPACING, + + /** + * @brief The factor used to customise the scroll speed while dragging and swiping the SpiralLayout. + * @details Name "spiralScrollSpeedFactor",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 0.01f. + */ + SPIRAL_SCROLL_SPEED_FACTOR, + + /** + * @brief The maximum swipe speed in pixels per second of the SpiralLayout. + * @details Name "spiralMaximumSwipSpeed",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 30.0f. + */ + SPIRAL_MAXIMUM_SWIPE_SPEED, + + /** + * @brief The duration of the flick animation in seconds of the SpiralLayout. + * @details Name "spiralItemFlickAnimationDuration",Property::FLOAT + * @note Optional. + * @note This is the time taken to animate each item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered by a swipe gesture. + * @note Must be greater than zero; If not supplied, the default is 0.1f. + */ + SPIRAL_ITEM_FLICK_ANIMATION_DURATION, + + /** + * @brief The vertical distance for one revolution of the SpiralLayout. + * @details Name "spiralRevolutionDistance",Property::FLOAT + * @note Optional. + * @note If not supplied, the default is 190.0f. + */ + SPIRAL_REVOLUTION_DISTANCE, + + /** + * @brief The alignment of the top-item, when at the beginning of the SpiralLayout. + * @details Name "spiralTopItemAlignment",Property::FLOAT + * @note Optional. + * @note When at the beginning of the spiral (with a first-item layout-position of zero).A value of 0 indicates that the top-item is centered in the middle of the layout. + * A value of -0.5 or 0.5 indicates that the top-item is centred at the top or bottom of the layout respectively. + * @note If not supplied, the default is (-0.125f). + */ + SPIRAL_TOP_ITEM_ALIGNMENT, +}; + +} // namespace Toolkit + +} // namespace Dali + +} + +#endif // DALI_TOOLKIT_DEFAULT_ITEM_LAYOUT_PROPERTY_H + diff --git a/dali-toolkit/devel-api/controls/scrollable/item-view/item-view-devel.h b/dali-toolkit/devel-api/controls/scrollable/item-view/item-view-devel.h new file mode 100644 index 0000000..50168ea --- /dev/null +++ b/dali-toolkit/devel-api/controls/scrollable/item-view/item-view-devel.h @@ -0,0 +1,69 @@ +#ifndef DALI_TOOLKIT_ITEM_VIEW_DEVEL_H +#define DALI_TOOLKIT_ITEM_VIEW_DEVEL_H + +/* + * 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace DevelItemView +{ + +namespace Property +{ + +enum +{ + // Event side properties + MINIMUM_SWIPE_SPEED = Dali::Toolkit::ItemView::Property::MINIMUM_SWIPE_SPEED, + MINIMUM_SWIPE_DISTANCE = Dali::Toolkit::ItemView::Property::MINIMUM_SWIPE_DISTANCE, + WHEEL_SCROLL_DISTANCE_STEP = Dali::Toolkit::ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, + SNAP_TO_ITEM_ENABLED = Dali::Toolkit::ItemView::Property::SNAP_TO_ITEM_ENABLED, + REFRESH_INTERVAL = Dali::Toolkit::ItemView::Property::REFRESH_INTERVAL, + + /** + * @brief The layout used. + * @details Name "layout", type Property::ARRAY + * @see SetLayout() + */ + LAYOUT = REFRESH_INTERVAL + 1, + + // Animatable properties + LAYOUT_POSITION = Dali::Toolkit::ItemView::Property::LAYOUT_POSITION, + SCROLL_SPEED = Dali::Toolkit::ItemView::Property::SCROLL_SPEED, + OVERSHOOT = Dali::Toolkit::ItemView::Property::OVERSHOOT, + SCROLL_DIRECTION = Dali::Toolkit::ItemView::Property::SCROLL_DIRECTION, + LAYOUT_ORIENTATION = Dali::Toolkit::ItemView::Property::LAYOUT_ORIENTATION, + SCROLL_CONTENT_SIZE = Dali::Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE +}; + +} // namespace Property + +} // namespace DevelItemView + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_ITEM_VIEW_DEVEL_H diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 566949b..48cc2aa 100644 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -62,6 +62,10 @@ devel_api_builder_header_files = \ devel_api_effects_view_header_files = \ $(devel_api_src_dir)/controls/effects-view/effects-view.h +devel_api_item_view_header_files = \ + $(devel_api_src_dir)/controls/scrollable/item-view/default-item-layout-property.h \ + $(devel_api_src_dir)/controls/scrollable/item-view/item-view-devel.h + devel_api_magnifier_header_files = \ $(devel_api_src_dir)/controls/magnifier/magnifier.h diff --git a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp old mode 100644 new mode 100755 index d765df1..3b53bac --- a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -445,6 +446,11 @@ 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 ) { @@ -499,6 +505,63 @@ void DepthLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector } } +void DepthLayout::SetDepthLayoutProperties(const Property::Map& properties) +{ + // Set any properties specified for DepthLayout. + for( unsigned int idx = 0, mapCount = properties.Count(); idx < mapCount; ++idx ) + { + KeyValuePair propertyPair = properties.GetKeyValue( idx ); + switch(DefaultItemLayoutProperty::Property(propertyPair.first.indexKey)) + { + case DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER: + { + SetNumberOfColumns(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::DEPTH_ROW_NUMBER: + { + SetNumberOfRows(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::DEPTH_ROW_SPACING: + { + SetRowSpacing(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::DEPTH_MAXIMUM_SWIPE_SPEED: + { + SetMaximumSwipeSpeed(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::DEPTH_SCROLL_SPEED_FACTOR: + { + SetScrollSpeedFactor(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::DEPTH_TILT_ANGLE: + { + SetTiltAngle(Degree(Radian(propertyPair.second.Get()))); + break; + } + case DefaultItemLayoutProperty::DEPTH_ITEM_TILT_ANGLE: + { + SetItemTiltAngle(Degree(Radian(propertyPair.second.Get()))); + break; + } + case DefaultItemLayoutProperty::DEPTH_ITEM_FLICK_ANIMATION_DURATION: + { + SetItemFlickAnimationDuration(propertyPair.second.Get()); + break; + } + default: + { + break; + } + } + } + ResetLayoutChangedFlag(); +} + Vector3 DepthLayout::GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const { Vector3 itemPosition = Vector3::ZERO; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.h b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.h old mode 100644 new mode 100755 index 6ce8c73..a59b7fe --- a/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/depth-layout.h @@ -21,6 +21,8 @@ // INTERNAL INCLUDES #include + + namespace Dali { @@ -52,6 +54,12 @@ public: virtual ~DepthLayout(); /** + * Apply depth layout Properties. + * @param[in] properties The properties of the layout. + */ + void SetDepthLayoutProperties(const Property::Map& properties); + + /** * Set the number of columns in the layout. * @param[in] columns The number of columns. */ diff --git a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp old mode 100644 new mode 100755 index e6cdf3f..e002245 --- a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -533,6 +534,10 @@ 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 ); @@ -621,6 +626,68 @@ void GridLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3 } } +void GridLayout::SetGridLayoutProperties(const Property::Map& properties) +{ + // Set any properties specified for gridLayout. + for( unsigned int idx = 0, mapCount = properties.Count(); idx < mapCount; ++idx ) + { + KeyValuePair propertyPair = properties.GetKeyValue( idx ); + switch(DefaultItemLayoutProperty::Property(propertyPair.first.indexKey)) + { + case DefaultItemLayoutProperty::GRID_COLUMN_NUMBER: + { + SetNumberOfColumns(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_ROW_SPACING: + { + SetRowSpacing(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_COLUMN_SPACING: + { + SetColumnSpacing(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_TOP_MARGIN: + { + SetTopMargin(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN: + { + SetBottomMargin(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_SIDE_MARGIN: + { + SetSideMargin(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR: + { + SetScrollSpeedFactor(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED: + { + SetMaximumSwipeSpeed(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION: + { + SetItemFlickAnimationDuration(propertyPair.second.Get()); + break; + } + default: + { + break; + } + } + } + ResetLayoutChangedFlag(); +} + Vector3 GridLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const { Vector3 itemPosition = Vector3::ZERO; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h old mode 100644 new mode 100755 index 7476822..13e68bc --- a/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h @@ -22,6 +22,9 @@ #include +#include + + namespace Dali { @@ -53,6 +56,12 @@ public: virtual ~GridLayout(); /** + * Apply grid layout Properties. + * @param[in] properties The properties of the layout. + */ + void SetGridLayoutProperties(const Property::Map& properties); + + /** * @brief Set the number of columns in the layout. * * @param[in] columns The number of columns. 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 100644 new mode 100755 index ca658b9..23fcd36 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -21,6 +21,8 @@ // EXTERNAL INCLUDES #include // for strcmp #include +#include + #include #include #include @@ -29,10 +31,17 @@ #include #include #include +#include // INTERNAL INCLUDES #include #include +#include +#include +#include +#include +#include +#include #include using std::string; @@ -250,6 +259,8 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "minimumSwipeDistance", FLO DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "wheelScrollDistanceStep", FLOAT, WHEEL_SCROLL_DISTANCE_STEP ) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "snapToItemEnabled", BOOLEAN, SNAP_TO_ITEM_ENABLED ) DALI_PROPERTY_REGISTRATION( Toolkit, ItemView, "refreshInterval", FLOAT, REFRESH_INTERVAL ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, ItemView, "layout", ARRAY, LAYOUT ) + DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "layoutPosition", FLOAT, LAYOUT_POSITION) DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollSpeed", FLOAT, SCROLL_SPEED) @@ -407,11 +418,11 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz // Remove constraints from previous layout actor.RemoveConstraints(); + mActiveLayout->ApplyConstraints(actor, itemId, targetSize, Self() ); + Vector3 size; mActiveLayout->GetItemSize( itemId, targetSize, size ); actor.SetSize( size.GetVectorXY() ); - - mActiveLayout->ApplyConstraints(actor, itemId, targetSize, Self() ); } // Refresh the new layout @@ -1732,6 +1743,89 @@ void ItemView::SetProperty( BaseObject* object, Property::Index index, const Pro itemViewImpl.SetRefreshInterval( value.Get() ); break; } + case Toolkit::DevelItemView::Property::LAYOUT: + { + // Get a Property::Array from the property if possible. + Property::Array layoutArray; + if( value.Get( layoutArray ) ) + { + itemViewImpl.SetLayoutArray( layoutArray ); + } + break; + } + } + } +} + +Property::Array ItemView::GetLayoutArray() +{ + return mlayoutArray; +} + +void ItemView::SetLayoutArray( const Property::Array& layouts ) +{ + mlayoutArray = layouts; + if(GetLayoutCount() > 0) + { + for(unsigned int index = GetLayoutCount() - 1; index >= 0; --index) + { + RemoveLayout(index); + if(index == 0) break; + } + } + + for( unsigned int arrayIdx = 0, arrayCount = layouts.Count(); arrayIdx < arrayCount; ++arrayIdx ) + { + const Property::Value& element = layouts.GetElementAt( arrayIdx ); + + Property::Map* layout = element.GetMap(); + if( layout != NULL ) + { + for( unsigned int mapIdx = 0, mapCount = (*layout).Count(); mapIdx < mapCount; ++mapIdx ) + { + KeyValuePair propertyPair( (*layout).GetKeyValue( mapIdx ) ); + + if(propertyPair.first == DefaultItemLayoutProperty::TYPE) + { + int layoutType = propertyPair.second.Get(); + if(layoutType <= DefaultItemLayout::SPIRAL && layoutType >= DefaultItemLayout::DEPTH) + { + //DEPTH, GRID, LIST, SPIRAL + switch(DefaultItemLayout::Type(layoutType)) + { + case DefaultItemLayout::DEPTH: + { + Internal::DepthLayoutPtr depthLayout = Internal::DepthLayout::New(); + (*depthLayout).SetLayoutProperties(*layout); + AddLayout(*depthLayout); + break; + } + case DefaultItemLayout::GRID: + { + Internal::GridLayoutPtr gridLayout = Internal::GridLayout::New(); + (*gridLayout).SetLayoutProperties(*layout); + AddLayout(*gridLayout); + break; + } + case DefaultItemLayout::LIST: + { + Internal::GridLayoutPtr listLayout = Internal::GridLayout::New(); + listLayout->SetNumberOfColumns( 1 ); + (*listLayout).SetLayoutProperties(*layout); + AddLayout(*listLayout); + break; + } + case DefaultItemLayout::SPIRAL: + { + Internal::SpiralLayoutPtr spiralLayout = Internal::SpiralLayout::New(); + (*spiralLayout).SetLayoutProperties(*layout); + AddLayout(*spiralLayout); + break; + } + } + } + } + } } } } @@ -1772,6 +1866,13 @@ Property::Value ItemView::GetProperty( BaseObject* object, Property::Index index value = itemViewImpl.GetRefreshInterval(); break; } + case Toolkit::DevelItemView::Property::LAYOUT: + { + Property::Array layouts= itemViewImpl.GetLayoutArray(); + value = layouts; + break; + } + } } 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 old mode 100644 new mode 100755 index 6ed616d..f49ee81 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -23,11 +23,14 @@ #include #include #include +#include +#include // INTERNAL INCLUDES #include #include #include +#include #include #include @@ -344,6 +347,18 @@ public: private: /** + * Get all the layouts used in the ItemView. + * @return The layout array + */ + Property::Array GetLayoutArray(); + + /** + * Set all the layouts. that will be used in the ItemView. + * @param[in] layouts The layouts used in the itemView. + */ + void SetLayoutArray( const Property::Array& layouts ); + + /** * Remove an Actor if found in the ItemPool. * @param[in] itemId The item to remove. * @return True if the remaining actors were reordered. @@ -592,6 +607,8 @@ private: typedef ItemPool::iterator ItemPoolIter; typedef ItemPool::const_iterator ConstItemPoolIter; + Property::Array mlayoutArray; + ItemPool mItemPool; ItemFactory& mItemFactory; std::vector< ItemLayoutPtr > mLayouts; ///< Container of Dali::Toolkit::ItemLayout objects diff --git a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp old mode 100644 new mode 100755 index 83d2a1f..9e8db62 --- a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -424,6 +425,11 @@ 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 ); @@ -498,6 +504,53 @@ void SpiralLayout::ApplyConstraints( Actor& actor, const int itemId, const Vecto } } +void SpiralLayout::SetSpiralLayoutProperties(const Property::Map& properties) +{ + // Set any properties specified for SpiralLayout. + for( unsigned int idx = 0, mapCount = properties.Count(); idx < mapCount; ++idx ) + { + KeyValuePair propertyPair = properties.GetKeyValue( idx ); + switch(DefaultItemLayoutProperty::Property(propertyPair.first.indexKey)) + { + case DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING: + { + SetItemSpacing(Radian(propertyPair.second.Get())); + break; + } + case DefaultItemLayoutProperty::SPIRAL_MAXIMUM_SWIPE_SPEED: + { + SetMaximumSwipeSpeed(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT: + { + SetTopItemAlignment(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::SPIRAL_SCROLL_SPEED_FACTOR: + { + SetScrollSpeedFactor(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::SPIRAL_REVOLUTION_DISTANCE: + { + SetRevolutionDistance(propertyPair.second.Get()); + break; + } + case DefaultItemLayoutProperty::SPIRAL_ITEM_FLICK_ANIMATION_DURATION: + { + SetItemFlickAnimationDuration(propertyPair.second.Get()); + break; + } + default: + { + break; + } + } + } + ResetLayoutChangedFlag(); +} + Vector3 SpiralLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const { Vector3 itemPosition = Vector3::ZERO; @@ -517,7 +570,7 @@ Vector3 SpiralLayout::GetItemPosition(int itemID, float currentLayoutPosition, c { positionConstraint.OrientationDown( itemPosition, currentLayoutPosition + itemID, layoutSize ); } - else // orientation == ControlOrientation::Right + else //orientation == ControlOrientation::Right { positionConstraint.OrientationRight( itemPosition, currentLayoutPosition + itemID, layoutSize ); } diff --git a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.h b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.h old mode 100644 new mode 100755 index 1a3e30c..29c46d5 --- a/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.h @@ -22,6 +22,7 @@ #include + namespace Dali { @@ -53,6 +54,12 @@ public: virtual ~SpiralLayout(); /** + * Apply spiral layout Properties. + * @param[in] properties The properties of the layout. + */ + void SetSpiralLayoutProperties(const Property::Map& properties); + + /** * Set spacing angle between items. * @param[in] itemSpacing The angle in radians. */ 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 old mode 100644 new mode 100755 index 2e7ddee..a9f2769 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -36,6 +37,8 @@ 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() @@ -133,6 +136,45 @@ float ItemLayout::GetFlickSpeedFactor() const return GetScrollSpeedFactor(); } +void ItemLayout::SetLayoutProperties(const Property::Map& properties) +{ + for( unsigned int idx = 0, mapCount = properties.Count(); idx < mapCount; ++idx ) + { + KeyValuePair propertyPair( properties.GetKeyValue( idx ) ); + + if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE) + { + SetItemSize(propertyPair.second.Get()); + } + else if(propertyPair.first == DefaultItemLayoutProperty::ORIENTATION) + { + //Up, Left, Down, Right + int orientationType = propertyPair.second.Get(); + if(orientationType <= ControlOrientation::Right && orientationType >= ControlOrientation::Up) + { + SetOrientation(ControlOrientation::Type(orientationType)); + } + } + } + mImpl->mHasLayoutChanged = true; + mImpl->mProperties = properties; +} + +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 old mode 100644 new mode 100755 index e9c5068..97af2df --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h @@ -20,6 +20,8 @@ // EXTERNAL INCLUDES #include +#include +#include // INTERNAL INCLUDES #include @@ -165,6 +167,33 @@ public: DALI_IMPORT_API ControlOrientation::Type GetOrientation() const; /** + * @brief Apply the layout Properties. + * @SINCE_1_2.20 + * @param[in] properties The properties the layout. + */ + void SetLayoutProperties(const Property::Map& properties); + + /** + * @brief Get the layout Properties. + * @SINCE_1_2.20 + * @return the property of the layout. + */ + 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(). diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h old mode 100644 new mode 100755 diff --git a/plugins/dali-swig/SWIG/dali-toolkit.i b/plugins/dali-swig/SWIG/dali-toolkit.i old mode 100644 new mode 100755 index 56693b8..61376cc --- a/plugins/dali-swig/SWIG/dali-toolkit.i +++ b/plugins/dali-swig/SWIG/dali-toolkit.i @@ -100,6 +100,7 @@ %rename(LoadImageSynchronously) Dali::Toolkit::SyncImageLoader::Load; %rename(ControlOrientationType) Dali::Toolkit::ControlOrientation::Type; %rename(DefaultItemLayoutType) Dali::Toolkit::DefaultItemLayout::Type; +%rename(DefaultItemLayoutProperty) Dali::Toolkit::DefaultItemLayoutProperty::Property; %rename(NewItemLayout) Dali::Toolkit::DefaultItemLayout::New; %rename(ContentDirectionType) Dali::Toolkit::FlexContainer::ContentDirection; %rename(FlexDirectionType) Dali::Toolkit::FlexContainer::FlexDirection; @@ -210,6 +211,7 @@ typedef Dali::IntrusivePtr RulerPtr; %include %include %include +%include %include %include %include