1 #ifndef __DALI_TOOLKIT_SPIRAL_LAYOUT_H__
2 #define __DALI_TOOLKIT_SPIRAL_LAYOUT_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/dali.h>
24 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
26 namespace Dali DALI_IMPORT_API
34 typedef IntrusivePtr<SpiralLayout> SpiralLayoutPtr;
37 * An ItemView layout which arranges items in a spiral.
39 class SpiralLayout : public ItemLayout
43 typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
44 typedef boost::function<float (const Vector3& layoutSize)> SpiralRadiusFunction;
47 * Create a new spiral layout
49 static SpiralLayoutPtr New();
54 virtual ~SpiralLayout();
57 * Set the function used to calculate the item-size, for a given layout-size.
58 * @param[in] function The item-size function.
60 void SetItemSizeFunction(ItemSizeFunction function);
63 * Get the function used to calculate the item-size
64 * @return The item-size function.
66 ItemSizeFunction GetItemSizeFunction() const;
69 * Set spacing angle between items.
70 * @param[in] itemSpacing The angle in radians.
72 void SetItemSpacing(Radian itemSpacing);
75 * Get spacing angle between items.
76 * @return The angle in radians.
78 Radian GetItemSpacing() const;
81 * Set the vertical distance for one revolution of the spiral.
82 * @param[in] distance The revolution distance.
84 void SetRevolutionDistance(float distance);
87 * Get the vertical distance for one revolution of the spiral.
88 * @return The revolution distance.
90 float GetRevolutionDistance() const;
93 * Set the function used to calculate the spiral radius, for a given layout-size.
94 * @param[in] function The spiral-radius function.
96 void SetSpiralRadiusFunction(SpiralRadiusFunction function);
99 * Get the function used to calculate the spiral radius.
100 * @return The spiral-radius function.
102 SpiralRadiusFunction GetSpiralRadiusFunction() const;
105 * Set the alignment of the top-item, when at the beginning of the spiral (with a first-item layout-position of zero).
106 * 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
107 * that the top-item is centred at the top or bottom of the layout respectively.
108 * @param[in] alignment The top-item alignment.
110 void SetTopItemAlignment(float alignment);
113 * Get the alignment of the top-item, when at the beginning of the spiral
114 * @return The top-item alignment.
116 float GetTopItemAlignment() const;
119 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
120 * @param[in] scrollSpeed The scroll speed factor.
122 void SetScrollSpeedFactor(float scrollSpeed);
125 * Set the maximum swipe speed in pixels per second.
126 * @param[in] speed The maximum swipe speed.
128 void SetMaximumSwipeSpeed(float speed);
131 * Set the duration of the flick animation in second. This is the time taken to animate each
132 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
133 * by a swipe gesture.
134 * @pre durationSeconds must be greater than zero.
135 * @param[in] durationSeconds The duration of flick animation in seconds.
137 void SetItemFlickAnimationDuration(float durationSeconds);
140 * @copydoc ItemLayout::GetScrollSpeedFactor()
142 virtual float GetScrollSpeedFactor() const;
145 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
147 virtual float GetMaximumSwipeSpeed() const;
150 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
152 virtual float GetItemFlickAnimationDuration() const;
155 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
157 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
162 * @copydoc ItemLayout::GetMinimumLayoutPosition()
164 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
167 * @copydoc ItemLayout::GetClosestAnchorPosition()
169 virtual float GetClosestAnchorPosition(float layoutPosition) const;
172 * @copydoc ItemLayout::GetItemScrollToPosition()
174 virtual float GetItemScrollToPosition(unsigned int itemId) const;
177 * @copydoc ItemLayout::GetItemsWithinArea()
179 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
182 * @copydoc ItemLayout::GetReserveItemCount()
184 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
187 * @copydoc ItemLayout::GetItemSize()
189 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
192 * @copydoc ItemLayout::GetResizeAnimation()
194 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
197 * @copydoc ItemLayout::GetPositionConstraint()
199 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
202 * @copydoc ItemLayout::GetRotationConstraint()
204 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
207 * @copydoc ItemLayout::GetScaleConstraint()
209 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
212 * @copydoc ItemLayout::GetColorConstraint()
214 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
217 * @copydoc ItemLayout::GetVisibilityConstraint()
219 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
222 * @copydoc ItemLayout::GetScrollDirection()
224 virtual Degree GetScrollDirection() const;
229 * Protected constructor; see also SpiralLayout::New()
239 } // namespace Toolkit
243 #endif // __DALI_TOOLKIT_SPIRAL_LAYOUT_H__