1 #ifndef __DALI_TOOLKIT_GRID_LAYOUT_H__
2 #define __DALI_TOOLKIT_GRID_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 * @addtogroup CAPI_DALI_TOOLKIT_ITEM_VIEW_MODULE
26 #include <dali/dali.h>
28 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
30 namespace Dali DALI_IMPORT_API
38 typedef IntrusivePtr<GridLayout> GridLayoutPtr; ///< Pointer to a Dali::Toolkit::GridLayout object
41 * @brief An ItemView layout which arranges items in a grid.
43 class GridLayout : public ItemLayout
48 * @brief Function signature for a method to calculate the item size.
50 * @see SetItemSizeFunction()
52 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)> ItemSizeFunction;
55 * @brief Create a new grid layout.
57 static GridLayoutPtr New();
60 * @brief Virtual destructor.
62 virtual ~GridLayout();
65 * @brief Set the number of columns in the layout.
67 * @param[in] columns The number of columns.
69 void SetNumberOfColumns(unsigned int columns);
72 * @brief Get the number of columns in the layout.
74 * @return The number of columns.
76 unsigned int GetNumberOfColumns() const;
79 * @brief Set the spacing between rows.
81 * @param[in] spacing The row spacing.
83 void SetRowSpacing(float spacing);
86 * @brief Get the spacing between rows.
88 * @return The row spacing.
90 float GetRowSpacing() const;
93 * @brief Set the spacing between columns.
95 * @param[in] spacing The row spacing.
97 void SetColumnSpacing(float spacing);
100 * @brief Get the spacing between columns.
102 * @return The row spacing.
104 float GetColumnSpacing() const;
107 * @brief Set the margin in the top of the layout.
109 * @param[in] margin The layout top margin.
111 void SetTopMargin(float margin);
114 * @brief Get the margin in the top of the layout.
116 * @return The layout top margin.
118 float GetTopMargin() const;
121 * @brief Set the margin in the bottom of the layout.
123 * @param[in] margin The layout bottom margin.
125 void SetBottomMargin(float margin);
128 * @brief Get the margin in the bottom of the layout.
130 * @return The layout bottom margin.
132 float GetBottomMargin() const;
135 * @brief Set the margin in the left and right of the layout.
137 * @param[in] margin The layout side margin.
139 void SetSideMargin(float margin);
142 * @brief Get the margin in the left and right of the layout.
144 * @return The layout side margin.
146 float GetSideMargin() const;
149 * @brief Set the gap of items in the Z axis in different columns.
151 * @param[in] gap The gap of items.
153 void SetZGap(float gap);
156 * @brief Get the gap of items in the Z axis in different columns.
158 * @return The gap of items.
160 float GetZGap() const;
163 * @brief Set the function used to calculate the item-size, for a given layout-size.
165 * @param[in] function The item-size function.
167 void SetItemSizeFunction(ItemSizeFunction function);
170 * @brief Get the function used to calculate the item-size.
172 * @return The item-size function.
174 ItemSizeFunction GetItemSizeFunction() const;
177 * @brief Set the factor used to customise the scroll speed while dragging and swiping the layout.
179 * @param[in] scrollSpeed The scroll speed factor.
181 void SetScrollSpeedFactor(float scrollSpeed);
184 * @brief Set the maximum swipe speed in pixels per second.
186 * @param[in] speed The maximum swipe speed.
188 void SetMaximumSwipeSpeed(float speed);
191 * @brief Set the duration of the flick animation in seconds.
193 * This is the time taken to animate each item to its next layout
194 * position (e.g. from 1.0 to 2.0) when a flick animation is
195 * triggered by a swipe gesture.
197 * @pre durationSeconds must be greater than zero.
198 * @param[in] durationSeconds The duration of flick animation in seconds.
200 void SetItemFlickAnimationDuration(float durationSeconds);
203 * @copydoc ItemLayout::GetScrollSpeedFactor()
205 virtual float GetScrollSpeedFactor() const;
208 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
210 virtual float GetMaximumSwipeSpeed() const;
213 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
215 virtual float GetItemFlickAnimationDuration() const;
218 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
220 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
223 * @copydoc ItemLayout::GetNextFocusItemID()
225 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
230 * @copydoc ItemLayout::GetMinimumLayoutPosition()
232 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
235 * @copydoc ItemLayout::GetClosestAnchorPosition()
237 virtual float GetClosestAnchorPosition(float layoutPosition) const;
240 * @copydoc ItemLayout::GetItemScrollToPosition()
242 virtual float GetItemScrollToPosition(unsigned int itemId) const;
245 * @copydoc ItemLayout::GetItemsWithinArea()
247 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
250 * @copydoc ItemLayout::GetReserveItemCount()
252 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
255 * @copydoc ItemLayout::GetItemSize()
257 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
260 * @copydoc ItemLayout::GetResizeAnimation()
262 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
265 * @copydoc ItemLayout::GetPositionConstraint()
267 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
270 * @copydoc ItemLayout::GetRotationConstraint()
272 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
275 * @copydoc ItemLayout::GetScaleConstraint()
277 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
280 * @copydoc ItemLayout::GetColorConstraint()
282 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
285 * @copydoc ItemLayout::GetVisibilityConstraint()
287 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
290 * @copydoc ItemLayout::GetScrollDirection()
292 virtual Degree GetScrollDirection() const;
297 * @brief Protected constructor; see also GridLayout::New().
307 } // namespace Toolkit
314 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__