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/dali.h>
24 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
26 namespace Dali DALI_IMPORT_API
34 typedef IntrusivePtr<DepthLayout> DepthLayoutPtr;
37 * This layout arranges items in a grid, which scrolls along the Z-Axis.
39 class DepthLayout : public ItemLayout
43 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth)> ItemSizeFunction;
45 typedef boost::function<float (float layoutHeight)> BottomMarginFunction;
47 typedef boost::function<float (unsigned int numberOfColumns,
48 unsigned int columnNumber,
49 const Vector3& itemSize,
50 float layoutWidth)> ColumnPositionFunction;
53 * Create a new spiral layout
55 static DepthLayoutPtr New();
60 virtual ~DepthLayout();
63 * Set the number of columns in the layout.
64 * @param[in] columns The number of columns.
66 void SetNumberOfColumns(unsigned int columns);
69 * Get the number of columns in the layout.
70 * @return The number of columns.
72 unsigned int GetNumberOfColumns() const;
75 * Set the number of rows in the layout.
76 * The default is 20, with 10 behind the viewable area.
77 * @param[in] rows The number-of-rows.
79 void SetNumberOfRows(unsigned int rows);
82 * Get the number of rows in the layout.
83 * @return The number of rows.
85 unsigned int GetNumberOfRows() const;
88 * Set the spacing between rows.
89 * @param[in] spacing The row spacing.
91 void SetRowSpacing(float spacing);
94 * Get the spacing between rows.
95 * @return The row spacing.
97 float GetRowSpacing() const;
100 * Set the tilt angle of the layout; this is clamped between -45 & 45 degrees.
101 * @param[in] angle The tilt angle in degrees.
103 void SetTiltAngle(Degree angle);
106 * Get the tilt angle of the layout.
107 * @return The tilt angle in degrees.
109 Degree GetTiltAngle() const;
112 * Set the function used to calculate the item-size, for a given layout-size.
113 * @param[in] function The item-size function.
115 void SetItemSizeFunction(ItemSizeFunction function);
118 * Get the function used to calculate the item-size.
119 * @return The item-size function.
121 ItemSizeFunction GetItemSizeFunction() const;
124 * Set the function used to calculate the margin in the bottom of the layout, for a given layout-size.
125 * @param[in] function The bottom margin function.
127 void SetBottomMarginFunction(BottomMarginFunction function);
130 * Get the function used to calculate the margin in the bottom of the layout.
131 * @return The bottom margin function.
133 BottomMarginFunction GetBottomMarginFunction() const;
136 * Set the tilt angle of the individual items in the layout.
137 * @param[in] angle The item tilt angle in degrees.
139 void SetItemTiltAngle(Degree angle);
142 * Get the tilt angle of the individual items in the layout.
143 * @return The item tilt angle in degrees.
145 Degree GetItemTiltAngle() const;
148 * Set the function used to calculate the horizontal position of each column, for a given column, item-size & layout-size.
149 * @param[in] function The column-position function.
151 void SetColumnPositionFunction(ColumnPositionFunction function);
154 * Get the function used to calculate the horizontal position of each column
155 * @return The column-position function.
157 ColumnPositionFunction GetColumnPositionFunction() const;
160 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
161 * @param[in] scrollSpeed The scroll speed factor.
163 void SetScrollSpeedFactor(float scrollSpeed);
166 * Set the maximum swipe speed in pixels per second.
167 * @param[in] speed The maximum swipe speed.
169 void SetMaximumSwipeSpeed(float speed);
172 * Set the duration of the flick animation in second. This is the time taken to animate each
173 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
174 * by a swipe gesture.
175 * @pre durationSeconds must be greater than zero.
176 * @param[in] durationSeconds The duration of flick animation in seconds.
178 void SetItemFlickAnimationDuration(float durationSeconds);
181 * @copydoc ItemLayout::GetScrollSpeedFactor()
183 virtual float GetScrollSpeedFactor() const;
186 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
188 virtual float GetMaximumSwipeSpeed() const;
191 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
193 virtual float GetItemFlickAnimationDuration() const;
196 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
198 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
201 * @copydoc ItemLayout::GetNextFocusItemID()
203 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
208 * @copydoc ItemLayout::GetMinimumLayoutPosition()
210 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
213 * @copydoc ItemLayout::GetClosestAnchorPosition()
215 virtual float GetClosestAnchorPosition(float layoutPosition) const;
218 * @copydoc ItemLayout::GetItemScrollToPosition()
220 virtual float GetItemScrollToPosition(unsigned int itemId) const;
223 * @copydoc ItemLayout::GetItemsWithinArea()
225 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
228 * @copydoc ItemLayout::GetReserveItemCount()
230 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
233 * @copydoc ItemLayout::GetItemSize()
235 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
238 * @copydoc ItemLayout::GetResizeAnimation()
240 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
243 * @copydoc ItemLayout::GetPositionConstraint()
245 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
248 * @copydoc ItemLayout::GetRotationConstraint()
250 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
253 * @copydoc ItemLayout::GetScaleConstraint()
255 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
258 * @copydoc ItemLayout::GetColorConstraint()
260 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
263 * @copydoc ItemLayout::GetVisibilityConstraint()
265 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
268 * @copydoc ItemLayout::GetScrollDirection()
270 virtual Degree GetScrollDirection() const;
275 * Protected constructor; see also DepthLayout::New()
285 } // namespace Toolkit
289 #endif // __DALI_TOOLKIT_DEPTH_LAYOUT_H__