[Tizen] Change the API macros for layout
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / layout-group.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H
2 #define DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H
3 /*
4  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #include <memory>
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/actors/actor-enumerations.h>
22 #include <dali-toolkit/devel-api/toolkit-property-index-ranges.h>
23 #include <dali-toolkit/devel-api/layouting/layout-item.h>
24 #include <dali-toolkit/devel-api/layouting/measure-spec.h>
25 #include <dali-toolkit/public-api/dali-toolkit-common.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34 class LayoutGroup;
35 }
36
37
38 /**
39  * A layout that has layout children. Implements LayoutItem.
40  * It can both layout it's children, and be laid out by a parent container.
41  *
42  * A layout group automatically handles adding a Control container's children to itself,
43  * both on startup and on child add/remove. If this functionality is not desired, this needs
44  * splitting into two classes; one that manages just the layout part, and the other which
45  * handles Actor hierarchy. (@todo Consider doing this anyway...)
46  *
47  * This handle class allows the application to set up layout properties for the layout group;
48  * it doesn't access measure/layout directly.
49  *
50  * To write a new layout, inherit from both LayoutGroup handle and Internal::LayoutGroup body.
51  *
52  */
53 class DALI_TOOLKIT_API LayoutGroup : public LayoutItem
54 {
55 public:
56   using LayoutId = unsigned int;
57   static const unsigned int UNKNOWN_ID = 0;
58
59   struct ChildProperty
60   {
61     enum
62     {
63       MARGIN_SPECIFICATION = LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX,
64     };
65   };
66
67
68   /**
69    * @brief Creates an uninitialized LayoutGroup handle.
70    *
71    * LayoutGroup is intended as a base class, and as such, does not have a New method.
72    *
73    * Calling member functions with an uninitialized handle is not allowed.
74    */
75   LayoutGroup();
76
77   /**
78    * @brief Default Destructor.
79    *
80    * This is non-virtual since derived Handle types must not contain data or virtual methods.
81    */
82   ~LayoutGroup() = default;
83
84   /**
85    * @brief Copy constructor
86    */
87   LayoutGroup(const LayoutGroup& copy) = default;
88
89   /**
90    * @brief Assigment operator
91    */
92   LayoutGroup& operator=(const LayoutGroup& rhs) = default;
93
94   /**
95    * @brief Downcasts a handle to a LayoutGroup handle.
96    *
97    * If handle points to a LayoutGroup, the downcast produces a valid handle.
98    * If not, the returned handle is left uninitialized.
99
100    * @param[in] handle to an object
101    * @return Handle to a LayoutGroup or an uninitialized handle
102    */
103   static LayoutGroup DownCast( BaseHandle handle );
104
105   /**
106    * @brief Add a child layout to the layout group
107    *
108    * @param[in] childLayout The layout to add.
109    * @return an Id of the child.
110    */
111   LayoutId Add( LayoutItem& childLayout );
112
113   /**
114    * @brief Add a child layout to the layout group
115    *
116    * @param[in] childId the id of the child to remove
117    */
118   void Remove( LayoutId childId );
119
120   /**
121    * @brief Remove a child layout from the layout group
122    *
123    * @param[in] childLayout The layout to remove.
124    */
125   void Remove( LayoutItem& childLayout );
126
127   /**
128    * @brief Get the child at the given index.
129    *
130    * @param[in] index The index of the child.
131    */
132   LayoutItem GetChildAt( unsigned int index ) const;
133
134   /**
135    * @brief Get the count of the children of the layout
136    *
137    * @return the count of the children of the layout
138    */
139   unsigned int GetChildCount() const ;
140
141   /**
142    * @brief Get the child referenced by childId.
143    *
144    * @param[in] childId The id of the child to get
145    * @return A handle to the child layout, or empty if not found
146    */
147   LayoutItem GetChild( LayoutId childId ) const ;
148
149   /**
150    * Delete template method to remove implicit casting to integer types.
151    */
152   template <typename T>
153     LayoutItem GetChild( T childId ) = delete;
154
155 public:
156   /// @cond internal
157   /**
158    * @brief This constructor is used by LayoutGroup::New() methods.
159    *
160    * @param[in] actor A pointer to a newly allocated Dali resource
161    */
162   explicit LayoutGroup( Internal::LayoutGroup* layoutGroup );
163   /// @endcond
164 };
165
166
167 } // namespace Toolkit
168 } // namespace Dali
169
170 #endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H