8a66dab000c2438d782bc23b3c2375cb8735061b
[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) 2020 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 size.
76    * @param[in]   id    The Actor ID
77    * @param[out]  size  Set to the Actor's current size, if Actor ID is valid
78    * @return Whether the method call was successful or not.
79    */
80   bool GetSize(uint32_t id, Vector3& size) const;
81
82   /**
83    * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
84    * @param[in]  id    The Actor ID
85    * @param[in]  size  The size 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 SetSize(uint32_t id, const Vector3& size);
90
91   /**
92    * @brief Allows baking an Actor's size from the Frame callback function.
93    * @param[in]  id    The Actor ID
94    * @param[in]  size  The size 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 BakeSize(uint32_t id, const Vector3& size);
99
100   /**
101    * @brief Given the Actor ID, this retrieves that Actor's local position and size.
102    * @param[in]   id        The Actor ID
103    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
104    * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
105    * @return Whether the method call was successful or not.
106    */
107   bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
108
109   /**
110    * @brief Given the Actor ID, this retrieves that Actor's local scale.
111    * @param[in]   id     The Actor ID
112    * @param[out]  scale  Set to the Actor's current scale, if Actor ID is valid
113    * @return Whether the method call was successful or not.
114    */
115   bool GetScale(uint32_t id, Vector3& scale) const;
116
117   /**
118    * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
119    * @param[in]  id     The Actor ID
120    * @param[in]  scale  The scale to set
121    * @return Whether the method call was successful or not.
122    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
123    */
124   bool SetScale(uint32_t id, const Vector3& scale);
125
126   /**
127    * @brief Allows baking an Actor's local scale from the Frame callback function.
128    * @param[in]  id     The Actor ID
129    * @param[in]  scale  The scale to bake
130    * @return Whether the method call was successful or not.
131    * @note The value is saved so will cause undesired effects if this property is being animated.
132    */
133   bool BakeScale(uint32_t id, const Vector3& scale);
134
135   /**
136    * @brief Given the Actor ID, this retrieves that Actor's local color.
137    * @param[in]   id     The Actor ID
138    * @param[out]  color  Set to the Actor's current color, if Actor ID is valid
139    * @return Whether the method call was successful or not.
140    */
141   bool GetColor(uint32_t id, Vector4& color) const;
142
143   /**
144    * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
145    * @param[in]  id     The Actor ID
146    * @param[in]  color  The color to set
147    * @return Whether the method call was successful or not.
148    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
149    */
150   bool SetColor(uint32_t id, const Vector4& color);
151
152   /**
153    * @brief Allows baking an Actor's local color from the Frame callback function.
154    * @param[in]  id     The Actor ID
155    * @param[in]  color  The color to bake
156    * @return Whether the method call was successful or not.
157    * @note The value is saved so will cause undesired effects if this property is being animated.
158    */
159   bool BakeColor(uint32_t id, const Vector4& color);
160
161 public: // Not intended for application developers
162   /// @cond internal
163
164   /**
165    * @brief Constructor.
166    * @param[in]  impl  A reference to the internal object.
167    */
168   DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
169
170   /**
171    * @brief Destructor.
172    */
173   DALI_INTERNAL ~UpdateProxy();
174
175   // Not copyable or movable
176
177   UpdateProxy(const UpdateProxy&) = delete;            ///< Deleted copy constructor
178   UpdateProxy(UpdateProxy&&)      = delete;            ///< Deleted move constructor
179   UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
180   UpdateProxy& operator=(UpdateProxy&&) = delete;      ///< Deleted move assignment operator
181
182   /// @endcond
183
184 private:
185   /// @cond internal
186   Internal::UpdateProxy& mImpl;
187   /// @endcond
188 };
189
190 } // namespace Dali
191
192 #endif // DALI_UPDATE_PROXY_H