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