1 #ifndef __DALI_TOOLKIT_GRID_LAYOUT_H__
2 #define __DALI_TOOLKIT_GRID_LAYOUT_H__
5 * Copyright (c) 2018 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>
25 #include <dali-toolkit/public-api/dali-toolkit-common.h>
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 Create a new grid layout.
51 static GridLayoutPtr New();
54 * @brief Virtual destructor.
56 virtual ~GridLayout();
59 * Apply grid layout Properties.
60 * @param[in] properties The properties of the layout.
62 void SetGridLayoutProperties(const Property::Map& properties);
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 factor used to customise the scroll speed while dragging and swiping the layout.
165 * @param[in] scrollSpeed The scroll speed factor.
167 void SetScrollSpeedFactor(float scrollSpeed);
170 * @brief Set the maximum swipe speed in pixels per second.
172 * @param[in] speed The maximum swipe speed.
174 void SetMaximumSwipeSpeed(float speed);
177 * @brief Set the duration of the flick animation in seconds.
179 * This is the time taken to animate each item to its next layout
180 * position (e.g. from 1.0 to 2.0) when a flick animation is
181 * triggered by a swipe gesture.
183 * @pre durationSeconds must be greater than zero.
184 * @param[in] durationSeconds The duration of flick animation in seconds.
186 void SetItemFlickAnimationDuration(float durationSeconds);
189 * @copydoc ItemLayout::GetScrollSpeedFactor()
191 virtual float GetScrollSpeedFactor() const;
194 * @copydoc ItemLayout::GetMaximumSwipeSpeed()
196 virtual float GetMaximumSwipeSpeed() const;
199 * @copydoc ItemLayout::GetItemFlickAnimationDuration()
201 virtual float GetItemFlickAnimationDuration() const;
204 * @copydoc ItemLayout::GetClosestOnScreenLayoutPosition()
206 virtual float GetClosestOnScreenLayoutPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize);
209 * @copydoc ItemLayout::GetNextFocusItemID()
211 virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled);
216 * @copydoc ItemLayout::GetMinimumLayoutPosition()
218 virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const;
221 * @copydoc ItemLayout::GetClosestAnchorPosition()
223 virtual float GetClosestAnchorPosition(float layoutPosition) const;
226 * @copydoc ItemLayout::GetItemScrollToPosition()
228 virtual float GetItemScrollToPosition(unsigned int itemId) const;
231 * @copydoc ItemLayout::GetItemsWithinArea()
233 virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const;
236 * @copydoc ItemLayout::GetReserveItemCount()
238 virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const;
241 * @copydoc ItemLayout::GetDefaultItemSize()
243 virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const;
246 * @copydoc ItemLayout::GetScrollDirection()
248 virtual Degree GetScrollDirection() const;
251 * @copydoc ItemLayout::ApplyConstraints()
253 virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor );
256 * @copydoc ItemLayout::GetItemPosition()
258 virtual Vector3 GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const;
263 * @brief Protected constructor; see also GridLayout::New().
270 GridLayout( const GridLayout& itemLayout );
273 GridLayout& operator=( const GridLayout& rhs );
281 } // namespace Internal
283 } // namespace Toolkit
287 #endif // __DALI_TOOLKIT_GRID_LAYOUT_H__