Uniform map handling
[platform/core/uifw/dali-core.git] / dali / public-api / object / handle.cpp
1 /*
2  * Copyright (c) 2015 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/public-api/object/handle.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/active-constraint.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/object/property-conditions.h>
25 #include <dali/public-api/object/property-notification.h>
26 #include <dali/internal/event/animation/constraint-impl.h>
27 #include <dali/internal/event/common/object-impl.h>
28 #include <dali/internal/event/object/custom-object-internal.h>
29 #include <dali/integration-api/debug.h>
30
31 namespace Dali
32 {
33
34 Handle::Handle( Dali::Internal::Object* handle )
35 : BaseHandle(handle)
36 {
37 }
38
39
40 Handle::Handle()
41 {
42 }
43
44 Handle Handle::New()
45 {
46   return Handle( Internal::CustomObject::New() );
47 }
48
49 Handle::~Handle()
50 {
51 }
52
53 Handle::Handle( const Handle& handle )
54 : BaseHandle( handle )
55 {
56 }
57
58 Handle& Handle::operator=( const Handle& rhs )
59 {
60   if( this != &rhs )
61   {
62     BaseHandle::operator=(rhs);
63   }
64
65   return *this;
66 }
67
68 Handle Handle::DownCast( BaseHandle handle )
69 {
70   return Handle( dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()) );
71 }
72
73
74 bool Handle::Supports( Capability capability ) const
75 {
76   return GetImplementation(*this).Supports( capability );
77 }
78
79 unsigned int Handle::GetPropertyCount() const
80 {
81   return GetImplementation(*this).GetPropertyCount();
82 }
83
84 std::string Handle::GetPropertyName( Property::Index index ) const
85 {
86   return GetImplementation(*this).GetPropertyName( index );
87 }
88
89 Property::Index Handle::GetPropertyIndex( const std::string& name ) const
90 {
91   return GetImplementation(*this).GetPropertyIndex( name );
92 }
93
94 bool Handle::IsPropertyWritable( Property::Index index ) const
95 {
96   return GetImplementation(*this).IsPropertyWritable( index );
97 }
98
99 bool Handle::IsPropertyAnimatable( Property::Index index ) const
100 {
101   return GetImplementation(*this).IsPropertyAnimatable( index );
102 }
103
104 bool Handle::IsPropertyAConstraintInput( Property::Index index ) const
105 {
106   return GetImplementation(*this).IsPropertyAConstraintInput( index );
107 }
108
109 Property::Type Handle::GetPropertyType( Property::Index index ) const
110 {
111   return GetImplementation(*this).GetPropertyType( index );
112 }
113
114 void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue )
115 {
116   GetImplementation(*this).SetProperty( index, propertyValue );
117 }
118
119 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
120 {
121   return GetImplementation(*this).RegisterProperty( name, propertyValue );
122 }
123
124 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
125 {
126   return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
127 }
128
129 Property::Value Handle::GetProperty( Property::Index index ) const
130 {
131   return GetImplementation(*this).GetProperty( index );
132 }
133
134 void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
135 {
136   GetImplementation(*this).GetPropertyIndices( indices );
137 }
138
139 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
140                                                             const PropertyCondition& condition )
141 {
142   return GetImplementation(*this).AddPropertyNotification( index, -1, condition );
143 }
144
145 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
146                                                             int componentIndex,
147                                                             const PropertyCondition& condition )
148 {
149   return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition );
150 }
151
152 void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification )
153 {
154   GetImplementation(*this).RemovePropertyNotification( propertyNotification );
155 }
156
157 void Handle::RemovePropertyNotifications()
158 {
159   GetImplementation(*this).RemovePropertyNotifications();
160 }
161
162 ActiveConstraint Handle::ApplyConstraint( Constraint constraint )
163 {
164   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) );
165 }
166
167 ActiveConstraint Handle::ApplyConstraint( Constraint constraint, Handle weightObject )
168 {
169   return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject );
170 }
171
172 void Handle::RemoveConstraint(ActiveConstraint activeConstraint)
173 {
174   GetImplementation(*this).RemoveConstraint( activeConstraint );
175 }
176
177 void Handle::RemoveConstraints()
178 {
179   GetImplementation(*this).RemoveConstraints();
180 }
181
182 void Handle::RemoveConstraints( unsigned int tag )
183 {
184   GetImplementation(*this).RemoveConstraints( tag );
185 }
186
187 void Handle::AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName )
188 {
189   GetImplementation(*this).AddUniformMapping( propertyIndex, uniformName );
190 }
191
192 void Handle::RemoveUniformMapping( const std::string uniformName )
193 {
194   GetImplementation(*this).RemoveUniformMapping( uniformName );
195 }
196
197 namespace WeightObject
198 {
199
200 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
201
202 Handle New()
203 {
204   Handle handle = Handle::New();
205
206   handle.RegisterProperty( "weight", 0.0f );
207
208   return handle;
209 }
210
211 } // namespace WeightObject
212
213 } // namespace Dali