License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / item-view / roll-layout.h
1 #ifndef __DALI_TOOLKIT_ROLL_LAYOUT_H__
2 #define __DALI_TOOLKIT_ROLL_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
24 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Toolkit
30 {
31
32 class RollLayout;
33
34 typedef IntrusivePtr<RollLayout> RollLayoutPtr;
35
36 /**
37  * An ItemView layout which arranges items in a roll.
38  */
39 class RollLayout : public ItemLayout
40 {
41 public:
42
43   typedef boost::function<Vector3 (float layoutWidth, float layoutHeight, float rowSpacing)> ItemSizeFunction;
44
45   /**
46    * Create a new roll layout
47    */
48   static RollLayoutPtr New();
49
50   /**
51    * Virtual destructor.
52    */
53   virtual ~RollLayout();
54
55   /**
56    * Set the spacing between rows.
57    * @param[in] spacing The row spacing.
58    */
59   void SetRowSpacing(float spacing);
60
61   /**
62    * Get the spacing between rows.
63    * @return The row spacing.
64    */
65   float GetRowSpacing() const;
66
67   /**
68    * Set the function used to calculate the item-size, for a given layout-size.
69    * @param[in] function The item-size function.
70    */
71   void SetItemSizeFunction(ItemSizeFunction function);
72
73   /**
74    * Get the function used to calculate the item-size.
75    * @return The item-size function.
76    */
77   ItemSizeFunction GetItemSizeFunction() const;
78
79   /**
80    * Set the factor used to customise the scroll speed while dragging and swiping the layout.
81    * @param[in] scrollSpeed The scroll speed factor.
82    */
83   void SetScrollSpeedFactor(float scrollSpeed);
84
85   /**
86    * Set the maximum swipe speed in pixels per second.
87    * @param[in] speed The maximum swipe speed.
88    */
89   void SetMaximumSwipeSpeed(float speed);
90
91   /**
92    * Set the duration of the flick animation in second. This is the time taken to animate each
93    * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
94    * by a swipe gesture.
95    * @pre durationSeconds must be greater than zero.
96    * @param[in] durationSeconds The duration of flick animation in seconds.
97    */
98   void SetItemFlickAnimationDuration(float durationSeconds);
99
100   /**
101    * @copydoc ItemLayout::GetScrollSpeedFactor()
102    */
103   virtual float GetScrollSpeedFactor() const;
104
105   /**
106    * @copydoc ItemLayout::GetMaximumSwipeSpeed()
107    */
108   virtual float GetMaximumSwipeSpeed() const;
109
110   /**
111    * @copydoc ItemLayout::GetItemFlickAnimationDuration()
112    */
113   virtual float GetItemFlickAnimationDuration() const;
114
115 private:
116
117   /**
118    * @copydoc ItemLayout::GetMinimumLayoutPosition()
119    */
120   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
121
122   /**
123    * @copydoc ItemLayout::GetClosestAnchorPosition()
124    */
125   virtual float GetClosestAnchorPosition(float layoutPosition) const;
126
127   /**
128    * @copydoc ItemLayout::GetItemScrollToPosition()
129    */
130   virtual float GetItemScrollToPosition(unsigned int itemId) const;
131
132   /**
133    * @copydoc ItemLayout::GetItemsWithinArea()
134    */
135   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
136
137   /**
138    * @copydoc ItemLayout::GetReserveItemCount()
139    */
140   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
141
142   /**
143    * @copydoc ItemLayout::GetItemSize()
144    */
145   virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
146
147   /**
148    * @copydoc ItemLayout::GetResizeAnimation()
149    */
150   virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
151
152   /**
153    * @copydoc ItemLayout::GetPositionConstraint()
154    */
155   virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
156
157   /**
158    * @copydoc ItemLayout::GetRotationConstraint()
159    */
160   virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
161
162   /**
163    * @copydoc ItemLayout::GetScaleConstraint()
164    */
165   virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
166
167   /**
168    * @copydoc ItemLayout::GetColorConstraint()
169    */
170   virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
171
172   /**
173    * @copydoc ItemLayout::GetVisibilityConstraint()
174    */
175   virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
176
177   /**
178    * @copydoc ItemLayout::GetScrollDirection()
179    */
180   virtual Degree GetScrollDirection() const;
181
182 protected:
183
184   /**
185    * Protected constructor; see also RollLayout::New()
186    */
187   RollLayout();
188
189 private:
190
191   struct Impl;
192   Impl* mImpl;
193 };
194
195 } // namespace Toolkit
196
197 } // namespace Dali
198
199 #endif // __DALI_TOOLKIT_ROLL_LAYOUT_H__