1 #ifndef DALI_TOOLKIT_SPIRAL_LAYOUT_H
2 #define DALI_TOOLKIT_SPIRAL_LAYOUT_H
5 * Copyright (c) 2021 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 SpiralLayout : public ItemLayout
42 * Create a new spiral layout
44 static SpiralLayoutPtr New();
49 virtual ~SpiralLayout();
52 * Apply spiral layout Properties.
53 * @param[in] properties The properties of the layout.
55 void SetSpiralLayoutProperties(const Property::Map& properties);
58 * Set spacing angle between items.
59 * @param[in] itemSpacing The angle in radians.
61 void SetItemSpacing(Radian itemSpacing);
64 * Get spacing angle between items.
65 * @return The angle in radians.
67 Radian GetItemSpacing() const;
70 * Set the vertical distance for one revolution of the spiral.
71 * @param[in] distance The revolution distance.
73 void SetRevolutionDistance(float distance);
76 * Get the vertical distance for one revolution of the spiral.
77 * @return The revolution distance.
79 float GetRevolutionDistance() const;
82 * Set the alignment of the top-item, when at the beginning of the spiral (with a first-item layout-position of zero).
83 * 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
84 * that the top-item is centred at the top or bottom of the layout respectively.
85 * @param[in] alignment The top-item alignment.
87 void SetTopItemAlignment(float alignment);
90 * Get the alignment of the top-item, when at the beginning of the spiral
91 * @return The top-item alignment.
93 float GetTopItemAlignment() const;
96 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
97 * @param[in] scrollSpeed The scroll speed factor.
99 void SetScrollSpeedFactor(float scrollSpeed);
102 * Set the maximum swipe speed in pixels per second.
103 * @param[in] speed The maximum swipe speed.
105 void SetMaximumSwipeSpeed(float speed);
108 * Set the duration of the flick animation in second. This is the time taken to animate each
109 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
110 * by a swipe gesture.
111 * @pre durationSeconds must be greater than zero.
112 * @param[in] durationSeconds The duration of flick animation in seconds.
114 void SetItemFlickAnimationDuration(float durationSeconds);
117 * @copydoc ItemLayout::GetScrollSpeedFactor()
119 float GetScrollSpeedFactor() const override;
122 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
124 float GetMaximumSwipeSpeed() const override;
127 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
129 float GetItemFlickAnimationDuration() const override;
132 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
134 float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) override;
138 * @copydoc ItemLayout::GetMinimumLayoutPosition()
140 float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const override;
143 * @copydoc ItemLayout::GetClosestAnchorPosition()
145 float GetClosestAnchorPosition(float layoutPosition) const override;
148 * @copydoc ItemLayout::GetItemScrollToPosition()
150 float GetItemScrollToPosition(unsigned int itemId) const override;
153 * @copydoc ItemLayout::GetItemsWithinArea()
155 ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const override;
158 * @copydoc ItemLayout::GetReserveItemCount()
160 unsigned int GetReserveItemCount(Vector3 layoutSize) const override;
163 * @copydoc ItemLayout::GetDefaultItemSize()
165 void GetDefaultItemSize(unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize) const override;
168 * @copydoc ItemLayout::GetScrollDirection()
170 Degree GetScrollDirection() const override;
173 * @copydoc ItemLayout::ApplyConstraints()
175 void ApplyConstraints(Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor) override;
178 * @copydoc ItemLayout::GetItemPosition()
180 Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const override;
184 * Protected constructor; see also SpiralLayout::New()
190 SpiralLayout(const SpiralLayout& spiralLayout);
193 SpiralLayout& operator=(const SpiralLayout& spiralLayout);
200 } // namespace Internal
202 } // namespace Toolkit
206 #endif // DALI_TOOLKIT_SPIRAL_LAYOUT_H