1 #ifndef DALI_INTERNAL_ACTOR_PARENT_IMPL_H
2 #define DALI_INTERNAL_ACTOR_PARENT_IMPL_H
4 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use actor 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/devel-api/actors/actor-devel.h>
21 #include <dali/internal/common/const-string.h>
22 #include <dali/internal/event/actors/actor-declarations.h>
23 #include <dali/internal/event/actors/actor-parent.h>
34 class ActorParentImpl : public ActorParent
39 * @param[in] owner The owning actor
41 ActorParentImpl(Actor& owner);
46 virtual ~ActorParentImpl();
49 * Adds a child Actor to this ActorParent.
50 * @pre The child actor is not the same as the parent actor.
51 * @pre The child actor does not already have a parent.
52 * @param [in] child The child.
53 * @param [in] notify Emits notification if set to true. Default is true.
54 * @post The child will be referenced by its parent.
56 void Add(Actor& child, bool notify = true);
59 * Removes a child Actor from this ActorParent.
60 * @param [in] child The child.
61 * @param [in] notify Emits notification if set to true. Default is true.
62 * @post The child will be unreferenced.
63 * @note If notify is false, Add() method must be called after this method.
65 void Remove(Actor& child, bool notify = true);
68 * Retrieve the number of children held by the actor.
69 * @return The number of children
71 uint32_t GetChildCount() const;
74 * @copydoc Dali::Actor::GetChildAt
76 ActorPtr GetChildAt(uint32_t index) const;
79 * @copydoc Dali::Actor::FindChildByName
81 ActorPtr FindChildByName(ConstString actorName) override;
84 * @copydoc Dali::Actor::FindChildById
86 ActorPtr FindChildById(const uint32_t id);
89 * Retrieve a reference to children.
90 * @note Not for public use.
91 * @return A reference to the container of children.
92 * @note The internal container is lazily initialized so ensure you check the child count before using this method.
94 ActorContainer& GetChildrenInternal()
100 * @brief Unparent all the children
102 void UnparentChildren();
105 * @brief Change the sibling order of the given child.
107 * @param[in] child The actor to change
108 * @param[in] order The new order for the actor
109 * @return true if order has been modified
111 void SetSiblingOrderOfChild(Actor& child, uint32_t order) override;
114 * @brief Get the sibling order of the given actor.
116 * @param[in] child The actor to query
117 * @return the order in the sibling array of the actor
119 uint32_t GetSiblingOrderOfChild(const Actor& child) const override;
122 * @brief Raise the actor within the siblings list by one
124 * @param[in] child The actor to move
125 * @return true if order has been modified
127 void RaiseChild(Actor& child) override;
130 * @brief Lower the actor within the siblings list by one
132 * @param[in] child The actor to move
133 * @return true if order has been modified
135 void LowerChild(Actor& child) override;
138 * @brief Raise the actor to the top of the siblings list.
140 * @param[in] child The actor to move
141 * @return true if order has been modified
143 void RaiseChildToTop(Actor& child) override;
146 * @brief Lower the actor to the bottom of the siblings list.
148 * @param[in] child The actor to move
149 * @return true if order has been modified
151 void LowerChildToBottom(Actor& child) override;
154 * @brief Raise the actor above the target actor within the siblings list.
156 * @param[in] child The actor to move
157 * @param[in] target The target actor
158 * @return true if order has been modified
160 void RaiseChildAbove(Actor& child, Actor& target) override;
163 * @brief Lower the actor below the target actor within the siblings list.
165 * @param[in] child The actor to move
166 * @param[in] target The target actor
167 * @return true if order has been modified
169 void LowerChildBelow(Actor& child, Actor& target) override;
172 * @copydoc DevelActor::ChildAddedSignal
174 DevelActor::ChildChangedSignalType& ChildAddedSignal()
176 return mChildAddedSignal;
180 * @copydoc DevelActor::ChildRemovedSignal
182 DevelActor::ChildChangedSignalType& ChildRemovedSignal()
184 return mChildRemovedSignal;
188 * @copydoc DevelActor::ChildOrderChangedSignal
190 DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal()
192 return mChildOrderChangedSignal;
197 * @brief Emits the ChildAdded signal for this actor
198 * @param[in] child The child actor that has been added
200 void EmitChildAddedSignal(Actor& child);
203 * @brief Emits the ChildRemoved signal for this actor
204 * @param[in] child The child actor that has been removed
206 void EmitChildRemovedSignal(Actor& child);
209 * @brief Emit the child order changed signal, and rebuild the depth tree
211 * @param[in] child The child actor that changed order
213 void EmitOrderChangedAndRebuild(Actor& child);
216 Dali::Internal::Actor& mOwner; ///* Owning actor
217 DevelActor::ChildChangedSignalType mChildAddedSignal;
218 DevelActor::ChildChangedSignalType mChildRemovedSignal;
219 DevelActor::ChildOrderChangedSignalType mChildOrderChangedSignal;
220 ActorContainer* mChildren{nullptr}; ///< Container of referenced actors, lazily initialized
223 } // namespace Internal