Fixed issue that ItemView overshoot appears before it reaches the end of the list
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / item-view / depth-layout.h
1 #ifndef __DALI_TOOLKIT_DEPTH_LAYOUT_H__
2 #define __DALI_TOOLKIT_DEPTH_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 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 class DepthLayout;
34
35 typedef IntrusivePtr<DepthLayout> DepthLayoutPtr;
36
37 /**
38  * This layout arranges items in a grid, which scrolls along the Z-Axis.
39  */
40 class DepthLayout : public ItemLayout
41 {
42 public:
43
44   /**
45    * Create a new spiral layout
46    */
47   static DepthLayoutPtr New();
48
49   /**
50    * Virtual destructor.
51    */
52   virtual ~DepthLayout();
53
54   /**
55    * Set the number of columns in the layout.
56    * @param[in] columns The number of columns.
57    */
58   void SetNumberOfColumns(unsigned int columns);
59
60   /**
61    * Get the number of columns in the layout.
62    * @return The number of columns.
63    */
64   unsigned int GetNumberOfColumns() const;
65
66   /**
67    * Set the number of rows in the layout.
68    * The default is 20, with 10 behind the viewable area.
69    * @param[in] rows The number-of-rows.
70    */
71   void SetNumberOfRows(unsigned int rows);
72
73   /**
74    * Get the number of rows in the layout.
75    * @return The number of rows.
76    */
77   unsigned int GetNumberOfRows() const;
78
79   /**
80    * Set the spacing between rows.
81    * @param[in] spacing The row spacing.
82    */
83   void SetRowSpacing(float spacing);
84
85   /**
86    * Get the spacing between rows.
87    * @return The row spacing.
88    */
89   float GetRowSpacing() const;
90
91   /**
92    * Set the tilt angle of the layout; this is clamped between -45 & 45 degrees.
93    * @param[in] angle The tilt angle in degrees.
94    */
95   void SetTiltAngle(Degree angle);
96
97   /**
98    * Get the tilt angle of the layout.
99    * @return The tilt angle in degrees.
100    */
101   Degree GetTiltAngle() const;
102
103   /**
104    * Set the tilt angle of the individual items in the layout.
105    * @param[in] angle The item tilt angle in degrees.
106    */
107   void SetItemTiltAngle(Degree angle);
108
109   /**
110    * Get the tilt angle of the individual items in the layout.
111    * @return The item tilt angle in degrees.
112    */
113   Degree GetItemTiltAngle() const;
114
115   /**
116    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
117    * @param[in] scrollSpeed The scroll speed factor.
118    */
119   void SetScrollSpeedFactor(float scrollSpeed);
120
121   /**
122    * Set the maximum swipe speed in pixels per second.
123    * @param[in] speed The maximum swipe speed.
124    */
125   void SetMaximumSwipeSpeed(float speed);
126
127   /**
128    * Set the duration of the flick animation in second. This is the time taken to animate each
129    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
130    * by a swipe gesture.
131    * @pre durationSeconds must be greater than zero.
132    * @param[in] durationSeconds The duration of flick animation in seconds.
133    */
134   void SetItemFlickAnimationDuration(float durationSeconds);
135
136   /**
137    * @copydoc ItemLayout::GetScrollSpeedFactor()
138    */
139   virtual float GetScrollSpeedFactor() const;
140
141   /**
142    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
143    */
144   virtual float GetMaximumSwipeSpeed() const;
145
146   /**
147    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
148    */
149   virtual float GetItemFlickAnimationDuration() const;
150
151   /**
152    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
153    */
154   virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
155
156   /**
157    * @copydoc ItemLayout::GetNextFocusItemID()
158    */
159   virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled);
160
161 private:
162
163   /**
164    * @copydoc ItemLayout::GetMinimumLayoutPosition()
165    */
166   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
167
168   /**
169    * @copydoc ItemLayout::GetClosestAnchorPosition()
170    */
171   virtual float GetClosestAnchorPosition(float layoutPosition) const;
172
173   /**
174    * @copydoc ItemLayout::GetItemScrollToPosition()
175    */
176   virtual float GetItemScrollToPosition(unsigned int itemId) const;
177
178   /**
179    * @copydoc ItemLayout::GetItemsWithinArea()
180    */
181   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
182
183   /**
184    * @copydoc ItemLayout::GetReserveItemCount()
185    */
186   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
187
188   /**
189    * @copydoc ItemLayout::GetDefaultItemSize()
190    */
191   virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const;
192
193   /**
194    * @copydoc ItemLayout::GetScrollDirection()
195    */
196   virtual Degree GetScrollDirection() const;
197
198   /**
199    * @copydoc ItemLayout::ApplyConstraints()
200    */
201   virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor );
202
203   /**
204    * @copydoc ItemLayout::GetItemPosition()
205    */
206   virtual Vector3 GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const;
207
208 protected:
209
210   /**
211    * Protected constructor; see also DepthLayout::New()
212    */
213   DepthLayout();
214
215 private:
216
217   // Undefined
218   DepthLayout( const DepthLayout& depthLayout );
219
220   // Undefined
221   DepthLayout& operator=( const DepthLayout& depthLayout );
222
223 private:
224
225   struct Impl;
226   Impl* mImpl;
227 };
228
229 } // namespace Internal
230
231 } // namespace Toolkit
232
233 } // namespace Dali
234
235 #endif // __DALI_TOOLKIT_DEPTH_LAYOUT_H__