Merge HBoxLayout and VBoxLayout into LinearLayout.
[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_IMPORT_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 Creates an uninitialized LinearLayout handle.
61    *
62    * Initialize it using LinearLayout::New().
63    * Calling member functions with an uninitialized handle is not allowed.
64    */
65   LinearLayout();
66
67   /**
68    * @brief Creates a LinearLayout object.
69    */
70   static LinearLayout New();
71
72   /**
73    * @brief Downcasts a handle to a LinearLayout handle.
74    *
75    * If handle points to a LinearLayout, the downcast produces a valid handle.
76    * If not, the returned handle is left uninitialized.
77
78    * @param[in] handle to an object
79    * @return Handle to a LinearLayout or an uninitialized handle
80    */
81   static LinearLayout DownCast( BaseHandle handle );
82
83   /**
84    * @brief Copy constructor
85    */
86   LinearLayout( const LinearLayout& other );
87
88   /**
89    * @brief Assigment operator
90    */
91   LinearLayout& operator=( const LinearLayout& other );
92
93   /**
94    * @brief Default destructor.
95    *
96    * This is non-virtual, since derived Handle types must not contain data or virtual methods
97    */
98   ~LinearLayout()=default;
99
100   /**
101    * @brief Set the padding between cells in the layout
102    *
103    * @param[in] size The padding between cells.
104    */
105   void SetCellPadding( LayoutSize size );
106
107   /**
108    * @brief Get the padding between cells in the layout
109    *
110    * @return The padding between cells.
111    */
112   LayoutSize GetCellPadding();
113
114   /**
115    * @brief Set the orientation in the layout
116    *
117    * @param[in] orientation The orientation.
118    */
119   void SetOrientation( Orientation orientation );
120
121   /**
122    * @brief Get the orientation in the layout
123    *
124    * @return The orientation.
125    */
126   Orientation GetOrientation();
127
128 public: // Not intended for application developers
129
130   /// @cond internal
131   /**
132    * @brief This constructor is used by LinearLayout::New() methods.
133    *
134    * @param[in] actor A pointer to a newly allocated Dali resource
135    */
136   explicit DALI_INTERNAL LinearLayout( Internal::LinearLayout* body );
137   /// @endcond
138 };
139
140 } // namespace Toolkit
141 } // namespace Dali
142
143 #endif // DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H