Added rotation support to frame-callback
[platform/core/uifw/dali-core.git] / dali / devel-api / update / update-proxy.h
1 #ifndef DALI_UPDATE_PROXY_H
2 #define DALI_UPDATE_PROXY_H
3
4 /*
5  * Copyright (c) 2023 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 // EXTERNAL INCLUDES
22 #include <cstdint>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/math/matrix.h>
27 #include <dali/public-api/math/vector3.h>
28
29 namespace Dali
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class UpdateProxy;
34 }
35
36 /**
37  * @brief This class is used to access data of the actors from the update-thread.
38  *
39  * The Actor API _CANNOT_ be called directly from the update-thread.
40  * This class can be used as a proxy to that required Actor data.
41  * An actor's data can be accessed using the Actor's Unique ID.
42  * The unique ID should be passed to the callback using this class in a thread-safe manner
43  * (as you cannot call Actor::GetId from the update-thread).
44  */
45 class DALI_CORE_API UpdateProxy
46 {
47 public:
48   /**
49    * @brief Given the Actor ID, this retrieves that Actor's local position.
50    * @param[in]   id        The Actor ID
51    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
52    * @return Whether the method call was successful or not.
53    */
54   bool GetPosition(uint32_t id, Vector3& position) const;
55
56   /**
57    * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
58    * @param[in]  id        The Actor ID
59    * @param[in]  position  The position to set
60    * @return Whether the method call was successful or not.
61    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
62    */
63   bool SetPosition(uint32_t id, const Vector3& position);
64
65   /**
66    * @brief Allows baking an Actor's local position from the Frame callback function.
67    * @param[in]  id        The Actor ID
68    * @param[in]  position  The position to bake
69    * @return Whether the method call was successful or not.
70    * @note The value is saved so will cause undesired effects if this property is being animated.
71    */
72   bool BakePosition(uint32_t id, const Vector3& position);
73
74   /**
75    * @brief Given the Actor ID, this retrieves that Actor's local orientation.
76    * @param[in]   id        The Actor ID
77    * @param[out]  orientation  Set to the Actor's current orientation, if Actor ID is valid
78    * @return Whether the method call was successful or not.
79    */
80   bool GetOrientation(uint32_t id, Quaternion& orientation) const;
81
82   /**
83    * @brief Allows setting an Actor's local orientation from the Frame callback function for the current frame only.
84    * @param[in]  id        The Actor ID
85    * @param[in]  orientation  The orientation to set
86    * @return Whether the method call was successful or not.
87    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
88    */
89   bool SetOrientation(uint32_t id, const Quaternion& orientation);
90
91   /**
92    * @brief Allows baking an Actor's local orientation from the Frame callback function.
93    * @param[in]  id        The Actor ID
94    * @param[in]  orientation  The orientation to bake
95    * @return Whether the method call was successful or not.
96    * @note The value is saved so will cause undesired effects if this property is being animated.
97    */
98   bool BakeOrientation(uint32_t id, const Quaternion& orientation);
99
100   /**
101    * @brief Given the Actor ID, this retrieves that Actor's size.
102    * @param[in]   id    The Actor ID
103    * @param[out]  size  Set to the Actor's current size, if Actor ID is valid
104    * @return Whether the method call was successful or not.
105    */
106   bool GetSize(uint32_t id, Vector3& size) const;
107
108   /**
109    * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
110    * @param[in]  id    The Actor ID
111    * @param[in]  size  The size to set
112    * @return Whether the method call was successful or not.
113    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
114    */
115   bool SetSize(uint32_t id, const Vector3& size);
116
117   /**
118    * @brief Allows baking an Actor's size from the Frame callback function.
119    * @param[in]  id    The Actor ID
120    * @param[in]  size  The size to bake
121    * @return Whether the method call was successful or not.
122    * @note The value is saved so will cause undesired effects if this property is being animated.
123    */
124   bool BakeSize(uint32_t id, const Vector3& size);
125
126   /**
127    * @brief Given the Actor ID, this retrieves that Actor's local position and size.
128    * @param[in]   id        The Actor ID
129    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
130    * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
131    * @return Whether the method call was successful or not.
132    */
133   bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
134
135   /**
136    * @brief Given the Actor ID, this retrieves that Actor's world position and size.
137    * @param[in]   id        The Actor ID
138    * @param[out]  position  Set to the Actor's current world position, if Actor ID is valid
139    * @param[out]  scale     Set to the Actor's current world scale, if Actor ID is valid
140    * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
141    * @return Whether the method call was successful or not.
142    */
143   bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
144
145   /**
146    * @brief Given the Actor ID, this retrieves that Actor's world transform properties and size.
147    * @param[in]   id        The Actor ID
148    * @param[out]  position  Set to the Actor's current world position, if Actor ID is valid
149    * @param[out]  scale     Set to the Actor's current world scale, if Actor ID is valid
150    * @param[out]  orientation Set to the Actor's current world orientation, if Actor ID is valid
151    * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
152    * @return Whether the method call was successful or not.
153    */
154   bool GetWorldTransformAndSize(uint32_t id, Vector3& position, Vector3& scale, Quaternion& orientation, Vector3& size) const;
155
156   /**
157    * @brief Given the Actor ID, this retrieves that Actor's local scale.
158    * @param[in]   id     The Actor ID
159    * @param[out]  scale  Set to the Actor's current scale, if Actor ID is valid
160    * @return Whether the method call was successful or not.
161    */
162   bool GetScale(uint32_t id, Vector3& scale) const;
163
164   /**
165    * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
166    * @param[in]  id     The Actor ID
167    * @param[in]  scale  The scale to set
168    * @return Whether the method call was successful or not.
169    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
170    */
171   bool SetScale(uint32_t id, const Vector3& scale);
172
173   /**
174    * @brief Allows baking an Actor's local scale from the Frame callback function.
175    * @param[in]  id     The Actor ID
176    * @param[in]  scale  The scale to bake
177    * @return Whether the method call was successful or not.
178    * @note The value is saved so will cause undesired effects if this property is being animated.
179    */
180   bool BakeScale(uint32_t id, const Vector3& scale);
181
182   /**
183    * @brief Given the Actor ID, this retrieves that Actor's local color.
184    * @param[in]   id     The Actor ID
185    * @param[out]  color  Set to the Actor's current color, if Actor ID is valid
186    * @return Whether the method call was successful or not.
187    */
188   bool GetColor(uint32_t id, Vector4& color) const;
189
190   /**
191    * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
192    * @param[in]  id     The Actor ID
193    * @param[in]  color  The color to set
194    * @return Whether the method call was successful or not.
195    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
196    */
197   bool SetColor(uint32_t id, const Vector4& color);
198
199   /**
200    * @brief Allows baking an Actor's local color from the Frame callback function.
201    * @param[in]  id     The Actor ID
202    * @param[in]  color  The color to bake
203    * @return Whether the method call was successful or not.
204    * @note The value is saved so will cause undesired effects if this property is being animated.
205    */
206   bool BakeColor(uint32_t id, const Vector4& color);
207
208 public: // Not intended for application developers
209   /// @cond internal
210
211   /**
212    * @brief Constructor.
213    * @param[in]  impl  A reference to the internal object.
214    */
215   DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
216
217   /**
218    * @brief Destructor.
219    */
220   DALI_INTERNAL ~UpdateProxy();
221
222   // Not copyable or movable
223
224   UpdateProxy(const UpdateProxy&) = delete;            ///< Deleted copy constructor
225   UpdateProxy(UpdateProxy&&)      = delete;            ///< Deleted move constructor
226   UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
227   UpdateProxy& operator=(UpdateProxy&&) = delete;      ///< Deleted move assignment operator
228
229   /// @endcond
230
231 private:
232   /// @cond internal
233   Internal::UpdateProxy& mImpl;
234   /// @endcond
235 };
236
237 } // namespace Dali
238
239 #endif // DALI_UPDATE_PROXY_H