2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/internal/event/object/custom-object-internal.h>
21 #include <dali/internal/event/common/stage-impl.h>
22 #include <dali/internal/update/common/animatable-property.h>
23 #include <dali/internal/update/common/property-owner.h>
24 #include <dali/internal/update/common/property-owner-messages.h>
25 #include <dali/internal/update/manager/update-manager.h>
26 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
28 using Dali::Internal::SceneGraph::PropertyOwner;
29 using Dali::Internal::SceneGraph::PropertyBase;
30 using Dali::Internal::SceneGraph::UpdateManager;
31 using Dali::Internal::SceneGraph::AnimatableProperty;
35 const std::string INVALID_PROPERTY_NAME;
44 CustomObject* CustomObject::New()
46 return new CustomObject();
49 bool CustomObject::IsSceneObjectRemovable() const
54 const SceneGraph::PropertyOwner* CustomObject::GetSceneObject() const
59 const PropertyBase* CustomObject::GetSceneObjectAnimatableProperty( Property::Index index ) const
61 const PropertyBase* property( NULL );
63 CustomPropertyLookup::const_iterator entry = GetCustomPropertyLookup().find( index );
65 DALI_ASSERT_ALWAYS( GetCustomPropertyLookup().end() != entry && "index is invalid" );
67 property = dynamic_cast<const PropertyBase*>( entry->second.GetSceneGraphProperty() );
72 const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::Index index ) const
74 return GetSceneObjectAnimatableProperty( index );
77 unsigned int CustomObject::GetDefaultPropertyCount() const
82 void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
86 const std::string& CustomObject::GetDefaultPropertyName( Property::Index index ) const
88 return INVALID_PROPERTY_NAME;
91 Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const
93 return Property::INVALID_INDEX;
96 bool CustomObject::IsDefaultPropertyWritable(Property::Index index) const
101 bool CustomObject::IsDefaultPropertyAnimatable(Property::Index index) const
106 bool CustomObject::IsDefaultPropertyAConstraintInput( Property::Index index ) const
111 Property::Type CustomObject::GetDefaultPropertyType(Property::Index index) const
113 return Property::NONE;
116 void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property )
121 Property::Value CustomObject::GetDefaultProperty(Property::Index index) const
123 return Property::Value();
126 void CustomObject::InstallSceneObjectProperty( PropertyBase& newProperty, const std::string& name, unsigned int index )
128 if( NULL != mUpdateObject )
130 // mUpdateObject is being used in a separate thread; queue a message to add the property
131 InstallCustomPropertyMessage( Stage::GetCurrent()->GetUpdateInterface(), *mUpdateObject, newProperty ); // Message takes ownership
135 CustomObject::~CustomObject()
137 // Guard to allow handle destruction after Core has been destroyed
138 if( Stage::IsInstalled() )
140 if( NULL != mUpdateObject )
142 RemoveObjectMessage( Stage::GetCurrent()->GetUpdateManager(), mUpdateObject );
143 mUpdateObject = NULL; // object is about to be destroyed
148 CustomObject::CustomObject()
150 PropertyOwner* updateObject = PropertyOwner::New();
152 // Pass ownership to the update-thread
153 AddObjectMessage( Stage::GetCurrent()->GetUpdateManager(), updateObject );
155 // Keep as const since this should only be modified from update-thread
156 mUpdateObject = updateObject;
159 } // namespace Internal