1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_IMPL_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.
21 #include <dali/public-api/common/intrusive-ptr.h>
22 #include <dali/public-api/object/base-object.h>
25 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
26 #include <dali-toolkit/devel-api/layouting/grid.h>
27 #include <dali-toolkit/internal/layouting/grid-locations.h>
37 using GridPtr = IntrusivePtr<Grid>;
39 class Grid final : public LayoutGroup
44 * Creates a pointer to an Internal Grid
49 * Set grid's the number of columns
50 * @param[in] columns number of columns
52 void SetNumberOfColumns( int columns );
55 * Get number of columns, -1 would indicate AUTO_FIT
56 * which means the number has not been set but will be calculated.
57 * @return the number of columns set
59 int GetNumberOfColumns() const;
61 // Movable but not copyable
62 Grid( const Grid& other ) = delete;
63 Grid& operator=( const Grid& other ) = delete;
64 Grid( Grid && ) = default;
65 Grid& operator=( Grid && ) = default;
80 * @copydoc LayoutItem::OnMeasure
82 virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
85 * @copydoc LayoutItem::OnLayout
87 virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
93 * For the given availableSpace, calculate or retreive the number of required columns.
94 * @param[in] availableSpace the space available for a child in each column.
96 void DetermineNumberOfColumns( int availableSpace );
100 GridLocationsPtr mLocations;
102 LayoutLength mTotalHeight;
103 LayoutLength mTotalWidth;
105 const int AUTO_FIT = -1;
110 int mRequestedColumnWidth;
111 int mRequestedNumColumns;
114 } // namespace Internal
116 inline Internal::Grid& GetImplementation( Dali::Toolkit::Grid& handle )
118 DALI_ASSERT_ALWAYS( handle && "Grid handle is empty" );
119 BaseObject& object = handle.GetBaseObject();
120 return static_cast<Internal::Grid&>( object );
123 inline const Internal::Grid& GetImplementation( const Dali::Toolkit::Grid& handle )
125 DALI_ASSERT_ALWAYS( handle && "Grid handle is empty" );
126 const BaseObject& object = handle.GetBaseObject();
127 return static_cast<const Internal::Grid&>( object );
130 } // namespace Toolkit
133 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner