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/object/custom-object-internal.h>
22 #include <dali/internal/event/common/stage-impl.h>
23 #include <dali/internal/update/common/animatable-property.h>
24 #include <dali/internal/update/common/property-owner.h>
25 #include <dali/internal/update/common/property-owner-messages.h>
26 #include <dali/internal/update/manager/update-manager.h>
27 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
29 using Dali::Internal::SceneGraph::PropertyOwner;
30 using Dali::Internal::SceneGraph::PropertyBase;
31 using Dali::Internal::SceneGraph::UpdateManager;
32 using Dali::Internal::SceneGraph::AnimatableProperty;
40 CustomObject* CustomObject::New()
42 return new CustomObject();
45 bool CustomObject::IsSceneObjectRemovable() const
50 const SceneGraph::PropertyOwner* CustomObject::GetSceneObject() const
55 const PropertyBase* CustomObject::GetSceneObjectAnimatableProperty( Property::Index index ) const
57 const PropertyBase* property( NULL );
59 CustomPropertyLookup::const_iterator entry = GetCustomPropertyLookup().find( index );
61 DALI_ASSERT_ALWAYS( GetCustomPropertyLookup().end() != entry && "index is invalid" );
63 property = dynamic_cast<const PropertyBase*>( entry->second.GetSceneGraphProperty() );
68 const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::Index index ) const
70 return GetSceneObjectAnimatableProperty( index );
73 unsigned int CustomObject::GetDefaultPropertyCount() const
78 void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
82 const char* CustomObject::GetDefaultPropertyName( Property::Index index ) const
87 Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const
89 return Property::INVALID_INDEX;
92 bool CustomObject::IsDefaultPropertyWritable(Property::Index index) const
97 bool CustomObject::IsDefaultPropertyAnimatable(Property::Index index) const
102 bool CustomObject::IsDefaultPropertyAConstraintInput( Property::Index index ) const
107 Property::Type CustomObject::GetDefaultPropertyType(Property::Index index) const
109 return Property::NONE;
112 void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property )
117 Property::Value CustomObject::GetDefaultProperty(Property::Index index) const
119 return Property::Value();
122 void CustomObject::InstallSceneObjectProperty( PropertyBase& newProperty, const std::string& name, unsigned int index )
124 if( NULL != mUpdateObject )
126 // mUpdateObject is being used in a separate thread; queue a message to add the property
127 InstallCustomPropertyMessage( Stage::GetCurrent()->GetUpdateInterface(), *mUpdateObject, newProperty ); // Message takes ownership
131 CustomObject::~CustomObject()
133 // Guard to allow handle destruction after Core has been destroyed
134 if( Stage::IsInstalled() )
136 if( NULL != mUpdateObject )
138 RemoveObjectMessage( Stage::GetCurrent()->GetUpdateManager(), mUpdateObject );
139 mUpdateObject = NULL; // object is about to be destroyed
144 CustomObject::CustomObject()
146 PropertyOwner* updateObject = PropertyOwner::New();
148 // Pass ownership to the update-thread
149 AddObjectMessage( Stage::GetCurrent()->GetUpdateManager(), updateObject );
151 // Keep as const since this should only be modified from update-thread
152 mUpdateObject = updateObject;
155 } // namespace Internal