Synchronous Set/Get behaviour for default properties
[platform/core/uifw/dali-core.git] / dali / internal / event / object / custom-object-internal.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/object/custom-object-internal.h>
20
21 // INTERNAL INCLUDES
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/manager/update-manager.h>
26 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
27
28 using Dali::Internal::SceneGraph::PropertyOwner;
29 using Dali::Internal::SceneGraph::PropertyBase;
30 using Dali::Internal::SceneGraph::UpdateManager;
31 using Dali::Internal::SceneGraph::AnimatableProperty;
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 CustomObject* CustomObject::New()
40 {
41   return new CustomObject();
42 }
43
44 const SceneGraph::PropertyOwner* CustomObject::GetSceneObject() const
45 {
46   return mUpdateObject;
47 }
48
49 const PropertyBase* CustomObject::GetSceneObjectAnimatableProperty( Property::Index index ) const
50 {
51   CustomPropertyMetadata* custom = FindCustomProperty( index );
52   DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
53   return custom->GetSceneGraphProperty();
54 }
55
56 const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::Index index ) const
57 {
58   return GetSceneObjectAnimatableProperty( index );
59 }
60
61 unsigned int CustomObject::GetDefaultPropertyCount() const
62 {
63   return 0u;
64 }
65
66 void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
67 {
68 }
69
70 const char* CustomObject::GetDefaultPropertyName( Property::Index index ) const
71 {
72   return NULL;
73 }
74
75 Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const
76 {
77   return Property::INVALID_INDEX;
78 }
79
80 bool CustomObject::IsDefaultPropertyWritable(Property::Index index) const
81 {
82   return false;
83 }
84
85 bool CustomObject::IsDefaultPropertyAnimatable(Property::Index index) const
86 {
87   return false;
88 }
89
90 bool CustomObject::IsDefaultPropertyAConstraintInput( Property::Index index ) const
91 {
92   return false;
93 }
94
95 Property::Type CustomObject::GetDefaultPropertyType(Property::Index index) const
96 {
97   return Property::NONE;
98 }
99
100 void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property )
101 {
102   // do nothing
103 }
104
105 Property::Value CustomObject::GetDefaultProperty(Property::Index index) const
106 {
107   return Property::Value();
108 }
109
110 Property::Value CustomObject::GetDefaultPropertyCurrentValue( Property::Index index ) const
111 {
112   return Property::Value();
113 }
114
115 CustomObject::~CustomObject()
116 {
117   // Guard to allow handle destruction after Core has been destroyed
118   if( Stage::IsInstalled() )
119   {
120     if( NULL != mUpdateObject )
121     {
122       RemoveObjectMessage( GetEventThreadServices().GetUpdateManager(), mUpdateObject );
123       mUpdateObject = NULL; // object is about to be destroyed
124     }
125   }
126 }
127
128 CustomObject::CustomObject()
129 {
130   PropertyOwner* updateObject = PropertyOwner::New();
131
132   // Pass ownership to the update-thread
133   AddObjectMessage( GetEventThreadServices().GetUpdateManager(), updateObject );
134
135   // Keep as const since this should only be modified from update-thread
136   mUpdateObject = updateObject;
137 }
138
139 } // namespace Internal
140
141 } // namespace Dali