License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / item-view / navigation-layout.h
1 #ifndef __DALI_TOOLKIT_NAVIGATION_LAYOUT_H__
2 #define __DALI_TOOLKIT_NAVIGATION_LAYOUT_H__
3
4 /*
5  * Copyright (c) 2014 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/dali.h>
23 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27 namespace Toolkit
28 {
29 class NavigationLayout;
30
31 typedef IntrusivePtr<NavigationLayout> NavigationLayoutPtr;
32
33 /**
34  * An ItemView layout which arranges items in navigation mode.
35  */
36 class NavigationLayout: public ItemLayout
37 {
38 public:
39
40   typedef boost::function<Vector3 (const Vector3& layoutSize,
41                                    const unsigned int orientation,
42                                    const unsigned int numberOfColumns,
43                                    const float columnSpacing,
44                                    const float sideMargin)>  ResizeFunction;
45
46   /**
47    * @deprecated This should not have been added to an ItemLayout
48    */
49   typedef SignalV2< void (int) > NavigationSignalV2;
50
51   /**
52    * Create a new navigation layout
53    */
54   static NavigationLayoutPtr New();
55
56   /**
57    * Virtual destructor.
58    */
59   virtual ~NavigationLayout();
60
61   /**
62    * Get the pan signal
63    */
64   NavigationSignalV2& PanSignal();
65
66   /**
67    * Set the number of columns in the layout.
68    * @param[in] columns  The number of columns.
69    */
70   void SetNumberOfColumns(unsigned int columns);
71
72   /**
73    * Get the number of columns in the layout.
74    * @return The number of columns.
75    */
76   unsigned int GetNumberOfColumns() const;
77
78   /**
79    * Set the spacing between columns.
80    * @param[in] spacing The spacing.
81    */
82   void SetColumnSpacing(float spacing);
83
84   /**
85    * Get the spacing between columns.
86    * @return The spacing.
87    */
88   float GetColumnSpacing() const;
89
90   /**
91    * Set the margin in the top of the layout
92    * @param[in] margin The layout top margin.
93    */
94   void SetTopMargin(float margin);
95
96   /**
97    * Get the margin in the top of the layout
98    * @return The layout top margin.
99    */
100   float GetTopMargin() const;
101
102   /**
103    * Set the margin in the bottom of the layout
104    * @param[in] margin The layout bottom margin.
105    */
106   void SetBottomMargin(float margin);
107
108   /**
109    * Get the margin in the bottom of the layout
110    * @return The layout bottom margin.
111    */
112   float GetBottomMargin() const;
113
114   /**
115    * Set the margin in the left and right of the layout
116    * @param[in] margin The layout side margin.
117    */
118   void SetSideMargin(float margin);
119
120   /**
121    * Get the margin in the left and right of the layout
122    * @return The layout side margin.
123    */
124   float GetSideMargin() const;
125
126   /**
127    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
128    * @param[in] scrollSpeed The scroll speed factor.
129    */
130   void SetScrollSpeedFactor(float scrollSpeed);
131
132   /**
133    * Set the maximum swipe speed in pixels per second.
134    * @param[in] speed The maximum swipe speed.
135    */
136   void SetMaximumSwipeSpeed(float speed);
137
138   /**
139    * Set the duration of the flick animation in second. This is the time taken to animate each
140    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
141    * by a swipe gesture.
142    * @pre durationSeconds must be greater than zero.
143    * @param[in] durationSeconds The duration of flick animation in seconds.
144    */
145   void SetItemFlickAnimationDuration(float durationSeconds);
146
147   /**
148    * @copydoc ItemLayout::GetScrollSpeedFactor()
149    */
150   virtual float GetScrollSpeedFactor() const;
151
152   /**
153    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
154    */
155   virtual float GetMaximumSwipeSpeed() const;
156
157   /**
158    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
159    */
160   virtual float GetItemFlickAnimationDuration() const;
161
162 private:
163
164   /**
165    * @copydoc ItemLayout::GetMinimumLayoutPosition()
166    */
167   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
168
169   /**
170    * @copydoc ItemLayout::GetClosestAnchorPosition()
171    */
172   virtual float GetClosestAnchorPosition(float layoutPosition) const;
173
174   /**
175    * @copydoc ItemLayout::GetItemScrollToPosition()
176    */
177   virtual float GetItemScrollToPosition(unsigned int itemId) const;
178
179   /**
180    * @copydoc ItemLayout::GetItemsWithinArea()
181    */
182   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
183
184   /**
185    * @copydoc ItemLayout::GetReserveItemCount()
186    */
187   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
188
189   /**
190    * @copydoc ItemLayout::GetItemSize()
191    */
192   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
193
194   /**
195    * @copydoc ItemLayout::GetResizeAnimation()
196    */
197   virtual void GetResizeAnimation(Animation& animation,
198                                         Actor actor,
199                                         Vector3 size,
200                                         float durationSeconds) const;
201
202   /**
203    * @copydoc ItemLayout::GetPositionConstraint()
204    */
205   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
206
207   /**
208    * @copydoc ItemLayout::GetRotationConstraint()
209    */
210   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
211
212   /**
213    * @copydoc ItemLayout::GetScaleConstraint()
214    */
215   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
216
217   /**
218    * @copydoc ItemLayout::GetColorConstraint()
219    */
220   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
221
222   /**
223    * @copydoc ItemLayout::GetVisibilityConstraint()
224    */
225   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
226
227   /**
228    * @copydoc ItemLayout::GetScrollDirection()
229    */
230   virtual Degree GetScrollDirection() const;
231
232 protected:
233
234   /**
235    * Protected constructor; see also GridLayout::New()
236    */
237   NavigationLayout();
238
239 private:
240
241   struct Impl;
242   Impl* mImpl;
243 };
244
245 }
246 }
247 #endif //__DALI_TOOLKIT_NAVIGATION_LAYOUT_H__