Updated all header files to new format
[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) 2021 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-toolkit/public-api/dali-toolkit-common.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33 class GridLayout;
34
35 typedef IntrusivePtr<GridLayout> GridLayoutPtr; ///< Pointer to a Dali::Toolkit::GridLayout object
36
37 /**
38  * @brief An ItemView layout which arranges items in a grid.
39  */
40 class GridLayout : public ItemLayout
41 {
42 public:
43   /**
44    * @brief Create a new grid layout.
45    */
46   static GridLayoutPtr New();
47
48   /**
49    * @brief Virtual destructor.
50    */
51   virtual ~GridLayout();
52
53   /**
54    * Apply grid layout Properties.
55    * @param[in] properties The properties of the layout.
56    */
57   void SetGridLayoutProperties(const Property::Map& properties);
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 factor used to customise the scroll speed while dragging and swiping the layout.
159    *
160    * @param[in] scrollSpeed The scroll speed factor.
161    */
162   void SetScrollSpeedFactor(float scrollSpeed);
163
164   /**
165    * @brief Set the maximum swipe speed in pixels per second.
166    *
167    * @param[in] speed The maximum swipe speed.
168    */
169   void SetMaximumSwipeSpeed(float speed);
170
171   /**
172    * @brief Set the duration of the flick animation in seconds.
173    *
174    * This is the time taken to animate each item to its next layout
175    * position (e.g. from 1.0 to 2.0) when a flick animation is
176    * triggered by a swipe gesture.
177    *
178    * @pre durationSeconds must be greater than zero.
179    * @param[in] durationSeconds The duration of flick animation in seconds.
180    */
181   void SetItemFlickAnimationDuration(float durationSeconds);
182
183   /**
184    * @copydoc ItemLayout::GetScrollSpeedFactor()
185    */
186   float GetScrollSpeedFactor() const override;
187
188   /**
189    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
190    */
191   float GetMaximumSwipeSpeed() const override;
192
193   /**
194    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
195    */
196   float GetItemFlickAnimationDuration() const override;
197
198   /**
199    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
200    */
201   float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) override;
202
203   /**
204    * @copydoc ItemLayout::GetNextFocusItemID()
205    */
206   int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled) override;
207
208 private:
209   /**
210    * @copydoc ItemLayout::GetMinimumLayoutPosition()
211    */
212   float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const override;
213
214   /**
215    * @copydoc ItemLayout::GetClosestAnchorPosition()
216    */
217   float GetClosestAnchorPosition(float layoutPosition) const override;
218
219   /**
220    * @copydoc ItemLayout::GetItemScrollToPosition()
221    */
222   float GetItemScrollToPosition(unsigned int itemId) const override;
223
224   /**
225    * @copydoc ItemLayout::GetItemsWithinArea()
226    */
227   ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const override;
228
229   /**
230    * @copydoc ItemLayout::GetReserveItemCount()
231    */
232   unsigned int GetReserveItemCount(Vector3 layoutSize) const override;
233
234   /**
235    * @copydoc ItemLayout::GetDefaultItemSize()
236    */
237   void GetDefaultItemSize(unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize) const override;
238
239   /**
240    * @copydoc ItemLayout::GetScrollDirection()
241    */
242   Degree GetScrollDirection() const override;
243
244   /**
245    * @copydoc ItemLayout::ApplyConstraints()
246    */
247   void ApplyConstraints(Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor) override;
248
249   /**
250    * @copydoc ItemLayout::GetItemPosition()
251    */
252   Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const override;
253
254 protected:
255   /**
256    * @brief Protected constructor; see also GridLayout::New().
257    */
258   GridLayout();
259
260 private:
261   // Undefined
262   GridLayout(const GridLayout& itemLayout);
263
264   // Undefined
265   GridLayout& operator=(const GridLayout& rhs);
266
267 private:
268   struct Impl;
269   Impl* mImpl;
270 };
271
272 } // namespace Internal
273
274 } // namespace Toolkit
275
276 } // namespace Dali
277
278 #endif // DALI_TOOLKIT_GRID_LAYOUT_H