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.
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>
29 namespace Internal DALI_INTERNAL
35 * @brief This class is used to access data of the actors from the update-thread.
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).
43 class DALI_CORE_API UpdateProxy
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.
53 bool GetPosition( unsigned int id, Vector3& position ) const;
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.
62 bool SetPosition( unsigned int id, const Vector3& position );
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.
71 bool BakePosition( unsigned int id, const Vector3& position );
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.
79 bool GetSize( unsigned int id, Vector3& size ) const;
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.
88 bool SetSize( unsigned int id, const Vector3& size );
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.
97 bool BakeSize( unsigned int id, const Vector3& size );
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.
106 bool GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
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.
114 bool GetScale( unsigned int id, Vector3& scale ) const;
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.
123 bool SetScale( unsigned int id, const Vector3& scale );
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.
132 bool BakeScale( unsigned int id, const Vector3& scale );
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.
140 bool GetColor( unsigned int id, Vector4& color ) const;
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.
149 bool SetColor( unsigned int id, const Vector4& color ) const;
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.
158 bool BakeColor( unsigned int id, const Vector4& color ) const;
160 public: // Not intended for application developers
165 * @brief Constructor.
166 * @param[in] impl A reference to the internal object.
168 DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
173 DALI_INTERNAL ~UpdateProxy();
175 // Not copyable or movable
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
187 Internal::UpdateProxy& mImpl;
193 #endif // DALI_UPDATE_PROXY_H