From 62a036e95cc8447bba0ef068948c8feb15de76b2 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Thu, 18 Dec 2014 10:15:09 +0000 Subject: [PATCH] Cleaning up the property framework; removal of duplicate methods and incorrect assers Change-Id: I84eb603bee6fb87d9fed4fe23efa935b132ef981 --- automated-tests/src/dali/utc-Dali-Handle.cpp | 14 +- dali/internal/event/actors/actor-impl.cpp | 170 ++++++++-------- dali/internal/event/actors/actor-impl.h | 16 +- .../event/animation/active-constraint-base.cpp | 38 +--- .../event/animation/active-constraint-base.h | 10 - dali/internal/event/animation/path-impl.cpp | 2 +- dali/internal/event/animation/path-impl.h | 5 - dali/internal/event/common/custom-property.h | 4 +- dali/internal/event/common/object-impl.h | 31 ++- .../event/common/property-notification-impl.cpp | 32 +-- dali/internal/event/common/proxy-object.cpp | 214 +++++++++++---------- dali/internal/event/common/proxy-object.h | 78 +++++--- dali/internal/event/common/type-info-impl.cpp | 6 +- dali/internal/event/effects/shader-effect-impl.cpp | 8 +- dali/internal/event/effects/shader-effect-impl.h | 4 +- .../event/events/gesture-detector-impl.cpp | 10 - dali/internal/event/events/gesture-detector-impl.h | 10 - .../event/events/pan-gesture-detector-impl.cpp | 11 -- .../event/events/pan-gesture-detector-impl.h | 10 - .../event/modeling/animatable-mesh-impl.cpp | 22 +-- .../internal/event/modeling/animatable-mesh-impl.h | 10 - .../event/object/custom-object-internal.cpp | 10 - .../internal/event/object/custom-object-internal.h | 5 - .../event/render-tasks/render-task-impl.cpp | 15 +- .../internal/event/render-tasks/render-task-impl.h | 10 - .../update/common/property-owner-messages.h | 6 +- dali/public-api/object/handle.cpp | 40 ++-- dali/public-api/object/handle.h | 54 +++--- 28 files changed, 362 insertions(+), 483 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index a2314d1..fdfb01f 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -534,7 +534,7 @@ int UtcDaliHandleNonAnimtableProperties(void) 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(), TEST_LOCATION ); @@ -714,16 +714,8 @@ int UtcDaliHandleSetProperty02(void) 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; } diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 5ff09c1..d9a67fe 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -2630,125 +2629,122 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr 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* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::FLOAT: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::FLOAT: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::INTEGER: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::INTEGER: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::VECTOR2: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR2: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::VECTOR3: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR3: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::VECTOR4: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR4: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property, &AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::ROTATION: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::ROTATION: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::MATRIX: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::MATRIX: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); - break; - } + break; + } - case Property::MATRIX3: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::MATRIX3: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); + // property is being used in a separate thread; queue a message to set the property + SceneGraph::NodePropertyMessage::Send( mStage->GetUpdateManager(), mNode, property,&AnimatableProperty::Bake, value.Get() ); - 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; } } } @@ -3027,13 +3023,9 @@ Property::Value Actor::GetDefaultProperty(Property::Index index) const 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 diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 83b649f..74ad86e 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1188,9 +1188,9 @@ public: // Default property extensions from ProxyObject 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() @@ -1198,9 +1198,9 @@ public: // Default property extensions from ProxyObject 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() @@ -1298,14 +1298,6 @@ private: /** * 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. diff --git a/dali/internal/event/animation/active-constraint-base.cpp b/dali/internal/event/animation/active-constraint-base.cpp index 121ed80..05b58c5 100644 --- a/dali/internal/event/animation/active-constraint-base.cpp +++ b/dali/internal/event/animation/active-constraint-base.cpp @@ -385,54 +385,24 @@ Property::Type ActiveConstraintBase::GetDefaultPropertyType( Property::Index ind void ActiveConstraintBase::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { - switch ( index ) + if( Dali::ActiveConstraint::WEIGHT == index ) { - case Dali::ActiveConstraint::WEIGHT: - { - SetWeight( propertyValue.Get() ); - break; - } - - default: - { - DALI_ASSERT_ALWAYS( false && "ActiveConstraint property out of bounds" ); // should not come here - break; - } + SetWeight( propertyValue.Get() ); } } -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; diff --git a/dali/internal/event/animation/active-constraint-base.h b/dali/internal/event/animation/active-constraint-base.h index de4e751..6ff45a7 100644 --- a/dali/internal/event/animation/active-constraint-base.h +++ b/dali/internal/event/animation/active-constraint-base.h @@ -237,21 +237,11 @@ public: // Default property extensions from ProxyObject 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; diff --git a/dali/internal/event/animation/path-impl.cpp b/dali/internal/event/animation/path-impl.cpp index b273245..7edc684 100644 --- a/dali/internal/event/animation/path-impl.cpp +++ b/dali/internal/event/animation/path-impl.cpp @@ -203,7 +203,7 @@ void Path::SetDefaultProperty(Property::Index index, const Property::Value& prop } default: { - DALI_ASSERT_ALWAYS(false && "Path::Property is out of bounds"); + // no read only properties break; } } diff --git a/dali/internal/event/animation/path-impl.h b/dali/internal/event/animation/path-impl.h index 6d1f1c0..78ccb1d 100644 --- a/dali/internal/event/animation/path-impl.h +++ b/dali/internal/event/animation/path-impl.h @@ -123,11 +123,6 @@ private: 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; } diff --git a/dali/internal/event/common/custom-property.h b/dali/internal/event/common/custom-property.h index 7034468..9b2a188 100644 --- a/dali/internal/event/common/custom-property.h +++ b/dali/internal/event/common/custom-property.h @@ -114,8 +114,8 @@ public: */ 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 diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 7e585c5..df70fa5 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -48,7 +48,7 @@ public: /** * @copydoc Dali::Handle::Supports() */ - virtual bool Supports(Capability capability) const = 0; + virtual bool Supports( Capability capability ) const = 0; /** * @copydoc Dali::Handle::GetPropertyCount() @@ -58,42 +58,42 @@ public: /** * @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() @@ -103,31 +103,30 @@ public: /** * @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: /** diff --git a/dali/internal/event/common/property-notification-impl.cpp b/dali/internal/event/common/property-notification-impl.cpp index 834cfb4..510c344 100644 --- a/dali/internal/event/common/property-notification-impl.cpp +++ b/dali/internal/event/common/property-notification-impl.cpp @@ -209,21 +209,23 @@ bool PropertyNotification::CompareSceneObject( const SceneGraph::PropertyNotific 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() diff --git a/dali/internal/event/common/proxy-object.cpp b/dali/internal/event/common/proxy-object.cpp index c9bbbc2..7d00513 100644 --- a/dali/internal/event/common/proxy-object.cpp +++ b/dali/internal/event/common/proxy-object.cpp @@ -23,12 +23,12 @@ // INTERNAL INCLUDES #include -#include -#include #include +#include #include #include #include +#include #include #include #include @@ -250,7 +250,6 @@ bool ProxyObject::IsPropertyWritable( Property::Index index ) const CustomProperty* custom = FindCustomProperty( index ); if( custom ) { - // Check that the index is valid return custom->IsWritable(); } return false; @@ -339,8 +338,6 @@ void ProxyObject::SetProperty( Property::Index index, const Property::Value& pro 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 ) ) @@ -359,12 +356,17 @@ void ProxyObject::SetProperty( Property::Index index, const Property::Value& pro { 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 } } @@ -528,7 +530,7 @@ void ProxyObject::GetPropertyIndices( Property::IndexContainer& indices ) const } } -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 newProperty; @@ -596,29 +598,45 @@ Property::Index ProxyObject::RegisterProperty( std::string name, const Property: 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; @@ -773,107 +791,103 @@ ActiveConstraintBase* ProxyObject::DoApplyConstraint( Constraint& constraint, Da 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* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::FLOAT: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::FLOAT: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::INTEGER: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::INTEGER: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::VECTOR2: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR2: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::VECTOR3: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR3: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::VECTOR4: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::VECTOR4: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::ROTATION: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::ROTATION: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::MATRIX: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::MATRIX: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + break; + } - case Property::MATRIX3: - { - const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); - DALI_ASSERT_DEBUG( NULL != property ); + case Property::MATRIX3: + { + const AnimatableProperty* property = dynamic_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); + DALI_ASSERT_DEBUG( NULL != property ); - // property is being used in a separate thread; queue a message to set the property - BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); - break; - } + // property is being used in a separate thread; queue a message to set the property + BakeMessage( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get() ); + 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 } } } diff --git a/dali/internal/event/common/proxy-object.h b/dali/internal/event/common/proxy-object.h index b0e3bbe..0ae1e31 100644 --- a/dali/internal/event/common/proxy-object.h +++ b/dali/internal/event/common/proxy-object.h @@ -123,14 +123,14 @@ public: * 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. @@ -182,37 +182,37 @@ public: // Property system interface from Internal::Object /** * @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() @@ -222,24 +222,24 @@ public: // Property system interface from Internal::Object /** * @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() @@ -247,6 +247,7 @@ public: // Property system interface from Internal::Object void RemovePropertyNotifications(); private: + /** * Enable property notifications in scene graph */ @@ -324,10 +325,10 @@ protected: private: // Undefined - ProxyObject(const ProxyObject&); + ProxyObject( const ProxyObject& ); // Undefined - ProxyObject& operator=(const ProxyObject& rhs); + ProxyObject& operator=( const ProxyObject& rhs ); /** * Helper for ApplyConstraint overloads. @@ -342,6 +343,13 @@ private: */ 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 @@ -410,14 +418,6 @@ 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. @@ -425,17 +425,37 @@ private: // Default property extensions for derived classes 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) diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index 45377e3..1da80f0 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -446,8 +446,10 @@ void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Pro 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 { diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index f16eeae..bd41274 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "dali-shaders.h" @@ -576,7 +575,7 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va default: { - DALI_ASSERT_ALWAYS(false && "ShaderEffect property enumeration out of range"); // should not come here + // nothing to do break; } } @@ -588,13 +587,10 @@ Property::Value ShaderEffect::GetDefaultProperty(Property::Index /*index*/) cons 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 diff --git a/dali/internal/event/effects/shader-effect-impl.h b/dali/internal/event/effects/shader-effect-impl.h index 25f7e05..2faee40 100644 --- a/dali/internal/event/effects/shader-effect-impl.h +++ b/dali/internal/event/effects/shader-effect-impl.h @@ -185,9 +185,9 @@ public: // Default property extensions from ProxyObject 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() diff --git a/dali/internal/event/events/gesture-detector-impl.cpp b/dali/internal/event/events/gesture-detector-impl.cpp index f9c0076..bf012cc 100644 --- a/dali/internal/event/events/gesture-detector-impl.cpp +++ b/dali/internal/event/events/gesture-detector-impl.cpp @@ -226,21 +226,11 @@ void GestureDetector::SetDefaultProperty( Property::Index index, const Property: // 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; diff --git a/dali/internal/event/events/gesture-detector-impl.h b/dali/internal/event/events/gesture-detector-impl.h index 6d2e659..f0566ef 100644 --- a/dali/internal/event/events/gesture-detector-impl.h +++ b/dali/internal/event/events/gesture-detector-impl.h @@ -208,21 +208,11 @@ private: // Default property extensions from ProxyObject 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; diff --git a/dali/internal/event/events/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture-detector-impl.cpp index 57be6fc..77bb5bb 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture-detector-impl.cpp @@ -407,11 +407,6 @@ void PanGestureDetector::SetDefaultProperty( Property::Index index, const Proper // 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; @@ -519,12 +514,6 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co 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 diff --git a/dali/internal/event/events/pan-gesture-detector-impl.h b/dali/internal/event/events/pan-gesture-detector-impl.h index 8648455..bd1778a 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.h +++ b/dali/internal/event/events/pan-gesture-detector-impl.h @@ -254,21 +254,11 @@ private: 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; diff --git a/dali/internal/event/modeling/animatable-mesh-impl.cpp b/dali/internal/event/modeling/animatable-mesh-impl.cpp index d8e3309..1dc391a 100644 --- a/dali/internal/event/modeling/animatable-mesh-impl.cpp +++ b/dali/internal/event/modeling/animatable-mesh-impl.cpp @@ -280,7 +280,7 @@ Property::Type AnimatableMesh::GetDefaultPropertyType(Property::Index index) con 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; @@ -301,14 +301,14 @@ void AnimatableMesh::SetDefaultProperty( Property::Index index, const Property:: SetTextureCoords( vertexIndex, property.Get() ); 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; @@ -332,16 +332,16 @@ Property::Value AnimatableMesh::GetDefaultProperty(Property::Index index) const 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; diff --git a/dali/internal/event/modeling/animatable-mesh-impl.h b/dali/internal/event/modeling/animatable-mesh-impl.h index 8d96601..0d001ec 100644 --- a/dali/internal/event/modeling/animatable-mesh-impl.h +++ b/dali/internal/event/modeling/animatable-mesh-impl.h @@ -200,21 +200,11 @@ public: // Implementation of ProxyObject 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; diff --git a/dali/internal/event/object/custom-object-internal.cpp b/dali/internal/event/object/custom-object-internal.cpp index 77dc526..8805451 100644 --- a/dali/internal/event/object/custom-object-internal.cpp +++ b/dali/internal/event/object/custom-object-internal.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -108,15 +107,6 @@ Property::Value CustomObject::GetDefaultProperty(Property::Index index) const 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 diff --git a/dali/internal/event/object/custom-object-internal.h b/dali/internal/event/object/custom-object-internal.h index 9778f0a..b16caec 100644 --- a/dali/internal/event/object/custom-object-internal.h +++ b/dali/internal/event/object/custom-object-internal.h @@ -107,11 +107,6 @@ public: */ 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: /** diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 71e441b..d324556 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -543,21 +543,14 @@ void RenderTask::SetDefaultProperty( Property::Index index, const Property::Valu SetClearColor( property.Get() ); 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; @@ -591,12 +584,6 @@ Property::Value RenderTask::GetDefaultProperty(Property::Index index) const 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; diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index c45b347..f58ad2b 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -279,21 +279,11 @@ public: // Implementation of ProxyObject 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; diff --git a/dali/internal/update/common/property-owner-messages.h b/dali/internal/update/common/property-owner-messages.h index 5f672f9..ff49b37 100644 --- a/dali/internal/update/common/property-owner-messages.h +++ b/dali/internal/update/common/property-owner-messages.h @@ -33,15 +33,15 @@ namespace SceneGraph // 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 > 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 ) diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index 4c1b482..98fea25 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -40,12 +40,12 @@ Handle::~Handle() { } -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 ) { @@ -61,7 +61,7 @@ Handle Handle::DownCast( BaseHandle handle ) } -bool Handle::Supports(Capability capability) const +bool Handle::Supports( Capability capability ) const { return GetImplementation(*this).Supports( capability ); } @@ -71,52 +71,52 @@ unsigned int Handle::GetPropertyCount() const 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 ); } @@ -126,20 +126,20 @@ void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const 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 ); } diff --git a/dali/public-api/object/handle.h b/dali/public-api/object/handle.h index 8ad0111..3718402 100644 --- a/dali/public-api/object/handle.h +++ b/dali/public-api/object/handle.h @@ -67,7 +67,7 @@ public: * * @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. @@ -96,7 +96,7 @@ public: * * @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. @@ -104,7 +104,7 @@ public: * @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. @@ -123,7 +123,7 @@ public: * @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. @@ -139,15 +139,16 @@ public: * @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(). @@ -156,7 +157,7 @@ public: * @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. @@ -164,7 +165,7 @@ public: * @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. @@ -172,7 +173,7 @@ public: * @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. @@ -180,23 +181,26 @@ public: * @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 @@ -209,9 +213,9 @@ public: * - 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. @@ -234,7 +238,7 @@ public: * @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. @@ -242,7 +246,7 @@ public: * @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. @@ -252,7 +256,7 @@ public: * @return The property value. */ template - T GetProperty(Property::Index index) const + T GetProperty( Property::Index index ) const { Property::Value value = GetProperty(index); @@ -275,8 +279,8 @@ public: * * @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. @@ -287,16 +291,16 @@ public: * * @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. -- 2.7.4