Remove obsolete and non functional SizeChanged signal from actor
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / cluster / cluster-style-impl.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // INTERNAL INCLUDES
19 #include <dali/public-api/object/ref-object.h>
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/math/vector3.h>
22 #include <dali/public-api/object/base-object.h>
23 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 class ClusterStyle;
35
36 typedef IntrusivePtr<ClusterStyle>       ClusterStylePtr;
37
38 /**
39  * ClusterStyle internal implementation
40  */
41 class ClusterStyle : public Dali::BaseObject
42 {
43 public:
44
45   /**
46    * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren
47    */
48   unsigned int GetMaximumNumberOfChildren() const;
49
50   /**
51    * @copydoc Toolkit::ClusterStyle::ApplyStyle
52    */
53   virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
54
55   /**
56    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
57    */
58   virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
59
60   /**
61    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
62    */
63   virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
64
65   /**
66     * Set the size of cluster
67     */
68   void SetClusterSize( const Vector3& clusterSize );
69
70 protected:
71
72   /**
73    * Set the maximum number of children this Style can handle.
74    * @param[in] The maximum number of children.
75    */
76   void SetMaximumNumberOfChildren(unsigned int children);
77
78   /**
79    * Set the title properties
80    * @param[in] relativePosition Relative position of the title
81    * @param[in] offsetPosition Offset position of the title
82    * @param[in] size The size of the title
83    */
84   void SetTitleProperties(const Vector3& relativePosition,
85                           const Vector3& offsetPosition,
86                           const Vector3& size);
87
88   /**
89    * Set the background properties
90    * @param[in] relativePosition Relative position of the background
91    * @param[in] offsetPosition Offset position of the background
92    * @param[in] size The size of the title
93    */
94   void SetBackgroundProperties(const Vector3& relativePosition,
95                                const Vector3& offsetPosition,
96                                const Vector3& size);
97
98   /**
99    * Get the size of cluster.
100    * @return the cluster size
101    */
102    Vector3 GetClusterSize() const;
103
104    /**
105     * Apply the given position & size to the actor
106     * @param[in] position The target position
107     * @param[in] size The target size
108     * @param[in] size The size to resize to
109     * @param[in] alpha The alpha function to use.
110     * @param[in] durationSeconds The time period to apply this style.
111     */
112    void Apply( Actor actor,
113                const Vector3& position,
114                const Vector3& size,
115                AlphaFunction alpha,
116                const TimePeriod& durationSeconds);
117    /**
118     * Apply the given position & size to the actor
119     * @param[in] actor The actor to apply the changes
120     * @param[in] position The target position
121     * @param[in] size The target size
122     * @param[in] rotation The target Quaternion value
123     * @param[in] scale The target scale
124     * @param[in] alpha The alpha function to use.
125     * @param[in] durationSeconds The time period to apply this style.
126     */
127    void Apply( Actor actor,
128                const Vector3& position,
129                const Vector3& size,
130                const Quaternion& rotation,
131                const Vector3& scale,
132                AlphaFunction alpha,
133                const TimePeriod& durationSeconds);
134
135 protected:
136
137   /**
138    * Protected constructor see ClusterStyle::New().
139    */
140   ClusterStyle();
141
142   /**
143    * A reference counted object may only be deleted by calling Unreference()
144    */
145   virtual ~ClusterStyle();
146
147 protected:
148
149   unsigned int mMaxChildren;                      ///< Maximum number of children that this style supports
150   Vector3 mTitlePositionRelative;                 ///< Title's position relative to size of cluster
151   Vector3 mTitlePositionOffset;                   ///< Title's position offset
152   Vector3 mTitleSize;                             ///< Title's size relative to size of cluster
153   Vector3 mBackgroundPositionRelative;            ///< Background's position relative to size of cluster
154   Vector3 mBackgroundPositionOffset;              ///< Background's position offset
155   Vector3 mBackgroundSize;                        ///< Background's size relative to size of cluster
156   Vector3 mClusterSize;                           ///< The size of cluster
157 };
158
159 /**
160  * ClusterStyleStandard internal implementation
161  */
162 class ClusterStyleStandard : public ClusterStyle
163 {
164 public:
165
166   typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
167
168 public:
169
170   /**
171    * Create a new cluster style.
172    * @param[in] style The style type to create.
173    * @return A smart-pointer to the newly allocated ClusterStyle.
174    */
175   static ClusterStylePtr New(StyleType style);
176
177 public:
178
179   /**
180    * @copydoc Toolkit::ClusterStyle::ApplyStyle
181    */
182   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
183
184 private:
185
186   /**
187    * Set the relative sizes of the children
188    * @param[in] size The list of sizes for the children
189    */
190   void SetSizes(const float *sizes);
191
192   /**
193    * Set the relative positions of the children
194    * @param[in] positions The list of positions for the children
195    */
196   void SetPositions(const Vector3 *positions);
197
198 protected:
199
200   /**
201    * Protected constructor see ClusterStyleRandom::New().
202    */
203   ClusterStyleStandard(StyleType style);
204
205 private:
206
207   const float *mSizes;                            ///< List of sizes
208   const Vector3 *mPositions;                      ///< List of positions
209
210 };
211
212 /**
213  * ClusterStyleRandom internal implementation
214  */
215 class ClusterStyleRandom : public ClusterStyle
216 {
217 public:
218
219   /**
220    * Create a new cluster style.
221    * @return A smart-pointer to the newly allocated ClusterStyle.
222    */
223   static ClusterStylePtr New();
224
225 public:
226
227   /**
228    * @copydoc Toolkit::ClusterStyle::ApplyStyle
229    */
230   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
231
232 protected:
233
234   /**
235    * Protected constructor see ClusterStyleRandom::New().
236    */
237   ClusterStyleRandom();
238
239 private:
240
241 };
242
243 } // namespace Internal
244
245 // Helpers for public-api forwarding methods
246
247 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
248 {
249   DALI_ASSERT_ALWAYS(pub);
250
251   Dali::RefObject& handle = pub.GetBaseObject();
252
253   return static_cast<Internal::ClusterStyle&>(handle);
254 }
255
256 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
257 {
258   DALI_ASSERT_ALWAYS(pub);
259
260   const Dali::RefObject& handle = pub.GetBaseObject();
261
262   return static_cast<const Internal::ClusterStyle&>(handle);
263 }
264
265 } // namespace Toolkit
266
267 } // namespace Dali