+AnimatablePropertyMetadata* Object::FindAnimatableProperty( Property::Index index ) const
+{
+ for ( int arrayIndex = 0; arrayIndex < (int)mAnimatableProperties.Count(); arrayIndex++ )
+ {
+ AnimatablePropertyMetadata* property = static_cast<AnimatablePropertyMetadata*>( mAnimatableProperties[ arrayIndex ] );
+ if( property->index == index )
+ {
+ return property;
+ }
+ }
+ return NULL;
+}
+
+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.
+ const std::string& propertyName = typeInfo->GetPropertyName(index);
+ RegisterSceneGraphProperty(propertyName, Property::INVALID_KEY, index, typeInfo->GetPropertyDefaultValue(index));
+ AddUniformMapping( index, propertyName );
+ }
+ else
+ {
+ // Since the property is a component of a base property, check whether the base property is registered.
+ animatableProperty = FindAnimatableProperty( basePropertyIndex );
+ if( !animatableProperty )
+ {
+ // If the base property is not registered yet, register the base property first.
+ const std::string& basePropertyName = typeInfo->GetPropertyName(basePropertyIndex);
+
+ if( Property::INVALID_INDEX != RegisterSceneGraphProperty( basePropertyName, Property::INVALID_KEY, basePropertyIndex, typeInfo->GetPropertyDefaultValue( basePropertyIndex ) ) )
+ {
+ animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ AddUniformMapping( basePropertyIndex, basePropertyName );
+ }
+ }
+
+ if(animatableProperty)
+ {
+ // Create the metadata for the property component.
+ mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, typeInfo->GetComponentIndex(index), animatableProperty->value, 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;
+}
+
+void Object::ResolveChildProperties()
+{
+ // Resolve index for the child property
+ Object* parent = GetParentObject();
+ if( parent )
+ {
+ const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
+ if( parentTypeInfo )
+ {
+ // Go through each custom property
+ for ( int arrayIndex = 0; arrayIndex < (int)mCustomProperties.Count(); arrayIndex++ )
+ {
+ CustomPropertyMetadata* customProperty = static_cast<CustomPropertyMetadata*>( mCustomProperties[ arrayIndex ] );
+
+ if( customProperty->name == "" )
+ {
+ if( customProperty->childPropertyIndex != Property::INVALID_INDEX )
+ {
+ // Resolve name for any child property with no name
+ customProperty->name = parentTypeInfo->GetChildPropertyName( customProperty->childPropertyIndex );
+ }
+ }
+ else
+ {
+ Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name );
+ if( childPropertyIndex != Property::INVALID_INDEX )
+ {
+ // Resolve index for any property with a name that matches the parent's child property name
+ customProperty->childPropertyIndex = childPropertyIndex;
+ }
+ }
+ }
+ }
+ }
+}
+