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/common/owner-pointer.h>
23 #include <dali/internal/event/actors/actor-declarations.h>
24 #include <dali/internal/event/actors/actor-parent.h>
25 #include <dali/internal/update/nodes/node-declarations.h>
36 class ActorParentImpl : public ActorParent
41 * @param[in] owner The owning actor
43 ActorParentImpl(Actor& owner);
48 virtual ~ActorParentImpl();
51 * Adds a child Actor to this ActorParent.
52 * @pre The child actor is not the same as the parent actor.
53 * @pre The child actor does not already have a parent.
54 * @param [in] child The child.
55 * @param [in] notify Emits notification if set to true. Default is true.
56 * @post The child will be referenced by its parent.
58 void Add(Actor& child, bool notify = true);
61 * Removes a child Actor from this ActorParent.
62 * @param [in] child The child.
63 * @param [in] notify Emits notification if set to true. Default is true.
64 * @post The child will be unreferenced.
65 * @note If notify is false, Add() method must be called after this method.
67 void Remove(Actor& child, bool notify = true);
70 * Retrieve the number of children held by the actor.
71 * @return The number of children
73 uint32_t GetChildCount() const;
76 * @copydoc Dali::Actor::GetChildAt
78 ActorPtr GetChildAt(uint32_t index) const;
81 * @copydoc Dali::Actor::FindChildByName
83 ActorPtr FindChildByName(ConstString actorName) override;
86 * @copydoc Dali::Actor::FindChildById
88 ActorPtr FindChildById(const uint32_t id);
91 * Retrieve a reference to children.
92 * @note Not for public use.
93 * @return A reference to the container of children.
94 * @note The internal container is lazily initialized so ensure you check the child count before using this method.
96 ActorContainer& GetChildrenInternal()
102 * @brief Unparent all the children
104 void UnparentChildren();
107 * @brief Change the sibling order of the given child.
109 * @param[in] child The actor to change
110 * @param[in] order The new order for the actor
111 * @return true if order has been modified
113 void SetSiblingOrderOfChild(Actor& child, uint32_t order) override;
116 * @brief Get the sibling order of the given actor.
118 * @param[in] child The actor to query
119 * @return the order in the sibling array of the actor
121 uint32_t GetSiblingOrderOfChild(const Actor& child) const override;
124 * @brief Raise the actor within the siblings list by one
126 * @param[in] child The actor to move
127 * @return true if order has been modified
129 void RaiseChild(Actor& child) override;
132 * @brief Lower the actor within the siblings list by one
134 * @param[in] child The actor to move
135 * @return true if order has been modified
137 void LowerChild(Actor& child) override;
140 * @brief Raise the actor to the top of the siblings list.
142 * @param[in] child The actor to move
143 * @return true if order has been modified
145 void RaiseChildToTop(Actor& child) override;
148 * @brief Lower the actor to the bottom of the siblings list.
150 * @param[in] child The actor to move
151 * @return true if order has been modified
153 void LowerChildToBottom(Actor& child) override;
156 * @brief Raise the actor above the target actor within the siblings list.
158 * @param[in] child The actor to move
159 * @param[in] target The target actor
160 * @return true if order has been modified
162 void RaiseChildAbove(Actor& child, Actor& target) override;
165 * @brief Lower the actor below the target actor within the siblings list.
167 * @param[in] child The actor to move
168 * @param[in] target The target actor
169 * @return true if order has been modified
171 void LowerChildBelow(Actor& child, Actor& target) override;
174 * @copydoc DevelActor::ChildAddedSignal
176 DevelActor::ChildChangedSignalType& ChildAddedSignal()
178 return mChildAddedSignal;
182 * @copydoc DevelActor::ChildRemovedSignal
184 DevelActor::ChildChangedSignalType& ChildRemovedSignal()
186 return mChildRemovedSignal;
190 * @copydoc DevelActor::ChildOrderChangedSignal
192 DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal()
194 return mChildOrderChangedSignal;
198 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
199 * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
200 * @param[in,out] depthIndex The current depth index (traversal index)
202 void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
205 * Helper to recursively connect a tree of actors.
206 * This is not interrupted by user callbacks
207 * @param[in] depth The depth in the hierarchy of the actor
208 * @param[out] connectionList On return, the list of connected actors which require notification.
210 void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
213 * Helper to recursively disconnect a tree of actors.
214 * This is not interrupted by user callbacks.
215 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
217 void RecursiveDisconnectFromScene(ActorContainer& disconnectionList);
220 * @brief Propagates layout direction recursively.
221 * @param[in] direction New layout direction.
223 void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
226 * @brief Recursively emits the visibility-changed-signal on the actor tree.
228 * @param[in] visible The new visibility of the actor
229 * @param[in] type Whether the actor's visible property has changed or a parent's
231 void EmitVisibilityChangedSignalRecursively(bool visible,
232 DevelActor::VisibilityChange::Type type);
236 * @brief Emits the ChildAdded signal for this actor
237 * @param[in] child The child actor that has been added
239 void EmitChildAddedSignal(Actor& child);
242 * @brief Emits the ChildRemoved signal for this actor
243 * @param[in] child The child actor that has been removed
245 void EmitChildRemovedSignal(Actor& child);
248 * @brief Emit the child order changed signal, and rebuild the depth tree
250 * @param[in] child The child actor that changed order
252 void EmitOrderChangedAndRebuild(Actor& child);
255 Dali::Internal::Actor& mOwner; ///* Owning actor
256 DevelActor::ChildChangedSignalType mChildAddedSignal;
257 DevelActor::ChildChangedSignalType mChildRemovedSignal;
258 DevelActor::ChildOrderChangedSignalType mChildOrderChangedSignal;
259 ActorContainer* mChildren{nullptr}; ///< Container of referenced actors, lazily initialized
262 } // namespace Internal