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