1 #ifndef __DALI_TOOLKIT_GRID_LAYOUT_H__
2 #define __DALI_TOOLKIT_GRID_LAYOUT_H__
5 * Copyright (c) 2015 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>
36 typedef IntrusivePtr<GridLayout> GridLayoutPtr; ///< Pointer to a Dali::Toolkit::GridLayout object
39 * @brief An ItemView layout which arranges items in a grid.
41 class GridLayout : public ItemLayout
46 * @brief Create a new grid layout.
48 static GridLayoutPtr New();
51 * @brief Virtual destructor.
53 virtual ~GridLayout();
56 * @brief Set the number of columns in the layout.
58 * @param[in] columns The number of columns.
60 void SetNumberOfColumns(unsigned int columns);
63 * @brief Get the number of columns in the layout.
65 * @return The number of columns.
67 unsigned int GetNumberOfColumns() const;
70 * @brief Set the spacing between rows.
72 * @param[in] spacing The row spacing.
74 void SetRowSpacing(float spacing);
77 * @brief Get the spacing between rows.
79 * @return The row spacing.
81 float GetRowSpacing() const;
84 * @brief Set the spacing between columns.
86 * @param[in] spacing The row spacing.
88 void SetColumnSpacing(float spacing);
91 * @brief Get the spacing between columns.
93 * @return The row spacing.
95 float GetColumnSpacing() const;
98 * @brief Set the margin in the top of the layout.
100 * @param[in] margin The layout top margin.
102 void SetTopMargin(float margin);
105 * @brief Get the margin in the top of the layout.
107 * @return The layout top margin.
109 float GetTopMargin() const;
112 * @brief Set the margin in the bottom of the layout.
114 * @param[in] margin The layout bottom margin.
116 void SetBottomMargin(float margin);
119 * @brief Get the margin in the bottom of the layout.
121 * @return The layout bottom margin.
123 float GetBottomMargin() const;
126 * @brief Set the margin in the left and right of the layout.
128 * @param[in] margin The layout side margin.
130 void SetSideMargin(float margin);
133 * @brief Get the margin in the left and right of the layout.
135 * @return The layout side margin.
137 float GetSideMargin() const;
140 * @brief Set the gap of items in the Z axis in different columns.
142 * @param[in] gap The gap of items.
144 void SetZGap(float gap);
147 * @brief Get the gap of items in the Z axis in different columns.
149 * @return The gap of items.
151 float GetZGap() const;
154 * @brief Set the factor used to customise the scroll speed while dragging and swiping the layout.
156 * @param[in] scrollSpeed The scroll speed factor.
158 void SetScrollSpeedFactor(float scrollSpeed);
161 * @brief Set the maximum swipe speed in pixels per second.
163 * @param[in] speed The maximum swipe speed.
165 void SetMaximumSwipeSpeed(float speed);
168 * @brief Set the duration of the flick animation in seconds.
170 * This is the time taken to animate each item to its next layout
171 * position (e.g. from 1.0 to 2.0) when a flick animation is
172 * triggered 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::KeyboardFocus::Direction 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::GetDefaultItemSize()
234 virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const;
237 * @copydoc ItemLayout::GetScrollDirection()
239 virtual Degree GetScrollDirection() const;
242 * @copydoc ItemLayout::ApplyConstraints()
244 virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor );
247 * @copydoc ItemLayout::GetItemPosition()
249 virtual Vector3 GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const;
254 * @brief Protected constructor; see also GridLayout::New().
264 } // namespace Internal
266 } // namespace Toolkit
270 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__