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