[dali_1.3.40] Merge branch '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 // 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 position.
49    * @param[in]  id  The Actor ID
50    * @return If valid Actor ID, then the Actor's position is returned.
51    */
52   Vector3 GetPosition( unsigned int id ) const;
53
54   /**
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.
59    */
60   void SetPosition( unsigned int id, const Vector3& position );
61
62   /**
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.
66    */
67   const Vector3& GetSize( unsigned int id ) const;
68
69   /**
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.
74    */
75   void SetSize( unsigned int id, const Vector3& size );
76
77   /**
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
82    */
83   void GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
84
85   /**
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.
89    */
90   Vector4 GetWorldColor( unsigned int id ) const;
91
92   /**
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.
97    */
98   void SetWorldColor( unsigned int id, const Vector4& color ) const;
99
100   /**
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
105    */
106   void GetWorldMatrixAndSize( unsigned int id, Matrix& worldMatrix, Vector3& size ) const;
107
108   /**
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.
112    */
113   const Matrix& GetWorldMatrix( unsigned int id ) const;
114
115   /**
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).
123    */
124   void SetWorldMatrix( unsigned int id, const Matrix& worldMatrix );
125
126 public: // Not intended for application developers
127
128   /// @cond internal
129
130   /**
131    * @brief Constructor.
132    * @param[in]  impl  A reference to the internal object.
133    */
134   DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl );
135
136   /**
137    * @brief Destructor.
138    */
139   DALI_INTERNAL ~UpdateProxy();
140
141   // Not copyable or movable
142
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
147
148   /// @endcond
149
150 private:
151
152   /// @cond internal
153   Internal::UpdateProxy& mImpl;
154   /// @endcond
155 };
156
157 } // namespace Dali
158
159 #endif // DALI_UPDATE_PROXY_H