Merge "Actor's position and size is not updated after DevelControl::SetLayout." into...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / linear-layout.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
2 #define DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali-toolkit/devel-api/layouting/layout-group.h>
23 #include <dali-toolkit/devel-api/layouting/layout-size.h>
24 #include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
25
26 namespace Dali
27 {
28 namespace Toolkit
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class LinearLayout;
34 }
35
36 /**
37  * This class implements a linear box layout, automatically handling
38  * right to left or left to right direction change.
39  */
40 class DALI_TOOLKIT_API LinearLayout : public LayoutGroup
41 {
42 public:
43
44   enum PropertyRange
45   {
46     CHILD_PROPERTY_START_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX,
47     CHILD_PROPERTY_END_INDEX   = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX
48   };
49
50   /**
51    * @brief Enumeration for the direction in which the content is laid out
52    */
53   enum class Orientation
54   {
55     HORIZONTAL,                 ///< Horizontal (row)
56     VERTICAL                    ///< Vertical (column)
57   };
58
59   /**
60    * @brief Enumeration for the alignment of the linear layout items.
61    */
62   struct Alignment
63   {
64     enum Type
65     {
66       BEGIN                     = 0x1,  ///< At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation)
67       END                       = 0x2,  ///< At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation)
68       CENTER_HORIZONTAL         = 0x4,  ///< At the horizontal center of the container
69       TOP                       = 0x8,  ///< At the top edge of the container
70       BOTTOM                    = 0x10, ///< At the bottom edge of the container
71       CENTER_VERTICAL           = 0x20  ///< At the vertical center of the container
72     };
73   };
74
75   struct ChildProperty
76   {
77     enum
78     {
79       WEIGHT = CHILD_PROPERTY_START_INDEX, ///< name "weight", The proportion of the free space in the container the linear item will receive after all other non weighted items measured and all items specification width & height added. Type FLOAT
80     };
81   };
82
83   /**
84    * @brief Creates an uninitialized LinearLayout handle.
85    *
86    * Initialize it using LinearLayout::New().
87    * Calling member functions with an uninitialized handle is not allowed.
88    */
89   LinearLayout();
90
91   /**
92    * @brief Creates a LinearLayout object.
93    */
94   static LinearLayout New();
95
96   /**
97    * @brief Downcasts a handle to a LinearLayout handle.
98    *
99    * If handle points to a LinearLayout, the downcast produces a valid handle.
100    * If not, the returned handle is left uninitialized.
101
102    * @param[in] handle to an object
103    * @return Handle to a LinearLayout or an uninitialized handle
104    */
105   static LinearLayout DownCast( BaseHandle handle );
106
107   /**
108    * @brief Copy constructor
109    */
110   LinearLayout( const LinearLayout& other );
111
112   /**
113    * @brief Assigment operator
114    */
115   LinearLayout& operator=( const LinearLayout& other );
116
117   /**
118    * @brief Default destructor.
119    *
120    * This is non-virtual, since derived Handle types must not contain data or virtual methods
121    */
122   ~LinearLayout()=default;
123
124   /**
125    * @brief Set the padding between cells in the layout
126    *
127    * @param[in] size The padding between cells.
128    */
129   void SetCellPadding( LayoutSize size );
130
131   /**
132    * @brief Get the padding between cells in the layout
133    *
134    * @return The padding between cells.
135    */
136   LayoutSize GetCellPadding() const;
137
138   /**
139    * @brief Set the orientation in the layout
140    *
141    * @param[in] orientation The orientation.
142    */
143   void SetOrientation( Orientation orientation );
144
145   /**
146    * @brief Get the orientation in the layout
147    *
148    * @return The orientation.
149    */
150   Orientation GetOrientation() const;
151
152   /**
153    * @brief Set the alignment in the layout
154    *
155    * @param[in] alignment The alignment.
156    */
157   void SetAlignment( unsigned int alignment );
158
159   /**
160    * @brief Get the alignment in the layout
161    *
162    * @return The alignment.
163    */
164   unsigned int GetAlignment() const;
165
166 public: // Not intended for application developers
167
168   /// @cond internal
169   /**
170    * @brief This constructor is used by LinearLayout::New() methods.
171    *
172    * @param[in] actor A pointer to a newly allocated Dali resource
173    */
174   explicit DALI_INTERNAL LinearLayout( Internal::LinearLayout* body );
175   /// @endcond
176 };
177
178 } // namespace Toolkit
179 } // namespace Dali
180
181 #endif // DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H