Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / item-view / depth-layout.h
1 #ifndef __DALI_TOOLKIT_DEPTH_LAYOUT_H__
2 #define __DALI_TOOLKIT_DEPTH_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 DepthLayout;
32
33 typedef IntrusivePtr<DepthLayout> DepthLayoutPtr;
34
35 /**
36  * This layout arranges items in a grid, which scrolls along the Z-Axis.
37  */
38 class DepthLayout : public ItemLayout
39 {
40 public:
41
42   typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth)> ItemSizeFunction;
43
44   typedef boost::function<float (float layoutHeight)> BottomMarginFunction;
45
46   typedef boost::function<float (unsigned int numberOfColumns,
47                                  unsigned int columnNumber,
48                                  const Vector3& itemSize,
49                                  float layoutWidth)> ColumnPositionFunction;
50
51   /**
52    * Create a new spiral layout
53    */
54   static DepthLayoutPtr New();
55
56   /**
57    * Virtual destructor.
58    */
59   virtual ~DepthLayout();
60
61   /**
62    * Set the number of columns in the layout.
63    * @param[in] columns The number of columns.
64    */
65   void SetNumberOfColumns(unsigned int columns);
66
67   /**
68    * Get the number of columns in the layout.
69    * @return The number of columns.
70    */
71   unsigned int GetNumberOfColumns() const;
72
73   /**
74    * Set the number of rows in the layout.
75    * The default is 20, with 10 behind the viewable area.
76    * @param[in] rows The number-of-rows.
77    */
78   void SetNumberOfRows(unsigned int rows);
79
80   /**
81    * Get the number of rows in the layout.
82    * @return The number of rows.
83    */
84   unsigned int GetNumberOfRows() const;
85
86   /**
87    * Set the spacing between rows.
88    * @param[in] spacing The row spacing.
89    */
90   void SetRowSpacing(float spacing);
91
92   /**
93    * Get the spacing between rows.
94    * @return The row spacing.
95    */
96   float GetRowSpacing() const;
97
98   /**
99    * Set the tilt angle of the layout; this is clamped between -45 & 45 degrees.
100    * @param[in] angle The tilt angle in degrees.
101    */
102   void SetTiltAngle(Degree angle);
103
104   /**
105    * Get the tilt angle of the layout.
106    * @return The tilt angle in degrees.
107    */
108   Degree GetTiltAngle() const;
109
110   /**
111    * Set the function used to calculate the item-size, for a given layout-size.
112    * @param[in] function The item-size function.
113    */
114   void SetItemSizeFunction(ItemSizeFunction function);
115
116   /**
117    * Get the function used to calculate the item-size.
118    * @return The item-size function.
119    */
120   ItemSizeFunction GetItemSizeFunction() const;
121
122   /**
123    * Set the function used to calculate the margin in the bottom of the layout, for a given layout-size.
124    * @param[in] function The bottom margin function.
125    */
126   void SetBottomMarginFunction(BottomMarginFunction function);
127
128   /**
129    * Get the function used to calculate the margin in the bottom of the layout.
130    * @return The bottom margin function.
131    */
132   BottomMarginFunction GetBottomMarginFunction() const;
133
134   /**
135    * Set the tilt angle of the individual items in the layout.
136    * @param[in] angle The item tilt angle in degrees.
137    */
138   void SetItemTiltAngle(Degree angle);
139
140   /**
141    * Get the tilt angle of the individual items in the layout.
142    * @return The item tilt angle in degrees.
143    */
144   Degree GetItemTiltAngle() const;
145
146   /**
147    * Set the function used to calculate the horizontal position of each column, for a given column, item-size & layout-size.
148    * @param[in] function The column-position function.
149    */
150   void SetColumnPositionFunction(ColumnPositionFunction function);
151
152   /**
153    * Get the function used to calculate the horizontal position of each column
154    * @return The column-position function.
155    */
156   ColumnPositionFunction GetColumnPositionFunction() const;
157
158   /**
159    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
160    * @param[in] scrollSpeed The scroll speed factor.
161    */
162   void SetScrollSpeedFactor(float scrollSpeed);
163
164   /**
165    * Set the maximum swipe speed in pixels per second.
166    * @param[in] speed The maximum swipe speed.
167    */
168   void SetMaximumSwipeSpeed(float speed);
169
170   /**
171    * Set the duration of the flick animation in second. This is the time taken to animate each
172    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
173    * by a swipe gesture.
174    * @pre durationSeconds must be greater than zero.
175    * @param[in] durationSeconds The duration of flick animation in seconds.
176    */
177   void SetItemFlickAnimationDuration(float durationSeconds);
178
179   /**
180    * @copydoc ItemLayout::GetScrollSpeedFactor()
181    */
182   virtual float GetScrollSpeedFactor() const;
183
184   /**
185    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
186    */
187   virtual float GetMaximumSwipeSpeed() const;
188
189   /**
190    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
191    */
192   virtual float GetItemFlickAnimationDuration() const;
193
194   /**
195    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
196    */
197   virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
198
199   /**
200    * @copydoc ItemLayout::GetNextFocusItemID()
201    */
202   virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
203
204 private:
205
206   /**
207    * @copydoc ItemLayout::GetMinimumLayoutPosition()
208    */
209   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
210
211   /**
212    * @copydoc ItemLayout::GetClosestAnchorPosition()
213    */
214   virtual float GetClosestAnchorPosition(float layoutPosition) const;
215
216   /**
217    * @copydoc ItemLayout::GetItemScrollToPosition()
218    */
219   virtual float GetItemScrollToPosition(unsigned int itemId) const;
220
221   /**
222    * @copydoc ItemLayout::GetItemsWithinArea()
223    */
224   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
225
226   /**
227    * @copydoc ItemLayout::GetReserveItemCount()
228    */
229   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
230
231   /**
232    * @copydoc ItemLayout::GetItemSize()
233    */
234   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
235
236   /**
237    * @copydoc ItemLayout::GetResizeAnimation()
238    */
239   virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
240
241   /**
242    * @copydoc ItemLayout::GetPositionConstraint()
243    */
244   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
245
246   /**
247    * @copydoc ItemLayout::GetRotationConstraint()
248    */
249   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
250
251   /**
252    * @copydoc ItemLayout::GetScaleConstraint()
253    */
254   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
255
256   /**
257    * @copydoc ItemLayout::GetColorConstraint()
258    */
259   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
260
261   /**
262    * @copydoc ItemLayout::GetVisibilityConstraint()
263    */
264   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
265
266   /**
267    * @copydoc ItemLayout::GetScrollDirection()
268    */
269   virtual Degree GetScrollDirection() const;
270
271 protected:
272
273   /**
274    * Protected constructor; see also DepthLayout::New()
275    */
276   DepthLayout();
277
278 private:
279
280   struct Impl;
281   Impl* mImpl;
282 };
283
284 } // namespace Toolkit
285
286 } // namespace Dali
287
288 #endif // __DALI_TOOLKIT_DEPTH_LAYOUT_H__