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.
23 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
33 typedef IntrusivePtr<SpiralLayout> SpiralLayoutPtr;
36 * An ItemView layout which arranges items in a spiral.
38 class DALI_IMPORT_API SpiralLayout : public ItemLayout
42 typedef boost::function<Vector3 (const Vector3& layoutSize)> ItemSizeFunction;
43 typedef boost::function<float (const Vector3& layoutSize)> SpiralRadiusFunction;
46 * Create a new spiral layout
48 static SpiralLayoutPtr New();
53 virtual ~SpiralLayout();
56 * Set the function used to calculate the item-size, for a given layout-size.
57 * @param[in] function The item-size function.
59 void SetItemSizeFunction(ItemSizeFunction function);
62 * Get the function used to calculate the item-size
63 * @return The item-size function.
65 ItemSizeFunction GetItemSizeFunction() const;
68 * Set spacing angle between items.
69 * @param[in] itemSpacing The angle in radians.
71 void SetItemSpacing(Radian itemSpacing);
74 * Get spacing angle between items.
75 * @return The angle in radians.
77 Radian GetItemSpacing() const;
80 * Set the vertical distance for one revolution of the spiral.
81 * @param[in] distance The revolution distance.
83 void SetRevolutionDistance(float distance);
86 * Get the vertical distance for one revolution of the spiral.
87 * @return The revolution distance.
89 float GetRevolutionDistance() const;
92 * Set the function used to calculate the spiral radius, for a given layout-size.
93 * @param[in] function The spiral-radius function.
95 void SetSpiralRadiusFunction(SpiralRadiusFunction function);
98 * Get the function used to calculate the spiral radius.
99 * @return The spiral-radius function.
101 SpiralRadiusFunction GetSpiralRadiusFunction() const;
104 * Set the alignment of the top-item, when at the beginning of the spiral (with a first-item layout-position of zero).
105 * 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
106 * that the top-item is centred at the top or bottom of the layout respectively.
107 * @param[in] alignment The top-item alignment.
109 void SetTopItemAlignment(float alignment);
112 * Get the alignment of the top-item, when at the beginning of the spiral
113 * @return The top-item alignment.
115 float GetTopItemAlignment() const;
118 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
119 * @param[in] scrollSpeed The scroll speed factor.
121 void SetScrollSpeedFactor(float scrollSpeed);
124 * Set the maximum swipe speed in pixels per second.
125 * @param[in] speed The maximum swipe speed.
127 void SetMaximumSwipeSpeed(float speed);
130 * Set the duration of the flick animation in second. This is the time taken to animate each
131 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
132 * by a swipe gesture.
133 * @pre durationSeconds must be greater than zero.
134 * @param[in] durationSeconds The duration of flick animation in seconds.
136 void SetItemFlickAnimationDuration(float durationSeconds);
139 * @copydoc ItemLayout::GetScrollSpeedFactor()
141 virtual float GetScrollSpeedFactor() const;
144 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
146 virtual float GetMaximumSwipeSpeed() const;
149 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
151 virtual float GetItemFlickAnimationDuration() const;
154 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
156 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
161 * @copydoc ItemLayout::GetMinimumLayoutPosition()
163 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
166 * @copydoc ItemLayout::GetClosestAnchorPosition()
168 virtual float GetClosestAnchorPosition(float layoutPosition) const;
171 * @copydoc ItemLayout::GetItemScrollToPosition()
173 virtual float GetItemScrollToPosition(unsigned int itemId) const;
176 * @copydoc ItemLayout::GetItemsWithinArea()
178 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
181 * @copydoc ItemLayout::GetReserveItemCount()
183 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
186 * @copydoc ItemLayout::GetItemSize()
188 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
191 * @copydoc ItemLayout::GetResizeAnimation()
193 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
196 * @copydoc ItemLayout::GetPositionConstraint()
198 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
201 * @copydoc ItemLayout::GetRotationConstraint()
203 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
206 * @copydoc ItemLayout::GetScaleConstraint()
208 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
211 * @copydoc ItemLayout::GetColorConstraint()
213 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
216 * @copydoc ItemLayout::GetVisibilityConstraint()
218 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
221 * @copydoc ItemLayout::GetScrollDirection()
223 virtual Degree GetScrollDirection() const;
228 * Protected constructor; see also SpiralLayout::New()
238 } // namespace Toolkit
242 #endif // __DALI_TOOLKIT_SPIRAL_LAYOUT_H__