f4e6eb5348af7b3a218a6647d0903500729c16f5
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / item-view / album-layout.h
1 #ifndef __DALI_TOOLKIT_ALBUM_LAYOUT_H__
2 #define __DALI_TOOLKIT_ALBUM_LAYOUT_H__
3
4 /*
5  * Copyright (c) 2014 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 /*
22 Note:This layout is customized for music player application, so there are some limitations:
23 1.This layout can only be used with 1280x720 mode (not 720x1280);
24 2.Need promram in application layer to support it(EX.SetNum).
25 */
26
27 // EXTERNAL INCLUDES
28 #include <boost/function.hpp>
29 #include <dali/public-api/common/vector-wrapper.h>
30
31 // INTERNAL INCLUDES
32 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
33
34 namespace Dali DALI_IMPORT_API
35 {
36
37 namespace Toolkit
38 {
39
40 class AlbumLayout;
41
42 typedef IntrusivePtr<AlbumLayout> AlbumLayoutPtr;
43
44 /**
45  * An ItemView layout which arranges items in a album.
46  */
47 class AlbumLayout : public ItemLayout
48 {
49 public:
50
51   typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
52   typedef boost::function<float   (const Vector3& layoutSize)> AlbumRadiusFunction;
53
54   /**
55    * Create a new album layout
56    */
57   static AlbumLayoutPtr New();
58
59   /**
60    * Virtual destructor.
61    */
62   virtual ~AlbumLayout();
63
64   /**
65    * Set the function used to calculate the item-size, for a given layout-size.
66    * @param[in] function The item-size function.
67    */
68   void SetItemSizeFunction(ItemSizeFunction function);
69
70   /**
71    * Get the function used to calculate the item-size
72    * @return The item-size function.
73    */
74   ItemSizeFunction GetItemSizeFunction() const;
75
76   /**
77    * Set the function used to calculate the album radius, for a given layout-size.
78    * @param[in] function The spiral-radius function.
79    */
80   void SetAlbumRadiusFunction(AlbumRadiusFunction function);
81
82   /**
83    * Get the function used to calculate the album radius.
84    * @return The album-radius function.
85    */
86   AlbumRadiusFunction GetAlbumRadiusFunction() const;
87
88   /**
89    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
90    * @param[in] scrollSpeed The scroll speed factor.
91    */
92   void SetScrollSpeedFactor(float scrollSpeed);
93
94   /**
95    * Set the maximum swipe speed in pixels per second.
96    * @param[in] speed The maximum swipe speed.
97    */
98   void SetMaximumSwipeSpeed(float speed);
99
100   /**
101    * Set the duration of the flick animation in second. This is the time taken to animate each
102    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
103    * by a swipe gesture.
104    * @pre durationSeconds must be greater than zero.
105    * @param[in] durationSeconds The duration of flick animation in seconds.
106    */
107   void SetItemFlickAnimationDuration(float durationSeconds);
108
109   /**
110    * @copydoc ItemLayout::GetScrollSpeedFactor()
111    */
112   virtual float GetScrollSpeedFactor() const;
113
114   /**
115    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
116    */
117   virtual float GetMaximumSwipeSpeed() const;
118
119   /**
120    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
121    */
122   virtual float GetItemFlickAnimationDuration() const;
123
124   /**
125    * Set the num of items.
126    * @param[in] num The number of items.
127    */
128   void SetNumOfItems(int num);
129
130   /**
131    * Get the num of items.
132    */
133   int GetNumOfItems() const;
134
135   /**
136    * Set the items num of stack.
137    * @param[in] num The number of items on the stack.
138    */
139   void SetStackNum(int num);
140
141   /**
142    * Get the items num of stack.
143    */
144   int GetStackNum() const;
145
146   /**
147    * Set the position of each item.
148    * @param[in] positionList The vector which contains the position for each item.
149    */
150   void SetPosition(std::vector<Vector3> positionList);
151
152   /**
153    * Get the position of each item.
154    */
155   std::vector<Vector3> GetPosition() const;
156
157   /**
158    * Set the rotation of each item.
159    * @param[in] rotation around X, the vector which contains the rotation for each item.
160    */
161   void SetRotationX(float rotation);
162
163   /**
164    * Set the rotation of each item.
165    */
166   float GetRotationX() const;
167
168   /**
169    * Set the rotation of each item.
170    * @param[in] rotationList around Z, the vector which contains the rotation for each item.
171    */
172   void SetRotationZ(std::vector<float> rotationList);
173
174   /**
175    * Get the rotation of each item.
176    */
177   std::vector<float> GetRotationZ() const;
178
179   /**
180    * Set the scale of each item.
181    * @param[in] scaleList The vector which contains the scale for each item.
182    */
183   void SetScale(std::vector<float> scaleList);
184
185   /**
186    * Get the scale of each item.
187    */
188   std::vector<float> GetScale() const;
189
190   /**
191    * Set the color of each item.
192    * @param[in] colorList The vector which contains the color for each item.
193    */
194   void SetColor(std::vector<Vector2> colorList);
195
196   /**
197    * Get the color of each item.
198    */
199   std::vector<Vector2> GetColor() const;
200
201   /**
202    * Set the position of center(selected) item.
203    * @param[in] pos The positon to set.
204    */
205   void SetCenterPosition(Vector3 pos);
206
207
208   /**
209    * Get the position of center(selected) item.
210    */
211   Vector3 GetCenterPosition() const;
212
213   /**
214    * Set the scale of center(selected) item.
215    * @param[in] scale The scale to set.
216    */
217   void SetCenterScale(float scale);
218
219   /**
220    * Get the scale of center(selected) item.
221    */
222   float GetCenterScale() const;
223
224   /**
225     * Set the color of center(selected) item.
226     * @param[in] color The color to set.
227    */
228   void SetCenterColor(Vector2 color);
229
230   /**
231    * Get the color of center(selected) item.
232    */
233   Vector2 GetCenterColor() const;
234
235   /**
236     * Set the postion of stack item(right stack and left stack).
237     * @param[in] rightPos The position of right stack.
238     * @param[in] leftPos The position of left stack,.
239    */
240   void SetStackPosition(Vector3 rightPos, Vector3 leftPos);
241
242   /**
243    * Get the postion of right stack .
244    */
245   Vector3 GetRightStackPosition() const;
246
247   /**
248    * Get the postion of left stack .
249    */
250   Vector3 GetLeftStackPosition() const;
251
252   /**
253     * Set the scale of stack item(right stack and left stack).
254     * @param[in] rightScale The scale of right stack.
255     * @param[in] leftScale The scale of left stack,.
256    */
257   void SetStackScale(float rightScale, float leftScale);
258
259   /**
260    * Get the scale of right stack.
261    */
262   float GetRightStackScale() const;
263
264   /**
265    * Get the scale of left stack.
266    */
267   float GetLeftStackScale() const;
268
269   /**
270     * Set the color of stack item(right stack and left stack).
271     * @param[in] rightColor The color of right stack.
272     * @param[in] leftColor The color of left stack.
273    */
274   void SetStackColor(Vector2 rightColor, Vector2 leftColor);
275
276   /**
277     * Get the color of right stack.
278     */
279   Vector2 GetRightStackColor() const;
280
281   /**
282    * Get the color of left stack.
283    */
284   Vector2 GetLeftStackColor() const;
285
286 private:
287
288   /**
289    * @copydoc ItemLayout::GetMinimumLayoutPosition()
290    */
291   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
292
293   /**
294    * @copydoc ItemLayout::GetClosestAnchorPosition()
295    */
296   virtual float GetClosestAnchorPosition(float layoutPosition) const;
297
298   /**
299    * @copydoc ItemLayout::GetItemScrollToPosition()
300    */
301   virtual float GetItemScrollToPosition(unsigned int itemId) const;
302
303   /**
304    * @copydoc ItemLayout::GetItemsWithinArea()
305    */
306   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
307
308   /**
309    * @copydoc ItemLayout::GetReserveItemCount()
310    */
311   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
312
313   /**
314    * @copydoc ItemLayout::GetItemSize()
315    */
316   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
317
318   /**
319    * @copydoc ItemLayout::GetResizeAnimation()
320    */
321   virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
322
323   /**
324    * @copydoc ItemLayout::GetPositionConstraint()
325    */
326   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
327
328   /**
329    * @copydoc ItemLayout::GetRotationConstraint()
330    */
331   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
332
333   /**
334    * @copydoc ItemLayout::GetScaleConstraint()
335    */
336   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
337
338   /**
339    * @copydoc ItemLayout::GetColorConstraint()
340    */
341   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
342
343   /**
344    * @copydoc ItemLayout::GetVisibilityConstraint()
345    */
346   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
347
348   /**
349    * @copydoc ItemLayout::GetScrollDirection()
350    */
351   virtual Degree GetScrollDirection() const;
352
353 protected:
354
355   /**
356    * Protected constructor; see also AlbumLayout::New()
357    */
358   AlbumLayout();
359
360 private:
361
362   struct Impl;
363   Impl* mImpl;
364 };
365
366 } // namespace Toolkit
367
368 } // namespace Dali
369
370 #endif // __DALI_TOOLKIT_ALBUM_LAYOUT_H__