Add 'ExclusiveArch: armv7l' limit build to arm architecture
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / item-view / spiral-layout.h
1 #ifndef __DALI_TOOLKIT_SPIRAL_LAYOUT_H__
2 #define __DALI_TOOLKIT_SPIRAL_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 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22
23 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Toolkit
29 {
30
31 class SpiralLayout;
32
33 typedef IntrusivePtr<SpiralLayout> SpiralLayoutPtr;
34
35 /**
36  * An ItemView layout which arranges items in a spiral.
37  */
38 class SpiralLayout : public ItemLayout
39 {
40 public:
41
42   typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
43   typedef boost::function<float   (const Vector3& layoutSize)> SpiralRadiusFunction;
44
45   /**
46    * Create a new spiral layout
47    */
48   static SpiralLayoutPtr New();
49
50   /**
51    * Virtual destructor.
52    */
53   virtual ~SpiralLayout();
54
55   /**
56    * Set the function used to calculate the item-size, for a given layout-size.
57    * @param[in] function The item-size function.
58    */
59   void SetItemSizeFunction(ItemSizeFunction function);
60
61   /**
62    * Get the function used to calculate the item-size
63    * @return The item-size function.
64    */
65   ItemSizeFunction GetItemSizeFunction() const;
66
67   /**
68    * Set spacing angle between items.
69    * @param[in] itemSpacing The angle in radians.
70    */
71   void SetItemSpacing(Radian itemSpacing);
72
73   /**
74    * Get spacing angle between items.
75    * @return The angle in radians.
76    */
77   Radian GetItemSpacing() const;
78
79   /**
80    * Set the vertical distance for one revolution of the spiral.
81    * @param[in] distance The revolution distance.
82    */
83   void SetRevolutionDistance(float distance);
84
85   /**
86    * Get the vertical distance for one revolution of the spiral.
87    * @return The revolution distance.
88    */
89   float GetRevolutionDistance() const;
90
91   /**
92    * Set the function used to calculate the spiral radius, for a given layout-size.
93    * @param[in] function The spiral-radius function.
94    */
95   void SetSpiralRadiusFunction(SpiralRadiusFunction function);
96
97   /**
98    * Get the function used to calculate the spiral radius.
99    * @return The spiral-radius function.
100    */
101   SpiralRadiusFunction GetSpiralRadiusFunction() const;
102
103   /**
104    * Set the alignment of the top-item, when at the beginning of the spiral (with a first-item layout-position of zero).
105    * A value of 0 indicates that the top-item is centered in the middle of the layout. A value of -0.5 or 0.5 indicates
106    * that the top-item is centred at the top or bottom of the layout respectively.
107    * @param[in] alignment The top-item alignment.
108    */
109   void SetTopItemAlignment(float alignment);
110
111   /**
112    * Get the alignment of the top-item, when at the beginning of the spiral
113    * @return The top-item alignment.
114    */
115   float GetTopItemAlignment() const;
116
117   /**
118    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
119    * @param[in] scrollSpeed The scroll speed factor.
120    */
121   void SetScrollSpeedFactor(float scrollSpeed);
122
123   /**
124    * Set the maximum swipe speed in pixels per second.
125    * @param[in] speed The maximum swipe speed.
126    */
127   void SetMaximumSwipeSpeed(float speed);
128
129   /**
130    * Set the duration of the flick animation in second. This is the time taken to animate each
131    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
132    * by a swipe gesture.
133    * @pre durationSeconds must be greater than zero.
134    * @param[in] durationSeconds The duration of flick animation in seconds.
135    */
136   void SetItemFlickAnimationDuration(float durationSeconds);
137
138   /**
139    * @copydoc ItemLayout::GetScrollSpeedFactor()
140    */
141   virtual float GetScrollSpeedFactor() const;
142
143   /**
144    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
145    */
146   virtual float GetMaximumSwipeSpeed() const;
147
148   /**
149    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
150    */
151   virtual float GetItemFlickAnimationDuration() const;
152
153   /**
154    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
155    */
156   virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
157
158 private:
159
160   /**
161    * @copydoc ItemLayout::GetMinimumLayoutPosition()
162    */
163   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
164
165   /**
166    * @copydoc ItemLayout::GetClosestAnchorPosition()
167    */
168   virtual float GetClosestAnchorPosition(float layoutPosition) const;
169
170   /**
171    * @copydoc ItemLayout::GetItemScrollToPosition()
172    */
173   virtual float GetItemScrollToPosition(unsigned int itemId) const;
174
175   /**
176    * @copydoc ItemLayout::GetItemsWithinArea()
177    */
178   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
179
180   /**
181    * @copydoc ItemLayout::GetReserveItemCount()
182    */
183   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
184
185   /**
186    * @copydoc ItemLayout::GetItemSize()
187    */
188   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
189
190   /**
191    * @copydoc ItemLayout::GetResizeAnimation()
192    */
193   virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
194
195   /**
196    * @copydoc ItemLayout::GetPositionConstraint()
197    */
198   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
199
200   /**
201    * @copydoc ItemLayout::GetRotationConstraint()
202    */
203   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
204
205   /**
206    * @copydoc ItemLayout::GetScaleConstraint()
207    */
208   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
209
210   /**
211    * @copydoc ItemLayout::GetColorConstraint()
212    */
213   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
214
215   /**
216    * @copydoc ItemLayout::GetVisibilityConstraint()
217    */
218   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
219
220   /**
221    * @copydoc ItemLayout::GetScrollDirection()
222    */
223   virtual Degree GetScrollDirection() const;
224
225 protected:
226
227   /**
228    * Protected constructor; see also SpiralLayout::New()
229    */
230   SpiralLayout();
231
232 private:
233
234   struct Impl;
235   Impl* mImpl;
236 };
237
238 } // namespace Toolkit
239
240 } // namespace Dali
241
242 #endif // __DALI_TOOLKIT_SPIRAL_LAYOUT_H__