Toolkit - Fixes TC build issues and compile warnings.
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / scrollable / item-view / grid-layout.h
1 #ifndef __DALI_TOOLKIT_GRID_LAYOUT_H__
2 #define __DALI_TOOLKIT_GRID_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  * @addtogroup CAPI_DALI_TOOLKIT_ITEM_VIEW_MODULE
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali/dali.h>
28
29 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
30
31 namespace Dali DALI_IMPORT_API
32 {
33
34 namespace Toolkit
35 {
36
37 class GridLayout;
38
39 typedef IntrusivePtr<GridLayout> GridLayoutPtr; ///< Pointer to a Dali::Toolkit::GridLayout object
40
41 /**
42  * @brief An ItemView layout which arranges items in a grid.
43  */
44 class GridLayout : public ItemLayout
45 {
46 public:
47
48   /**
49    * @brief Function signature for a method to calculate the item size.
50    *
51    * @see SetItemSizeFunction()
52    */
53   typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)> ItemSizeFunction;
54
55   /**
56    * @brief Create a new grid layout.
57    */
58   static GridLayoutPtr New();
59
60   /**
61    * @brief Virtual destructor.
62    */
63   virtual ~GridLayout();
64
65   /**
66    * @brief Set the number of columns in the layout.
67    *
68    * @param[in] columns The number of columns.
69    */
70   void SetNumberOfColumns(unsigned int columns);
71
72   /**
73    * @brief Get the number of columns in the layout.
74    *
75    * @return The number of columns.
76    */
77   unsigned int GetNumberOfColumns() const;
78
79   /**
80    * @brief Set the spacing between rows.
81    *
82    * @param[in] spacing The row spacing.
83    */
84   void SetRowSpacing(float spacing);
85
86   /**
87    * @brief Get the spacing between rows.
88    *
89    * @return The row spacing.
90    */
91   float GetRowSpacing() const;
92
93   /**
94    * @brief Set the spacing between columns.
95    *
96    * @param[in] spacing The row spacing.
97    */
98   void SetColumnSpacing(float spacing);
99
100   /**
101    * @brief Get the spacing between columns.
102    *
103    * @return The row spacing.
104    */
105   float GetColumnSpacing() const;
106
107   /**
108    * @brief Set the margin in the top of the layout.
109    *
110    * @param[in] margin The layout top margin.
111    */
112   void SetTopMargin(float margin);
113
114   /**
115    * @brief Get the margin in the top of the layout.
116    *
117    * @return The layout top margin.
118    */
119   float GetTopMargin() const;
120
121   /**
122    * @brief Set the margin in the bottom of the layout.
123    *
124    * @param[in] margin The layout bottom margin.
125    */
126   void SetBottomMargin(float margin);
127
128   /**
129    * @brief Get the margin in the bottom of the layout.
130    *
131    * @return The layout bottom margin.
132    */
133   float GetBottomMargin() const;
134
135   /**
136    * @brief Set the margin in the left and right of the layout.
137    *
138    * @param[in] margin The layout side margin.
139    */
140   void SetSideMargin(float margin);
141
142   /**
143    * @brief Get the margin in the left and right of the layout.
144    *
145    * @return The layout side margin.
146    */
147   float GetSideMargin() const;
148
149   /**
150    * @brief Set the gap of items in the Z axis in different columns.
151    *
152    * @param[in] gap The gap of items.
153    */
154   void SetZGap(float gap);
155
156   /**
157    * @brief Get the gap of items in the Z axis in different columns.
158    *
159    * @return The gap of items.
160    */
161   float GetZGap() const;
162
163   /**
164    * @brief Set the function used to calculate the item-size, for a given layout-size.
165    *
166    * @param[in] function The item-size function.
167    */
168   void SetItemSizeFunction(ItemSizeFunction function);
169
170   /**
171    * @brief Get the function used to calculate the item-size.
172    *
173    * @return The item-size function.
174    */
175   ItemSizeFunction GetItemSizeFunction() const;
176
177   /**
178    * @brief Set the factor used to customise the scroll speed while dragging and swiping the layout.
179    *
180    * @param[in] scrollSpeed The scroll speed factor.
181    */
182   void SetScrollSpeedFactor(float scrollSpeed);
183
184   /**
185    * @brief Set the maximum swipe speed in pixels per second.
186    *
187    * @param[in] speed The maximum swipe speed.
188    */
189   void SetMaximumSwipeSpeed(float speed);
190
191   /**
192    * @brief Set the duration of the flick animation in seconds.
193    *
194    * This is the time taken to animate each item to its next layout
195    * position (e.g. from 1.0 to 2.0) when a flick animation is
196    * triggered by a swipe gesture.
197    *
198    * @pre durationSeconds must be greater than zero.
199    * @param[in] durationSeconds The duration of flick animation in seconds.
200    */
201   void SetItemFlickAnimationDuration(float durationSeconds);
202
203   /**
204    * @copydoc ItemLayout::GetScrollSpeedFactor()
205    */
206   virtual float GetScrollSpeedFactor() const;
207
208   /**
209    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
210    */
211   virtual float GetMaximumSwipeSpeed() const;
212
213   /**
214    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
215    */
216   virtual float GetItemFlickAnimationDuration() const;
217
218   /**
219    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
220    */
221   virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
222
223   /**
224    * @copydoc ItemLayout::GetNextFocusItemID()
225    */
226   virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
227
228 private:
229
230   /**
231    * @copydoc ItemLayout::GetMinimumLayoutPosition()
232    */
233   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
234
235   /**
236    * @copydoc ItemLayout::GetClosestAnchorPosition()
237    */
238   virtual float GetClosestAnchorPosition(float layoutPosition) const;
239
240   /**
241    * @copydoc ItemLayout::GetItemScrollToPosition()
242    */
243   virtual float GetItemScrollToPosition(unsigned int itemId) const;
244
245   /**
246    * @copydoc ItemLayout::GetItemsWithinArea()
247    */
248   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
249
250   /**
251    * @copydoc ItemLayout::GetReserveItemCount()
252    */
253   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
254
255   /**
256    * @copydoc ItemLayout::GetItemSize()
257    */
258   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
259
260   /**
261    * @copydoc ItemLayout::GetResizeAnimation()
262    */
263   virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
264
265   /**
266    * @copydoc ItemLayout::GetPositionConstraint()
267    */
268   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
269
270   /**
271    * @copydoc ItemLayout::GetRotationConstraint()
272    */
273   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
274
275   /**
276    * @copydoc ItemLayout::GetScaleConstraint()
277    */
278   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
279
280   /**
281    * @copydoc ItemLayout::GetColorConstraint()
282    */
283   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
284
285   /**
286    * @copydoc ItemLayout::GetVisibilityConstraint()
287    */
288   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
289
290   /**
291    * @copydoc ItemLayout::GetScrollDirection()
292    */
293   virtual Degree GetScrollDirection() const;
294
295 protected:
296
297   /**
298    * @brief Protected constructor; see also GridLayout::New().
299    */
300   GridLayout();
301
302 private:
303
304   struct Impl;
305   Impl* mImpl;
306 };
307
308 } // namespace Toolkit
309
310 } // namespace Dali
311
312 /**
313  * @}
314  */
315 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__