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