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