From 8dcc28c84192bb52789a2ac82bab24975df7076b Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Fri, 24 Apr 2015 11:33:48 +0100 Subject: [PATCH] (Properties) OnPropertySet is called when any property is set Change-Id: I075dca41b6bd975cd0a682ef62f4296d094334ab --- dali/internal/event/actors/actor-impl.cpp | 2 -- dali/internal/event/common/object-impl.cpp | 33 ++++++++++++++++-------------- dali/internal/event/common/object-impl.h | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 5d99b15..6cf14fc 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -2930,8 +2930,6 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr // TODO: This method needs to be removed void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ) { - OnPropertySet( index, value ); - switch( entry.type ) { case Property::BOOLEAN: diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index 34bd166..fb689da 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -355,6 +355,8 @@ void Object::SetProperty( Property::Index index, const Property::Value& property { DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" ); + bool propertySet( true ); + if ( index < DEFAULT_PROPERTY_MAX_COUNT ) { SetDefaultProperty( index, propertyValue ); @@ -362,14 +364,7 @@ void Object::SetProperty( Property::Index index, const Property::Value& property else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) { const TypeInfo* typeInfo( GetTypeInfo() ); - if ( typeInfo ) - { - typeInfo->SetProperty( this, index, propertyValue ); - } - else - { - DALI_LOG_ERROR("Cannot find property index\n"); - } + typeInfo->SetProperty( this, index, propertyValue ); } else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { @@ -378,13 +373,10 @@ void Object::SetProperty( Property::Index index, const Property::Value& property if(!animatableProperty) { const TypeInfo* typeInfo( GetTypeInfo() ); - if (!typeInfo) - { - DALI_LOG_ERROR("Cannot find property index\n"); - } - else if ( Property::INVALID_INDEX == RegisterSceneGraphProperty( typeInfo->GetPropertyName( index ), index, propertyValue ) ) + if ( Property::INVALID_INDEX == RegisterSceneGraphProperty( typeInfo->GetPropertyName( index ), index, propertyValue ) ) { DALI_LOG_ERROR("Cannot register property\n"); + propertySet = false; } } else @@ -406,15 +398,26 @@ void Object::SetProperty( Property::Index index, const Property::Value& property else if( custom->IsWritable() ) { custom->value = propertyValue; - OnPropertySet(index, propertyValue); } - // trying to set value on read only property is no-op + else + { + // trying to set value on read only property is no-op + propertySet = false; + } } else { DALI_LOG_ERROR("Invalid property index\n"); + propertySet = false; } } + + // Let derived classes know that a property has been set + // TODO: We should not call this for read-only properties, SetDefaultProperty() && TypeInfo::SetProperty() should return a bool, which would be true if the property is set + if ( propertySet ) + { + OnPropertySet(index, propertyValue); + } } Property::Value Object::GetProperty(Property::Index index) const diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index be66703..9f34aed 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -300,7 +300,7 @@ protected: /** * For use in derived classes. - * This is called after a non animatable custom property is set. + * This is called after a property is set. * @param [in] index The index of the property. * @param [in] propertyValue The value of the property. */ -- 2.7.4