1 #ifndef DALI_UPDATE_PROXY_H
2 #define DALI_UPDATE_PROXY_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
32 namespace Internal DALI_INTERNAL
38 * @brief This class is used to access data of the actors from the update-thread.
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).
46 class DALI_CORE_API UpdateProxy
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.
56 bool GetPosition( uint32_t id, Vector3& position ) const;
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.
65 bool SetPosition( uint32_t id, const Vector3& position );
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.
74 bool BakePosition( uint32_t id, const Vector3& position );
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.
82 bool GetSize( uint32_t id, Vector3& size ) const;
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.
91 bool SetSize( uint32_t id, const Vector3& size );
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.
100 bool BakeSize( uint32_t id, const Vector3& size );
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.
109 bool GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const;
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.
117 bool GetScale( uint32_t id, Vector3& scale ) const;
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.
126 bool SetScale( uint32_t id, const Vector3& scale );
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.
135 bool BakeScale( uint32_t id, const Vector3& scale );
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.
143 bool GetColor( uint32_t id, Vector4& color ) const;
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.
152 bool SetColor( uint32_t id, const Vector4& color );
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.
161 bool BakeColor( uint32_t id, const Vector4& color );
163 public: // Not intended for application developers
168 * @brief Constructor.
169 * @param[in] impl A reference to the internal object.
171 DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
176 DALI_INTERNAL ~UpdateProxy();
178 // Not copyable or movable
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
190 Internal::UpdateProxy& mImpl;
196 #endif // DALI_UPDATE_PROXY_H