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