Include required header files directly rather than through dali.h
[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) = 0;
59
60   /**
61    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
62    */
63   virtual void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds) = 0;
64
65 protected:
66
67   /**
68    * Set the maximum number of children this Style can handle.
69    * @param[in] The maximum number of children.
70    */
71   void SetMaximumNumberOfChildren(unsigned int children);
72
73   /**
74    * Set the title properties
75    * @param[in] relativePosition Relative position of the title
76    * @param[in] offsetPosition Offset position of the title
77    * @param[in] size The size of the title
78    */
79   void SetTitleProperties(const Vector3& relativePosition,
80                           const Vector3& offsetPosition,
81                           const Vector3& size);
82
83   /**
84    * Set the background properties
85    * @param[in] relativePosition Relative position of the background
86    * @param[in] offsetPosition Offset position of the background
87    * @param[in] size The size of the title
88    */
89   void SetBackgroundProperties(const Vector3& relativePosition,
90                                const Vector3& offsetPosition,
91                                const Vector3& size);
92
93 protected:
94
95   /**
96    * Protected constructor see ClusterStyle::New().
97    */
98   ClusterStyle();
99
100   /**
101    * A reference counted object may only be deleted by calling Unreference()
102    */
103   virtual ~ClusterStyle();
104
105 protected:
106
107   unsigned int mMaxChildren;                      ///< Maximum number of children that this style supports
108   Vector3 mTitlePositionRelative;                 ///< Title's position relative to size of cluster
109   Vector3 mTitlePositionOffset;                   ///< Title's position offset
110   Vector3 mTitleSize;                             ///< Title's size relative to size of cluster
111   Vector3 mBackgroundPositionRelative;            ///< Background's position relative to size of cluster
112   Vector3 mBackgroundPositionOffset;              ///< Background's position offset
113   Vector3 mBackgroundSize;                        ///< Background's size relative to size of cluster
114
115 };
116
117 /**
118  * ClusterStyleStandard internal implementation
119  */
120 class ClusterStyleStandard : public ClusterStyle
121 {
122 public:
123
124   typedef Toolkit::ClusterStyleStandard::StyleType StyleType;
125
126 public:
127
128   /**
129    * Create a new cluster style.
130    * @param[in] style The style type to create.
131    * @return A smart-pointer to the newly allocated ClusterStyle.
132    */
133   static ClusterStylePtr New(StyleType style);
134
135 public:
136
137   /**
138    * @copydoc Toolkit::ClusterStyle::ApplyStyle
139    */
140   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
141
142   /**
143    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
144    */
145   void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
146
147   /**
148    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
149    */
150   void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
151
152 private:
153
154   /**
155    * Set the relative sizes of the children
156    * @param[in] size The list of sizes for the children
157    */
158   void SetSizes(const float *sizes);
159
160   /**
161    * Set the relative positions of the children
162    * @param[in] positions The list of positions for the children
163    */
164   void SetPositions(const Vector3 *positions);
165
166 protected:
167
168   /**
169    * Protected constructor see ClusterStyleRandom::New().
170    */
171   ClusterStyleStandard(StyleType style);
172
173 private:
174
175   const float *mSizes;                            ///< List of sizes
176   const Vector3 *mPositions;                      ///< List of positions
177
178 };
179
180 /**
181  * ClusterStyleRandom internal implementation
182  */
183 class ClusterStyleRandom : public ClusterStyle
184 {
185 public:
186
187   /**
188    * Create a new cluster style.
189    * @return A smart-pointer to the newly allocated ClusterStyle.
190    */
191   static ClusterStylePtr New();
192
193 public:
194
195   /**
196    * @copydoc Toolkit::ClusterStyle::ApplyStyle
197    */
198   void ApplyStyle(Actor child, unsigned int index, AlphaFunction alpha, const TimePeriod& durationSeconds);
199
200   /**
201    * @copydoc Toolkit::ClusterStyle::ApplyStyleToBackground
202    */
203   void ApplyStyleToBackground(Actor background, AlphaFunction alpha, const TimePeriod& durationSeconds);
204
205   /**
206    * @copydoc Toolkit::ClusterStyle::ApplyStyleToTitle
207    */
208   void ApplyStyleToTitle(Actor title, AlphaFunction alpha, const TimePeriod& durationSeconds);
209
210 protected:
211
212   /**
213    * Protected constructor see ClusterStyleRandom::New().
214    */
215   ClusterStyleRandom();
216
217 private:
218
219 };
220
221 } // namespace Internal
222
223 // Helpers for public-api forwarding methods
224
225 inline Internal::ClusterStyle& GetImpl(Toolkit::ClusterStyle& pub)
226 {
227   DALI_ASSERT_ALWAYS(pub);
228
229   Dali::RefObject& handle = pub.GetBaseObject();
230
231   return static_cast<Internal::ClusterStyle&>(handle);
232 }
233
234 inline const Internal::ClusterStyle& GetImpl(const Toolkit::ClusterStyle& pub)
235 {
236   DALI_ASSERT_ALWAYS(pub);
237
238   const Dali::RefObject& handle = pub.GetBaseObject();
239
240   return static_cast<const Internal::ClusterStyle&>(handle);
241 }
242
243 } // namespace Toolkit
244
245 } // namespace Dali