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 position.
49 * @param[in] id The Actor ID
50 * @return If valid Actor ID, then the Actor's position is returned.
52 Vector3 GetPosition( unsigned int id ) const;
55 * @brief Allows setting an Actor's position from the Frame callback function.
56 * @param[in] id The Actor ID
57 * @param[in] position The position to set.
58 * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
60 void SetPosition( unsigned int id, const Vector3& position );
63 * @brief Given the Actor ID, this retrieves that Actor's size.
64 * @param[in] id The Actor ID
65 * @return If valid Actor ID, then Actor's size is returned, otherwise Vector3::ZERO.
67 const Vector3& GetSize( unsigned int id ) const;
70 * @brief Allows setting an Actor's size from the Frame callback function.
71 * @param[in] id The Actor ID
72 * @param[in] size The size to set.
73 * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
75 void SetSize( unsigned int id, const Vector3& size );
78 * @brief Given the Actor ID, this retrieves that Actor's position and size.
79 * @param[in] id The Actor ID
80 * @param[out] position If valid Actor ID, then Actor's position is set
81 * @param[out] size If valid Actor ID, then Actor's size is set
83 void GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
86 * @brief Given the Actor ID, this retrieves that Actor's color.
87 * @param[in] id The Actor ID
88 * @return If valid Actor ID, then Actor's color is returned, otherwise Vector4::ZERO.
90 Vector4 GetWorldColor( unsigned int id ) const;
93 * @brief Allows setting an Actor's color from the Frame callback function.
94 * @param[in] id The Actor ID
95 * @param[in] color The color to set
96 * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
98 void SetWorldColor( unsigned int id, const Vector4& color ) const;
101 * @brief Given the Actor ID, this retrieves that Actor's world-matrix and size.
102 * @param[in] id The Actor ID
103 * @param[out] worldMatrix If valid Actor ID, then Actor's world matrix is set
104 * @param[out] size If valid Actor ID, then Actor's size is set
106 void GetWorldMatrixAndSize( unsigned int id, Matrix& worldMatrix, Vector3& size ) const;
109 * @brief Given the Actor ID, this retrieves that Actor's world-matrix.
110 * @param[in] id The Actor ID
111 * @return If valid Actor ID, then Actor's world matrix is returned, otherwise Matrix::IDENTITY.
113 const Matrix& GetWorldMatrix( unsigned int id ) const;
116 * @brief Allows the setting an Actor's world-matrix from the Frame callback function.
117 * @param[in] id The Actor ID
118 * @param[in] worldMatrix The world matrix to set.
119 * @note This will get reset to the internally calculated value in the next frame, so will have to be set again.
120 * @note This will only set the world matrix for that particular actor.
121 * The world matrices of the children will not change and will have to be manually changed in the callback
122 * as well (if required).
124 void SetWorldMatrix( unsigned int id, const Matrix& worldMatrix );
126 public: // Not intended for application developers
131 * @brief Constructor.
132 * @param[in] impl A reference to the internal object.
134 DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
139 DALI_INTERNAL ~UpdateProxy();
141 // Not copyable or movable
143 UpdateProxy( const UpdateProxy& ) = delete; ///< Deleted copy constructor
144 UpdateProxy( UpdateProxy&& ) = delete; ///< Deleted move constructor
145 UpdateProxy& operator=( const UpdateProxy& ) = delete; ///< Deleted copy assignment operator
146 UpdateProxy& operator=( UpdateProxy&& ) = delete; ///< Deleted move assignment operator
153 Internal::UpdateProxy& mImpl;
159 #endif // DALI_UPDATE_PROXY_H