2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/common/proxy-object.h>
25 #include <dali/integration-api/debug.h>
26 #include <dali/internal/event/common/stage-impl.h>
27 #include <dali/internal/update/common/animatable-property.h>
28 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
29 #include <dali/internal/update/common/property-owner-messages.h>
30 #include <dali/internal/event/animation/active-constraint-base.h>
31 #include <dali/internal/event/animation/constraint-impl.h>
32 #include <dali/internal/event/common/property-notification-impl.h>
33 #include <dali/internal/event/common/property-index-ranges.h>
34 #include <dali/internal/event/common/type-registry-impl.h>
36 using Dali::Internal::SceneGraph::AnimatableProperty;
37 using Dali::Internal::SceneGraph::PropertyBase;
45 namespace // unnamed namespace
47 const int SUPPORTED_CAPABILITIES = Dali::Handle::DYNAMIC_PROPERTIES; // ProxyObject provides this capability
48 typedef Dali::Vector<ProxyObject::Observer*>::Iterator ObserverIter;
49 typedef Dali::Vector<ProxyObject::Observer*>::ConstIterator ConstObserverIter;
51 #if defined(DEBUG_ENABLED)
52 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_PROXY_OBJECT" );
54 } // unnamed namespace
56 ProxyObject::ProxyObject()
59 mPropertyNotifications( NULL )
63 void ProxyObject::AddObserver(Observer& observer)
65 // make sure an observer doesn't observe the same object twice
66 // otherwise it will get multiple calls to OnSceneObjectAdd(), OnSceneObjectRemove() and ProxyDestroyed()
67 DALI_ASSERT_DEBUG( mObservers.End() == std::find( mObservers.Begin(), mObservers.End(), &observer));
69 mObservers.PushBack( &observer );
72 void ProxyObject::RemoveObserver(Observer& observer)
74 // Find the observer...
75 const ConstObserverIter endIter = mObservers.End();
76 for( ObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
78 if( (*iter) == &observer)
80 mObservers.Erase( iter );
84 DALI_ASSERT_DEBUG(endIter != mObservers.End());
87 void ProxyObject::OnSceneObjectAdd()
89 // Notification for this object's constraints
92 const ActiveConstraintConstIter endIter = mConstraints->end();
93 for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
95 ActiveConstraintBase& baseConstraint = GetImplementation( *iter );
96 baseConstraint.OnParentSceneObjectAdded();
100 // Notification for observers
101 for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter)
103 (*iter)->SceneObjectAdded(*this);
106 // enable property notifications in scene graph
107 EnablePropertyNotifications();
110 void ProxyObject::OnSceneObjectRemove()
112 // Notification for this object's constraints
115 const ActiveConstraintConstIter endIter = mConstraints->end();
116 for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
118 ActiveConstraintBase& baseConstraint = GetImplementation( *iter );
119 baseConstraint.OnParentSceneObjectRemoved();
123 // Notification for observers
124 for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter )
126 (*iter)->SceneObjectRemoved(*this);
129 // disable property notifications in scene graph
130 DisablePropertyNotifications();
133 int ProxyObject::GetPropertyComponentIndex( Property::Index index ) const
135 return Property::INVALID_COMPONENT_INDEX;
138 bool ProxyObject::Supports( Capability capability ) const
140 return (capability & SUPPORTED_CAPABILITIES);
143 unsigned int ProxyObject::GetPropertyCount() const
145 unsigned int count = GetDefaultPropertyCount();
147 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Default Properties: %d\n", count );
149 const TypeInfo* typeInfo( GetTypeInfo() );
152 unsigned int manual( typeInfo->GetPropertyCount() );
155 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Manual Properties: %d\n", manual );
158 unsigned int custom( mCustomProperties.Count() );
160 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Custom Properties: %d\n", custom );
162 DALI_LOG_INFO( gLogFilter, Debug::Concise, "Total Properties: %d\n", count );
167 std::string ProxyObject::GetPropertyName( Property::Index index ) const
169 DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index out of bounds" );
171 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
173 return GetDefaultPropertyName( index );
176 if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
178 const TypeInfo* typeInfo( GetTypeInfo() );
181 return typeInfo->GetPropertyName( index );
185 DALI_ASSERT_ALWAYS( ! "Property index is invalid" );
189 CustomProperty* custom = FindCustomProperty( index );
197 Property::Index ProxyObject::GetPropertyIndex(const std::string& name) const
199 Property::Index index = GetDefaultPropertyIndex( name );
201 if ( index == Property::INVALID_INDEX )
203 const TypeInfo* typeInfo( GetTypeInfo() );
206 index = typeInfo->GetPropertyIndex( name );
210 if( ( index == Property::INVALID_INDEX )&&( mCustomProperties.Count() > 0 ) )
212 Property::Index count = PROPERTY_CUSTOM_START_INDEX;
213 const CustomPropertyLookup::ConstIterator end = mCustomProperties.End();
214 for( CustomPropertyLookup::ConstIterator iter = mCustomProperties.Begin(); iter != end; ++iter, ++count )
216 CustomProperty* custom = *iter;
217 if ( custom->name == name )
228 bool ProxyObject::IsPropertyWritable( Property::Index index ) const
230 DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
232 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
234 return IsDefaultPropertyWritable( index );
237 if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
239 const TypeInfo* typeInfo( GetTypeInfo() );
242 return typeInfo->IsPropertyWritable( index );
246 DALI_ASSERT_ALWAYS( ! "Invalid property index" );
250 CustomProperty* custom = FindCustomProperty( index );
253 // Check that the index is valid
254 return custom->IsWritable();
259 bool ProxyObject::IsPropertyAnimatable( Property::Index index ) const
261 DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
263 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
265 return IsDefaultPropertyAnimatable( index );
268 if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
270 // Type Registry event-thread only properties are not animatable.
274 CustomProperty* custom = FindCustomProperty( index );
277 return custom->IsAnimatable();
282 bool ProxyObject::IsPropertyAConstraintInput( Property::Index index ) const
284 DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
286 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
288 return IsDefaultPropertyAConstraintInput( index );
291 if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
293 // Type Registry event-thread only properties cannot be used as an input to a constraint.
297 CustomProperty* custom = FindCustomProperty( index );
300 // ... custom properties can be used as input to a constraint.
306 Property::Type ProxyObject::GetPropertyType( Property::Index index ) const
308 DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
310 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
312 return GetDefaultPropertyType( index );
315 if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
317 const TypeInfo* typeInfo( GetTypeInfo() );
320 return typeInfo->GetPropertyType( index );
324 DALI_ASSERT_ALWAYS( ! "Cannot find property index" );
328 CustomProperty* custom = FindCustomProperty( index );
333 return Property::NONE;
336 void ProxyObject::SetProperty( Property::Index index, const Property::Value& propertyValue )
338 DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
340 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
342 DALI_ASSERT_ALWAYS( IsDefaultPropertyWritable(index) && "Property is read-only" );
344 SetDefaultProperty( index, propertyValue );
346 else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
348 const TypeInfo* typeInfo( GetTypeInfo() );
351 typeInfo->SetProperty( this, index, propertyValue );
355 DALI_ASSERT_ALWAYS( ! "Cannot find property index" );
360 CustomProperty* custom = FindCustomProperty( index );
361 DALI_ASSERT_ALWAYS( custom && "Invalid property index" );
362 DALI_ASSERT_ALWAYS( custom->IsWritable() && "Property is read-only" );
364 // this is only relevant for non animatable properties, but we'll do it anyways
365 custom->value = propertyValue;
366 // set the scene graph property value
367 SetCustomProperty(index, *custom, propertyValue);
371 Property::Value ProxyObject::GetProperty(Property::Index index) const
373 DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index is out of bounds" );
375 Property::Value value;
377 if ( index < DEFAULT_PROPERTY_MAX_COUNT )
379 value = GetDefaultProperty( index );
381 else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
383 const TypeInfo* typeInfo( GetTypeInfo() );
386 value = typeInfo->GetProperty( this, index );
390 DALI_ASSERT_ALWAYS( ! "Cannot find property index" );
393 else if( mCustomProperties.Count() > 0 )
395 CustomProperty* custom = FindCustomProperty( index );
396 DALI_ASSERT_ALWAYS( custom && "Invalid property index" );
398 if( !custom->IsAnimatable() )
400 value = custom->value;
404 BufferIndex bufferIndex( Stage::GetCurrent()->GetEventBufferIndex() );
406 switch ( custom->type )
408 case Property::BOOLEAN:
410 const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( custom->GetSceneGraphProperty() );
411 DALI_ASSERT_DEBUG( NULL != property );
413 value = (*property)[ bufferIndex ];
417 case Property::FLOAT:
419 const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( custom->GetSceneGraphProperty() );
420 DALI_ASSERT_DEBUG( NULL != property );
422 value = (*property)[ bufferIndex ];
426 case Property::INTEGER:
428 const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( custom->GetSceneGraphProperty() );
429 DALI_ASSERT_DEBUG( NULL != property );
431 value = (*property)[ bufferIndex ];
435 case Property::VECTOR2:
437 const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( custom->GetSceneGraphProperty() );
438 DALI_ASSERT_DEBUG( NULL != property );
440 value = (*property)[ bufferIndex ];
444 case Property::VECTOR3:
446 const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( custom->GetSceneGraphProperty() );
447 DALI_ASSERT_DEBUG( NULL != property );
449 value = (*property)[ bufferIndex ];
453 case Property::VECTOR4:
455 const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( custom->GetSceneGraphProperty() );
456 DALI_ASSERT_DEBUG( NULL != property );
458 value = (*property)[ bufferIndex ];
462 case Property::MATRIX:
464 const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( custom->GetSceneGraphProperty() );
465 DALI_ASSERT_DEBUG( NULL != property );
467 value = (*property)[ bufferIndex ];
471 case Property::MATRIX3:
473 const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( custom->GetSceneGraphProperty() );
474 DALI_ASSERT_DEBUG( NULL != property );
476 value = (*property)[ bufferIndex ];
480 case Property::ROTATION:
482 const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( custom->GetSceneGraphProperty() );
483 DALI_ASSERT_DEBUG( NULL != property );
485 value = (*property)[ bufferIndex ];
491 DALI_ASSERT_ALWAYS( false && "PropertyType enumeration is out of bounds" );
502 void ProxyObject::GetPropertyIndices( Property::IndexContainer& indices ) const
506 // Default Properties
507 GetDefaultPropertyIndices( indices );
510 const TypeInfo* typeInfo( GetTypeInfo() );
513 typeInfo->GetPropertyIndices( indices );
517 if ( mCustomProperties.Count() > 0 )
519 indices.reserve( indices.size() + mCustomProperties.Count() );
521 CustomPropertyLookup::ConstIterator iter = mCustomProperties.Begin();
522 const CustomPropertyLookup::ConstIterator endIter = mCustomProperties.End();
524 for ( ; iter != endIter; ++iter, ++i )
526 indices.push_back( PROPERTY_CUSTOM_START_INDEX + i );
531 Property::Index ProxyObject::RegisterProperty( std::string name, const Property::Value& propertyValue)
533 // Create a new property
534 Dali::Internal::OwnerPointer<PropertyBase> newProperty;
536 switch ( propertyValue.GetType() )
538 case Property::BOOLEAN:
540 newProperty = new AnimatableProperty<bool>( propertyValue.Get<bool>() );
544 case Property::FLOAT:
546 newProperty = new AnimatableProperty<float>( propertyValue.Get<float>() );
550 case Property::INTEGER:
552 newProperty = new AnimatableProperty<int>( propertyValue.Get<int>() );
556 case Property::VECTOR2:
558 newProperty = new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>() );
562 case Property::VECTOR3:
564 newProperty = new AnimatableProperty<Vector3>( propertyValue.Get<Vector3>() );
568 case Property::VECTOR4:
570 newProperty = new AnimatableProperty<Vector4>( propertyValue.Get<Vector4>() );
574 case Property::MATRIX:
576 newProperty = new AnimatableProperty<Matrix>( propertyValue.Get<Matrix>() );
580 case Property::MATRIX3:
582 newProperty = new AnimatableProperty<Matrix3>( propertyValue.Get<Matrix3>() );
586 case Property::ROTATION:
588 newProperty = new AnimatableProperty<Quaternion>( propertyValue.Get<Quaternion>() );
592 case Property::UNSIGNED_INTEGER:
593 case Property::RECTANGLE:
594 case Property::STRING:
595 case Property::ARRAY:
598 DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
599 DALI_ASSERT_ALWAYS( false && "PropertyType is not animatable" );
605 DALI_LOG_WARNING( "Property Type %d\n", propertyValue.GetType() );
606 DALI_ASSERT_ALWAYS( false && "PropertyType enumeration is out of bounds" );
611 const Property::Index index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
612 mCustomProperties.PushBack( new CustomProperty( name, propertyValue.GetType(), newProperty.Get() ) );
614 // The derived class now passes ownership of this new property to a scene-object
615 // TODO: change this so that OwnerPointer is passed all the way as owership passing cannot be done with a reference
616 InstallSceneObjectProperty( *(newProperty.Release()), name, index );
621 Property::Index ProxyObject::RegisterProperty( std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode)
623 Property::Index index = Property::INVALID_INDEX;
625 if(Property::ANIMATABLE == accessMode)
627 index = RegisterProperty(name, propertyValue);
631 // Add entry to the property lookup
632 index = PROPERTY_CUSTOM_START_INDEX + mCustomProperties.Count();
633 mCustomProperties.PushBack( new CustomProperty( name, propertyValue, accessMode ) );
639 Dali::PropertyNotification ProxyObject::AddPropertyNotification(Property::Index index,
641 const Dali::PropertyCondition& condition)
643 if ( index >= DEFAULT_PROPERTY_MAX_COUNT )
645 if ( index <= PROPERTY_REGISTRATION_MAX_INDEX )
647 DALI_ASSERT_ALWAYS( false && "Property notification added to event side only property." );
649 else if ( mCustomProperties.Count() > 0 )
651 CustomProperty* custom = FindCustomProperty( index );
652 DALI_ASSERT_ALWAYS( custom && "Invalid property index" );
653 DALI_ASSERT_ALWAYS( custom->IsAnimatable() && "Property notification added to event side only property." );
657 Dali::Handle self(this);
658 Property target( self, index );
660 PropertyNotificationPtr internal = PropertyNotification::New( target, componentIndex, condition );
661 Dali::PropertyNotification propertyNotification(internal.Get());
663 if( !mPropertyNotifications )
665 mPropertyNotifications = new PropertyNotificationContainer;
667 mPropertyNotifications->push_back(propertyNotification);
669 return propertyNotification;
672 void ProxyObject::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
674 if( mPropertyNotifications )
676 PropertyNotificationContainerIter iter = mPropertyNotifications->begin();
677 while(iter != mPropertyNotifications->end() )
679 if(*iter == propertyNotification)
681 mPropertyNotifications->erase(iter);
682 // As we can't ensure all references are removed, we can just disable
684 GetImplementation(propertyNotification).Disable();
692 void ProxyObject::RemovePropertyNotifications()
694 if( mPropertyNotifications )
696 PropertyNotificationContainerIter iter = mPropertyNotifications->begin();
697 while(iter != mPropertyNotifications->end() )
699 // As we can't ensure all references are removed, we can just disable
701 GetImplementation(*iter).Disable();
705 mPropertyNotifications->clear();
709 void ProxyObject::EnablePropertyNotifications()
711 if( mPropertyNotifications )
713 PropertyNotificationContainerIter iter = mPropertyNotifications->begin();
714 PropertyNotificationContainerIter endIter = mPropertyNotifications->end();
716 for( ; iter != endIter; ++iter )
718 GetImplementation(*iter).Enable();
723 void ProxyObject::DisablePropertyNotifications()
725 if( mPropertyNotifications )
727 PropertyNotificationContainerIter iter = mPropertyNotifications->begin();
728 PropertyNotificationContainerIter endIter = mPropertyNotifications->end();
730 for( ; iter != endIter; ++iter )
732 GetImplementation(*iter).Disable();
737 Dali::ActiveConstraint ProxyObject::ApplyConstraint( Constraint& constraint )
739 return Dali::ActiveConstraint( DoApplyConstraint( constraint, Dali::Constrainable() ) );
742 Dali::ActiveConstraint ProxyObject::ApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject )
744 return Dali::ActiveConstraint( DoApplyConstraint( constraint, weightObject ) );
747 ActiveConstraintBase* ProxyObject::DoApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject )
749 ActiveConstraintBase* activeConstraintImpl = constraint.CreateActiveConstraint();
750 DALI_ASSERT_DEBUG( NULL != activeConstraintImpl );
752 Dali::ActiveConstraint activeConstraint( activeConstraintImpl );
756 ProxyObject& weightObjectImpl = GetImplementation( weightObject );
757 Property::Index weightIndex = weightObjectImpl.GetPropertyIndex( "weight" );
759 if( Property::INVALID_INDEX != weightIndex )
761 activeConstraintImpl->SetCustomWeightObject( weightObjectImpl, weightIndex );
767 mConstraints = new ActiveConstraintContainer;
769 mConstraints->push_back( activeConstraint );
771 activeConstraintImpl->FirstApply( *this, constraint.GetApplyTime() );
773 return activeConstraintImpl;
776 void ProxyObject::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value )
778 if( entry.IsAnimatable() )
780 switch ( entry.type )
782 case Property::BOOLEAN:
784 const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
785 DALI_ASSERT_DEBUG( NULL != property );
787 // property is being used in a separate thread; queue a message to set the property
788 BakeMessage<bool>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<bool>() );
792 case Property::FLOAT:
794 const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
795 DALI_ASSERT_DEBUG( NULL != property );
797 // property is being used in a separate thread; queue a message to set the property
798 BakeMessage<float>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<float>() );
802 case Property::INTEGER:
804 const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
805 DALI_ASSERT_DEBUG( NULL != property );
807 // property is being used in a separate thread; queue a message to set the property
808 BakeMessage<int>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<int>() );
812 case Property::VECTOR2:
814 const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
815 DALI_ASSERT_DEBUG( NULL != property );
817 // property is being used in a separate thread; queue a message to set the property
818 BakeMessage<Vector2>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector2>() );
822 case Property::VECTOR3:
824 const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
825 DALI_ASSERT_DEBUG( NULL != property );
827 // property is being used in a separate thread; queue a message to set the property
828 BakeMessage<Vector3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector3>() );
832 case Property::VECTOR4:
834 const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
835 DALI_ASSERT_DEBUG( NULL != property );
837 // property is being used in a separate thread; queue a message to set the property
838 BakeMessage<Vector4>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Vector4>() );
842 case Property::ROTATION:
844 const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
845 DALI_ASSERT_DEBUG( NULL != property );
847 // property is being used in a separate thread; queue a message to set the property
848 BakeMessage<Quaternion>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Quaternion>() );
852 case Property::MATRIX:
854 const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
855 DALI_ASSERT_DEBUG( NULL != property );
857 // property is being used in a separate thread; queue a message to set the property
858 BakeMessage<Matrix>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix>() );
862 case Property::MATRIX3:
864 const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
865 DALI_ASSERT_DEBUG( NULL != property );
867 // property is being used in a separate thread; queue a message to set the property
868 BakeMessage<Matrix3>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<Matrix3>() );
874 DALI_ASSERT_ALWAYS(false && "Property type enumeration out of bounds"); // should not come here
881 const TypeInfo* ProxyObject::GetTypeInfo() const
885 // This uses a dynamic_cast so can be quite expensive so we only really want to do it once
886 // especially as the type-info does not change during the life-time of an application
888 Dali::TypeInfo typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this );
889 if ( typeInfoHandle )
891 mTypeInfo = &GetImplementation( typeInfoHandle );
898 void ProxyObject::RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph )
900 // guard against constraint sending messages during core destruction
901 if ( Stage::IsInstalled() )
905 ActiveConstraintBase& baseConstraint = GetImplementation( constraint );
906 baseConstraint.BeginRemove();
911 void ProxyObject::RemoveConstraint( Dali::ActiveConstraint activeConstraint )
913 // guard against constraint sending messages during core destruction
914 if( mConstraints && Stage::IsInstalled() )
916 bool isInSceneGraph( NULL != GetSceneObject() );
918 ActiveConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), activeConstraint ) );
919 if( it != mConstraints->end() )
921 RemoveConstraint( *it, isInSceneGraph );
922 mConstraints->erase( it );
927 void ProxyObject::RemoveConstraints( unsigned int tag )
929 // guard against constraint sending messages during core destruction
930 if( mConstraints && Stage::IsInstalled() )
932 bool isInSceneGraph( NULL != GetSceneObject() );
934 ActiveConstraintIter iter( mConstraints->begin() );
935 while(iter != mConstraints->end() )
937 ActiveConstraintBase& constraint = GetImplementation( *iter );
938 if( constraint.GetTag() == tag )
940 RemoveConstraint( *iter, isInSceneGraph );
941 iter = mConstraints->erase( iter );
951 void ProxyObject::RemoveConstraints()
953 // guard against constraint sending messages during core destruction
954 if( mConstraints && Stage::IsInstalled() )
956 // If we have nothing in the scene-graph, just clear constraint containers
957 const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject();
958 if ( NULL != propertyOwner )
960 const ActiveConstraintConstIter endIter = mConstraints->end();
961 for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
963 RemoveConstraint( *iter, true );
972 void ProxyObject::SetTypeInfo( const TypeInfo* typeInfo )
974 mTypeInfo = typeInfo;
977 ProxyObject::~ProxyObject()
979 // Notification for this object's constraints
980 // (note that the ActiveConstraint handles may outlive the ProxyObject)
983 const ActiveConstraintConstIter endIter = mConstraints->end();
984 for ( ActiveConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter )
986 ActiveConstraintBase& baseConstraint = GetImplementation( *iter );
987 baseConstraint.OnParentDestroyed();
991 // Notification for observers
992 for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter)
994 (*iter)->ProxyDestroyed(*this);
998 delete mPropertyNotifications;
1001 CustomProperty* ProxyObject::FindCustomProperty( Property::Index index ) const
1003 CustomProperty* property( NULL );
1004 int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
1005 if( arrayIndex >= 0 )
1007 if( arrayIndex < (int)mCustomProperties.Count() ) // we can only access the first 2 billion custom properties
1009 property = mCustomProperties[ arrayIndex ];
1015 } // namespace Internal