(ItemView) Make default layout properties public
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / item-view / grid-layout.cpp
old mode 100644 (file)
new mode 100755 (executable)
index e6cdf3f..3e28d80
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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,6 +25,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-view.h>
+#include <dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout-property.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -621,6 +622,67 @@ 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<int>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_ROW_SPACING:
+      {
+        SetRowSpacing(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_COLUMN_SPACING:
+      {
+        SetColumnSpacing(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_TOP_MARGIN:
+      {
+        SetTopMargin(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN:
+      {
+        SetBottomMargin(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_SIDE_MARGIN:
+      {
+        SetSideMargin(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR:
+      {
+        SetScrollSpeedFactor(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED:
+      {
+        SetMaximumSwipeSpeed(propertyPair.second.Get<float>());
+        break;
+      }
+      case DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION:
+      {
+        SetItemFlickAnimationDuration(propertyPair.second.Get<float>());
+        break;
+      }
+      default:
+      {
+        break;
+      }
+    }
+  }
+}
+
 Vector3 GridLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const
 {
   Vector3 itemPosition = Vector3::ZERO;