Follow the include-order coding conventions
[platform/core/uifw/dali-toolkit.git] / 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 // EXTERNAL 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
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class ClusterStyle;
37
38 typedef IntrusivePtr<ClusterStyle>       ClusterStylePtr;
39
40 /**
41  * ClusterStyle internal implementation
42  */
43 class ClusterStyle : public Dali::BaseObject
44 {
45 public:
46
47   /**
48    * @copydoc Toolkit::ClusterStyle::GetMaximumNumberOfChildren
49    */
50   unsigned int GetMaximumNumberOfChildren() const;
51
52   /**
53    * @copydoc Toolkit::ClusterStyle::ApplyStyle
54    */
55   virtual void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
56
57   /**
58    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
59    */
60   virtual void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
61
62   /**
63    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
64    */
65   virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
66
67   /**
68     * Set the size of cluster
69     */
70   void SetClusterSize( const Vector3& clusterSize );
71
72 protected:
73
74   /**
75    * Set the maximum number of children this Style can handle.
76    * @param[in] The maximum number of children.
77    */
78   void SetMaximumNumberOfChildren(unsigned int children);
79
80   /**
81    * Set the title properties
82    * @param[in] relativePosition Relative position of the title
83    * @param[in] offsetPosition Offset position of the title
84    * @param[in] size The size of the title
85    */
86   void SetTitleProperties(const Vector3& relativePosition,
87                           const Vector3& offsetPosition,
88                           const Vector3& size);
89
90   /**
91    * Set the background properties
92    * @param[in] relativePosition Relative position of the background
93    * @param[in] offsetPosition Offset position of the background
94    * @param[in] size The size of the title
95    */
96   void SetBackgroundProperties(const Vector3& relativePosition,
97                                const Vector3& offsetPosition,
98                                const Vector3& size);
99
100   /**
101    * Get the size of cluster.
102    * @return the cluster size
103    */
104    Vector3 GetClusterSize() const;
105
106    /**
107     * Apply the given position & size to the actor
108     * @param[in] position The target position
109     * @param[in] size The target size
110     * @param[in] size The size to resize to
111     * @param[in] alpha The alpha function to use.
112     * @param[in] durationSeconds The time period to apply this style.
113     */
114    void Apply( Actor actor,
115                const Vector3& position,
116                const Vector3& size,
117                AlphaFunction alpha,
118                const TimePeriod& durationSeconds);
119    /**
120     * Apply the given position & size to the actor
121     * @param[in] actor The actor to apply the changes
122     * @param[in] position The target position
123     * @param[in] size The target size
124     * @param[in] rotation The target Quaternion value
125     * @param[in] scale The target scale
126     * @param[in] alpha The alpha function to use.
127     * @param[in] durationSeconds The time period to apply this style.
128     */
129    void Apply( Actor actor,
130                const Vector3& position,
131                const Vector3& size,
132                const Quaternion& rotation,
133                const Vector3& scale,
134                AlphaFunction alpha,
135                const TimePeriod& durationSeconds);
136
137 protected:
138
139   /**
140    * Protected constructor see ClusterStyle::New().
141    */
142   ClusterStyle();
143
144   /**
145    * A reference counted object may only be deleted by calling Unreference()
146    */
147   virtual ~ClusterStyle();
148
149 protected:
150
151   unsigned int mMaxChildren;                      ///< Maximum number of children that this style supports
152   Vector3 mTitlePositionRelative;                 ///< Title's position relative to size of cluster
153   Vector3 mTitlePositionOffset;                   ///< Title's position offset
154   Vector3 mTitleSize;                             ///< Title's size relative to size of cluster
155   Vector3 mBackgroundPositionRelative;            ///< Background's position relative to size of cluster
156   Vector3 mBackgroundPositionOffset;              ///< Background's position offset
157   Vector3 mBackgroundSize;                        ///< Background's size relative to size of cluster
158   Vector3 mClusterSize;                           ///< The size of cluster
159 };
160
161 /**
162  * ClusterStyleStandard internal implementation
163  */
164 class ClusterStyleStandard : public ClusterStyle
165 {
166 public:
167
168   typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
169
170 public:
171
172   /**
173    * Create a new cluster style.
174    * @param[in] style The style type to create.
175    * @return A smart-pointer to the newly allocated ClusterStyle.
176    */
177   static ClusterStylePtr New(StyleType style);
178
179 public:
180
181   /**
182    * @copydoc Toolkit::ClusterStyle::ApplyStyle
183    */
184   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
185
186 private:
187
188   /**
189    * Set the relative sizes of the children
190    * @param[in] size The list of sizes for the children
191    */
192   void SetSizes(const float *sizes);
193
194   /**
195    * Set the relative positions of the children
196    * @param[in] positions The list of positions for the children
197    */
198   void SetPositions(const Vector3 *positions);
199
200 protected:
201
202   /**
203    * Protected constructor see ClusterStyleRandom::New().
204    */
205   ClusterStyleStandard(StyleType style);
206
207 private:
208
209   const float *mSizes;                            ///< List of sizes
210   const Vector3 *mPositions;                      ///< List of positions
211
212 };
213
214 /**
215  * ClusterStyleRandom internal implementation
216  */
217 class ClusterStyleRandom : public ClusterStyle
218 {
219 public:
220
221   /**
222    * Create a new cluster style.
223    * @return A smart-pointer to the newly allocated ClusterStyle.
224    */
225   static ClusterStylePtr New();
226
227 public:
228
229   /**
230    * @copydoc Toolkit::ClusterStyle::ApplyStyle
231    */
232   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
233
234 protected:
235
236   /**
237    * Protected constructor see ClusterStyleRandom::New().
238    */
239   ClusterStyleRandom();
240
241 private:
242
243 };
244
245 } // namespace Internal
246
247 // Helpers for public-api forwarding methods
248
249 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
250 {
251   DALI_ASSERT_ALWAYS(pub);
252
253   Dali::RefObject& handle = pub.GetBaseObject();
254
255   return static_cast<Internal::ClusterStyle&>(handle);
256 }
257
258 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
259 {
260   DALI_ASSERT_ALWAYS(pub);
261
262   const Dali::RefObject& handle = pub.GetBaseObject();
263
264   return static_cast<const Internal::ClusterStyle&>(handle);
265 }
266
267 } // namespace Toolkit
268
269 } // namespace Dali