1 #ifndef DALI_INTERNAL_ACTOR_H
2 #define DALI_INTERNAL_ACTOR_H
5 * Copyright (c) 2021 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.
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/internal/common/internal-constants.h>
27 #include <dali/internal/common/memory-pool-object-allocator.h>
28 #include <dali/internal/event/actors/actor-declarations.h>
29 #include <dali/internal/event/common/object-impl.h>
30 #include <dali/internal/event/common/stage-def.h>
31 #include <dali/internal/event/rendering/renderer-impl.h>
32 #include <dali/internal/update/manager/update-manager.h>
33 #include <dali/internal/update/nodes/node-declarations.h>
34 #include <dali/public-api/actors/actor.h>
35 #include <dali/public-api/common/dali-common.h>
36 #include <dali/public-api/common/vector-wrapper.h>
37 #include <dali/public-api/events/gesture.h>
38 #include <dali/public-api/math/viewport.h>
39 #include <dali/public-api/object/ref-object.h>
40 #include <dali/public-api/size-negotiation/relayout-container.h>
52 class ActorGestureData;
58 using ActorContainer = std::vector<ActorPtr>;
59 using ActorIter = ActorContainer::iterator;
60 using ActorConstIter = ActorContainer::const_iterator;
62 using RendererContainer = std::vector<RendererPtr>;
63 using RendererIter = RendererContainer::iterator;
65 class ActorDepthTreeNode;
66 using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator<ActorDepthTreeNode>;
69 * Actor is the primary object which Dali applications interact with.
70 * UI controls can be built by combining multiple actors.
71 * Multi-Touch events are received through signals emitted by the actor tree.
73 * An Actor is a proxy for a Node in the scene graph.
74 * When an Actor is added to the Stage, it creates a node and connects it to the scene graph.
75 * The scene-graph can be updated in a separate thread, so the connection is done using an asynchronous message.
76 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
78 class Actor : public Object
82 * @brief Struct to hold an actor and a dimension
84 struct ActorDimensionPair
89 * @param[in] newActor The actor to assign
90 * @param[in] newDimension The dimension to assign
92 ActorDimensionPair(Actor* newActor, Dimension::Type newDimension)
94 dimension(newDimension)
99 * @brief Equality operator
101 * @param[in] lhs The left hand side argument
102 * @param[in] rhs The right hand side argument
104 bool operator==(const ActorDimensionPair& rhs)
106 return (actor == rhs.actor) && (dimension == rhs.dimension);
109 Actor* actor; ///< The actor to hold
110 Dimension::Type dimension; ///< The dimension to hold
113 using ActorDimensionStack = std::vector<ActorDimensionPair>;
117 * Create a new actor.
118 * @return A smart-pointer to the newly allocated Actor.
120 static ActorPtr New();
123 * Helper to create node for derived classes who don't have their own node type
124 * @return pointer to newly created unique node
126 static const SceneGraph::Node* CreateNode();
129 * Retrieve the name of the actor.
132 const std::string& GetName() const
138 * Set the name of the actor.
139 * @param[in] name The new name.
141 void SetName(const std::string& name);
144 * @copydoc Dali::Actor::GetId
146 uint32_t GetId() const;
151 * Query whether an actor is the root actor, which is owned by the Stage.
152 * @return True if the actor is a root actor.
160 * Query whether the actor is connected to the Scene.
168 * Query whether the actor has any renderers.
169 * @return True if the actor is renderable.
171 bool IsRenderable() const
173 // inlined as this is called a lot in hit testing
174 return mRenderers && !mRenderers->empty();
178 * Query whether the actor is of class Dali::Layer
179 * @return True if the actor is a layer.
183 // inlined as this is called a lot in hit testing
188 * Gets the layer in which the actor is present
189 * @return The layer, which will be uninitialized if the actor is off-stage.
191 Dali::Layer GetLayer();
194 * Adds a child Actor to this Actor.
195 * @pre The child actor is not the same as the parent actor.
196 * @pre The child actor does not already have a parent.
197 * @param [in] child The child.
198 * @post The child will be referenced by its parent.
200 void Add(Actor& child);
203 * Removes a child Actor from this Actor.
204 * @param [in] child The child.
205 * @post The child will be unreferenced.
207 void Remove(Actor& child);
210 * @copydoc Dali::Actor::Unparent
215 * Retrieve the number of children held by the actor.
216 * @return The number of children
218 uint32_t GetChildCount() const;
221 * @copydoc Dali::Actor::GetChildAt
223 ActorPtr GetChildAt(uint32_t index) const;
226 * Retrieve a reference to Actor's children.
227 * @note Not for public use.
228 * @return A reference to the container of children.
229 * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method.
231 ActorContainer& GetChildrenInternal()
237 * @copydoc Dali::Actor::FindChildByName
239 ActorPtr FindChildByName(const std::string& actorName);
242 * @copydoc Dali::Actor::FindChildById
244 ActorPtr FindChildById(const uint32_t id);
247 * Retrieve the parent of an Actor.
248 * @return The parent actor, or NULL if the Actor does not have a parent.
250 Actor* GetParent() const
256 * Calculates screen position and size.
258 * @return pair of two values, position of top-left corner on screen and size respectively.
260 Rect<> CalculateScreenExtents() const;
263 * Sets the size of an actor.
264 * This does not interfere with the actors scale factor.
265 * @param [in] width The new width.
266 * @param [in] height The new height.
268 void SetSize(float width, float height);
271 * Sets the size of an actor.
272 * This does not interfere with the actors scale factor.
273 * @param [in] width The size of the actor along the x-axis.
274 * @param [in] height The size of the actor along the y-axis.
275 * @param [in] depth The size of the actor along the z-axis.
277 void SetSize(float width, float height, float depth);
280 * Sets the size of an actor.
281 * This does not interfere with the actors scale factor.
282 * @param [in] size The new size.
284 void SetSize(const Vector2& size);
287 * Sets the update size for an actor.
289 * @param[in] size The size to set.
291 void SetSizeInternal(const Vector2& size);
294 * Sets the size of an actor.
295 * This does not interfere with the actors scale factor.
296 * @param [in] size The new size.
298 void SetSize(const Vector3& size);
301 * Sets the update size for an actor.
303 * @param[in] size The size to set.
305 void SetSizeInternal(const Vector3& size);
308 * Set the width component of the Actor's size.
309 * @param [in] width The new width component.
311 void SetWidth(float width);
314 * Set the height component of the Actor's size.
315 * @param [in] height The new height component.
317 void SetHeight(float height);
320 * Set the depth component of the Actor's size.
321 * @param [in] depth The new depth component.
323 void SetDepth(float depth);
326 * Retrieve the Actor's size from event side.
327 * This size will be the size set or if animating then the target size.
328 * @return The Actor's size.
330 Vector3 GetTargetSize() const;
333 * Retrieve the Actor's size from update side.
334 * This size will be the size set or animating but will be a frame behind.
335 * @return The Actor's size.
337 const Vector3& GetCurrentSize() const;
340 * Return the natural size of the actor
342 * @return The actor's natural size
344 virtual Vector3 GetNaturalSize() const;
347 * Set the origin of an actor, within its parent's area.
348 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
349 * and (1.0, 1.0, 0.5) is the bottom-right corner.
350 * The default parent-origin is top-left (0.0, 0.0, 0.5).
351 * An actor position is the distance between this origin, and the actors anchor-point.
352 * @param [in] origin The new parent-origin.
354 void SetParentOrigin(const Vector3& origin);
357 * Retrieve the parent-origin of an actor.
358 * @return The parent-origin.
360 const Vector3& GetCurrentParentOrigin() const;
363 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
364 * (0.0, 0.0, 0.5) is the top-left corner of the actor, and (1.0, 1.0, 0.5) is the bottom-right corner.
365 * The default anchor point is top-left (0.0, 0.0, 0.5).
366 * An actor position is the distance between its parent-origin, and this anchor-point.
367 * An actor's rotation is centered around its anchor-point.
368 * @param [in] anchorPoint The new anchor-point.
370 void SetAnchorPoint(const Vector3& anchorPoint);
373 * Retrieve the anchor-point of an actor.
374 * @return The anchor-point.
376 const Vector3& GetCurrentAnchorPoint() const;
379 * Sets the position of the Actor.
380 * The coordinates are relative to the Actor's parent.
381 * The Actor's z position will be set to 0.0f.
382 * @param [in] x The new x position
383 * @param [in] y The new y position
385 void SetPosition(float x, float y);
388 * Sets the position of the Actor.
389 * The coordinates are relative to the Actor's parent.
390 * @param [in] x The new x position
391 * @param [in] y The new y position
392 * @param [in] z The new z position
394 void SetPosition(float x, float y, float z);
397 * Sets the position of the Actor.
398 * The coordinates are relative to the Actor's parent.
399 * @param [in] position The new position.
401 void SetPosition(const Vector3& position);
404 * Set the position of an actor along the X-axis.
405 * @param [in] x The new x position
410 * Set the position of an actor along the Y-axis.
411 * @param [in] y The new y position.
416 * Set the position of an actor along the Z-axis.
417 * @param [in] z The new z position
422 * Translate an actor relative to its existing position.
423 * @param[in] distance The actor will move by this distance.
425 void TranslateBy(const Vector3& distance);
428 * Retrieve the position of the Actor.
429 * The coordinates are relative to the Actor's parent.
430 * @return the Actor's position.
432 const Vector3& GetCurrentPosition() const;
435 * Retrieve the target position of the Actor.
436 * The coordinates are relative to the Actor's parent.
437 * @return the Actor's position.
439 const Vector3& GetTargetPosition() const
441 return mTargetPosition;
445 * @copydoc Dali::Actor::GetCurrentWorldPosition()
447 const Vector3& GetCurrentWorldPosition() const;
450 * @copydoc Dali::Actor::SetInheritPosition()
452 void SetInheritPosition(bool inherit);
455 * @copydoc Dali::Actor::IsPositionInherited()
457 bool IsPositionInherited() const
459 return mInheritPosition;
463 * Sets the orientation of the Actor.
464 * @param [in] angleRadians The new orientation angle in radians.
465 * @param [in] axis The new axis of orientation.
467 void SetOrientation(const Radian& angleRadians, const Vector3& axis);
470 * Sets the orientation of the Actor.
471 * @param [in] orientation The new orientation.
473 void SetOrientation(const Quaternion& orientation);
476 * Rotate an actor around its existing rotation axis.
477 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
478 * @param[in] axis The axis of the rotation to combine with the existing rotation.
480 void RotateBy(const Radian& angleRadians, const Vector3& axis);
483 * Apply a relative rotation to an actor.
484 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
486 void RotateBy(const Quaternion& relativeRotation);
489 * Retreive the Actor's orientation.
490 * @return the orientation.
492 const Quaternion& GetCurrentOrientation() const;
495 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
496 * Switching this off means that using SetOrientation() sets the actor's world orientation.
497 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
499 void SetInheritOrientation(bool inherit);
502 * Returns whether the actor inherit's it's parent's orientation.
503 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
505 bool IsOrientationInherited() const
507 return mInheritOrientation;
511 * Sets the factor of the parents size used for the child actor.
512 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
513 * @param[in] factor The vector to multiply the parents size by to get the childs size.
515 void SetSizeModeFactor(const Vector3& factor);
518 * Gets the factor of the parents size used for the child actor.
519 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
520 * @return The vector being used to multiply the parents size by to get the childs size.
522 const Vector3& GetSizeModeFactor() const;
525 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
527 const Quaternion& GetCurrentWorldOrientation() const;
530 * Sets a scale factor applied to an actor.
531 * @param [in] scale The scale factor applied on all axes.
533 void SetScale(float scale);
536 * Sets a scale factor applied to an actor.
537 * @param [in] scaleX The scale factor applied along the x-axis.
538 * @param [in] scaleY The scale factor applied along the y-axis.
539 * @param [in] scaleZ The scale factor applied along the z-axis.
541 void SetScale(float scaleX, float scaleY, float scaleZ);
544 * Sets a scale factor applied to an actor.
545 * @param [in] scale A vector representing the scale factor for each axis.
547 void SetScale(const Vector3& scale);
550 * Set the x component of the scale factor.
551 * @param [in] x The new x value.
553 void SetScaleX(float x);
556 * Set the y component of the scale factor.
557 * @param [in] y The new y value.
559 void SetScaleY(float y);
562 * Set the z component of the scale factor.
563 * @param [in] z The new z value.
565 void SetScaleZ(float z);
568 * Apply a relative scale to an actor.
569 * @param[in] relativeScale The scale to combine with the actors existing scale.
571 void ScaleBy(const Vector3& relativeScale);
574 * Retrieve the scale factor applied to an actor.
575 * @return A vector representing the scale factor for each axis.
577 const Vector3& GetCurrentScale() const;
580 * @copydoc Dali::Actor::GetCurrentWorldScale()
582 const Vector3& GetCurrentWorldScale() const;
585 * @copydoc Dali::Actor::SetInheritScale()
587 void SetInheritScale(bool inherit);
590 * @copydoc Dali::Actor::IsScaleInherited()
592 bool IsScaleInherited() const
594 return mInheritScale;
598 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
600 Matrix GetCurrentWorldMatrix() const;
605 * Sets the visibility flag of an actor.
606 * @param[in] visible The new visibility flag.
608 void SetVisible(bool visible);
611 * Retrieve the visibility flag of an actor.
612 * @return The visibility flag.
614 bool IsVisible() const;
617 * Sets the opacity of an actor.
618 * @param [in] opacity The new opacity.
620 void SetOpacity(float opacity);
623 * Retrieve the actor's opacity.
624 * @return The actor's opacity.
626 float GetCurrentOpacity() const;
629 * Retrieve the actor's clipping mode.
630 * @return The actor's clipping mode (cached)
632 ClippingMode::Type GetClippingMode() const
634 return mClippingMode;
638 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
639 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
640 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
641 * hover event signal will be emitted.
643 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
645 * actor.SetSensitive(false);
648 * Then, to re-enable the touch or hover event signal emission, the application should call:
650 * actor.SetSensitive(true);
653 * @see SignalTouch() and SignalHover().
654 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
655 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
657 void SetSensitive(bool sensitive)
659 mSensitive = sensitive;
663 * Query whether an actor emits touch or hover event signals.
664 * @see SetSensitive(bool)
665 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
667 bool IsSensitive() const
673 * @copydoc Dali::Actor::SetDrawMode
675 void SetDrawMode(DrawMode::Type drawMode);
678 * @copydoc Dali::Actor::GetDrawMode
680 DrawMode::Type GetDrawMode() const
686 * @copydoc Dali::Actor::IsOverlay
688 bool IsOverlay() const
690 return (DrawMode::OVERLAY_2D == mDrawMode);
694 * Sets the actor's color. The final color of actor depends on its color mode.
695 * This final color is applied to the drawable elements of an actor.
696 * @param [in] color The new color.
698 void SetColor(const Vector4& color);
701 * Set the red component of the color.
702 * @param [in] red The new red component.
704 void SetColorRed(float red);
707 * Set the green component of the color.
708 * @param [in] green The new green component.
710 void SetColorGreen(float green);
713 * Set the blue component of the scale factor.
714 * @param [in] blue The new blue value.
716 void SetColorBlue(float blue);
719 * Retrieve the actor's color.
722 const Vector4& GetCurrentColor() const;
725 * Sets the actor's color mode.
726 * Color mode specifies whether Actor uses its own color or inherits its parent color
727 * @param [in] colorMode to use.
729 void SetColorMode(ColorMode colorMode);
732 * Returns the actor's color mode.
733 * @return currently used colorMode.
735 ColorMode GetColorMode() const
741 * @copydoc Dali::Actor::GetCurrentWorldColor()
743 const Vector4& GetCurrentWorldColor() const;
746 * @copydoc Dali::Actor::GetHierarchyDepth()
748 inline int32_t GetHierarchyDepth() const
759 * Get the actor's sorting depth
761 * @return The depth used for hit-testing and renderer sorting
763 uint32_t GetSortingDepth()
769 // Size negotiation virtual functions
772 * @brief Called after the size negotiation has been finished for this control.
774 * The control is expected to assign this given size to itself/its children.
776 * Should be overridden by derived classes if they need to layout
777 * actors differently after certain operations like add or remove
778 * actors, resize or after changing specific properties.
780 * Note! As this function is called from inside the size negotiation algorithm, you cannot
781 * call RequestRelayout (the call would just be ignored)
783 * @param[in] size The allocated size.
784 * @param[in,out] container The control should add actors to this container that it is not able
785 * to allocate a size for.
787 virtual void OnRelayout(const Vector2& size, RelayoutContainer& container)
792 * @brief Notification for deriving classes when the resize policy is set
794 * @param[in] policy The policy being set
795 * @param[in] dimension The dimension the policy is being set for
797 virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
802 * @brief Virtual method to notify deriving classes that relayout dependencies have been
803 * met and the size for this object is about to be calculated for the given dimension
805 * @param dimension The dimension that is about to be calculated
807 virtual void OnCalculateRelayoutSize(Dimension::Type dimension)
812 * @brief Virtual method to notify deriving classes that the size for a dimension
813 * has just been negotiated
815 * @param[in] size The new size for the given dimension
816 * @param[in] dimension The dimension that was just negotiated
818 virtual void OnLayoutNegotiated(float size, Dimension::Type dimension)
823 * @brief Determine if this actor is dependent on it's children for relayout
825 * @param dimension The dimension(s) to check for
826 * @return Return if the actor is dependent on it's children
828 virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
831 * @brief Determine if this actor is dependent on it's children for relayout.
833 * Called from deriving classes
835 * @param dimension The dimension(s) to check for
836 * @return Return if the actor is dependent on it's children
838 virtual bool RelayoutDependentOnChildrenBase(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
841 * @brief Calculate the size for a child
843 * @param[in] child The child actor to calculate the size for
844 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
845 * @return Return the calculated size for the given dimension
847 virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension);
850 * @brief This method is called during size negotiation when a height is required for a given width.
852 * Derived classes should override this if they wish to customize the height returned.
854 * @param width to use.
855 * @return the height based on the width.
857 virtual float GetHeightForWidth(float width);
860 * @brief This method is called during size negotiation when a width is required for a given height.
862 * Derived classes should override this if they wish to customize the width returned.
864 * @param height to use.
865 * @return the width based on the width.
867 virtual float GetWidthForHeight(float height);
873 * @brief Called by the RelayoutController to negotiate the size of an actor.
875 * The size allocated by the the algorithm is passed in which the
876 * actor must adhere to. A container is passed in as well which
877 * the actor should populate with actors it has not / or does not
878 * need to handle in its size negotiation.
880 * @param[in] size The allocated size.
881 * @param[in,out] container The container that holds actors that are fed back into the
882 * RelayoutController algorithm.
884 void NegotiateSize(const Vector2& size, RelayoutContainer& container);
887 * @brief Set whether size negotiation should use the assigned size of the actor
888 * during relayout for the given dimension(s)
890 * @param[in] use Whether the assigned size of the actor should be used
891 * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions
893 void SetUseAssignedSize(bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
896 * @brief Returns whether size negotiation should use the assigned size of the actor
897 * during relayout for a single dimension
899 * @param[in] dimension The dimension to get
900 * @return Return whether the assigned size of the actor should be used. If more than one dimension is requested, just return the first one found
902 bool GetUseAssignedSize(Dimension::Type dimension) const;
905 * @copydoc Dali::Actor::SetResizePolicy()
907 void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
910 * @copydoc Dali::Actor::GetResizePolicy()
912 ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
915 * @copydoc Dali::Actor::SetSizeScalePolicy()
917 void SetSizeScalePolicy(SizeScalePolicy::Type policy);
920 * @copydoc Dali::Actor::GetSizeScalePolicy()
922 SizeScalePolicy::Type GetSizeScalePolicy() const;
925 * @copydoc Dali::Actor::SetDimensionDependency()
927 void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
930 * @copydoc Dali::Actor::GetDimensionDependency()
932 Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
935 * @brief Set the size negotiation relayout enabled on this actor
937 * @param[in] relayoutEnabled Boolean to enable or disable relayout
939 void SetRelayoutEnabled(bool relayoutEnabled);
942 * @brief Return if relayout is enabled
944 * @return Return if relayout is enabled or not for this actor
946 bool IsRelayoutEnabled() const;
949 * @brief Mark an actor as having it's layout dirty
951 * @param dirty Whether to mark actor as dirty or not
952 * @param dimension The dimension(s) to mark as dirty
954 void SetLayoutDirty(bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
957 * @brief Return if any of an actor's dimensions are marked as dirty
959 * @param dimension The dimension(s) to check
960 * @return Return if any of the requested dimensions are dirty
962 bool IsLayoutDirty(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
965 * @brief Returns if relayout is enabled and the actor is not dirty
967 * @return Return if it is possible to relayout the actor
969 bool RelayoutPossible(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
972 * @brief Returns if relayout is enabled and the actor is dirty
974 * @return Return if it is required to relayout the actor
976 bool RelayoutRequired(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
979 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
981 * This method is automatically called from OnSceneConnection(), OnChildAdd(),
982 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
984 * This method can also be called from a derived class every time it needs a different size.
985 * At the end of event processing, the relayout process starts and
986 * all controls which requested Relayout will have their sizes (re)negotiated.
988 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
989 * only performed once, i.e. there is no need to keep track of this in the calling side.
991 void RelayoutRequest(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
994 * @brief Determine if this actor is dependent on it's parent for relayout
996 * @param dimension The dimension(s) to check for
997 * @return Return if the actor is dependent on it's parent
999 bool RelayoutDependentOnParent(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1002 * @brief Determine if this actor has another dimension depedent on the specified one
1004 * @param dimension The dimension to check for
1005 * @param dependentDimension The dimension to check for dependency with
1006 * @return Return if the actor is dependent on this dimension
1008 bool RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension);
1011 * Negotiate sizes for a control in all dimensions
1013 * @param[in] allocatedSize The size constraint that the control must respect
1015 void NegotiateDimensions(const Vector2& allocatedSize);
1018 * Negotiate size for a specific dimension
1020 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1021 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1022 * LayoutDimensionNegotiated flags being filled in on the actor.
1024 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1025 * calculated and set as well as the LayoutDimensionNegotiated flags.
1027 * @param[in] dimension The dimension to negotiate on
1028 * @param[in] allocatedSize The size constraint that the actor must respect
1030 void NegotiateDimension(Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack);
1033 * @brief Calculate the size of a dimension
1035 * @param[in] dimension The dimension to calculate the size for
1036 * @param[in] maximumSize The upper bounds on the size
1037 * @return Return the calculated size for the dimension
1039 float CalculateSize(Dimension::Type dimension, const Vector2& maximumSize);
1042 * Negotiate a dimension based on the size of the parent
1044 * @param[in] dimension The dimension to negotiate on
1045 * @return Return the negotiated size
1047 float NegotiateFromParent(Dimension::Type dimension);
1050 * Negotiate a dimension based on the size of the parent. Fitting inside.
1052 * @param[in] dimension The dimension to negotiate on
1053 * @return Return the negotiated size
1055 float NegotiateFromParentFit(Dimension::Type dimension);
1058 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1060 * @param[in] dimension The dimension to negotiate on
1061 * @return Return the negotiated size
1063 float NegotiateFromParentFlood(Dimension::Type dimension);
1066 * @brief Negotiate a dimension based on the size of the children
1068 * @param[in] dimension The dimension to negotiate on
1069 * @return Return the negotiated size
1071 float NegotiateFromChildren(Dimension::Type dimension);
1074 * Set the negotiated dimension value for the given dimension(s)
1076 * @param negotiatedDimension The value to set
1077 * @param dimension The dimension(s) to set the value for
1079 void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1082 * Return the value of negotiated dimension for the given dimension
1084 * @param dimension The dimension to retrieve
1085 * @return Return the value of the negotiated dimension
1087 float GetNegotiatedDimension(Dimension::Type dimension) const;
1090 * @brief Set the padding for a dimension
1092 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1093 * @param[in] dimension The dimension to set
1095 void SetPadding(const Vector2& padding, Dimension::Type dimension);
1098 * Return the value of padding for the given dimension
1100 * @param dimension The dimension to retrieve
1101 * @return Return the value of padding for the dimension
1103 Vector2 GetPadding(Dimension::Type dimension) const;
1106 * Return the actor size for a given dimension
1108 * @param[in] dimension The dimension to retrieve the size for
1109 * @return Return the size for the given dimension
1111 float GetSize(Dimension::Type dimension) const;
1114 * Return the natural size of the actor for a given dimension
1116 * @param[in] dimension The dimension to retrieve the size for
1117 * @return Return the natural size for the given dimension
1119 float GetNaturalSize(Dimension::Type dimension) const;
1122 * @brief Return the amount of size allocated for relayout
1124 * May include padding
1126 * @param[in] dimension The dimension to retrieve
1127 * @return Return the size
1129 float GetRelayoutSize(Dimension::Type dimension) const;
1132 * @brief If the size has been negotiated return that else return normal size
1134 * @param[in] dimension The dimension to retrieve
1135 * @return Return the size
1137 float GetLatestSize(Dimension::Type dimension) const;
1140 * Apply the negotiated size to the actor
1142 * @param[in] container The container to fill with actors that require further relayout
1144 void SetNegotiatedSize(RelayoutContainer& container);
1147 * @brief Flag the actor as having it's layout dimension negotiated.
1149 * @param[in] negotiated The status of the flag to set.
1150 * @param[in] dimension The dimension to set the flag for
1152 void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1155 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1157 * @param[in] dimension The dimension to determine the value of the flag for
1158 * @return Return if the layout dimension is negotiated or not.
1160 bool IsLayoutNegotiated(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
1163 * @brief provides the Actor implementation of GetHeightForWidth
1164 * @param width to use.
1165 * @return the height based on the width.
1167 float GetHeightForWidthBase(float width);
1170 * @brief provides the Actor implementation of GetWidthForHeight
1171 * @param height to use.
1172 * @return the width based on the height.
1174 float GetWidthForHeightBase(float height);
1177 * @brief Calculate the size for a child
1179 * @param[in] child The child actor to calculate the size for
1180 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1181 * @return Return the calculated size for the given dimension
1183 float CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension);
1186 * @brief Set the preferred size for size negotiation
1188 * @param[in] size The preferred size to set
1190 void SetPreferredSize(const Vector2& size);
1193 * @brief Return the preferred size used for size negotiation
1195 * @return Return the preferred size
1197 Vector2 GetPreferredSize() const;
1200 * @copydoc Dali::Actor::SetMinimumSize
1202 void SetMinimumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1205 * @copydoc Dali::Actor::GetMinimumSize
1207 float GetMinimumSize(Dimension::Type dimension) const;
1210 * @copydoc Dali::Actor::SetMaximumSize
1212 void SetMaximumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1215 * @copydoc Dali::Actor::GetMaximumSize
1217 float GetMaximumSize(Dimension::Type dimension) const;
1220 * @copydoc Dali::Actor::AddRenderer()
1222 uint32_t AddRenderer(Renderer& renderer);
1225 * @copydoc Dali::Actor::GetRendererCount()
1227 uint32_t GetRendererCount() const;
1230 * @copydoc Dali::Actor::GetRendererAt()
1232 RendererPtr GetRendererAt(uint32_t index);
1235 * @copydoc Dali::Actor::RemoveRenderer()
1237 void RemoveRenderer(Renderer& renderer);
1240 * @copydoc Dali::Actor::RemoveRenderer()
1242 void RemoveRenderer(uint32_t index);
1246 * Converts screen coordinates into the actor's coordinate system.
1247 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1248 * @param[out] localX On return, the X-coordinate relative to the actor.
1249 * @param[out] localY On return, the Y-coordinate relative to the actor.
1250 * @param[in] screenX The screen X-coordinate.
1251 * @param[in] screenY The screen Y-coordinate.
1252 * @return True if the conversion succeeded.
1254 bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
1257 * Converts screen coordinates into the actor's coordinate system.
1258 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1259 * @param[in] renderTask The render-task used to display the actor.
1260 * @param[out] localX On return, the X-coordinate relative to the actor.
1261 * @param[out] localY On return, the Y-coordinate relative to the actor.
1262 * @param[in] screenX The screen X-coordinate.
1263 * @param[in] screenY The screen Y-coordinate.
1264 * @return True if the conversion succeeded.
1266 bool ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const;
1269 * Converts from the actor's coordinate system to screen coordinates.
1270 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1271 * @param[in] viewMatrix The view-matrix
1272 * @param[in] projectionMatrix The projection-matrix
1273 * @param[in] viewport The view-port
1274 * @param[out] localX On return, the X-coordinate relative to the actor.
1275 * @param[out] localY On return, the Y-coordinate relative to the actor.
1276 * @param[in] screenX The screen X-coordinate.
1277 * @param[in] screenY The screen Y-coordinate.
1278 * @return True if the conversion succeeded.
1280 bool ScreenToLocal(const Matrix& viewMatrix,
1281 const Matrix& projectionMatrix,
1282 const Viewport& viewport,
1286 float screenY) const;
1289 * Sets whether the actor should receive a notification when touch or hover motion events leave
1290 * the boundary of the actor.
1292 * @note By default, this is set to false as most actors do not require this.
1293 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1295 * @param[in] required Should be set to true if a Leave event is required
1297 void SetLeaveRequired(bool required)
1299 mLeaveRequired = required;
1303 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1304 * the boundary of the actor.
1305 * @return true if a Leave event is required, false otherwise.
1307 bool GetLeaveRequired() const
1309 return mLeaveRequired;
1313 * @copydoc Dali::Actor::SetKeyboardFocusable()
1315 void SetKeyboardFocusable(bool focusable)
1317 mKeyboardFocusable = focusable;
1321 * @copydoc Dali::Actor::IsKeyboardFocusable()
1323 bool IsKeyboardFocusable() const
1325 return mKeyboardFocusable;
1329 * Set whether this view can focus by touch.
1330 * @param[in] focusable focuable by touch.
1332 void SetTouchFocusable(bool focusable)
1334 mTouchFocusable = focusable;
1338 * This returns whether this actor can focus by touch.
1339 * @return true if this actor can focus by touch.
1341 bool IsTouchFocusable() const
1343 return mTouchFocusable;
1347 * Query whether the application or derived actor type requires intercept touch events.
1348 * @return True if intercept touch events are required.
1350 bool GetInterceptTouchRequired() const
1352 return !mInterceptTouchedSignal.Empty();
1356 * Query whether the application or derived actor type requires touch events.
1357 * @return True if touch events are required.
1359 bool GetTouchRequired() const
1361 return !mTouchedSignal.Empty();
1365 * Query whether the application or derived actor type requires hover events.
1366 * @return True if hover events are required.
1368 bool GetHoverRequired() const
1370 return !mHoveredSignal.Empty();
1374 * Query whether the application or derived actor type requires wheel events.
1375 * @return True if wheel events are required.
1377 bool GetWheelEventRequired() const
1379 return !mWheelEventSignal.Empty();
1383 * Query whether the actor is actually hittable. This method checks whether the actor is
1384 * sensitive, has the visibility flag set to true and is not fully transparent.
1385 * @return true, if it can be hit, false otherwise.
1387 bool IsHittable() const
1389 return IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
1393 * Query whether the actor captures all touch after it starts even if touch leaves its boundary.
1394 * @return true, if it captures all touch after start
1396 bool CapturesAllTouchAfterStart() const
1398 return mCaptureAllTouchAfterStart;
1402 * Sets the touch area offset of an actor.
1403 * @param [in] offset The new offset of area (left, right, bottom, top).
1405 void SetTouchAreaOffset(Rect<int> offset)
1407 mTouchAreaOffset = offset;
1411 * Retrieve the Actor's touch area offset.
1412 * @return The Actor's touch area offset.
1414 const Rect<int>& GetTouchAreaOffset() const
1416 return mTouchAreaOffset;
1422 * Retrieve the gesture data associated with this actor. The first call to this method will
1423 * allocate space for the ActorGestureData so this should only be called if an actor really does
1425 * @return Reference to the ActorGestureData for this actor.
1426 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1427 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1429 ActorGestureData& GetGestureData();
1432 * Queries whether the actor requires the gesture type.
1433 * @param[in] type The gesture type.
1434 * @return True if the gesture is required, false otherwise.
1436 bool IsGestureRequired(GestureType::Value type) const;
1441 * Used by the EventProcessor to emit intercept touch event signals.
1442 * @param[in] touch The touch data.
1443 * @return True if the event was intercepted.
1445 bool EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch);
1448 * Used by the EventProcessor to emit touch event signals.
1449 * @param[in] touch The touch data.
1450 * @return True if the event was consumed.
1452 bool EmitTouchEventSignal(const Dali::TouchEvent& touch);
1455 * Used by the EventProcessor to emit hover event signals.
1456 * @param[in] event The hover event.
1457 * @return True if the event was consumed.
1459 bool EmitHoverEventSignal(const Dali::HoverEvent& event);
1462 * Used by the EventProcessor to emit wheel event signals.
1463 * @param[in] event The wheel event.
1464 * @return True if the event was consumed.
1466 bool EmitWheelEventSignal(const Dali::WheelEvent& event);
1469 * @brief Emits the visibility change signal for this actor and all its children.
1470 * @param[in] visible Whether the actor has become visible or not.
1471 * @param[in] type Whether the actor's visible property has changed or a parent's.
1473 void EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type);
1476 * @brief Emits the layout direction change signal for this actor and all its children.
1477 * @param[in] type Whether the actor's layout direction property has changed or a parent's.
1479 void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type);
1482 * @brief Emits the ChildAdded signal for this actor
1483 * @param[in] child The child actor that has been added
1485 void EmitChildAddedSignal(Actor& child);
1488 * @brief Emits the ChildRemoved signal for this actor
1489 * @param[in] child The child actor that has been removed
1491 void EmitChildRemovedSignal(Actor& child);
1494 * @copydoc DevelActor::InterceptTouchedSignal()
1496 Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
1498 return mInterceptTouchedSignal;
1502 * @copydoc Dali::Actor::TouchedSignal()
1504 Dali::Actor::TouchEventSignalType& TouchedSignal()
1506 return mTouchedSignal;
1510 * @copydoc Dali::Actor::HoveredSignal()
1512 Dali::Actor::HoverSignalType& HoveredSignal()
1514 return mHoveredSignal;
1518 * @copydoc Dali::Actor::WheelEventSignal()
1520 Dali::Actor::WheelEventSignalType& WheelEventSignal()
1522 return mWheelEventSignal;
1526 * @copydoc Dali::Actor::OnSceneSignal()
1528 Dali::Actor::OnSceneSignalType& OnSceneSignal()
1530 return mOnSceneSignal;
1534 * @copydoc Dali::Actor::OffSceneSignal()
1536 Dali::Actor::OffSceneSignalType& OffSceneSignal()
1538 return mOffSceneSignal;
1542 * @copydoc Dali::Actor::OnRelayoutSignal()
1544 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal()
1546 return mOnRelayoutSignal;
1550 * @copydoc DevelActor::VisibilityChangedSignal
1552 DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal()
1554 return mVisibilityChangedSignal;
1558 * @copydoc LayoutDirectionChangedSignal
1560 Dali::Actor::LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal()
1562 return mLayoutDirectionChangedSignal;
1566 * @copydoc DevelActor::ChildAddedSignal
1568 DevelActor::ChildChangedSignalType& ChildAddedSignal()
1570 return mChildAddedSignal;
1574 * @copydoc DevelActor::ChildRemovedSignal
1576 DevelActor::ChildChangedSignalType& ChildRemovedSignal()
1578 return mChildRemovedSignal;
1582 * @copydoc DevelActor::ChildOrderChangedSignal
1584 DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal()
1586 return mChildOrderChangedSignal;
1590 * Connects a callback function with the object's signals.
1591 * @param[in] object The object providing the signal.
1592 * @param[in] tracker Used to disconnect the signal.
1593 * @param[in] signalName The signal to connect to.
1594 * @param[in] functor A newly allocated FunctorDelegate.
1595 * @return True if the signal was connected.
1596 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1598 static bool DoConnectSignal(BaseObject* object,
1599 ConnectionTrackerInterface* tracker,
1600 const std::string& signalName,
1601 FunctorDelegate* functor);
1604 * Performs actions as requested using the action name.
1605 * @param[in] object The object on which to perform the action.
1606 * @param[in] actionName The action to perform.
1607 * @param[in] attributes The attributes with which to perfrom this action.
1608 * @return true if the action was done.
1610 static bool DoAction(BaseObject* object,
1611 const std::string& actionName,
1612 const Property::Map& attributes);
1618 * For use in derived classes.
1619 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1621 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
1634 * Protected Constructor. See Actor::New().
1635 * The second-phase construction Initialize() member should be called immediately after this.
1636 * @param[in] derivedType The derived type of actor (if any).
1637 * @param[in] reference to the node
1639 Actor(DerivedType derivedType, const SceneGraph::Node& node);
1642 * Second-phase constructor. Must be called immediately after creating a new Actor;
1644 void Initialize(void);
1647 * A reference counted object may only be deleted by calling Unreference()
1652 * Called on a child during Add() when the parent actor is connected to the Scene.
1653 * @param[in] parentDepth The depth of the parent in the hierarchy.
1655 void ConnectToScene(uint32_t parentDepth);
1658 * Helper for ConnectToScene, to recursively connect a tree of actors.
1659 * This is atomic i.e. not interrupted by user callbacks.
1660 * @param[in] depth The depth in the hierarchy of the actor
1661 * @param[out] connectionList On return, the list of connected actors which require notification.
1663 void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
1666 * Connect the Node associated with this Actor to the scene-graph.
1668 void ConnectToSceneGraph();
1671 * Helper for ConnectToScene, to notify a connected actor through the public API.
1673 void NotifyStageConnection();
1676 * Called on a child during Remove() when the actor was previously on the Stage.
1678 void DisconnectFromStage();
1681 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1682 * This is atomic i.e. not interrupted by user callbacks.
1683 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1685 void RecursiveDisconnectFromStage(ActorContainer& disconnectionList);
1688 * Disconnect the Node associated with this Actor from the scene-graph.
1690 void DisconnectFromSceneGraph();
1693 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1695 void NotifyStageDisconnection();
1698 * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph.
1699 * @return True if the Actor is OnScene & has a Node connected to the scene graph.
1701 bool IsNodeConnected() const;
1705 * Trigger a rebuild of the actor depth tree from this root
1706 * If a Layer3D is encountered, then this doesn't descend any further.
1707 * The mSortedDepth of each actor is set appropriately.
1709 void RebuildDepthTree();
1713 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1714 * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
1715 * @param[in,out] depthIndex The current depth index (traversal index)
1717 void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
1720 // Default property extensions from Object
1723 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1725 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
1728 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1730 void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value) override;
1733 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1735 Property::Value GetDefaultProperty(Property::Index index) const override;
1738 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1740 Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
1743 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
1745 void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
1748 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1750 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
1753 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1755 const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
1758 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1760 int32_t GetPropertyComponentIndex(Property::Index index) const override;
1763 * @copydoc Dali::Internal::Object::IsAnimationPossible()
1765 bool IsAnimationPossible() const override
1771 * Retrieve the actor's node.
1772 * @return The node used by this actor
1774 const SceneGraph::Node& GetNode() const
1776 return *static_cast<const SceneGraph::Node*>(mUpdateObject);
1780 * @copydoc Dali::DevelActor::Raise()
1785 * @copydoc Dali::DevelActor::Lower()
1790 * @copydoc Dali::DevelActor::RaiseToTop()
1795 * @copydoc Dali::DevelActor::LowerToBottom()
1797 void LowerToBottom();
1800 * @copydoc Dali::DevelActor::RaiseAbove()
1802 void RaiseAbove(Internal::Actor& target);
1805 * @copydoc Dali::DevelActor::LowerBelow()
1807 void LowerBelow(Internal::Actor& target);
1811 * Sets the scene which this actor is added to.
1812 * @param[in] scene The scene
1814 void SetScene(Scene& scene)
1820 * Gets the scene which this actor is added to.
1823 Scene& GetScene() const
1838 struct AnimatedSizeFlag
1851 // Remove default constructor and copy constructor
1853 Actor(const Actor&) = delete;
1854 Actor& operator=(const Actor& rhs) = delete;
1857 * Set the actors parent.
1858 * @param[in] parent The new parent.
1860 void SetParent(Actor* parent);
1863 * For use in derived classes, called after Initialize()
1865 virtual void OnInitialize()
1870 * For use in internal derived classes.
1871 * This is called during ConnectToScene(), after the actor has finished adding its node to the scene-graph.
1872 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1874 virtual void OnSceneConnectionInternal()
1879 * For use in internal derived classes.
1880 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1881 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1883 virtual void OnSceneDisconnectionInternal()
1888 * For use in external (CustomActor) derived classes.
1889 * This is called after the atomic ConnectToScene() traversal has been completed.
1891 virtual void OnSceneConnectionExternal(int depth)
1896 * For use in external (CustomActor) derived classes.
1897 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1899 virtual void OnSceneDisconnectionExternal()
1904 * For use in derived classes; this is called after Add() has added a child.
1905 * @param[in] child The child that was added.
1907 virtual void OnChildAdd(Actor& child)
1912 * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1913 * @param[in] child The child that was removed.
1915 virtual void OnChildRemove(Actor& child)
1920 * For use in derived classes.
1921 * This is called after SizeSet() has been called.
1923 virtual void OnSizeSet(const Vector3& targetSize)
1928 * @brief Retrieves the cached event side value of a default property.
1929 * @param[in] index The index of the property
1930 * @param[out] value Is set with the cached value of the property if found.
1931 * @return True if value set, false otherwise.
1933 bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const;
1936 * @brief Retrieves the current value of a default property from the scene-graph.
1937 * @param[in] index The index of the property
1938 * @param[out] value Is set with the current scene-graph value of the property
1939 * @return True if value set, false otherwise.
1941 bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
1944 * @brief Ensure the relayouter is allocated
1946 Relayouter& EnsureRelayouter();
1949 * @brief Apply the size set policy to the input size
1951 * @param[in] size The size to apply the policy to
1952 * @return Return the adjusted size
1954 Vector2 ApplySizeSetPolicy(const Vector2& size);
1957 * Retrieve the parent object of an Actor.
1958 * @return The parent object, or NULL if the Actor does not have a parent.
1960 Object* GetParentObject() const override
1967 * @param[in] order The sibling order this Actor should be. It will place
1968 * the actor at this index in it's parent's child array.
1970 void SetSiblingOrder(uint32_t order);
1974 * @return the order of this actor amongst it's siblings
1976 uint32_t GetSiblingOrder() const;
1979 * Request that the stage rebuilds the actor depth indices.
1981 void RequestRebuildDepthTree();
1984 * @brief Get the current position of the actor in screen coordinates.
1986 * @return Returns the screen position of actor
1988 const Vector2 GetCurrentScreenPosition() const;
1991 * Sets the visibility flag of an actor.
1992 * @param[in] visible The new visibility flag.
1993 * @param[in] sendMessage Whether to send a message to the update thread or not.
1995 void SetVisibleInternal(bool visible, SendMessage::Type sendMessage);
1998 * Set whether a child actor inherits it's parent's layout direction. Default is to inherit.
1999 * @param[in] inherit - true if the actor should inherit layout direction, false otherwise.
2001 void SetInheritLayoutDirection(bool inherit);
2004 * Returns whether the actor inherits it's parent's layout direction.
2005 * @return true if the actor inherits it's parent's layout direction, false otherwise.
2007 bool IsLayoutDirectionInherited() const
2009 return mInheritLayoutDirection;
2013 * @brief Propagates layout direction recursively.
2014 * @param[in] actor The actor for seting layout direction.
2015 * @param[in] direction New layout direction.
2017 void InheritLayoutDirectionRecursively(ActorPtr actor, Dali::LayoutDirection::Type direction, bool set = false);
2020 * @brief Sets the update size hint of an actor.
2021 * @param [in] updateSizeHint The update size hint.
2023 void SetUpdateSizeHint(const Vector2& updateSizeHint);
2026 Scene* mScene; ///< The scene the actor is added to
2028 Actor* mParent; ///< Each actor (except the root) can have one parent
2029 ActorContainer* mChildren; ///< Container of referenced actors, lazily initialized
2030 RendererContainer* mRenderers; ///< Renderer container
2032 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
2033 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
2035 Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
2037 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
2040 Dali::Actor::TouchEventSignalType mInterceptTouchedSignal;
2041 Dali::Actor::TouchEventSignalType mTouchedSignal;
2042 Dali::Actor::HoverSignalType mHoveredSignal;
2043 Dali::Actor::WheelEventSignalType mWheelEventSignal;
2044 Dali::Actor::OnSceneSignalType mOnSceneSignal;
2045 Dali::Actor::OffSceneSignalType mOffSceneSignal;
2046 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
2047 DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal;
2048 Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal;
2049 DevelActor::ChildChangedSignalType mChildAddedSignal;
2050 DevelActor::ChildChangedSignalType mChildRemovedSignal;
2051 DevelActor::ChildOrderChangedSignalType mChildOrderChangedSignal;
2053 Quaternion mTargetOrientation; ///< Event-side storage for orientation
2054 Vector4 mTargetColor; ///< Event-side storage for color
2055 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
2056 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
2057 Vector3 mTargetScale; ///< Event-side storage for scale
2058 Vector3 mAnimatedSize; ///< Event-side storage for size animation
2059 Rect<int> mTouchAreaOffset; ///< touch area offset (left, right, bottom, top)
2061 std::string mName; ///< Name of the actor
2062 uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
2063 int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
2064 uint16_t mUseAnimatedSize; ///< Whether the size is animated.
2066 const bool mIsRoot : 1; ///< Flag to identify the root actor
2067 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
2068 bool mIsOnScene : 1; ///< Flag to identify whether the actor is on-scene
2069 bool mSensitive : 1; ///< Whether the actor emits touch event signals
2070 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
2071 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
2072 bool mTouchFocusable : 1; ///< Whether the actor should be focusable by touch
2073 bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection
2074 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
2075 bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited.
2076 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
2077 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
2078 bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not.
2079 bool mVisible : 1; ///< Cached: Whether the actor is visible or not.
2080 bool mInheritLayoutDirection : 1; ///< Whether the actor inherits the layout direction from parent.
2081 bool mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area.
2082 LayoutDirection::Type mLayoutDirection : 2; ///< Layout direction, Left to Right or Right to Left.
2083 DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn
2084 ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited
2085 ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use.
2088 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
2090 struct PropertyHandler;
2093 } // namespace Internal
2095 // Helpers for public-api forwarding methods
2097 inline Internal::Actor& GetImplementation(Dali::Actor& actor)
2099 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2101 BaseObject& handle = actor.GetBaseObject();
2103 return static_cast<Internal::Actor&>(handle);
2106 inline const Internal::Actor& GetImplementation(const Dali::Actor& actor)
2108 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2110 const BaseObject& handle = actor.GetBaseObject();
2112 return static_cast<const Internal::Actor&>(handle);
2117 #endif // DALI_INTERNAL_ACTOR_H