62c4bf77ae466fef3a01f00af97447f9fb0f3d5d
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / hbox-layout.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H
2 #define DALI_TOOLKIT_LAYOUTING_HBOX_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 HboxLayout;
34 }
35
36 /**
37  * This class implements a horizontal box layout, automatically handling
38  * right to left or left to right direction change.
39  */
40 class DALI_IMPORT_API HboxLayout : public LayoutGroup
41 {
42 public:
43
44   enum PropertyRange
45   {
46     CHILD_PROPERTY_START_INDEX = LayoutGroup::CHILD_PROPERTY_START_INDEX+100,
47     CHILD_PROPERTY_END_INDEX   = CHILD_PROPERTY_START_INDEX+1000
48   };
49
50   struct Property
51   {
52     // @todo When we can have event-only properties for BaseObject, this will be useful.
53     enum
54     {
55       CELL_PADDING = PROPERTY_REGISTRATION_START_INDEX + 2000
56     };
57   };
58
59   struct ChildProperty
60   {
61     enum
62     {
63       WEIGHT = CHILD_PROPERTY_START_INDEX
64     };
65   };
66
67   /**
68    * @brief Creates an uninitialized HboxLayout handle.
69    *
70    * Initialize it using HboxLayout::New().
71    * Calling member functions with an uninitialized handle is not allowed.
72    */
73   HboxLayout();
74
75   /**
76    * @brief Creates a HboxLayout object.
77    */
78   static HboxLayout New();
79
80   /**
81    * @brief Downcasts a handle to a HboxLayout handle.
82    *
83    * If handle points to a HboxLayout, the downcast produces a valid handle.
84    * If not, the returned handle is left uninitialized.
85
86    * @param[in] handle to an object
87    * @return Handle to a HboxLayout or an uninitialized handle
88    */
89   static HboxLayout DownCast( BaseHandle handle );
90
91   /**
92    * @brief Copy constructor
93    */
94   HboxLayout( const HboxLayout& other );
95
96   /**
97    * @brief Assigment operator
98    */
99   HboxLayout& operator=( const HboxLayout& other );
100
101   /**
102    * @brief Default destructor.
103    *
104    * This is non-virtual, since derived Handle types must not contain data or virtual methods
105    */
106   ~HboxLayout()=default;
107
108   /**
109    * @brief Set the padding between cells in the layout
110    *
111    * @param[in] size The padding between cells.
112    */
113   void SetCellPadding( LayoutSize size );
114
115   /**
116    * @brief Get the padding between cells in the layout
117    *
118    * @return The padding between cells.
119    */
120   LayoutSize GetCellPadding();
121
122 public: // Not intended for application developers
123
124   /// @cond internal
125   /**
126    * @brief This constructor is used by HboxLayout::New() methods.
127    *
128    * @param[in] actor A pointer to a newly allocated Dali resource
129    */
130   explicit DALI_INTERNAL HboxLayout( Internal::HboxLayout* body );
131   /// @endcond
132 };
133
134 } // namespace Toolkit
135 } // namespace Dali
136
137 #endif // DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H