Merge "Add push-button sample for dashboard" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / 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) 2015 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 #include <dali/public-api/common/dali-common.h>
26
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
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 Create a new grid layout.
50    */
51   static GridLayoutPtr New();
52
53   /**
54    * @brief Virtual destructor.
55    */
56   virtual ~GridLayout();
57
58   /**
59    * Apply grid layout Properties.
60    * @param[in] properties The properties of the layout.
61    */
62   void SetGridLayoutProperties(const Property::Map& properties);
63
64   /**
65    * @brief Set the number of columns in the layout.
66    *
67    * @param[in] columns The number of columns.
68    */
69   void SetNumberOfColumns(unsigned int columns);
70
71   /**
72    * @brief Get the number of columns in the layout.
73    *
74    * @return The number of columns.
75    */
76   unsigned int GetNumberOfColumns() const;
77
78   /**
79    * @brief Set the spacing between rows.
80    *
81    * @param[in] spacing The row spacing.
82    */
83   void SetRowSpacing(float spacing);
84
85   /**
86    * @brief Get the spacing between rows.
87    *
88    * @return The row spacing.
89    */
90   float GetRowSpacing() const;
91
92   /**
93    * @brief Set the spacing between columns.
94    *
95    * @param[in] spacing The row spacing.
96    */
97   void SetColumnSpacing(float spacing);
98
99   /**
100    * @brief Get the spacing between columns.
101    *
102    * @return The row spacing.
103    */
104   float GetColumnSpacing() const;
105
106   /**
107    * @brief Set the margin in the top of the layout.
108    *
109    * @param[in] margin The layout top margin.
110    */
111   void SetTopMargin(float margin);
112
113   /**
114    * @brief Get the margin in the top of the layout.
115    *
116    * @return The layout top margin.
117    */
118   float GetTopMargin() const;
119
120   /**
121    * @brief Set the margin in the bottom of the layout.
122    *
123    * @param[in] margin The layout bottom margin.
124    */
125   void SetBottomMargin(float margin);
126
127   /**
128    * @brief Get the margin in the bottom of the layout.
129    *
130    * @return The layout bottom margin.
131    */
132   float GetBottomMargin() const;
133
134   /**
135    * @brief Set the margin in the left and right of the layout.
136    *
137    * @param[in] margin The layout side margin.
138    */
139   void SetSideMargin(float margin);
140
141   /**
142    * @brief Get the margin in the left and right of the layout.
143    *
144    * @return The layout side margin.
145    */
146   float GetSideMargin() const;
147
148   /**
149    * @brief Set the gap of items in the Z axis in different columns.
150    *
151    * @param[in] gap The gap of items.
152    */
153   void SetZGap(float gap);
154
155   /**
156    * @brief Get the gap of items in the Z axis in different columns.
157    *
158    * @return The gap of items.
159    */
160   float GetZGap() const;
161
162   /**
163    * @brief Set the factor used to customise the scroll speed while dragging and swiping the layout.
164    *
165    * @param[in] scrollSpeed The scroll speed factor.
166    */
167   void SetScrollSpeedFactor(float scrollSpeed);
168
169   /**
170    * @brief Set the maximum swipe speed in pixels per second.
171    *
172    * @param[in] speed The maximum swipe speed.
173    */
174   void SetMaximumSwipeSpeed(float speed);
175
176   /**
177    * @brief Set the duration of the flick animation in seconds.
178    *
179    * This is the time taken to animate each item to its next layout
180    * position (e.g. from 1.0 to 2.0) when a flick animation is
181    * triggered by a swipe gesture.
182    *
183    * @pre durationSeconds must be greater than zero.
184    * @param[in] durationSeconds The duration of flick animation in seconds.
185    */
186   void SetItemFlickAnimationDuration(float durationSeconds);
187
188   /**
189    * @copydoc ItemLayout::GetScrollSpeedFactor()
190    */
191   virtual float GetScrollSpeedFactor() const;
192
193   /**
194    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
195    */
196   virtual float GetMaximumSwipeSpeed() const;
197
198   /**
199    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
200    */
201   virtual float GetItemFlickAnimationDuration() const;
202
203   /**
204    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
205    */
206   virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
207
208   /**
209    * @copydoc ItemLayout::GetNextFocusItemID()
210    */
211   virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled);
212
213 private:
214
215   /**
216    * @copydoc ItemLayout::GetMinimumLayoutPosition()
217    */
218   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
219
220   /**
221    * @copydoc ItemLayout::GetClosestAnchorPosition()
222    */
223   virtual float GetClosestAnchorPosition(float layoutPosition) const;
224
225   /**
226    * @copydoc ItemLayout::GetItemScrollToPosition()
227    */
228   virtual float GetItemScrollToPosition(unsigned int itemId) const;
229
230   /**
231    * @copydoc ItemLayout::GetItemsWithinArea()
232    */
233   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
234
235   /**
236    * @copydoc ItemLayout::GetReserveItemCount()
237    */
238   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
239
240   /**
241    * @copydoc ItemLayout::GetDefaultItemSize()
242    */
243   virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const;
244
245   /**
246    * @copydoc ItemLayout::GetScrollDirection()
247    */
248   virtual Degree GetScrollDirection() const;
249
250   /**
251    * @copydoc ItemLayout::ApplyConstraints()
252    */
253   virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor );
254
255   /**
256    * @copydoc ItemLayout::GetItemPosition()
257    */
258   virtual Vector3 GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const;
259
260 protected:
261
262   /**
263    * @brief Protected constructor; see also GridLayout::New().
264    */
265   GridLayout();
266
267 private:
268
269   // Undefined
270   GridLayout( const GridLayout& itemLayout );
271
272   // Undefined
273   GridLayout& operator=( const GridLayout& rhs );
274
275 private:
276
277   struct Impl;
278   Impl* mImpl;
279 };
280
281 } // namespace Internal
282
283 } // namespace Toolkit
284
285 } // namespace Dali
286
287 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__