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_FRAMEWORK
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;
41 * An ItemView layout which arranges items in a grid.
43 class GridLayout : public ItemLayout
47 typedef boost::function<Vector3 (unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing)> ItemSizeFunction;
50 * Create a new grid layout
52 static GridLayoutPtr New();
57 virtual ~GridLayout();
60 * Set the number of columns in the layout.
61 * @param[in] columns The number of columns.
63 void SetNumberOfColumns(unsigned int columns);
66 * Get the number of columns in the layout.
67 * @return The number of columns.
69 unsigned int GetNumberOfColumns() const;
72 * Set the spacing between rows.
73 * @param[in] spacing The row spacing.
75 void SetRowSpacing(float spacing);
78 * Get the spacing between rows.
79 * @return The row spacing.
81 float GetRowSpacing() const;
84 * Set the spacing between columns.
85 * @param[in] spacing The row spacing.
87 void SetColumnSpacing(float spacing);
90 * Get the spacing between columns.
91 * @return The row spacing.
93 float GetColumnSpacing() const;
96 * Set the margin in the top of the layout
97 * @param[in] margin The layout top margin.
99 void SetTopMargin(float margin);
102 * Get the margin in the top of the layout
103 * @return The layout top margin.
105 float GetTopMargin() const;
108 * Set the margin in the bottom of the layout
109 * @param[in] margin The layout bottom margin.
111 void SetBottomMargin(float margin);
114 * Get the margin in the bottom of the layout
115 * @return The layout bottom margin.
117 float GetBottomMargin() const;
120 * Set the margin in the left and right of the layout
121 * @param[in] margin The layout side margin.
123 void SetSideMargin(float margin);
126 * Get the margin in the left and right of the layout
127 * @return The layout side margin.
129 float GetSideMargin() const;
132 * Set the gap of items in the Z axis in different columns.
133 * @param[in] gap The gap of items.
135 void SetZGap(float gap);
138 * Get the gap of items in the Z axis in different columns.
139 * @return The gap of items.
141 float GetZGap() const;
144 * Set the function used to calculate the item-size, for a given layout-size.
145 * @param[in] function The item-size function.
147 void SetItemSizeFunction(ItemSizeFunction function);
150 * Get the function used to calculate the item-size.
151 * @return The item-size function.
153 ItemSizeFunction GetItemSizeFunction() const;
156 * Set the factor used to customise the scroll speed while dragging and swiping the layout.
157 * @param[in] scrollSpeed The scroll speed factor.
159 void SetScrollSpeedFactor(float scrollSpeed);
162 * Set the maximum swipe speed in pixels per second.
163 * @param[in] speed The maximum swipe speed.
165 void SetMaximumSwipeSpeed(float speed);
168 * Set the duration of the flick animation in second. This is the time taken to animate each
169 * item to its next layout position (e.g. from 1.0 to 2.0) when a flick animation is triggered
170 * by a swipe gesture.
171 * @pre durationSeconds must be greater than zero.
172 * @param[in] durationSeconds The duration of flick animation in seconds.
174 void SetItemFlickAnimationDuration(float durationSeconds);
177 * @copydoc ItemLayout::GetScrollSpeedFactor()
179 virtual float GetScrollSpeedFactor() const;
182 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
184 virtual float GetMaximumSwipeSpeed() const;
187 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
189 virtual float GetItemFlickAnimationDuration() const;
192 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
194 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
197 * @copydoc ItemLayout::GetNextFocusItemID()
199 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
204 * @copydoc ItemLayout::GetMinimumLayoutPosition()
206 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
209 * @copydoc ItemLayout::GetClosestAnchorPosition()
211 virtual float GetClosestAnchorPosition(float layoutPosition) const;
214 * @copydoc ItemLayout::GetItemScrollToPosition()
216 virtual float GetItemScrollToPosition(unsigned int itemId) const;
219 * @copydoc ItemLayout::GetItemsWithinArea()
221 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
224 * @copydoc ItemLayout::GetReserveItemCount()
226 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
229 * @copydoc ItemLayout::GetItemSize()
231 virtual bool GetItemSize(unsigned int itemId, Vector3 layoutSize, Vector3& itemSize) const;
234 * @copydoc ItemLayout::GetResizeAnimation()
236 virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const;
239 * @copydoc ItemLayout::GetPositionConstraint()
241 virtual bool GetPositionConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
244 * @copydoc ItemLayout::GetRotationConstraint()
246 virtual bool GetRotationConstraint(unsigned int itemId, ItemLayout::QuaternionFunction& constraint) const;
249 * @copydoc ItemLayout::GetScaleConstraint()
251 virtual bool GetScaleConstraint(unsigned int itemId, ItemLayout::Vector3Function& constraint) const;
254 * @copydoc ItemLayout::GetColorConstraint()
256 virtual bool GetColorConstraint(unsigned int itemId, ItemLayout::Vector4Function& constraint) const;
259 * @copydoc ItemLayout::GetVisibilityConstraint()
261 virtual bool GetVisibilityConstraint(unsigned int itemId, ItemLayout::BoolFunction& constraint) const;
264 * @copydoc ItemLayout::GetScrollDirection()
266 virtual Degree GetScrollDirection() const;
271 * Protected constructor; see also GridLayout::New()
281 } // namespace Toolkit
288 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__