Updated all header files to new format
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / item-view / spiral-layout.h
1 #ifndef DALI_TOOLKIT_SPIRAL_LAYOUT_H
2 #define DALI_TOOLKIT_SPIRAL_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 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Internal
30 {
31 class SpiralLayout;
32
33 typedef IntrusivePtr<SpiralLayout> SpiralLayoutPtr;
34
35 /**
36  * An ItemView layout which arranges items in a spiral.
37  */
38 class SpiralLayout : public ItemLayout
39 {
40 public:
41   /**
42    * Create a new spiral layout
43    */
44   static SpiralLayoutPtr New();
45
46   /**
47    * Virtual destructor.
48    */
49   virtual ~SpiralLayout();
50
51   /**
52    * Apply spiral layout Properties.
53    * @param[in] properties The properties of the layout.
54    */
55   void SetSpiralLayoutProperties(const Property::Map& properties);
56
57   /**
58    * Set spacing angle between items.
59    * @param[in] itemSpacing The angle in radians.
60    */
61   void SetItemSpacing(Radian itemSpacing);
62
63   /**
64    * Get spacing angle between items.
65    * @return The angle in radians.
66    */
67   Radian GetItemSpacing() const;
68
69   /**
70    * Set the vertical distance for one revolution of the spiral.
71    * @param[in] distance The revolution distance.
72    */
73   void SetRevolutionDistance(float distance);
74
75   /**
76    * Get the vertical distance for one revolution of the spiral.
77    * @return The revolution distance.
78    */
79   float GetRevolutionDistance() const;
80
81   /**
82    * Set the alignment of the top-item, when at the beginning of the spiral (with a first-item layout-position of zero).
83    * A value of 0 indicates that the top-item is centered in the middle of the layout. A value of -0.5 or 0.5 indicates
84    * that the top-item is centred at the top or bottom of the layout respectively.
85    * @param[in] alignment The top-item alignment.
86    */
87   void SetTopItemAlignment(float alignment);
88
89   /**
90    * Get the alignment of the top-item, when at the beginning of the spiral
91    * @return The top-item alignment.
92    */
93   float GetTopItemAlignment() const;
94
95   /**
96    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
97    * @param[in] scrollSpeed The scroll speed factor.
98    */
99   void SetScrollSpeedFactor(float scrollSpeed);
100
101   /**
102    * Set the maximum swipe speed in pixels per second.
103    * @param[in] speed The maximum swipe speed.
104    */
105   void SetMaximumSwipeSpeed(float speed);
106
107   /**
108    * Set the duration of the flick animation in second. This is the time taken to animate each
109    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
110    * by a swipe gesture.
111    * @pre durationSeconds must be greater than zero.
112    * @param[in] durationSeconds The duration of flick animation in seconds.
113    */
114   void SetItemFlickAnimationDuration(float durationSeconds);
115
116   /**
117    * @copydoc ItemLayout::GetScrollSpeedFactor()
118    */
119   float GetScrollSpeedFactor() const override;
120
121   /**
122    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
123    */
124   float GetMaximumSwipeSpeed() const override;
125
126   /**
127    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
128    */
129   float GetItemFlickAnimationDuration() const override;
130
131   /**
132    * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
133    */
134   float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) override;
135
136 private:
137   /**
138    * @copydoc ItemLayout::GetMinimumLayoutPosition()
139    */
140   float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const override;
141
142   /**
143    * @copydoc ItemLayout::GetClosestAnchorPosition()
144    */
145   float GetClosestAnchorPosition(float layoutPosition) const override;
146
147   /**
148    * @copydoc ItemLayout::GetItemScrollToPosition()
149    */
150   float GetItemScrollToPosition(unsigned int itemId) const override;
151
152   /**
153    * @copydoc ItemLayout::GetItemsWithinArea()
154    */
155   ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const override;
156
157   /**
158    * @copydoc ItemLayout::GetReserveItemCount()
159    */
160   unsigned int GetReserveItemCount(Vector3 layoutSize) const override;
161
162   /**
163    * @copydoc ItemLayout::GetDefaultItemSize()
164    */
165   void GetDefaultItemSize(unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize) const override;
166
167   /**
168    * @copydoc ItemLayout::GetScrollDirection()
169    */
170   Degree GetScrollDirection() const override;
171
172   /**
173    * @copydoc ItemLayout::ApplyConstraints()
174    */
175   void ApplyConstraints(Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor) override;
176
177   /**
178    * @copydoc ItemLayout::GetItemPosition()
179    */
180   Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const override;
181
182 protected:
183   /**
184    * Protected constructor; see also SpiralLayout::New()
185    */
186   SpiralLayout();
187
188 private:
189   // Undefined
190   SpiralLayout(const SpiralLayout& spiralLayout);
191
192   // Undefined
193   SpiralLayout& operator=(const SpiralLayout& spiralLayout);
194
195 private:
196   struct Impl;
197   Impl* mImpl;
198 };
199
200 } // namespace Internal
201
202 } // namespace Toolkit
203
204 } // namespace Dali
205
206 #endif // DALI_TOOLKIT_SPIRAL_LAYOUT_H