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