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