[Tizen] Not execute the remove callback
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / property-component-accessor.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/update/common/animatable-property.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 /**
30  * A wrapper class for getting/setting a float component of another property.
31  * Animators use this instead of accessing properties directly.
32  */
33 template<typename PropertyType>
34 class PropertyComponentAccessorX
35 {
36 public:
37   /**
38    * Create a property component.
39    * @param [in] property The property which holds a float component.
40    */
41   PropertyComponentAccessorX(SceneGraph::PropertyBase* property)
42   : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
43   {
44   }
45
46   /**
47    * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class.
48    */
49   ~PropertyComponentAccessorX() = default;
50
51   /**
52    * Query whether the accessor is set.
53    * @return True if set.
54    */
55   bool IsSet() const
56   {
57     return mProperty != nullptr;
58   }
59
60   /**
61    * Reset the property accessor
62    * @post Calling any other PropertyComponentAccessorX is invalid.
63    */
64   void Reset()
65   {
66     mProperty = nullptr;
67   }
68
69   /**
70    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
71    */
72   bool IsClean() const
73   {
74     return mProperty->IsClean();
75   }
76
77   /**
78    * Read access to the property.
79    * @param [in] bufferIndex The current update buffer index.
80    */
81   float Get(BufferIndex bufferIndex) const
82   {
83     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr");
84     return mProperty->Get(bufferIndex).x; // X Component only!
85   }
86
87   /**
88    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
89    */
90   void Set(BufferIndex bufferIndex, float value) const
91   {
92     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr");
93     mProperty->SetX(bufferIndex, value);
94   }
95
96   /**
97    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
98    */
99   void Bake(BufferIndex bufferIndex, float value) const
100   {
101     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr");
102     mProperty->BakeX(bufferIndex, value);
103   }
104
105 private:
106   // Undefined
107   PropertyComponentAccessorX()                                           = delete;
108   PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
109   PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
110
111 private:
112   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
113 };
114
115 /**
116  * A wrapper class for getting/setting a float component of another property.
117  * Animators use this instead of accessing properties directly.
118  */
119 template<typename PropertyType>
120 class PropertyComponentAccessorY
121 {
122 public:
123   /**
124    * Create a property component.
125    * @param [in] property The property which holds a float component.
126    */
127   PropertyComponentAccessorY(SceneGraph::PropertyBase* property)
128   : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
129   {
130   }
131
132   /**
133    * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class.
134    */
135   ~PropertyComponentAccessorY() = default;
136
137   /**
138    * Query whether the accessor is set.
139    * @return True if set.
140    */
141   bool IsSet() const
142   {
143     return mProperty != nullptr;
144   }
145
146   /**
147    * Reset the property accessor
148    * @post Calling any other PropertyComponentAccessorY is invalid.
149    */
150   void Reset()
151   {
152     mProperty = nullptr;
153   }
154
155   /**
156    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
157    */
158   bool IsClean() const
159   {
160     return mProperty->IsClean();
161   }
162
163   /**
164    * Read access to the property.
165    * @param [in] bufferIndex The current update buffer index.
166    */
167   float Get(BufferIndex bufferIndex) const
168   {
169     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr");
170     return mProperty->Get(bufferIndex).y; // Y Component only!
171   }
172
173   /**
174    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
175    */
176   void Set(BufferIndex bufferIndex, float value) const
177   {
178     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr");
179     mProperty->SetY(bufferIndex, value);
180   }
181
182   /**
183    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
184    */
185   void Bake(BufferIndex bufferIndex, float value) const
186   {
187     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr");
188     mProperty->BakeY(bufferIndex, value);
189   }
190
191 private:
192   // Undefined
193   PropertyComponentAccessorY()                                           = delete;
194   PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
195   PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
196
197 private:
198   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
199 };
200
201 /**
202  * A wrapper class for getting/setting a float component of another property.
203  * Animators use this instead of accessing properties directly.
204  */
205 template<typename PropertyType>
206 class PropertyComponentAccessorZ
207 {
208 public:
209   /**
210    * Create a property component.
211    * @param [in] property The property which holds a float component.
212    */
213   PropertyComponentAccessorZ(SceneGraph::PropertyBase* property)
214   : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
215   {
216   }
217
218   /**
219    * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class.
220    */
221   ~PropertyComponentAccessorZ() = default;
222
223   /**
224    * Query whether the accessor is set.
225    * @return True if set.
226    */
227   bool IsSet() const
228   {
229     return mProperty != nullptr;
230   }
231
232   /**
233    * Reset the property accessor
234    * @post Calling any other PropertyComponentAccessorZ is invalid.
235    */
236   void Reset()
237   {
238     mProperty = nullptr;
239   }
240
241   /**
242    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
243    */
244   bool IsClean() const
245   {
246     return mProperty->IsClean();
247   }
248
249   /**
250    * Read access to the property.
251    * @param [in] bufferIndex The current update buffer index.
252    */
253   float Get(BufferIndex bufferIndex) const
254   {
255     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr");
256     return mProperty->Get(bufferIndex).z; // Z Component only!
257   }
258
259   /**
260    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
261    */
262   void Set(BufferIndex bufferIndex, float value) const
263   {
264     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr");
265     mProperty->SetZ(bufferIndex, value);
266   }
267
268   /**
269    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
270    */
271   void Bake(BufferIndex bufferIndex, float value) const
272   {
273     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr");
274     mProperty->BakeZ(bufferIndex, value);
275   }
276
277 private:
278   // Undefined
279   PropertyComponentAccessorZ()                                           = delete;
280   PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
281   PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
282
283 private:
284   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
285 };
286
287 /**
288  * A wrapper class for getting/setting a float component of another property.
289  * Animators use this instead of accessing properties directly.
290  */
291 template<typename PropertyType>
292 class PropertyComponentAccessorW
293 {
294 public:
295   /**
296    * Create a property component.
297    * @param [in] property The property which holds a float component.
298    */
299   PropertyComponentAccessorW(SceneGraph::PropertyBase* property)
300   : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
301   {
302   }
303
304   /**
305    * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class.
306    */
307   ~PropertyComponentAccessorW() = default;
308
309   /**
310    * Query whether the accessor is set.
311    * @return True if set.
312    */
313   bool IsSet() const
314   {
315     return mProperty != nullptr;
316   }
317
318   /**
319    * Reset the property accessor
320    * @post Calling any other PropertyComponentAccessorW is invalid.
321    */
322   void Reset()
323   {
324     mProperty = nullptr;
325   }
326
327   /**
328    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
329    */
330   bool IsClean() const
331   {
332     return mProperty->IsClean();
333   }
334
335   /**
336    * Read access to the property.
337    * @param [in] bufferIndex The current update buffer index.
338    */
339   float Get(BufferIndex bufferIndex) const
340   {
341     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr");
342     return mProperty->Get(bufferIndex).w; // W Component only!
343   }
344
345   /**
346    * @copydoc SceneGraph::AnimatableProperty<float>::Set()
347    */
348   void Set(BufferIndex bufferIndex, float value) const
349   {
350     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr");
351     mProperty->SetW(bufferIndex, value);
352   }
353
354   /**
355    * @copydoc SceneGraph::AnimatableProperty<float>::Bake()
356    */
357   void Bake(BufferIndex bufferIndex, float value) const
358   {
359     DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr");
360     mProperty->BakeW(bufferIndex, value);
361   }
362
363 private:
364   // Undefined
365   PropertyComponentAccessorW()                                           = delete;
366   PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
367   PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
368
369 private:
370   SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
371 };
372
373 } // namespace Internal
374
375 } // namespace Dali
376
377 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H