(FrameCallback) All values now local & baking of the value supported
[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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/math/matrix.h>
24 #include <dali/public-api/math/vector3.h>
25
26 namespace Dali
27 {
28
29 namespace Internal DALI_INTERNAL
30 {
31 class UpdateProxy;
32 }
33
34 /**
35  * @brief This class is used to access data of the actors from the update-thread.
36  *
37  * The Actor API _CANNOT_ be called directly from the update-thread.
38  * This class can be used as a proxy to that required Actor data.
39  * An actor's data can be accessed using the Actor's Unique ID.
40  * The unique ID should be passed to the callback using this class in a thread-safe manner
41  * (as you cannot call Actor::GetId from the update-thread).
42  */
43 class DALI_CORE_API UpdateProxy
44 {
45 public:
46
47   /**
48    * @brief Given the Actor ID, this retrieves that Actor's local position.
49    * @param[in]   id        The Actor ID
50    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
51    * @return Whether the method call was successful or not.
52    */
53   bool GetPosition( unsigned int id, Vector3& position ) const;
54
55   /**
56    * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
57    * @param[in]  id        The Actor ID
58    * @param[in]  position  The position to set
59    * @return Whether the method call was successful or not.
60    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
61    */
62   bool SetPosition( unsigned int id, const Vector3& position );
63
64   /**
65    * @brief Allows baking an Actor's local position from the Frame callback function.
66    * @param[in]  id        The Actor ID
67    * @param[in]  position  The position to bake
68    * @return Whether the method call was successful or not.
69    * @note The value is saved so will cause undesired effects if this property is being animated.
70    */
71   bool BakePosition( unsigned int id, const Vector3& position );
72
73   /**
74    * @brief Given the Actor ID, this retrieves that Actor's size.
75    * @param[in]   id    The Actor ID
76    * @param[out]  size  Set to the Actor's current size, if Actor ID is valid
77    * @return Whether the method call was successful or not.
78    */
79   bool GetSize( unsigned int id, Vector3& size ) const;
80
81   /**
82    * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
83    * @param[in]  id    The Actor ID
84    * @param[in]  size  The size to set
85    * @return Whether the method call was successful or not.
86    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
87    */
88   bool SetSize( unsigned int id, const Vector3& size );
89
90   /**
91    * @brief Allows baking an Actor's size from the Frame callback function.
92    * @param[in]  id    The Actor ID
93    * @param[in]  size  The size to bake
94    * @return Whether the method call was successful or not.
95    * @note The value is saved so will cause undesired effects if this property is being animated.
96    */
97   bool BakeSize( unsigned int id, const Vector3& size );
98
99   /**
100    * @brief Given the Actor ID, this retrieves that Actor's local position and size.
101    * @param[in]   id        The Actor ID
102    * @param[out]  position  Set to the Actor's current position, if Actor ID is valid
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 GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
107
108   /**
109    * @brief Given the Actor ID, this retrieves that Actor's local scale.
110    * @param[in]   id     The Actor ID
111    * @param[out]  scale  Set to the Actor's current scale, if Actor ID is valid
112    * @return Whether the method call was successful or not.
113    */
114   bool GetScale( unsigned int id, Vector3& scale ) const;
115
116   /**
117    * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
118    * @param[in]  id     The Actor ID
119    * @param[in]  scale  The scale to set
120    * @return Whether the method call was successful or not.
121    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
122    */
123   bool SetScale( unsigned int id, const Vector3& scale );
124
125   /**
126    * @brief Allows baking an Actor's local scale from the Frame callback function.
127    * @param[in]  id     The Actor ID
128    * @param[in]  scale  The scale to bake
129    * @return Whether the method call was successful or not.
130    * @note The value is saved so will cause undesired effects if this property is being animated.
131    */
132   bool BakeScale( unsigned int id, const Vector3& scale );
133
134   /**
135    * @brief Given the Actor ID, this retrieves that Actor's local color.
136    * @param[in]   id     The Actor ID
137    * @param[out]  color  Set to the Actor's current color, if Actor ID is valid
138    * @return Whether the method call was successful or not.
139    */
140   bool GetColor( unsigned int id, Vector4& color ) const;
141
142   /**
143    * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
144    * @param[in]  id     The Actor ID
145    * @param[in]  color  The color to set
146    * @return Whether the method call was successful or not.
147    * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
148    */
149   bool SetColor( unsigned int id, const Vector4& color ) const;
150
151   /**
152    * @brief Allows baking an Actor's local color from the Frame callback function.
153    * @param[in]  id     The Actor ID
154    * @param[in]  color  The color to bake
155    * @return Whether the method call was successful or not.
156    * @note The value is saved so will cause undesired effects if this property is being animated.
157    */
158   bool BakeColor( unsigned int id, const Vector4& color ) const;
159
160 public: // Not intended for application developers
161
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
186   /// @cond internal
187   Internal::UpdateProxy& mImpl;
188   /// @endcond
189 };
190
191 } // namespace Dali
192
193 #endif // DALI_UPDATE_PROXY_H