+AnimatablePropertyMetadata* Object::RegisterAnimatableProperty(Property::Index index) const
+{
+ DALI_ASSERT_ALWAYS( (( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ))
+ && "Property index is out of bounds" );
+
+ // check whether the animatable property is registered already, if not then register one.
+ AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index );
+ if(!animatableProperty)
+ {
+ const TypeInfo* typeInfo( GetTypeInfo() );
+ if (typeInfo)
+ {
+ Property::Index basePropertyIndex = typeInfo->GetBasePropertyIndex(index);
+ if(basePropertyIndex == Property::INVALID_INDEX)
+ {
+ // If the property is not a component of a base property, register the whole property itself.
+ index = RegisterSceneGraphProperty(typeInfo->GetPropertyName(index), index, Property::Value(typeInfo->GetPropertyType(index)));
+ }
+ else
+ {
+ // Since the property is a component of a base property, check whether the base property is regsitered.
+ animatableProperty = FindAnimatableProperty( basePropertyIndex );
+ if(!animatableProperty)
+ {
+ // If the base property is not registered yet, register the base property first.
+ if(Property::INVALID_INDEX != RegisterSceneGraphProperty(typeInfo->GetPropertyName(basePropertyIndex), basePropertyIndex, Property::Value(typeInfo->GetPropertyType(basePropertyIndex))))
+ {
+ animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ }
+ }
+
+ if(animatableProperty)
+ {
+ // Create the metadata for the property component.
+ mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, typeInfo->GetComponentIndex(index), animatableProperty->GetType(), animatableProperty->GetSceneGraphProperty() ) );
+ }
+ }
+
+ // The metadata has just been added and therefore should be in the end of the vector.
+ animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ }
+ }
+
+ return animatableProperty;
+}
+