Merge "(FrameCallback) Ensure setting a color is reset every frame" into devel/master
[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) 2018 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
32 namespace Internal DALI_INTERNAL
33 {
34 class UpdateProxy;
35 }
36
37 /**
38  * @brief This class is used to access data of the actors from the update-thread.
39  *
40  * The Actor API _CANNOT_ be called directly from the update-thread.
41  * This class can be used as a proxy to that required Actor data.
42  * An actor's data can be accessed using the Actor's Unique ID.
43  * The unique ID should be passed to the callback using this class in a thread-safe manner
44  * (as you cannot call Actor::GetId from the update-thread).
45  */
46 class DALI_CORE_API UpdateProxy
47 {
48 public:
49
50   /**
51    * @brief Given the Actor ID, this retrieves that Actor's local position.
52    * @param[in]   id        The Actor ID
53    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
54    * @return Whether the method call was successful or not.
55    */
56   bool GetPosition( uint32_t id, Vector3& position ) const;
57
58   /**
59    * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
60    * @param[in]  id        The Actor ID
61    * @param[in]  position  The position to set
62    * @return Whether the method call was successful or not.
63    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
64    */
65   bool SetPosition( uint32_t id, const Vector3& position );
66
67   /**
68    * @brief Allows baking an Actor's local position from the Frame callback function.
69    * @param[in]  id        The Actor ID
70    * @param[in]  position  The position to bake
71    * @return Whether the method call was successful or not.
72    * @note The value is saved so will cause undesired effects if this property is being animated.
73    */
74   bool BakePosition( uint32_t id, const Vector3& position );
75
76   /**
77    * @brief Given the Actor ID, this retrieves that Actor's size.
78    * @param[in]   id    The Actor ID
79    * @param[out]  size  Set to the Actor's current size, if Actor ID is valid
80    * @return Whether the method call was successful or not.
81    */
82   bool GetSize( uint32_t id, Vector3& size ) const;
83
84   /**
85    * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
86    * @param[in]  id    The Actor ID
87    * @param[in]  size  The size to set
88    * @return Whether the method call was successful or not.
89    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
90    */
91   bool SetSize( uint32_t id, const Vector3& size );
92
93   /**
94    * @brief Allows baking an Actor's size from the Frame callback function.
95    * @param[in]  id    The Actor ID
96    * @param[in]  size  The size to bake
97    * @return Whether the method call was successful or not.
98    * @note The value is saved so will cause undesired effects if this property is being animated.
99    */
100   bool BakeSize( uint32_t id, const Vector3& size );
101
102   /**
103    * @brief Given the Actor ID, this retrieves that Actor's local position and size.
104    * @param[in]   id        The Actor ID
105    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
106    * @param[out]  size      Set to the Actor's current size, if Actor ID is valid
107    * @return Whether the method call was successful or not.
108    */
109   bool GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const;
110
111   /**
112    * @brief Given the Actor ID, this retrieves that Actor's local scale.
113    * @param[in]   id     The Actor ID
114    * @param[out]  scale  Set to the Actor's current scale, if Actor ID is valid
115    * @return Whether the method call was successful or not.
116    */
117   bool GetScale( uint32_t id, Vector3& scale ) const;
118
119   /**
120    * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
121    * @param[in]  id     The Actor ID
122    * @param[in]  scale  The scale to set
123    * @return Whether the method call was successful or not.
124    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
125    */
126   bool SetScale( uint32_t id, const Vector3& scale );
127
128   /**
129    * @brief Allows baking an Actor's local scale from the Frame callback function.
130    * @param[in]  id     The Actor ID
131    * @param[in]  scale  The scale to bake
132    * @return Whether the method call was successful or not.
133    * @note The value is saved so will cause undesired effects if this property is being animated.
134    */
135   bool BakeScale( uint32_t id, const Vector3& scale );
136
137   /**
138    * @brief Given the Actor ID, this retrieves that Actor's local color.
139    * @param[in]   id     The Actor ID
140    * @param[out]  color  Set to the Actor's current color, if Actor ID is valid
141    * @return Whether the method call was successful or not.
142    */
143   bool GetColor( uint32_t id, Vector4& color ) const;
144
145   /**
146    * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
147    * @param[in]  id     The Actor ID
148    * @param[in]  color  The color to set
149    * @return Whether the method call was successful or not.
150    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
151    */
152   bool SetColor( uint32_t id, const Vector4& color );
153
154   /**
155    * @brief Allows baking an Actor's local color from the Frame callback function.
156    * @param[in]  id     The Actor ID
157    * @param[in]  color  The color to bake
158    * @return Whether the method call was successful or not.
159    * @note The value is saved so will cause undesired effects if this property is being animated.
160    */
161   bool BakeColor( uint32_t id, const Vector4& color );
162
163 public: // Not intended for application developers
164
165   /// @cond internal
166
167   /**
168    * @brief Constructor.
169    * @param[in]  impl  A reference to the internal object.
170    */
171   DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
172
173   /**
174    * @brief Destructor.
175    */
176   DALI_INTERNAL ~UpdateProxy();
177
178   // Not copyable or movable
179
180   UpdateProxy( const UpdateProxy& )            = delete; ///< Deleted copy constructor
181   UpdateProxy( UpdateProxy&& )                 = delete; ///< Deleted move constructor
182   UpdateProxy& operator=( const UpdateProxy& ) = delete; ///< Deleted copy assignment operator
183   UpdateProxy& operator=( UpdateProxy&& )      = delete; ///< Deleted move assignment operator
184
185   /// @endcond
186
187 private:
188
189   /// @cond internal
190   Internal::UpdateProxy& mImpl;
191   /// @endcond
192 };
193
194 } // namespace Dali
195
196 #endif // DALI_UPDATE_PROXY_H