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