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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
23 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
25 namespace Dali DALI_IMPORT_API
33 typedef IntrusivePtr<DepthLayout> DepthLayoutPtr;
36 * This layout arranges items in a grid, which scrolls along the Z-Axis.
38 class DepthLayout : public ItemLayout
42 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth)> ItemSizeFunction;
44 typedef boost::function<float (float layoutHeight)> BottomMarginFunction;
46 typedef boost::function<float (unsigned int numberOfColumns,
47 unsigned int columnNumber,
48 const Vector3& itemSize,
49 float layoutWidth)> ColumnPositionFunction;
52 * Create a new spiral layout
54 static DepthLayoutPtr New();
59 virtual ~DepthLayout();
62 * Set the number of columns in the layout.
63 * @param[in] columns The number of columns.
65 void SetNumberOfColumns(unsigned int columns);
68 * Get the number of columns in the layout.
69 * @return The number of columns.
71 unsigned int GetNumberOfColumns() const;
74 * Set the number of rows in the layout.
75 * The default is 20, with 10 behind the viewable area.
76 * @param[in] rows The number-of-rows.
78 void SetNumberOfRows(unsigned int rows);
81 * Get the number of rows in the layout.
82 * @return The number of rows.
84 unsigned int GetNumberOfRows() const;
87 * Set the spacing between rows.
88 * @param[in] spacing The row spacing.
90 void SetRowSpacing(float spacing);
93 * Get the spacing between rows.
94 * @return The row spacing.
96 float GetRowSpacing() const;
99 * Set the tilt angle of the layout; this is clamped between -45 & 45 degrees.
100 * @param[in] angle The tilt angle in degrees.
102 void SetTiltAngle(Degree angle);
105 * Get the tilt angle of the layout.
106 * @return The tilt angle in degrees.
108 Degree GetTiltAngle() const;
111 * Set the function used to calculate the item-size, for a given layout-size.
112 * @param[in] function The item-size function.
114 void SetItemSizeFunction(ItemSizeFunction function);
117 * Get the function used to calculate the item-size.
118 * @return The item-size function.
120 ItemSizeFunction GetItemSizeFunction() const;
123 * Set the function used to calculate the margin in the bottom of the layout, for a given layout-size.
124 * @param[in] function The bottom margin function.
126 void SetBottomMarginFunction(BottomMarginFunction function);
129 * Get the function used to calculate the margin in the bottom of the layout.
130 * @return The bottom margin function.
132 BottomMarginFunction GetBottomMarginFunction() const;
135 * Set the tilt angle of the individual items in the layout.
136 * @param[in] angle The item tilt angle in degrees.
138 void SetItemTiltAngle(Degree angle);
141 * Get the tilt angle of the individual items in the layout.
142 * @return The item tilt angle in degrees.
144 Degree GetItemTiltAngle() const;
147 * Set the function used to calculate the horizontal position of each column, for a given column, item-size & layout-size.
148 * @param[in] function The column-position function.
150 void SetColumnPositionFunction(ColumnPositionFunction function);
153 * Get the function used to calculate the horizontal position of each column
154 * @return The column-position function.
156 ColumnPositionFunction GetColumnPositionFunction() const;
159 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
160 * @param[in] scrollSpeed The scroll speed factor.
162 void SetScrollSpeedFactor(float scrollSpeed);
165 * Set the maximum swipe speed in pixels per second.
166 * @param[in] speed The maximum swipe speed.
168 void SetMaximumSwipeSpeed(float speed);
171 * Set the duration of the flick animation in second. This is the time taken to animate each
172 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
173 * by a swipe gesture.
174 * @pre durationSeconds must be greater than zero.
175 * @param[in] durationSeconds The duration of flick animation in seconds.
177 void SetItemFlickAnimationDuration(float durationSeconds);
180 * @copydoc ItemLayout::GetScrollSpeedFactor()
182 virtual float GetScrollSpeedFactor() const;
185 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
187 virtual float GetMaximumSwipeSpeed() const;
190 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
192 virtual float GetItemFlickAnimationDuration() const;
195 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
197 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
200 * @copydoc ItemLayout::GetNextFocusItemID()
202 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
207 * @copydoc ItemLayout::GetMinimumLayoutPosition()
209 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
212 * @copydoc ItemLayout::GetClosestAnchorPosition()
214 virtual float GetClosestAnchorPosition(float layoutPosition) const;
217 * @copydoc ItemLayout::GetItemScrollToPosition()
219 virtual float GetItemScrollToPosition(unsigned int itemId) const;
222 * @copydoc ItemLayout::GetItemsWithinArea()
224 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
227 * @copydoc ItemLayout::GetReserveItemCount()
229 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
232 * @copydoc ItemLayout::GetItemSize()
234 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
237 * @copydoc ItemLayout::GetResizeAnimation()
239 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
242 * @copydoc ItemLayout::GetPositionConstraint()
244 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
247 * @copydoc ItemLayout::GetRotationConstraint()
249 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
252 * @copydoc ItemLayout::GetScaleConstraint()
254 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
257 * @copydoc ItemLayout::GetColorConstraint()
259 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
262 * @copydoc ItemLayout::GetVisibilityConstraint()
264 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
267 * @copydoc ItemLayout::GetScrollDirection()
269 virtual Degree GetScrollDirection() const;
274 * Protected constructor; see also DepthLayout::New()
284 } // namespace Toolkit
288 #endif // __DALI_TOOLKIT_DEPTH_LAYOUT_H__