(Properties) Specify which properties can be registered as animatable 59/27959/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 23 Sep 2014 13:18:04 +0000 (14:18 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 24 Sep 2014 08:45:56 +0000 (01:45 -0700)
Change-Id: I9224afa9959dd8d7bc710d261077bf3b959ad6fb

automated-tests/src/dali/utc-Dali-Handle.cpp
dali/internal/event/common/proxy-object.cpp
dali/public-api/object/handle.h

index 1747227..04f7259 100644 (file)
@@ -971,3 +971,56 @@ int UtcDaliHandleGetPropertyIndices(void)
   DALI_TEST_EQUALS( indices.size(), actor.GetPropertyCount(), TEST_LOCATION );
   END_TEST;
 }
+
+int UtcDaliHandleRegisterPropertyTypes(void)
+{
+  TestApplication application;
+
+  struct PropertyTypeAnimatable
+  {
+    const char * name;
+    Property::Value value;
+    bool animatable;
+  };
+
+  Property::Array array;
+  Property::Map map;
+
+  PropertyTypeAnimatable properties[] =
+  {
+    { "Property::BOOLEAN",          true,              true  },
+    { "Property::FLOAT",            1.0f,              true  },
+    { "Property::INTEGER",          1,                 true  },
+    { "Property::UNSIGNED_INTEGER", 1u,                false },
+    { "Property::VECTOR2",          Vector2::ONE,      true  },
+    { "Property::VECTOR3",          Vector3::ONE,      true  },
+    { "Property::VECTOR4",          Vector4::ONE,      true  },
+    { "Property::MATRIX3",          Matrix3::IDENTITY, true  },
+    { "Property::MATRIX",           Matrix::IDENTITY,  true  },
+    { "Property::RECTANGLE",        Rect<int>(),       false },
+    { "Property::ROTATION",         AngleAxis(),       true  },
+    { "Property::STRING",           std::string("Me"), false },
+    { "Property::ARRAY",            array,             false },
+    { "Property::MAP",              map,               false },
+  };
+  unsigned int numOfProperties( sizeof( properties ) / sizeof( properties[0] ) );
+
+  for ( unsigned int i = 0; i < numOfProperties; ++i )
+  {
+    tet_printf( "Testing: %s\n", properties[i].name );
+
+    bool exception = false;
+    try
+    {
+      Actor actor = Actor::New();
+      actor.RegisterProperty( "man-from-delmonte", properties[i].value );
+    }
+    catch (Dali::DaliException& e)
+    {
+      exception = true;
+    }
+
+    DALI_TEST_CHECK( properties[i].animatable != exception );
+  }
+  END_TEST;
+}
index 0085d20..126d020 100644 (file)
@@ -612,6 +612,17 @@ Property::Index ProxyObject::RegisterProperty( std::string name, const Property:
       break;
     }
 
