1 #ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H
2 #define DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H
4 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/actors/actor-enumerations.h>
22 #include <dali-toolkit/devel-api/layouting/layout-item.h>
23 #include <dali-toolkit/devel-api/layouting/measure-spec.h>
37 * A layout that has layout children. Implements LayoutItem.
38 * It can both layout it's children, and be laid out by a parent container.
40 * A layout group automatically handles adding a Control container's children to itself,
41 * both on startup and on child add/remove. If this functionality is not desired, this needs
42 * splitting into two classes; one that manages just the layout part, and the other which
43 * handles Actor hierarchy. (@todo Consider doing this anyway...)
45 * This handle class allows the application to set up layout properties for the layout group;
46 * it doesn't access measure/layout directly.
48 * To write a new layout, inherit from both LayoutGroup handle and Internal::LayoutGroup body.
51 class DALI_IMPORT_API LayoutGroup : public LayoutItem
54 using LayoutId = unsigned int;
55 static const unsigned int UNKNOWN_ID = 0;
59 CHILD_PROPERTY_START_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX+100,
60 CHILD_PROPERTY_END_INDEX = CHILD_PROPERTY_START_INDEX+1000
67 MARGIN_SPECIFICATION = CHILD_PROPERTY_START_INDEX,
73 * @brief Creates an uninitialized LayoutGroup handle.
75 * LayoutGroup is intended as a base class, and as such, does not have a New method.
77 * Calling member functions with an uninitialized handle is not allowed.
82 * @brief Default Destructor.
84 * This is non-virtual since derived Handle types must not contain data or virtual methods.
86 ~LayoutGroup() = default;
89 * @brief Copy constructor
91 LayoutGroup(const LayoutGroup& copy) = default;
94 * @brief Assigment operator
96 LayoutGroup& operator=(const LayoutGroup& rhs) = default;
99 * @brief Downcasts a handle to a LayoutGroup handle.
101 * If handle points to a LayoutGroup, the downcast produces a valid handle.
102 * If not, the returned handle is left uninitialized.
104 * @param[in] handle to an object
105 * @return Handle to a LayoutGroup or an uninitialized handle
107 static LayoutGroup DownCast( BaseHandle handle );
110 * @brief Add a child layout to the layout group
112 * @param[in] childLayout The layout to add.
113 * @return an Id of the child.
115 LayoutId Add( LayoutItem& childLayout );
118 * @brief Add a child layout to the layout group
120 * @param[in] childId the id of the child to remove
122 void Remove( LayoutId childId );
125 * @brief Remove a child layout from the layout group
127 * @param[in] childLayout The layout to remove.
129 void Remove( LayoutItem& childLayout );
132 * @brief Get the child at the given index.
134 * @param[in] index The index of the child.
136 LayoutItem GetChildAt( unsigned int index ) const;
139 * @brief Get the count of the children of the layout
141 * @return the count of the children of the layout
143 unsigned int GetChildCount() const ;
146 * @brief Get the child referenced by childId.
148 * @param[in] childId The id of the child to get
149 * @return A handle to the child layout, or empty if not found
151 LayoutItem GetChild( LayoutId childId ) const ;
154 * Delete template method to remove implicit casting to integer types.
156 template <typename T>
157 LayoutItem GetChild( T childId ) = delete;
162 * @brief This constructor is used by LayoutGroup::New() methods.
164 * @param[in] actor A pointer to a newly allocated Dali resource
166 explicit LayoutGroup( Internal::LayoutGroup* layoutGroup );
171 } // namespace Toolkit
174 #endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H