1 #ifndef __DALI_TOOLKIT_DEPTH_LAYOUT_H__
2 #define __DALI_TOOLKIT_DEPTH_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-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
32 typedef IntrusivePtr<DepthLayout> DepthLayoutPtr;
35 * This layout arranges items in a grid, which scrolls along the Z-Axis.
37 class DALI_IMPORT_API DepthLayout : public ItemLayout
41 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth)> ItemSizeFunction;
43 typedef boost::function<float (float layoutHeight)> BottomMarginFunction;
45 typedef boost::function<float (unsigned int numberOfColumns,
46 unsigned int columnNumber,
47 const Vector3& itemSize,
48 float layoutWidth)> ColumnPositionFunction;
51 * Create a new spiral layout
53 static DepthLayoutPtr New();
58 virtual ~DepthLayout();
61 * Set the number of columns in the layout.
62 * @param[in] columns The number of columns.
64 void SetNumberOfColumns(unsigned int columns);
67 * Get the number of columns in the layout.
68 * @return The number of columns.
70 unsigned int GetNumberOfColumns() const;
73 * Set the number of rows in the layout.
74 * The default is 20, with 10 behind the viewable area.
75 * @param[in] rows The number-of-rows.
77 void SetNumberOfRows(unsigned int rows);
80 * Get the number of rows in the layout.
81 * @return The number of rows.
83 unsigned int GetNumberOfRows() const;
86 * Set the spacing between rows.
87 * @param[in] spacing The row spacing.
89 void SetRowSpacing(float spacing);
92 * Get the spacing between rows.
93 * @return The row spacing.
95 float GetRowSpacing() const;
98 * Set the tilt angle of the layout; this is clamped between -45 & 45 degrees.
99 * @param[in] angle The tilt angle in degrees.
101 void SetTiltAngle(Degree angle);
104 * Get the tilt angle of the layout.
105 * @return The tilt angle in degrees.
107 Degree GetTiltAngle() const;
110 * Set the function used to calculate the item-size, for a given layout-size.
111 * @param[in] function The item-size function.
113 void SetItemSizeFunction(ItemSizeFunction function);
116 * Get the function used to calculate the item-size.
117 * @return The item-size function.
119 ItemSizeFunction GetItemSizeFunction() const;
122 * Set the function used to calculate the margin in the bottom of the layout, for a given layout-size.
123 * @param[in] function The bottom margin function.
125 void SetBottomMarginFunction(BottomMarginFunction function);
128 * Get the function used to calculate the margin in the bottom of the layout.
129 * @return The bottom margin function.
131 BottomMarginFunction GetBottomMarginFunction() const;
134 * Set the tilt angle of the individual items in the layout.
135 * @param[in] angle The item tilt angle in degrees.
137 void SetItemTiltAngle(Degree angle);
140 * Get the tilt angle of the individual items in the layout.
141 * @return The item tilt angle in degrees.
143 Degree GetItemTiltAngle() const;
146 * Set the function used to calculate the horizontal position of each column, for a given column, item-size & layout-size.
147 * @param[in] function The column-position function.
149 void SetColumnPositionFunction(ColumnPositionFunction function);
152 * Get the function used to calculate the horizontal position of each column
153 * @return The column-position function.
155 ColumnPositionFunction GetColumnPositionFunction() const;
158 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
159 * @param[in] scrollSpeed The scroll speed factor.
161 void SetScrollSpeedFactor(float scrollSpeed);
164 * Set the maximum swipe speed in pixels per second.
165 * @param[in] speed The maximum swipe speed.
167 void SetMaximumSwipeSpeed(float speed);
170 * Set the duration of the flick animation in second. This is the time taken to animate each
171 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
172 * by a swipe gesture.
173 * @pre durationSeconds must be greater than zero.
174 * @param[in] durationSeconds The duration of flick animation in seconds.
176 void SetItemFlickAnimationDuration(float durationSeconds);
179 * @copydoc ItemLayout::GetScrollSpeedFactor()
181 virtual float GetScrollSpeedFactor() const;
184 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
186 virtual float GetMaximumSwipeSpeed() const;
189 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
191 virtual float GetItemFlickAnimationDuration() const;
194 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
196 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
199 * @copydoc ItemLayout::GetNextFocusItemID()
201 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
206 * @copydoc ItemLayout::GetMinimumLayoutPosition()
208 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
211 * @copydoc ItemLayout::GetClosestAnchorPosition()
213 virtual float GetClosestAnchorPosition(float layoutPosition) const;
216 * @copydoc ItemLayout::GetItemScrollToPosition()
218 virtual float GetItemScrollToPosition(unsigned int itemId) const;
221 * @copydoc ItemLayout::GetItemsWithinArea()
223 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
226 * @copydoc ItemLayout::GetReserveItemCount()
228 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
231 * @copydoc ItemLayout::GetItemSize()
233 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
236 * @copydoc ItemLayout::GetResizeAnimation()
238 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
241 * @copydoc ItemLayout::GetPositionConstraint()
243 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
246 * @copydoc ItemLayout::GetRotationConstraint()
248 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
251 * @copydoc ItemLayout::GetScaleConstraint()
253 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
256 * @copydoc ItemLayout::GetColorConstraint()
258 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
261 * @copydoc ItemLayout::GetVisibilityConstraint()
263 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
266 * @copydoc ItemLayout::GetScrollDirection()
268 virtual Degree GetScrollDirection() const;
273 * Protected constructor; see also DepthLayout::New()
283 } // namespace Toolkit
287 #endif // __DALI_TOOLKIT_DEPTH_LAYOUT_H__