exception = true;
}
- DALI_TEST_CHECK(exception);
+ DALI_TEST_CHECK(!exception);// trying to set a read-only property is a no-op
DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get<float>(), TEST_LOCATION );
DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::WORLD_POSITION ) );
- try
- {
- // World position is not writable
- actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) );
- }
- catch (Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT(e, "IsDefaultPropertyWritable(index) && \"Property is read-only\"", TEST_LOCATION);
- }
+ // World position is not writable so this is a no-op and should not crash
+ actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) );
END_TEST;
}
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/projection.h>
#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/update/nodes/node-messages.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/animation/scene-graph-constraint.h>
default:
{
- DALI_ASSERT_ALWAYS(false && "Actor::Property is out of bounds"); // should not come here
+ // this can happen in the case of a non-animatable default property so just do nothing
break;
}
}
}
-void Actor::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
+// TODO: This method needs to be removed
+void Actor::SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
{
- // TODO: This should be deprecated
OnPropertySet(index, value);
- if(entry.IsAnimatable())
+ switch ( entry.type )
{
- switch ( entry.type )
+ case Property::BOOLEAN:
{
- case Property::BOOLEAN:
- {
- const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<bool>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<bool>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
- break;
- }
+ break;
+ }
- case Property::FLOAT:
- {
- const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::FLOAT:
+ {
+ const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<float>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<float>::Bake, value.Get<float>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<float>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<float>::Bake, value.Get<float>() );
- break;
- }
+ break;
+ }
- case Property::INTEGER:
- {
- const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::INTEGER:
+ {
+ const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<int>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<int>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
- break;
- }
+ break;
+ }
- case Property::VECTOR2:
- {
- const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR2:
+ {
+ const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Vector2>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Vector2>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
- break;
- }
+ break;
+ }
- case Property::VECTOR3:
- {
- const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR3:
+ {
+ const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Vector3>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
- break;
- }
+ break;
+ }
- case Property::VECTOR4:
- {
- const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR4:
+ {
+ const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Vector4>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Vector4>::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
- break;
- }
+ break;
+ }
- case Property::ROTATION:
- {
- const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::ROTATION:
+ {
+ const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Quaternion>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Quaternion>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>() );
- break;
- }
+ break;
+ }
- case Property::MATRIX:
- {
- const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::MATRIX:
+ {
+ const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Matrix>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Matrix>::Bake, value.Get<Matrix>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Matrix>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Matrix>::Bake, value.Get<Matrix>() );
- break;
- }
+ break;
+ }
- case Property::MATRIX3:
- {
- const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::MATRIX3:
+ {
+ const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( NULL != property );
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Matrix3>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>() );
+ // property is being used in a separate thread; queue a message to set the property
+ SceneGraph::NodePropertyMessage<Matrix3>::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>() );
- break;
- }
+ 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;
}
}
}
return value;
}
-void Actor::InstallSceneObjectProperty( PropertyBase& newProperty, const std::string& name, unsigned int index )
+const SceneGraph::PropertyOwner* Actor::GetPropertyOwner() const
{
- if( NULL != mNode )
- {
- // mNode is being used in a separate thread; queue a message to add the property
- InstallCustomPropertyMessage( mStage->GetUpdateInterface(), *mNode, newProperty ); // Message takes ownership
- }
+ return mNode;
}
const SceneGraph::PropertyOwner* Actor::GetSceneObject() const
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
+ * @copydoc Dali::Internal::ProxyObject::SetSceneGraphProperty()
*/
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
+ virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
/**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
+ * @copydoc Dali::Internal::ProxyObject::GetPropertyOwner()
*/
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
/**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
/**
* For use in derived classes.
- * This is called after a non animatable custom property is set.
- * @param [in] index The index of the property.
- * @param [in] propertyValue The value of the property.
- */
- virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {}
-
- /**
- * For use in derived classes.
* This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
* @param[in] event The touch event.
* @return True if the event should be consumed.
void ActiveConstraintBase::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
{
- switch ( index )
+ if( Dali::ActiveConstraint::WEIGHT == index )
{
- case Dali::ActiveConstraint::WEIGHT:
- {
- SetWeight( propertyValue.Get<float>() );
- break;
- }
-
- default:
- {
- DALI_ASSERT_ALWAYS( false && "ActiveConstraint property out of bounds" ); // should not come here
- break;
- }
+ SetWeight( propertyValue.Get<float>() );
}
}
-void ActiveConstraintBase::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
-{
- DALI_ASSERT_ALWAYS( false && "ActiveConstraintBase does not have custom properties"); // should not come here
-}
-
Property::Value ActiveConstraintBase::GetDefaultProperty( Property::Index index ) const
{
Property::Value value;
- switch ( index )
+ if( Dali::ActiveConstraint::WEIGHT == index )
{
- case Dali::ActiveConstraint::WEIGHT:
- {
- value = GetCurrentWeight();
- break;
- }
-
- default:
- {
- DALI_ASSERT_ALWAYS( false && "ActiveConstraint property out of bounds" ); // should not come here
- break;
- }
+ value = GetCurrentWeight();
}
return value;
}
-void ActiveConstraintBase::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- DALI_ASSERT_ALWAYS( false && "ActiveConstraintBase does not have custom properties" ); // should not come here
-}
-
const SceneGraph::PropertyOwner* ActiveConstraintBase::GetSceneObject() const
{
return mSceneGraphConstraint;
virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
}
default:
{
- DALI_ASSERT_ALWAYS(false && "Path::Property is out of bounds");
+ // no read only properties
break;
}
}
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ){}
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const{ return NULL; }
*/
const SceneGraph::PropertyBase* GetSceneGraphProperty() const
{
- DALI_ASSERT_DEBUG(mProperty && "Get on uninitialized SceneGraph property") ;
- return mProperty ;
+ DALI_ASSERT_DEBUG(mProperty && "Accessing uninitialized SceneGraph property") ;
+ return mProperty;
}
std::string name; ///< The name of the property
/**
* @copydoc Dali::Handle::Supports()
*/
- virtual bool Supports(Capability capability) const = 0;
+ virtual bool Supports( Capability capability ) const = 0;
/**
* @copydoc Dali::Handle::GetPropertyCount()
/**
* @copydoc Dali::Handle::GetPropertyName()
*/
- virtual std::string GetPropertyName(Property::Index index) const = 0;
+ virtual std::string GetPropertyName( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::GetPropertyIndex()
*/
- virtual Property::Index GetPropertyIndex(const std::string& name) const = 0;
+ virtual Property::Index GetPropertyIndex( const std::string& name ) const = 0;
/**
* @copydoc Dali::Handle::IsPropertyWritable()
*/
- virtual bool IsPropertyWritable(Property::Index index) const = 0;
+ virtual bool IsPropertyWritable( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::IsPropertyAnimatable()
*/
- virtual bool IsPropertyAnimatable(Property::Index index) const = 0;
+ virtual bool IsPropertyAnimatable( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::IsPropertyAConstraintInput()
*/
- virtual bool IsPropertyAConstraintInput(Property::Index index) const = 0;
+ virtual bool IsPropertyAConstraintInput( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::GetPropertyType()
*/
- virtual Property::Type GetPropertyType(Property::Index index) const = 0;
+ virtual Property::Type GetPropertyType( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::SetProperty()
*/
- virtual void SetProperty(Property::Index index, const Property::Value& propertyValue) = 0;
+ virtual void SetProperty( Property::Index index, const Property::Value& propertyValue ) = 0;
/**
* @copydoc Dali::Handle::GetProperty()
*/
- virtual Property::Value GetProperty(Property::Index index) const = 0;
+ virtual Property::Value GetProperty( Property::Index index ) const = 0;
/**
* @copydoc Dali::Handle::GetPropertyIndices()
/**
* @copydoc Dali::Handle::RegisterProperty()
*/
- virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue) = 0;
+ virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ) = 0;
/**
* @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
*/
- virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode) = 0;
+ virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ) = 0;
/**
* @copydoc Dali::Handle::AddPropertyNotification()
*/
- virtual Dali::PropertyNotification AddPropertyNotification(Property::Index index,
- int componentIndex,
- const Dali::PropertyCondition& condition) = 0;
+ virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index,
+ int componentIndex,
+ const Dali::PropertyCondition& condition ) = 0;
/**
* @copydoc Dali::Handle::RemovePropertyNotification()
*/
- virtual void RemovePropertyNotification(Dali::PropertyNotification propertyNotification) = 0;
+ virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ) = 0;
/**
* @copydoc Dali::Handle::RemovePropertyNotifications()
*/
virtual void RemovePropertyNotifications() = 0;
-
protected:
/**
void PropertyNotification::CreateSceneObject()
{
- DALI_ASSERT_DEBUG( mPropertyNotification == NULL );
-
- // Create a new PropertyNotification, temporarily owned
- SceneGraph::PropertyNotification* propertyNotification = SceneGraph::PropertyNotification::New( *mProxy,
- mProxyPropertyIndex,
- mPropertyType,
- mComponentIndex,
- GetImplementation(mCondition).type,
- mRawConditionArgs,
- mNotifyMode );
- // Keep a const pointer to the PropertyNotification.
- mPropertyNotification = propertyNotification;
-
- // Transfer scene object ownership to the update manager through a message
- AddPropertyNotificationMessage( mUpdateManager, propertyNotification );
+ // this method can be called from constructor and on stage connection
+ if( !mPropertyNotification )
+ {
+ // Create a new PropertyNotification, temporarily owned
+ SceneGraph::PropertyNotification* propertyNotification = SceneGraph::PropertyNotification::New( *mProxy,
+ mProxyPropertyIndex,
+ mPropertyType,
+ mComponentIndex,
+ GetImplementation(mCondition).type,
+ mRawConditionArgs,
+ mNotifyMode );
+ // Keep a const pointer to the PropertyNotification.
+ mPropertyNotification = propertyNotification;
+
+ // Transfer scene object ownership to the update manager through a message
+ AddPropertyNotificationMessage( mUpdateManager, propertyNotification );
+ }
}
void PropertyNotification::DestroySceneObject()
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/event/animation/active-constraint-base.h>
#include <dali/internal/event/animation/constraint-impl.h>
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/property-index-ranges.h>
#include <dali/internal/event/common/type-registry-impl.h>
CustomProperty* custom = FindCustomProperty( index );
if( custom )
{
- // Check that the index is valid
return custom->IsWritable();
}
return false;
if ( index < DEFAULT_PROPERTY_MAX_COUNT )
{
- DALI_ASSERT_ALWAYS( IsDefaultPropertyWritable(index) && "Property is read-only" );
-
SetDefaultProperty( index, propertyValue );
}
else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
{
CustomProperty* custom = FindCustomProperty( index );
DALI_ASSERT_ALWAYS( custom && "Invalid property index" );
- DALI_ASSERT_ALWAYS( custom->IsWritable() && "Property is read-only" );
-
- // this is only relevant for non animatable properties, but we'll do it anyways
- custom->value = propertyValue;
- // set the scene graph property value
- SetCustomProperty(index, *custom, propertyValue);
+ if( custom->IsAnimatable() )
+ {
+ // set the scene graph property value
+ SetSceneGraphProperty( index, *custom, propertyValue );
+ }
+ else if( custom->IsWritable() )
+ {
+ custom->value = propertyValue;
+ OnPropertySet(index, propertyValue);
+ }
+ // trying to set value on read only property is no-op
}
}
}
}
-Property::Index ProxyObject::RegisterProperty( std::string name, const Property::Value& propertyValue)
+Property::Index ProxyObject::RegisterProperty( const std::string& name, const Property::Value& propertyValue)
{
// Create a new property
Dali::Internal::OwnerPointer<PropertyBase> newProperty;
case Property::MAP:
{
DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
- DALI_ASSERT_ALWAYS( false && "PropertyType is not animatable" );
+ DALI_ASSERT_ALWAYS( !"PropertyType is not animatable" );
break;
}
default:
{
DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
- DALI_ASSERT_ALWAYS( false && "PropertyType enumeration is out of bounds" );
+ DALI_ASSERT_ALWAYS( !"PropertyType enumeration is out of bounds" );
break;
}
}
- const Property::Index index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
- mCustomProperties.PushBack( new CustomProperty( name, propertyValue.GetType(), newProperty.Get() ) );
+ // get the scene property owner from derived class
+ const SceneGraph::PropertyOwner* scenePropertyOwner = GetPropertyOwner();
+ Property::Index index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
+ // we can only pass properties to scene graph side if there is a scene object
+ if( scenePropertyOwner )
+ {
+ // keep a local pointer to the property as the OwnerPointer will pass its copy to the message
+ const PropertyBase* property = newProperty.Get();
+ mCustomProperties.PushBack( new CustomProperty( name, propertyValue.GetType(), property ) );
- // The derived class now passes ownership of this new property to a scene-object
- // TODO: change this so that OwnerPointer is passed all the way as owership passing cannot be done with a reference
- InstallSceneObjectProperty( *(newProperty.Release()), name, index );
+ // queue a message to add the property
+ InstallCustomPropertyMessage( Stage::GetCurrent()->GetUpdateInterface(), *scenePropertyOwner, newProperty.Release() ); // Message takes ownership
+
+ // notify the derived class (optional) method in case it needs to do some more work on the new property
+ // note! have to use the local pointer as OwnerPointer now points to NULL as it handed over its ownership
+ NotifyScenePropertyInstalled( *property, name, index );
+ }
+ else
+ {
+ // property was orphaned and killed so return invalid index
+ index = Property::INVALID_INDEX;
+ }
return index;
}
-Property::Index ProxyObject::RegisterProperty( std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode)
+Property::Index ProxyObject::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode)
{
Property::Index index = Property::INVALID_INDEX;
return activeConstraintImpl;
}
-void ProxyObject::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
+void ProxyObject::SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
{
- if( entry.IsAnimatable() )
+ switch ( entry.type )
{
- switch ( entry.type )
+ case Property::BOOLEAN:
{
- case Property::BOOLEAN:
- {
- const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ const AnimatableProperty<bool>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::FLOAT:
+ {
+ const AnimatableProperty<float>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::INTEGER:
+ {
+ const AnimatableProperty<int>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR2:
+ {
+ const AnimatableProperty<Vector2>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR3:
+ {
+ const AnimatableProperty<Vector3>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::VECTOR4:
+ {
+ const AnimatableProperty<Vector4>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::ROTATION:
+ {
+ const AnimatableProperty<Quaternion>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::MATRIX:
+ {
+ const AnimatableProperty<Matrix>* property = dynamic_cast< const 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:
- {
- const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ case Property::MATRIX3:
+ {
+ const AnimatableProperty<Matrix3>* property = dynamic_cast< const 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:
+ {
+ // non-animatable scene graph property, do nothing
}
}
}
* Add an observer to the proxy.
* @param[in] observer The observer to add.
*/
- virtual void AddObserver(Observer& observer);
+ virtual void AddObserver( Observer& observer );
/**
* Remove an observer from the proxy
* @pre The observer has already been added.
* @param[in] observer The observer to remove.
*/
- virtual void RemoveObserver(Observer& observer);
+ virtual void RemoveObserver( Observer& observer );
/**
* Retrieve the scene-graph object added by this proxy.
/**
* @copydoc Dali::Internal::Object::GetPropertyIndex()
*/
- virtual Property::Index GetPropertyIndex(const std::string& name) const;
+ virtual Property::Index GetPropertyIndex( const std::string& name ) const;
/**
* @copydoc Dali::Internal::Object::IsPropertyWritable()
*/
- virtual bool IsPropertyWritable(Property::Index index) const;
+ virtual bool IsPropertyWritable( Property::Index index ) const;
/**
* @copydoc Dali::Internal::Object::IsPropertyAnimatable()
*/
- virtual bool IsPropertyAnimatable(Property::Index index) const;
+ virtual bool IsPropertyAnimatable( Property::Index index ) const;
/**
* @copydoc Dali::Internal::Object::IsPropertyAConstraintInput()
*/
- virtual bool IsPropertyAConstraintInput(Property::Index index) const;
+ virtual bool IsPropertyAConstraintInput( Property::Index index ) const;
/**
* @copydoc Dali::Internal::Object::GetPropertyType()
*/
- virtual Property::Type GetPropertyType(Property::Index index) const;
+ virtual Property::Type GetPropertyType( Property::Index index ) const;
/**
* @copydoc Dali::Internal::Object::SetProperty()
*/
- virtual void SetProperty(Property::Index index, const Property::Value& propertyValue);
+ virtual void SetProperty( Property::Index index, const Property::Value& propertyValue );
/**
* @copydoc Dali::Internal::Object::GetProperty()
*/
- virtual Property::Value GetProperty(Property::Index index) const;
+ virtual Property::Value GetProperty( Property::Index index ) const;
/**
* @copydoc Dali::Handle::GetPropertyIndices()
/**
* @copydoc Dali::Internal::Object::RegisterProperty()
*/
- virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue);
+ virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue );
/**
* @copydoc Dali::Internal::Object::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
*/
- virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode);
+ virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode );
/**
* @copydoc Dali::Internal::Object::AddPropertyNotification()
*/
- virtual Dali::PropertyNotification AddPropertyNotification(Property::Index index,
- int componentIndex,
- const Dali::PropertyCondition& condition);
+ virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index,
+ int componentIndex,
+ const Dali::PropertyCondition& condition );
/**
* @copydoc Dali::Internal::Object::RemovePropertyNotification()
*/
- virtual void RemovePropertyNotification(Dali::PropertyNotification propertyNotification);
+ virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification );
/**
* @copydoc Dali::Internal::Object::RemovePropertyNotifications()
void RemovePropertyNotifications();
private:
+
/**
* Enable property notifications in scene graph
*/
private:
// Undefined
- ProxyObject(const ProxyObject&);
+ ProxyObject( const ProxyObject& );
// Undefined
- ProxyObject& operator=(const ProxyObject& rhs);
+ ProxyObject& operator=( const ProxyObject& rhs );
/**
* Helper for ApplyConstraint overloads.
*/
void RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph );
+ /**
+ * Set the value of scene graph property.
+ * @param [in] index The index of the property.
+ * @param [in] entry An entry from the CustomPropertyLookup.
+ * @param [in] value The new value of the property.
+ */
+ virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
private: // Default property extensions for derived classes
virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) = 0;
/**
- * Set the value of custom property.
- * @param [in] index The index of the property.
- * @param [in] entry An entry from the CustomPropertyLookup.
- * @param [in] value The new value of the property.
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* Retrieve a default property value.
* @param [in] index The index of the property.
* @return The property value.
virtual Property::Value GetDefaultProperty( Property::Index index ) const = 0;
/**
- * Install a newly allocated scene-object property.
- * The derived class is responsible for this, since the type of scene-object is not known to this base class.
- * @param [in] newProperty A newly allocated scene-object property.
+ * @todo this is virtual so that for now actor can override it,
+ * it needs to be removed and only have GetSceneObject but that requires changing actor and constraint logic
+ * Retrieve the scene-graph object added by this proxy.
+ * @return A pointer to the object, or NULL if no object has been added to the scene-graph.
+ */
+ virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const
+ {
+ return GetSceneObject();
+ }
+
+ /**
+ * Notify derived class of installation of a new scene-object property.
+ * This method is called after the message is to sent to install the property
+ * @param [in] newProperty A newly allocated scene-object property. Ownership is obviously not passed.
* @param [in] name The name allocated to this custom property.
* @param [in] index The index allocated to this custom property.
*/
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) = 0;
+ virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
+ { }
protected:
/**
+ * For use in derived classes.
+ * This is called after a non animatable custom property is set.
+ * @param [in] index The index of the property.
+ * @param [in] propertyValue The value of the property.
+ */
+ virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {}
+
+ /**
* Retrieves the TypeInfo for this object. Only retrieves it from the type-registry once and then stores a pointer
* to it locally there-after. The type info will not change during the life-time of the application.
* @return The type-info for this object (Can be NULL)
PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
if ( iter != mRegisteredProperties.end() )
{
- DALI_ASSERT_ALWAYS( iter->second.setFunc && "Trying to write to a read-only property" );
- iter->second.setFunc( object, index, value );
+ if( iter->second.setFunc )
+ {
+ iter->second.setFunc( object, index, value );
+ }
}
else
{
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/render/shaders/shader.h>
#include <dali/internal/render/shaders/uniform-meta.h>
-#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include "dali-shaders.h"
default:
{
- DALI_ASSERT_ALWAYS(false && "ShaderEffect property enumeration out of range"); // should not come here
+ // nothing to do
break;
}
}
return Property::Value();
}
-void ShaderEffect::InstallSceneObjectProperty( PropertyBase& newProperty, const std::string& name, unsigned int index )
+void ShaderEffect::NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
{
// Warning - the property is added to the Shader object in the Update thread and the meta-data is added in the Render thread (through a secondary message)
- // mSceneObject is being used in a separate thread; queue a message to add the property
- InstallCustomPropertyMessage( mUpdateManager.GetEventToUpdate(), *mSceneObject, newProperty ); // Message takes ownership
-
// mSceneObject requires metadata for each custom property (uniform)
UniformMeta* meta = UniformMeta::New( name, newProperty, Dali::ShaderEffect::COORDINATE_TYPE_DEFAULT );
// mSceneObject is being used in a separate thread; queue a message to add the property
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
+ * @copydoc Dali::Internal::ProxyObject::NotifyScenePropertyInstalled()
*/
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
+ virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
/**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
// None of our properties should be settable from Public API
}
-void GestureDetector::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
-{
- // None of our properties should be settable from Public API
-}
-
Property::Value GestureDetector::GetDefaultProperty(Property::Index index) const
{
return Property::Value();
}
-void GestureDetector::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- // We do not want the user to install custom properties
-}
-
const SceneGraph::PropertyOwner* GestureDetector::GetSceneObject() const
{
return NULL;
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
// None of our properties should be settable from Public API
}
-void PanGestureDetector::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
-{
- // None of our properties should be settable from Public API
-}
-
Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
return value;
}
-void PanGestureDetector::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- // We do not want the user to install custom properties
- DALI_ASSERT_ALWAYS(false && "PanGestureDetector does not allow custom properties" );
-}
-
const SceneGraph::PropertyOwner* PanGestureDetector::GetSceneObject() const
{
// This method should only return an object connected to the scene-graph
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
void AnimatableMesh::SetDefaultProperty( Property::Index index, const Property::Value& property )
{
- DALI_ASSERT_ALWAYS( ( index >= 0 ) && ( index < mPropertyCount ) );
+ DALI_ASSERT_ALWAYS( ( index < mPropertyCount ) && "Property index out of bounds" );
int vertexProperty = index % VERTEX_PROPERTY_COUNT;
int vertexIndex = index / VERTEX_PROPERTY_COUNT;
SetTextureCoords( vertexIndex, property.Get<Vector2>() );
break;
}
+ default:
+ {
+ // nothing to do
+ break;
+ }
}
}
-void AnimatableMesh::SetCustomProperty( Property::Index /*index*/, const CustomProperty& /*entry*/, const Property::Value& /*value*/ )
-{
- DALI_ASSERT_ALWAYS( 0 && "AnimatableMesh does not support custom properties");
-}
-
Property::Value AnimatableMesh::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
value = GetCurrentTextureCoords(vertexIndex);
break;
}
+ default:
+ {
+ // nothing to do
+ break;
+ }
}
return value;
}
-void AnimatableMesh::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- DALI_ASSERT_ALWAYS( 0 && "AnimatableMesh does not support custom properties" );
-}
-
const SceneGraph::PropertyOwner* AnimatableMesh::GetSceneObject() const
{
return mSceneObject;
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
return Property::Value();
}
-void CustomObject::InstallSceneObjectProperty( PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- if( NULL != mUpdateObject )
- {
- // mUpdateObject is being used in a separate thread; queue a message to add the property
- InstallCustomPropertyMessage( Stage::GetCurrent()->GetUpdateInterface(), *mUpdateObject, newProperty ); // Message takes ownership
- }
-}
-
CustomObject::~CustomObject()
{
// Guard to allow handle destruction after Core has been destroyed
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
- /**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
protected:
/**
SetClearColor( property.Get<Vector4>() );
break;
}
-
default:
{
- DALI_ASSERT_ALWAYS(false && "RenderTask property index out of range"); // should not come here
+ // nothing to do
break;
}
}
}
-void RenderTask::SetCustomProperty( Property::Index /*index*/, const CustomProperty& /*entry*/, const Property::Value& /*value*/ )
-{
- // TODO: support them, it doesn't hurt.
- DALI_ASSERT_ALWAYS( 0 && "RenderTask does not support custom properties");
-}
-
Property::Value RenderTask::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
return value;
}
-void RenderTask::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index )
-{
- // TODO: support them, it doesn't hurt.
- DALI_ASSERT_ALWAYS( 0 && "RenderTask does not support custom properties" );
-}
-
const SceneGraph::PropertyOwner* RenderTask::GetSceneObject() const
{
return mSceneObject;
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
- */
- virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
- */
- virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
- /**
* @copydoc Dali::Internal::ProxyObject::GetSceneObject()
*/
virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
// Messages for PropertyOwner
-inline void InstallCustomPropertyMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, PropertyBase& property )
+inline void InstallCustomPropertyMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, PropertyBase* property )
{
- typedef MessageValue1< PropertyOwner, PropertyBase* > LocalType;
+ typedef MessageValue1< PropertyOwner, OwnerPointer<PropertyBase> > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, &property );
+ new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property );
}
inline void ApplyConstraintMessage( EventToUpdate& eventToUpdate, const PropertyOwner& owner, ConstraintBase& constraint )
{
}
-Handle::Handle(const Handle& handle)
- : BaseHandle(handle)
+Handle::Handle( const Handle& handle )
+: BaseHandle( handle )
{
}
-Handle& Handle::operator=(const Handle& rhs)
+Handle& Handle::operator=( const Handle& rhs )
{
if( this != &rhs )
{
}
-bool Handle::Supports(Capability capability) const
+bool Handle::Supports( Capability capability ) const
{
return GetImplementation(*this).Supports( capability );
}
return GetImplementation(*this).GetPropertyCount();
}
-std::string Handle::GetPropertyName(Property::Index index) const
+std::string Handle::GetPropertyName( Property::Index index ) const
{
return GetImplementation(*this).GetPropertyName( index );
}
-Property::Index Handle::GetPropertyIndex(std::string name) const
+Property::Index Handle::GetPropertyIndex( const std::string& name ) const
{
return GetImplementation(*this).GetPropertyIndex( name );
}
-bool Handle::IsPropertyWritable(Property::Index index) const
+bool Handle::IsPropertyWritable( Property::Index index ) const
{
return GetImplementation(*this).IsPropertyWritable( index );
}
-bool Handle::IsPropertyAnimatable(Property::Index index) const
+bool Handle::IsPropertyAnimatable( Property::Index index ) const
{
return GetImplementation(*this).IsPropertyAnimatable( index );
}
-bool Handle::IsPropertyAConstraintInput(Property::Index index) const
+bool Handle::IsPropertyAConstraintInput( Property::Index index ) const
{
return GetImplementation(*this).IsPropertyAConstraintInput( index );
}
-Property::Type Handle::GetPropertyType(Property::Index index) const
+Property::Type Handle::GetPropertyType( Property::Index index ) const
{
return GetImplementation(*this).GetPropertyType( index );
}
-void Handle::SetProperty(Property::Index index, Property::Value propertyValue)
+void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue )
{
GetImplementation(*this).SetProperty( index, propertyValue );
}
-Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue)
+Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
{
return GetImplementation(*this).RegisterProperty( name, propertyValue );
}
-Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
+Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
{
return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
}
-Property::Value Handle::GetProperty(Property::Index index) const
+Property::Value Handle::GetProperty( Property::Index index ) const
{
return GetImplementation(*this).GetProperty( index );
}
GetImplementation(*this).GetPropertyIndices( indices );
}
-Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
- const PropertyCondition& condition)
+Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
+ const PropertyCondition& condition )
{
return GetImplementation(*this).AddPropertyNotification( index, -1, condition );
}
-Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index,
- int componentIndex,
- const PropertyCondition& condition)
+Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
+ int componentIndex,
+ const PropertyCondition& condition )
{
return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition );
}
-void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
+void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification )
{
GetImplementation(*this).RemovePropertyNotification( propertyNotification );
}
*
* @param [in] handle A pointer to a newly allocated Dali resource
*/
- Handle(Dali::Internal::Object* handle);
+ Handle( Dali::Internal::Object* handle );
/**
* @brief This constructor provides an uninitialized Dali::Handle.
*
* @param [in] handle A reference to the copied handle
*/
- Handle(const Handle& handle);
+ Handle( const Handle& handle );
/**
* @brief This assignment operator is required for (smart) pointer semantics.
* @param [in] rhs A reference to the copied handle
* @return A reference to this
*/
- Handle& operator=(const Handle& rhs);
+ Handle& operator=( const Handle& rhs );
/**
* @brief Downcast to a handle.
* @param[in] capability The queried capability.
* @return True if the capability is supported.
*/
- bool Supports(Capability capability) const;
+ bool Supports( Capability capability ) const;
/**
* @brief Query how many properties are provided by an handle.
* @param [in] index The index of the property.
* @return The name of the property.
*/
- std::string GetPropertyName(Property::Index index) const;
+ std::string GetPropertyName( Property::Index index ) const;
/**
* @brief Query the index of a property.
+ * Returns the first property index that matches the given name exactly.
*
* @param [in] name The name of the property.
* @return The index of the property, or Property::INVALID_INDEX if no property exists with the given name.
*/
- Property::Index GetPropertyIndex(std::string name) const;
+ Property::Index GetPropertyIndex( const std::string& name ) const;
/**
* @brief Query whether a property can be set using SetProperty().
* @param [in] index The index of the property.
* @return True if the property is writable.
*/
- bool IsPropertyWritable(Property::Index index) const;
+ bool IsPropertyWritable( Property::Index index ) const;
/**
* @brief Query whether a writable property can be the target of an animation or constraint.
* @param [in] index The index of the property.
* @return True if the property is animatable.
*/
- bool IsPropertyAnimatable(Property::Index index) const;
+ bool IsPropertyAnimatable( Property::Index index ) const;
/**
* @brief Query whether a property can be used as in input to a constraint.
* @param [in] index The index of the property.
* @return True if the property can be used as a constraint input.
*/
- bool IsPropertyAConstraintInput(Property::Index index) const;
+ bool IsPropertyAConstraintInput( Property::Index index ) const;
/**
* @brief Query the type of a property.
* @param [in] index The index of the property.
* @return The type of the property.
*/
- Property::Type GetPropertyType(Property::Index index) const;
+ Property::Type GetPropertyType( Property::Index index ) const;
/**
* @brief Set the value of an existing property.
*
- * @pre Handle::IsPropertyWritable(index) returns true.
+ * Property should be write-able. Setting a read-only property is a no-op.
* @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index).
* @param [in] index The index of the property.
* @param [in] propertyValue The new value of the property.
*/
- void SetProperty(Property::Index index, Property::Value propertyValue);
+ void SetProperty( Property::Index index, const Property::Value& propertyValue );
/**
* @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.
+ * @pre The object supports dynamic properties i.e. Supports(Handle::DYNAMIC_PROPERTIES) returns true.
+ * Property names are expected to be unique, but this is not enforced.
+ * Property indices are unique to each registered custom property in a given object.
+ * returns Property::INVALID_INDEX if registration failed. This can happen if you try to register
+ * animatable property on an object that does not have scene graph object.
* @note Only the following types can be animated:
* - Property::BOOLEAN
* - Property::FLOAT
* - 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
+ * @return The index of the property or Property::INVALID_INDEX if registration failed
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue);
+ Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue );
/**
* @brief Register a new property.
* @param [in] accessMode The property access mode (writable, animatable etc).
* @return The index of the property
*/
- Property::Index RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode);
+ Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode );
/**
* @brief Retrieve a property value.
* @param [in] index The index of the property.
* @return The property value.
*/
- Property::Value GetProperty(Property::Index index) const;
+ Property::Value GetProperty( Property::Index index ) const;
/**
* @brief Convenience function for obtaining a property of a known type.
* @return The property value.
*/
template <typename T>
- T GetProperty(Property::Index index) const
+ T GetProperty( Property::Index index ) const
{
Property::Value value = GetProperty(index);
*
* @return A handle to the newly created PropertyNotification
*/
- PropertyNotification AddPropertyNotification(Property::Index index,
- const PropertyCondition& condition);
+ PropertyNotification AddPropertyNotification( Property::Index index,
+ const PropertyCondition& condition );
/**
* @brief Add a property notification to this object.
*
* @return A handle to the newly created PropertyNotification
*/
- PropertyNotification AddPropertyNotification(Property::Index index,
- int componentIndex,
- const PropertyCondition& condition);
+ PropertyNotification AddPropertyNotification( Property::Index index,
+ int componentIndex,
+ const PropertyCondition& condition );
/**
* @brief Remove a property notification from this object.
*
* @param [in] propertyNotification The propertyNotification to be removed.
*/
- void RemovePropertyNotification(Dali::PropertyNotification propertyNotification);
+ void RemovePropertyNotification( Dali::PropertyNotification propertyNotification );
/**
* @brief Remove all property notifications from this object.