Changes for std::vector removal from api 61/40161/2
authorLee Morgan <Lee.morgan@partner.samsung.com>
Fri, 29 May 2015 13:52:11 +0000 (14:52 +0100)
committerLee Morgan <Lee.morgan@partner.samsung.com>
Fri, 29 May 2015 14:19:36 +0000 (07:19 -0700)
Change-Id: I9f0acd2d9f4c70911e883d6637772e62c5e509e7

examples/cluster/cluster-impl.cpp
examples/cluster/cluster-impl.h

index 0edda67..a37214e 100644 (file)
@@ -23,7 +23,9 @@
 #include <cstring> // for strcmp
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/property-array.h>
 #include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -475,17 +477,21 @@ void Cluster::UpdateTitle(float duration)
   }
 }
 
-void Cluster::DoExpandAction(const PropertyValueContainer& attributes)
+void Cluster::DoExpandAction(const Property::Map& attributes)
 {
-  if(attributes.size() >= 1)
+  Property::Value* value = attributes.Find( "indices" );
+
+  if( value )
   {
-    for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter)
+    if( value->GetType() == Property::ARRAY )
     {
-      const Property::Value& value = *iter;
-
-      DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT);
-      unsigned int index = value.Get<float>();
-      ExpandChild( index );
+      Property::Array array = value->Get<Property::Array>();
+      for( size_t i = 0; i < array.Size(); i++ )
+      {
+        Property::Value& item = array[i];
+        DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER);
+        ExpandChild( item.Get<int>() );
+      }
     }
   }
   else
@@ -494,17 +500,21 @@ void Cluster::DoExpandAction(const PropertyValueContainer& attributes)
   }
 }
 
-void Cluster::DoCollapseAction(const PropertyValueContainer& attributes)
+void Cluster::DoCollapseAction(const Property::Map& attributes)
 {
-  if(attributes.size() >= 1)
+  Property::Value* value = attributes.Find( "indices" );
+
+  if( value )
   {
-    for(PropertyValueConstIter iter = attributes.begin(); iter != attributes.end(); ++iter)
+    if( value->GetType() == Property::ARRAY )
     {
-      const Property::Value& value = *iter;
-
-      DALI_ASSERT_ALWAYS(value.GetType() == Property::FLOAT);
-      unsigned int index = value.Get<float>();
-      CollapseChild( index, false );
+      Property::Array array = value->Get<Property::Array>();
+      for( size_t i = 0; i < array.Size(); i++ )
+      {
+        Property::Value& item = array[i];
+        DALI_ASSERT_ALWAYS(item.GetType() == Property::INTEGER);
+        CollapseChild( item.Get<int>(), false );
+      }
     }
   }
   else
@@ -513,27 +523,33 @@ void Cluster::DoCollapseAction(const PropertyValueContainer& attributes)
   }
 }
 
-void Cluster::DoTransformAction(const PropertyValueContainer& attributes)
+
+void Cluster::DoTransformAction(const Property::Map& attributes)
 {
-  DALI_ASSERT_ALWAYS(attributes.size() >= 2);
+  typedef Dali::StringValuePair StringValuePair;
 
-  DALI_ASSERT_ALWAYS(attributes[0].GetType() == Property::FLOAT);
-  unsigned int index = attributes[0].Get<float>();
+  int index = 0;
   Vector3 position;
   Vector3 scale(Vector3::ONE);
   Quaternion rotation( Dali::ANGLE_0, Vector3::ZAXIS );
 
-  DALI_ASSERT_ALWAYS(attributes[1].GetType() == Property::VECTOR3);
-  attributes[1].Get(position);
-
-  if(attributes.size()>2)
+  for(size_t i = 0; i < attributes.Count(); i++)
   {
-    attributes[2].Get(scale);
-  }
+    StringValuePair& stringValue = attributes.GetPair(i);
+    Property::Type type = stringValue.second.GetType();
 
-  if(attributes.size()>3)
-  {
-    attributes[3].Get(rotation);
+    if( Property::VECTOR3 == type && "position" == stringValue.first )
+    {
+      stringValue.second.Get(position);
+    }
+    else if( Property::VECTOR3 == type && "scale" == stringValue.first )
+    {
+      stringValue.second.Get(scale);
+    }
+    else if( "rotation" == stringValue.first )
+    {
+      (void)Scripting::SetRotation(stringValue.second, rotation);
+    }
   }
 
   // wrap index around -1 => size - 1
@@ -547,7 +563,7 @@ void Cluster::OnControlChildRemove(Actor& child)
   child.RemoveConstraints();
 }
 
-bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
+bool Cluster::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes)
 {
   bool ret = false;
 
index 7c8a408..a81a5ea 100644 (file)
@@ -212,7 +212,7 @@ private:
    * @param[in] attributes list of indices of actors to expand.
    * (if no attributes specifies, then all actors expand)
    */
-  void DoExpandAction(const PropertyValueContainer& attributes);
+  void DoExpandAction(const Property::Map& attributes);
 
   /**
    * Action: Collapse
@@ -221,7 +221,7 @@ private:
    * @param[in] attributes list of indices of actors to collapse.
    * (if no attributes specifies, then all actors collapse)
    */
-  void DoCollapseAction(const PropertyValueContainer& attributes);
+  void DoCollapseAction(const Property::Map& attributes);
 
   /**
    * Action: Transform
@@ -230,7 +230,7 @@ private:
    *
    * @param[in] attributes index and transform values.
    */
-  void DoTransformAction(const PropertyValueContainer& attributes);
+  void DoTransformAction(const Property::Map& attributes);
 
 private: // From Control
   /**
@@ -248,7 +248,7 @@ public:
    * @param[in] attributes The attributes with which to perfrom this action.
    * @return true if action has been accepted by this control
    */
-  static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
+  static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
 
 private: // From Control