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