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 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 * @addtogroup CAPI_DALI_TOOLKIT_ITEM_VIEW_MODULE
27 #include <dali/dali.h>
29 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
31 namespace Dali DALI_IMPORT_API
39 typedef IntrusivePtr<GridLayout> GridLayoutPtr; ///< Pointer to a Dali::Toolkit::GridLayout object
42 * @brief An ItemView layout which arranges items in a grid.
44 class GridLayout : public ItemLayout
49 * @brief Function signature for a method to calculate the item size.
51 * @see SetItemSizeFunction()
53 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)> ItemSizeFunction;
56 * @brief Create a new grid layout.
58 static GridLayoutPtr New();
61 * @brief Virtual destructor.
63 virtual ~GridLayout();
66 * @brief Set the number of columns in the layout.
68 * @param[in] columns The number of columns.
70 void SetNumberOfColumns(unsigned int columns);
73 * @brief Get the number of columns in the layout.
75 * @return The number of columns.
77 unsigned int GetNumberOfColumns() const;
80 * @brief Set the spacing between rows.
82 * @param[in] spacing The row spacing.
84 void SetRowSpacing(float spacing);
87 * @brief Get the spacing between rows.
89 * @return The row spacing.
91 float GetRowSpacing() const;
94 * @brief Set the spacing between columns.
96 * @param[in] spacing The row spacing.
98 void SetColumnSpacing(float spacing);
101 * @brief Get the spacing between columns.
103 * @return The row spacing.
105 float GetColumnSpacing() const;
108 * @brief Set the margin in the top of the layout.
110 * @param[in] margin The layout top margin.
112 void SetTopMargin(float margin);
115 * @brief Get the margin in the top of the layout.
117 * @return The layout top margin.
119 float GetTopMargin() const;
122 * @brief Set the margin in the bottom of the layout.
124 * @param[in] margin The layout bottom margin.
126 void SetBottomMargin(float margin);
129 * @brief Get the margin in the bottom of the layout.
131 * @return The layout bottom margin.
133 float GetBottomMargin() const;
136 * @brief Set the margin in the left and right of the layout.
138 * @param[in] margin The layout side margin.
140 void SetSideMargin(float margin);
143 * @brief Get the margin in the left and right of the layout.
145 * @return The layout side margin.
147 float GetSideMargin() const;
150 * @brief Set the gap of items in the Z axis in different columns.
152 * @param[in] gap The gap of items.
154 void SetZGap(float gap);
157 * @brief Get the gap of items in the Z axis in different columns.
159 * @return The gap of items.
161 float GetZGap() const;
164 * @brief Set the function used to calculate the item-size, for a given layout-size.
166 * @param[in] function The item-size function.
168 void SetItemSizeFunction(ItemSizeFunction function);
171 * @brief Get the function used to calculate the item-size.
173 * @return The item-size function.
175 ItemSizeFunction GetItemSizeFunction() const;
178 * @brief Set the factor used to customise the scroll speed while dragging and swiping the layout.
180 * @param[in] scrollSpeed The scroll speed factor.
182 void SetScrollSpeedFactor(float scrollSpeed);
185 * @brief Set the maximum swipe speed in pixels per second.
187 * @param[in] speed The maximum swipe speed.
189 void SetMaximumSwipeSpeed(float speed);
192 * @brief Set the duration of the flick animation in seconds.
194 * This is the time taken to animate each item to its next layout
195 * position (e.g. from 1.0 to 2.0) when a flick animation is
196 * triggered by a swipe gesture.
198 * @pre durationSeconds must be greater than zero.
199 * @param[in] durationSeconds The duration of flick animation in seconds.
201 void SetItemFlickAnimationDuration(float durationSeconds);
204 * @copydoc ItemLayout::GetScrollSpeedFactor()
206 virtual float GetScrollSpeedFactor() const;
209 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
211 virtual float GetMaximumSwipeSpeed() const;
214 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
216 virtual float GetItemFlickAnimationDuration() const;
219 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
221 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
224 * @copydoc ItemLayout::GetNextFocusItemID()
226 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
231 * @copydoc ItemLayout::GetMinimumLayoutPosition()
233 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
236 * @copydoc ItemLayout::GetClosestAnchorPosition()
238 virtual float GetClosestAnchorPosition(float layoutPosition) const;
241 * @copydoc ItemLayout::GetItemScrollToPosition()
243 virtual float GetItemScrollToPosition(unsigned int itemId) const;
246 * @copydoc ItemLayout::GetItemsWithinArea()
248 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
251 * @copydoc ItemLayout::GetReserveItemCount()
253 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
256 * @copydoc ItemLayout::GetItemSize()
258 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
261 * @copydoc ItemLayout::GetResizeAnimation()
263 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
266 * @copydoc ItemLayout::GetPositionConstraint()
268 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
271 * @copydoc ItemLayout::GetRotationConstraint()
273 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
276 * @copydoc ItemLayout::GetScaleConstraint()
278 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
281 * @copydoc ItemLayout::GetColorConstraint()
283 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
286 * @copydoc ItemLayout::GetVisibilityConstraint()
288 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
291 * @copydoc ItemLayout::GetScrollDirection()
293 virtual Degree GetScrollDirection() const;
298 * @brief Protected constructor; see also GridLayout::New().
308 } // namespace Toolkit
315 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__