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