+    case Property::UNSIGNED_INTEGER:
+    case Property::RECTANGLE:
+    case Property::STRING:
+    case Property::ARRAY:
+    case Property::MAP:
+    {
+      DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
+      DALI_ASSERT_ALWAYS( false && "PropertyType is not animatable" );
+      break;
+    }
+
     default:
     {
       DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
@@ -804,102 +815,105 @@ ActiveConstraintBase* ProxyObject::DoApplyConstraint( Constraint& constraint, Da
 
 void ProxyObject::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
 {
-  switch ( entry.type )
+  if( entry.IsAnimatable() )
   {
-    case Property::BOOLEAN:
+    switch ( entry.type )
     {
-      AnimatableProperty<bool>* property = dynamic_cast< AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::BOOLEAN:
+      {
+        AnimatableProperty<bool>* property = dynamic_cast< AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<bool>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<bool>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<bool>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<bool>() );
+        break;
+      }
 
-    case Property::FLOAT:
-    {
-      AnimatableProperty<float>* property = dynamic_cast< AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::FLOAT:
+      {
+        AnimatableProperty<float>* property = dynamic_cast< AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<float>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<float>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<float>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<float>() );
+        break;
+      }
 
-    case Property::INTEGER:
-    {
-      AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::INTEGER:
+      {
+        AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<int>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<int>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<int>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<int>() );
+        break;
+      }
 
-    case Property::VECTOR2:
-    {
-      AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::VECTOR2:
+      {
+        AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Vector2>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector2>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Vector2>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector2>() );
+        break;
+      }
 
-    case Property::VECTOR3:
-    {
-      AnimatableProperty<Vector3>* property = dynamic_cast< AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::VECTOR3:
+      {
+        AnimatableProperty<Vector3>* property = dynamic_cast< AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Vector3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector3>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Vector3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector3>() );
+        break;
+      }
 
-    case Property::VECTOR4:
-    {
-      AnimatableProperty<Vector4>* property = dynamic_cast< AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::VECTOR4:
+      {
+        AnimatableProperty<Vector4>* property = dynamic_cast< AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Vector4>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector4>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Vector4>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector4>() );
+        break;
+      }
 
-    case Property::ROTATION:
-    {
-      AnimatableProperty<Quaternion>* property = dynamic_cast< AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::ROTATION:
+      {
+        AnimatableProperty<Quaternion>* property = dynamic_cast< AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Quaternion>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Quaternion>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Quaternion>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Quaternion>() );
+        break;
+      }
 
-    case Property::MATRIX:
-    {
-      AnimatableProperty<Matrix>* property = dynamic_cast< AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::MATRIX:
+      {
+        AnimatableProperty<Matrix>* property = dynamic_cast< AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Matrix>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Matrix>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix>() );
+        break;
+      }
 
-    case Property::MATRIX3:
-    {
-      AnimatableProperty<Matrix3>* property = dynamic_cast< AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
-      DALI_ASSERT_DEBUG( NULL != property );
+      case Property::MATRIX3:
+      {
+        AnimatableProperty<Matrix3>* property = dynamic_cast< AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
+        DALI_ASSERT_DEBUG( NULL != property );
 
-      // property is being used in a separate thread; queue a message to set the property
-      BakeMessage<Matrix3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix3>() );
-      break;
-    }
+        // property is being used in a separate thread; queue a message to set the property
+        BakeMessage<Matrix3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix3>() );
+        break;
+      }
 
-    default:
-    {
-      DALI_ASSERT_ALWAYS(false && "Property type enumeration out of bounds"); // should not come here
-      break;
+      default:
+      {
+        DALI_ASSERT_ALWAYS(false && "Property type enumeration out of bounds"); // should not come here
+        break;
+      }
     }
   }
 }
index cdee861..6817a70 100644 (file)
@@ -203,10 +203,20 @@ public:
   void SetProperty(Property::Index index, Property::Value propertyValue);
 
   /**
-   * @brief Register a new property.
+   * @brief Register a new animatable property.
    *
    * @pre The handle supports dynamic properties i.e. Supports(Handle::DYNAMIC_PROPERTIES) returns true.
    * @pre name is unused i.e. GetPropertyIndex(name) returns PropertyIndex::INVALID.
+   * @note Only the following types can be animated:
+   *       - Property::BOOLEAN
+   *       - Property::FLOAT
+   *       - Property::INTEGER
+   *       - Property::VECTOR2
+   *       - Property::VECTOR3
+   *       - Property::VECTOR4
+   *       - Property::MATRIX3
+   *       - Property::MATRIX
+   *       - Property::ROTATION
    * @param [in] name The name of the property.
    * @param [in] propertyValue The new value of the property.
    * @return The index of the property
@@ -219,6 +229,16 @@ public:
    * Properties can be set as non animatable using property attributes.
    * @pre The handle supports dynamic properties i.e. Supports(Handle::DYNAMIC_PROPERTIES) returns true.
    * @pre name is unused i.e. GetPropertyIndex(name) returns PropertyIndex::INVALID.
+   * @note Only the following types can be animated:
+   *       - Property::BOOLEAN
+   *       - Property::FLOAT
+   *       - Property::INTEGER
+   *       - Property::VECTOR2
+   *       - Property::VECTOR3
+   *       - Property::VECTOR4
+   *       - Property::MATRIX3
+   *       - Property::MATRIX
+   *       - Property::ROTATION
    * @param [in] name The name of the property.
    * @param [in] propertyValue The new value of the property.
    * @param [in] accessMode The property access mode (writable, animatable etc).