1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_LOCATIONS_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_LOCATIONS_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/common/dali-vector.h>
23 #include <dali/public-api/object/ref-object.h>
27 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
37 using GridLocationsPtr = IntrusivePtr<GridLocations>;
39 /* @brief This internal class houses the algorithm for computing the locations and size of cells.
41 * A Grid layout uses two instances of this class
42 * distinguished by the "horizontal" flag which is true for the horizontal axis and false
43 * for the vertical one.
46 class GridLocations : public RefObject
51 static const int UNDEFINED = INT_MIN;
53 static const unsigned int HORIZONTAL = 0;
54 static const unsigned int VERTICAL = 1;
63 Cell( int x1, int x2, int y1, int y2): xStart(x1), xEnd(x2), yTop(y1), yBottom(y2){};
66 typedef std::vector< Cell > LocationVector;
70 static GridLocationsPtr New();
73 * Uses the given parameters to calculate the x,y coordinates of each cell and cell size.
75 void CalculateLocations( int numberOfColumns, unsigned int availableWidth,
76 unsigned int availableHeight, unsigned int numberOfCells );
78 LocationVector GetLocations();
84 GridLocations( const GridLocations& other ) = delete;
85 GridLocations& operator=( const GridLocations& other ) = delete;
89 LocationVector mLocations;
93 } // namespace Internal
94 } // namespace Toolkit
97 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_LOCATIONS_H