1 #ifndef __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
2 #define __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/size-negotiation/relayout-container.h>
25 #include <dali/internal/common/memory-pool-object-allocator.h>
26 #include <dali/internal/event/size-negotiation/memory-pool-relayout-container.h>
33 class RenderController;
40 * @brief The relayout controller is responsible for taking request from actors to relayout their sizes.
41 * The requests are actioned on at the end of the frame where all actors that have made a request are
44 class RelayoutController : public Dali::BaseObject
50 * We should only create a unique instance.
51 * @param[in] controller to request a render from the RenderController if core is not processing events.
53 RelayoutController( Integration::RenderController& controller );
58 virtual ~RelayoutController();
61 * @brief Get the singleton of RelayoutController object.
63 * @return A handle to the RelayoutController control.
65 static RelayoutController* Get();
68 * @brief Request to relayout the given actor and all sub-actors of it.
70 * This flags the actor and all actors dependent on it for relayout. The actual
71 * relayout is performed at the end of the frame. This means that multiple calls to relayout
72 * will not cause multiple relayouts to occur.
74 * @param[in] actor The actor to request relayout on
75 * @param[in] dimension The dimension(s) to request the relayout on. Defaults to all dimensions
77 void RequestRelayout( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
80 * @brief Request to relayout of all actors in the sub-tree below the given actor.
82 * This flags the actor and all actors below it for relayout. The actual
83 * relayout is performed at the end of the frame. This means that multiple calls to relayout
84 * will not cause multiple relayouts to occur.
86 * @param[in] actor The actor to request relayout on
88 void RequestRelayoutTree( Dali::Actor& actor );
91 * @brief Force propagate relayout flags through the tree. This is similiar to Request Relayout
92 * except all dependencies have their flags reset in spite of whether they are all ready set.
94 * This is useful for resetting layout flags during the layout process.
96 * @param[in] actor The actor to propagate from
97 * @param[in] dimension The dimension to propagate on
99 void PropagateFlags( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
102 * @brief Relayouts all actors that have been marked as dirty
107 * @brief Enable/disable the controller
109 * @param[in] enabled Flag to indicate whether the controller should be enabled or disabled
111 void SetEnabled( bool enabled );
114 * @brief Return true if the relayout controller is currently performing a relayout
116 * @return Return true if the relayout controller is currently performing a relayout
118 bool IsPerformingRelayout() const;
121 * @brief Sets whether core is processing events.
123 * @param[in] processingEvents whether core is processing events.
125 void SetProcessingCoreEvents( bool processingEvents );
130 * @brief Callback raised after the application creates the scene
132 void OnApplicationSceneCreated();
135 * @brief Callback for when an object is destroyed
137 * @param[in] object The object being destroyed
139 void OnObjectDestroyed( const Dali::RefObject* object );
143 typedef Dali::Vector< BaseObject* > RawActorList;
146 * @brief Request for relayout. Relays out whole scene.
151 * @brief Add actor to request list
153 * @param[in] actor The root of the sub tree to add
155 void AddRequest( Dali::Actor& actor );
158 * @brief Remove actor from request list
160 * @param[in] actor The root of the sub tree to remove
162 void RemoveRequest( Dali::Actor& actor );
165 * @brief Disconnect the Relayout() method from the Stage::EventProcessingFinishedSignal().
170 * @brief Propagate dirty layout flags to actor and all sub-actors. This will stop propagating when a dirty actor
173 * @param[in] actor The actor to propagate on
174 * @param[in] dimension The dimension to propagate on
175 * @param[in] topOfSubTreeStack The top of the sub tree that this actor is in
176 * @param[in] potentialRedundantSubRoots Actors collected as potentially already being included in relayout
178 void PropagateAll( Dali::Actor& actor, Dimension::Type dimension, std::vector< Dali::Actor >& topOfSubTreeStack, std::vector< Dali::Actor >& potentialRedundantSubRoots );
181 * Queue an actor on the relayout container
183 * @param[in] actor The actor to be queued
184 * @param[in] actors The container to add the actor to
185 * @param[in] size The size that this actor should be
187 void QueueActor( Dali::Actor& actor, RelayoutContainer& actors, Vector2 size );
190 * @brief Find the given object in the list and null it out
192 * @param[in] list The list to search
193 * @param[in] object The object to search for
195 void FindAndZero( const RawActorList& list, const Dali::RefObject* object );
198 RelayoutController(const RelayoutController&);
199 RelayoutController& operator=(const RelayoutController&);
203 Integration::RenderController& mRenderController;
204 MemoryPoolObjectAllocator< MemoryPoolRelayoutContainer::RelayoutInfo > mRelayoutInfoAllocator;
206 SlotDelegate< RelayoutController > mSlotDelegate;
208 RawActorList mDirtyLayoutSubTrees; ///< List of roots of sub trees that are dirty
209 MemoryPoolRelayoutContainer* mRelayoutStack; ///< Stack for relayouting
210 bool mRelayoutConnection : 1; ///< Whether EventProcessingFinishedSignal signal is connected.
211 bool mRelayoutFlag : 1; ///< Relayout flag to avoid unnecessary calls
212 bool mEnabled : 1; ///< Initially disabled. Must be enabled at some point.
213 bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout
214 bool mProcessingCoreEvents : 1; ///< Whether core is processing events.
218 } // namespace Internal
222 #endif // __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__