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