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/devel-api/rendering/renderer-devel.h>
27 #include <dali/internal/common/const-string.h>
28 #include <dali/internal/common/internal-constants.h>
29 #include <dali/internal/common/memory-pool-object-allocator.h>
30 #include <dali/internal/event/actors/actor-declarations.h>
31 #include <dali/internal/event/actors/actor-parent-impl.h>
32 #include <dali/internal/event/actors/actor-parent.h>
33 #include <dali/internal/event/actors/actor-renderer-container.h>
34 #include <dali/internal/event/common/object-impl.h>
35 #include <dali/internal/event/common/stage-def.h>
36 #include <dali/internal/update/nodes/node-declarations.h>
37 #include <dali/public-api/actors/actor.h>
38 #include <dali/public-api/common/dali-common.h>
39 #include <dali/public-api/common/vector-wrapper.h>
40 #include <dali/public-api/events/gesture.h>
41 #include <dali/public-api/math/viewport.h>
42 #include <dali/public-api/object/ref-object.h>
43 #include <dali/public-api/size-negotiation/relayout-container.h>
55 class ActorGestureData;
61 class ActorDepthTreeNode;
62 using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator<ActorDepthTreeNode>;
65 * Actor is the primary object with which Dali applications interact.
66 * UI controls can be built by combining multiple actors.
67 * Multi-Touch events are received through signals emitted by the actor tree.
69 * An Actor is a proxy for a Node in the scene graph.
70 * When an Actor is added to the Stage, it creates a node and connects it to the scene graph.
71 * The scene-graph can be updated in a separate thread, so the connection is done using an asynchronous message.
72 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
74 class Actor : public Object, public ActorParent
78 * @brief Struct to hold an actor and a dimension
80 struct ActorDimensionPair
85 * @param[in] newActor The actor to assign
86 * @param[in] newDimension The dimension to assign
88 ActorDimensionPair(Actor* newActor, Dimension::Type newDimension)
90 dimension(newDimension)
95 * @brief Equality operator
97 * @param[in] lhs The left hand side argument
98 * @param[in] rhs The right hand side argument
100 bool operator==(const ActorDimensionPair& rhs)
102 return (actor == rhs.actor) && (dimension == rhs.dimension);
105 Actor* actor; ///< The actor to hold
106 Dimension::Type dimension; ///< The dimension to hold
109 using ActorDimensionStack = std::vector<ActorDimensionPair>;
113 * Create a new actor.
114 * @return A smart-pointer to the newly allocated Actor.
116 static ActorPtr New();
119 * Helper to create node for derived classes who don't have their own node type
120 * @return pointer to newly created unique node
122 static const SceneGraph::Node* CreateNode();
125 * Retrieve the name of the actor.
128 std::string_view GetName() const
130 return mName.GetStringView();
134 * Set the name of the actor.
135 * @param[in] name The new name.
137 void SetName(std::string_view name);
140 * @copydoc Dali::Actor::GetId
142 uint32_t GetId() const;
147 * Query whether an actor is the root actor, which is owned by the Stage.
148 * @return True if the actor is a root actor.
156 * Query whether the actor is connected to the Scene.
164 * Query whether the actor has any renderers.
165 * @return True if the actor is renderable.
167 bool IsRenderable() const
169 // inlined as this is called a lot in hit testing
170 return mRenderers && !mRenderers->IsEmpty();
174 * Query whether the actor is of class Dali::Layer
175 * @return True if the actor is a layer.
179 // inlined as this is called a lot in hit testing
184 * Gets the layer in which the actor is present
185 * @return The layer, which will be uninitialized if the actor is off-stage.
187 Dali::Layer GetLayer();
190 * @copydoc Dali::Internal::ActorParent::Add()
192 void Add(Actor& child, bool notify = true) override;
195 * @copydoc Dali::Internal::ActorParent::Remove()
197 void Remove(Actor& child, bool notify = true) override;
200 * @copydoc Dali::DevelActor::SwitchParent()
202 void SwitchParent(Actor& newParent);
205 * @copydoc Dali::Actor::Unparent
210 * @copydoc Dali::Internal::ActorParent::GetChildCount()
212 uint32_t GetChildCount() const override;
215 * @copydoc Dali::Internal::ActorParent::GetChildAt
217 ActorPtr GetChildAt(uint32_t index) const override;
220 * Retrieve a reference to Actor's children.
221 * @note Not for public use.
222 * @return A reference to the container of children.
223 * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method.
225 ActorContainer& GetChildrenInternal();
228 * @copydoc Dali::Internal::ActorParent::FindChildByName
230 ActorPtr FindChildByName(ConstString actorName) override;
233 * @copydoc Dali::Internal::ActorParent::FindChildById
235 ActorPtr FindChildById(const uint32_t id) override;
238 * @copydoc Dali::Internal::ActorParent::UnparentChildren
240 void UnparentChildren() override;
243 * Retrieve the parent of an Actor.
244 * @return The parent actor, or NULL if the Actor does not have a parent.
246 Actor* GetParent() const
248 return static_cast<Actor*>(mParent);
252 * Calculates screen position and size.
254 * @return pair of two values, position of top-left corner on screen and size respectively.
256 Rect<> CalculateScreenExtents() const;
259 * @copydoc DevelActor::SetNeedGesturePropagation.
261 void SetNeedGesturePropagation(bool propagation);
264 * Retrieve need gesture propagation value
265 * @return The actor's need gesture propagation value.
267 bool NeedGesturePropagation();
270 * Sets the size of an actor.
271 * This does not interfere with the actors scale factor.
272 * @param [in] width The new width.
273 * @param [in] height The new height.
275 void SetSize(float width, float height);
278 * Sets the size of an actor.
279 * This does not interfere with the actors scale factor.
280 * @param [in] width The size of the actor along the x-axis.
281 * @param [in] height The size of the actor along the y-axis.
282 * @param [in] depth The size of the actor along the z-axis.
284 void SetSize(float width, float height, float depth);
287 * Sets the size of an actor.
288 * This does not interfere with the actors scale factor.
289 * @param [in] size The new size.
291 void SetSize(const Vector2& size);
294 * Sets the update size for an actor.
296 * @param[in] size The size to set.
298 void SetSizeInternal(const Vector2& size);
301 * Sets the size of an actor.
302 * This does not interfere with the actors scale factor.
303 * @param [in] size The new size.
305 void SetSize(const Vector3& size);
308 * Sets the update size for an actor.
310 * @param[in] size The size to set.
312 void SetSizeInternal(const Vector3& size);
315 * Set the width component of the Actor's size.
316 * @param [in] width The new width component.
318 void SetWidth(float width);
321 * Set the height component of the Actor's size.
322 * @param [in] height The new height component.
324 void SetHeight(float height);
327 * Set the depth component of the Actor's size.
328 * @param [in] depth The new depth component.
330 void SetDepth(float depth);
333 * Retrieve the Actor's size from event side.
334 * This size will be the size set or if animating then the target size.
335 * @return The Actor's size.
337 Vector3 GetTargetSize() const;
340 * Retrieve the Actor's size from update side.
341 * This size will be the size set or animating but will be a frame behind.
342 * @return The Actor's size.
344 const Vector3& GetCurrentSize() const;
347 * Return the natural size of the actor
349 * @return The actor's natural size
351 virtual Vector3 GetNaturalSize() const;
354 * Set the origin of an actor, within its parent's area.
355 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
356 * and (1.0, 1.0, 0.5) is the bottom-right corner.
357 * The default parent-origin is top-left (0.0, 0.0, 0.5).
358 * An actor position is the distance between this origin, and the actors anchor-point.
359 * @param [in] origin The new parent-origin.
361 void SetParentOrigin(const Vector3& origin);
364 * Retrieve the parent-origin of an actor.
365 * @return The parent-origin.
367 const Vector3& GetCurrentParentOrigin() const;
370 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
371 * (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.
372 * The default anchor point is top-left (0.0, 0.0, 0.5).
373 * An actor position is the distance between its parent-origin, and this anchor-point.
374 * An actor's rotation is centered around its anchor-point.
375 * @param [in] anchorPoint The new anchor-point.
377 void SetAnchorPoint(const Vector3& anchorPoint);
380 * Retrieve the anchor-point of an actor.
381 * @return The anchor-point.
383 const Vector3& GetCurrentAnchorPoint() const;
386 * Sets the position of the Actor.
387 * The coordinates are relative to the Actor's parent.
388 * The Actor's z position will be set to 0.0f.
389 * @param [in] x The new x position
390 * @param [in] y The new y position
392 void SetPosition(float x, float y);
395 * Sets the position of the Actor.
396 * The coordinates are relative to the Actor's parent.
397 * @param [in] x The new x position
398 * @param [in] y The new y position
399 * @param [in] z The new z position
401 void SetPosition(float x, float y, float z);
404 * Sets the position of the Actor.
405 * The coordinates are relative to the Actor's parent.
406 * @param [in] position The new position.
408 void SetPosition(const Vector3& position);
411 * Set the position of an actor along the X-axis.
412 * @param [in] x The new x position
417 * Set the position of an actor along the Y-axis.
418 * @param [in] y The new y position.
423 * Set the position of an actor along the Z-axis.
424 * @param [in] z The new z position
429 * Translate an actor relative to its existing position.
430 * @param[in] distance The actor will move by this distance.
432 void TranslateBy(const Vector3& distance);
435 * Retrieve the position of the Actor.
436 * The coordinates are relative to the Actor's parent.
437 * @return the Actor's position.
439 const Vector3& GetCurrentPosition() const;
442 * Retrieve the target position of the Actor.
443 * The coordinates are relative to the Actor's parent.
444 * @return the Actor's position.
446 const Vector3& GetTargetPosition() const
448 return mTargetPosition;
452 * @copydoc Dali::Actor::GetCurrentWorldPosition()
454 const Vector3& GetCurrentWorldPosition() const;
457 * @copydoc Dali::Actor::SetInheritPosition()
459 void SetInheritPosition(bool inherit);
462 * @copydoc Dali::Actor::IsPositionInherited()
464 bool IsPositionInherited() const
466 return mInheritPosition;
470 * Sets the orientation of the Actor.
471 * @param [in] angleRadians The new orientation angle in radians.
472 * @param [in] axis The new axis of orientation.
474 void SetOrientation(const Radian& angleRadians, const Vector3& axis);
477 * Sets the orientation of the Actor.
478 * @param [in] orientation The new orientation.
480 void SetOrientation(const Quaternion& orientation);
483 * Rotate an actor around its existing rotation axis.
484 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
485 * @param[in] axis The axis of the rotation to combine with the existing rotation.
487 void RotateBy(const Radian& angleRadians, const Vector3& axis);
490 * Apply a relative rotation to an actor.
491 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
493 void RotateBy(const Quaternion& relativeRotation);
496 * Retreive the Actor's orientation.
497 * @return the orientation.
499 const Quaternion& GetCurrentOrientation() const;
502 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
503 * Switching this off means that using SetOrientation() sets the actor's world orientation.
504 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
506 void SetInheritOrientation(bool inherit);
509 * Returns whether the actor inherit's it's parent's orientation.
510 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
512 bool IsOrientationInherited() const
514 return mInheritOrientation;
518 * Sets 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 * @param[in] factor The vector to multiply the parents size by to get the childs size.
522 void SetSizeModeFactor(const Vector3& factor);
525 * Gets the factor of the parents size used for the child actor.
526 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
527 * @return The vector being used to multiply the parents size by to get the childs size.
529 const Vector3& GetSizeModeFactor() const;
532 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
534 const Quaternion& GetCurrentWorldOrientation() const;
537 * Sets a scale factor applied to an actor.
538 * @param [in] scale The scale factor applied on all axes.
540 void SetScale(float scale);
543 * Sets a scale factor applied to an actor.
544 * @param [in] scaleX The scale factor applied along the x-axis.
545 * @param [in] scaleY The scale factor applied along the y-axis.
546 * @param [in] scaleZ The scale factor applied along the z-axis.
548 void SetScale(float scaleX, float scaleY, float scaleZ);
551 * Sets a scale factor applied to an actor.
552 * @param [in] scale A vector representing the scale factor for each axis.
554 void SetScale(const Vector3& scale);
557 * Set the x component of the scale factor.
558 * @param [in] x The new x value.
560 void SetScaleX(float x);
563 * Set the y component of the scale factor.
564 * @param [in] y The new y value.
566 void SetScaleY(float y);
569 * Set the z component of the scale factor.
570 * @param [in] z The new z value.
572 void SetScaleZ(float z);
575 * Apply a relative scale to an actor.
576 * @param[in] relativeScale The scale to combine with the actors existing scale.
578 void ScaleBy(const Vector3& relativeScale);
581 * Retrieve the scale factor applied to an actor.
582 * @return A vector representing the scale factor for each axis.
584 const Vector3& GetCurrentScale() const;
587 * @copydoc Dali::Actor::GetCurrentWorldScale()
589 const Vector3& GetCurrentWorldScale() const;
592 * @copydoc Dali::Actor::SetInheritScale()
594 void SetInheritScale(bool inherit);
597 * @copydoc Dali::Actor::IsScaleInherited()
599 bool IsScaleInherited() const
601 return mInheritScale;
605 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
607 Matrix GetCurrentWorldMatrix() const;
612 * Sets the visibility flag of an actor.
613 * @param[in] visible The new visibility flag.
615 void SetVisible(bool visible);
618 * Retrieve the visibility flag of an actor.
619 * @return The visibility flag.
621 bool IsVisible() const;
624 * Sets the opacity of an actor.
625 * @param [in] opacity The new opacity.
627 void SetOpacity(float opacity);
630 * Retrieve the actor's opacity.
631 * @return The actor's opacity.
633 float GetCurrentOpacity() const;
636 * Retrieve the actor's clipping mode.
637 * @return The actor's clipping mode (cached)
639 ClippingMode::Type GetClippingMode() const
641 return mClippingMode;
645 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
646 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
647 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
648 * hover event signal will be emitted.
650 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
652 * actor.SetSensitive(false);
655 * Then, to re-enable the touch or hover event signal emission, the application should call:
657 * actor.SetSensitive(true);
660 * @see SignalTouch() and SignalHover().
661 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
662 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
664 void SetSensitive(bool sensitive)
666 mSensitive = sensitive;
670 * Query whether an actor emits touch or hover event signals.
671 * @see SetSensitive(bool)
672 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
674 bool IsSensitive() const
680 * @copydoc Dali::Actor::SetDrawMode
682 void SetDrawMode(DrawMode::Type drawMode);
685 * @copydoc Dali::Actor::GetDrawMode
687 DrawMode::Type GetDrawMode() const
693 * @copydoc Dali::Actor::IsOverlay
695 bool IsOverlay() const
697 return (DrawMode::OVERLAY_2D == mDrawMode);
701 * Sets the actor's color. The final color of actor depends on its color mode.
702 * This final color is applied to the drawable elements of an actor.
703 * @param [in] color The new color.
705 void SetColor(const Vector4& color);
708 * Set the red component of the color.
709 * @param [in] red The new red component.
711 void SetColorRed(float red);
714 * Set the green component of the color.
715 * @param [in] green The new green component.
717 void SetColorGreen(float green);
720 * Set the blue component of the scale factor.
721 * @param [in] blue The new blue value.
723 void SetColorBlue(float blue);
726 * Retrieve the actor's color.
729 const Vector4& GetCurrentColor() const;
732 * Sets the actor's color mode.
733 * Color mode specifies whether Actor uses its own color or inherits its parent color
734 * @param [in] colorMode to use.
736 void SetColorMode(ColorMode colorMode);
739 * Returns the actor's color mode.
740 * @return currently used colorMode.
742 ColorMode GetColorMode() const
748 * @copydoc Dali::Actor::GetCurrentWorldColor()
750 const Vector4& GetCurrentWorldColor() const;
753 * @copydoc Dali::Actor::GetHierarchyDepth()
755 inline int32_t GetHierarchyDepth() const
766 * Get the actor's sorting depth
768 * @return The depth used for hit-testing and renderer sorting
770 uint32_t GetSortingDepth()
776 // Size negotiation virtual functions
779 * @brief Called after the size negotiation has been finished for this control.
781 * The control is expected to assign this given size to itself/its children.
783 * Should be overridden by derived classes if they need to layout
784 * actors differently after certain operations like add or remove
785 * actors, resize or after changing specific properties.
787 * Note! As this function is called from inside the size negotiation algorithm, you cannot
788 * call RequestRelayout (the call would just be ignored)
790 * @param[in] size The allocated size.
791 * @param[in,out] container The control should add actors to this container that it is not able
792 * to allocate a size for.
794 virtual void OnRelayout(const Vector2& size, RelayoutContainer& container)
799 * @brief Notification for deriving classes when the resize policy is set
801 * @param[in] policy The policy being set
802 * @param[in] dimension The dimension the policy is being set for
804 virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
809 * @brief Virtual method to notify deriving classes that relayout dependencies have been
810 * met and the size for this object is about to be calculated for the given dimension
812 * @param dimension The dimension that is about to be calculated
814 virtual void OnCalculateRelayoutSize(Dimension::Type dimension)
819 * @brief Virtual method to notify deriving classes that the size for a dimension
820 * has just been negotiated
822 * @param[in] size The new size for the given dimension
823 * @param[in] dimension The dimension that was just negotiated
825 virtual void OnLayoutNegotiated(float size, Dimension::Type dimension)
830 * @brief Determine if this actor is dependent on it's children for relayout
832 * @param dimension The dimension(s) to check for
833 * @return Return if the actor is dependent on it's children
835 virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
838 * @brief Determine if this actor is dependent on it's children for relayout.
840 * Called from deriving classes
842 * @param dimension The dimension(s) to check for
843 * @return Return if the actor is dependent on it's children
845 virtual bool RelayoutDependentOnChildrenBase(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
848 * @brief Calculate the size for a child
850 * @param[in] child The child actor to calculate the size for
851 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
852 * @return Return the calculated size for the given dimension
854 virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension);
857 * @brief This method is called during size negotiation when a height is required for a given width.
859 * Derived classes should override this if they wish to customize the height returned.
861 * @param width to use.
862 * @return the height based on the width.
864 virtual float GetHeightForWidth(float width);
867 * @brief This method is called during size negotiation when a width is required for a given height.
869 * Derived classes should override this if they wish to customize the width returned.
871 * @param height to use.
872 * @return the width based on the width.
874 virtual float GetWidthForHeight(float height);
880 * @brief Called by the RelayoutController to negotiate the size of an actor.
882 * The size allocated by the the algorithm is passed in which the
883 * actor must adhere to. A container is passed in as well which
884 * the actor should populate with actors it has not / or does not
885 * need to handle in its size negotiation.
887 * @param[in] size The allocated size.
888 * @param[in,out] container The container that holds actors that are fed back into the
889 * RelayoutController algorithm.
891 void NegotiateSize(const Vector2& size, RelayoutContainer& container);
894 * @brief Set whether size negotiation should use the assigned size of the actor
895 * during relayout for the given dimension(s)
897 * @param[in] use Whether the assigned size of the actor should be used
898 * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions
900 void SetUseAssignedSize(bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
903 * @brief Returns whether size negotiation should use the assigned size of the actor
904 * during relayout for a single dimension
906 * @param[in] dimension The dimension to get
907 * @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
909 bool GetUseAssignedSize(Dimension::Type dimension) const;
912 * @copydoc Dali::Actor::SetResizePolicy()
914 void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
917 * @copydoc Dali::Actor::GetResizePolicy()
919 ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
922 * @copydoc Dali::Actor::SetSizeScalePolicy()
924 void SetSizeScalePolicy(SizeScalePolicy::Type policy);
927 * @copydoc Dali::Actor::GetSizeScalePolicy()
929 SizeScalePolicy::Type GetSizeScalePolicy() const;
932 * @copydoc Dali::Actor::SetDimensionDependency()
934 void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
937 * @copydoc Dali::Actor::GetDimensionDependency()
939 Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
942 * @brief Set the size negotiation relayout enabled on this actor
944 * @param[in] relayoutEnabled Boolean to enable or disable relayout
946 void SetRelayoutEnabled(bool relayoutEnabled);
949 * @brief Return if relayout is enabled
951 * @return Return if relayout is enabled or not for this actor
953 bool IsRelayoutEnabled() const;
956 * @brief Mark an actor as having it's layout dirty
958 * @param dirty Whether to mark actor as dirty or not
959 * @param dimension The dimension(s) to mark as dirty
961 void SetLayoutDirty(bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
964 * @brief Return if any of an actor's dimensions are marked as dirty
966 * @param dimension The dimension(s) to check
967 * @return Return if any of the requested dimensions are dirty
969 bool IsLayoutDirty(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
972 * @brief Returns if relayout is enabled and the actor is not dirty
974 * @return Return if it is possible to relayout the actor
976 bool RelayoutPossible(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
979 * @brief Returns if relayout is enabled and the actor is dirty
981 * @return Return if it is required to relayout the actor
983 bool RelayoutRequired(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
986 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
988 * This method is automatically called from OnSceneConnection(), OnChildAdd(),
989 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
991 * This method can also be called from a derived class every time it needs a different size.
992 * At the end of event processing, the relayout process starts and
993 * all controls which requested Relayout will have their sizes (re)negotiated.
995 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
996 * only performed once, i.e. there is no need to keep track of this in the calling side.
998 void RelayoutRequest(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1001 * @brief Determine if this actor is dependent on it's parent for relayout
1003 * @param dimension The dimension(s) to check for
1004 * @return Return if the actor is dependent on it's parent
1006 bool RelayoutDependentOnParent(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1009 * @brief Determine if this actor has another dimension depedent on the specified one
1011 * @param dimension The dimension to check for
1012 * @param dependentDimension The dimension to check for dependency with
1013 * @return Return if the actor is dependent on this dimension
1015 bool RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension);
1018 * @brief Calculate the size of a dimension
1020 * @param[in] dimension The dimension to calculate the size for
1021 * @param[in] maximumSize The upper bounds on the size
1022 * @return Return the calculated size for the dimension
1024 float CalculateSize(Dimension::Type dimension, const Vector2& maximumSize);
1027 * Negotiate a dimension based on the size of the parent
1029 * @param[in] dimension The dimension to negotiate on
1030 * @return Return the negotiated size
1032 float NegotiateFromParent(Dimension::Type dimension);
1035 * Negotiate a dimension based on the size of the parent. Fitting inside.
1037 * @param[in] dimension The dimension to negotiate on
1038 * @return Return the negotiated size
1040 float NegotiateFromParentFit(Dimension::Type dimension);
1043 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1045 * @param[in] dimension The dimension to negotiate on
1046 * @return Return the negotiated size
1048 float NegotiateFromParentFlood(Dimension::Type dimension);
1051 * @brief Negotiate a dimension based on the size of the children
1053 * @param[in] dimension The dimension to negotiate on
1054 * @return Return the negotiated size
1056 float NegotiateFromChildren(Dimension::Type dimension);
1059 * Set the negotiated dimension value for the given dimension(s)
1061 * @param negotiatedDimension The value to set
1062 * @param dimension The dimension(s) to set the value for
1064 void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1067 * Return the value of negotiated dimension for the given dimension
1069 * @param dimension The dimension to retrieve
1070 * @return Return the value of the negotiated dimension
1072 float GetNegotiatedDimension(Dimension::Type dimension) const;
1075 * @brief Set the padding for a dimension
1077 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1078 * @param[in] dimension The dimension to set
1080 void SetPadding(const Vector2& padding, Dimension::Type dimension);
1083 * Return the value of padding for the given dimension
1085 * @param dimension The dimension to retrieve
1086 * @return Return the value of padding for the dimension
1088 Vector2 GetPadding(Dimension::Type dimension) const;
1091 * Return the actor size for a given dimension
1093 * @param[in] dimension The dimension to retrieve the size for
1094 * @return Return the size for the given dimension
1096 float GetSize(Dimension::Type dimension) const;
1099 * Return the natural size of the actor for a given dimension
1101 * @param[in] dimension The dimension to retrieve the size for
1102 * @return Return the natural size for the given dimension
1104 float GetNaturalSize(Dimension::Type dimension) const;
1107 * @brief Return the amount of size allocated for relayout
1109 * May include padding
1111 * @param[in] dimension The dimension to retrieve
1112 * @return Return the size
1114 float GetRelayoutSize(Dimension::Type dimension) const;
1117 * @brief If the size has been negotiated return that else return normal size
1119 * @param[in] dimension The dimension to retrieve
1120 * @return Return the size
1122 float GetLatestSize(Dimension::Type dimension) const;
1125 * Apply the negotiated size to the actor
1127 * @param[in] container The container to fill with actors that require further relayout
1129 void SetNegotiatedSize(RelayoutContainer& container);
1132 * @brief Flag the actor as having it's layout dimension negotiated.
1134 * @param[in] negotiated The status of the flag to set.
1135 * @param[in] dimension The dimension to set the flag for
1137 void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1140 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1142 * @param[in] dimension The dimension to determine the value of the flag for
1143 * @return Return if the layout dimension is negotiated or not.
1145 bool IsLayoutNegotiated(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
1148 * @brief provides the Actor implementation of GetHeightForWidth
1149 * @param width to use.
1150 * @return the height based on the width.
1152 float GetHeightForWidthBase(float width);
1155 * @brief provides the Actor implementation of GetWidthForHeight
1156 * @param height to use.
1157 * @return the width based on the height.
1159 float GetWidthForHeightBase(float height);
1162 * @brief Calculate the size for a child
1164 * @param[in] child The child actor to calculate the size for
1165 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1166 * @return Return the calculated size for the given dimension
1168 float CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension);
1171 * @brief Set the preferred size for size negotiation
1173 * @param[in] size The preferred size to set
1175 void SetPreferredSize(const Vector2& size);
1178 * @brief Return the preferred size used for size negotiation
1180 * @return Return the preferred size
1182 Vector2 GetPreferredSize() const;
1185 * @copydoc Dali::Actor::SetMinimumSize
1187 void SetMinimumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1190 * @copydoc Dali::Actor::GetMinimumSize
1192 float GetMinimumSize(Dimension::Type dimension) const;
1195 * @copydoc Dali::Actor::SetMaximumSize
1197 void SetMaximumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1200 * @copydoc Dali::Actor::GetMaximumSize
1202 float GetMaximumSize(Dimension::Type dimension) const;
1205 * @copydoc Dali::Actor::AddRenderer()
1207 uint32_t AddRenderer(Renderer& renderer);
1210 * @copydoc Dali::Actor::GetRendererCount()
1212 uint32_t GetRendererCount() const;
1215 * @copydoc Dali::Actor::GetRendererAt()
1217 RendererPtr GetRendererAt(uint32_t index);
1220 * @copydoc Dali::Actor::RemoveRenderer()
1222 void RemoveRenderer(Renderer& renderer);
1225 * @copydoc Dali::Actor::RemoveRenderer()
1227 void RemoveRenderer(uint32_t index);
1230 * @brief Set BlendEquation at each renderer that added on this Actor.
1232 void SetBlendEquation(DevelBlendEquation::Type blendEquation);
1235 * @brief Get Blend Equation that applied to this Actor
1237 DevelBlendEquation::Type GetBlendEquation() const;
1240 * @brief Set this Actor is transparent or not without any affection on the child Actors.
1242 void SetTransparent(bool transparent);
1245 * @brief Get this Actor is transparent or not.
1247 bool IsTransparent() const;
1251 * Converts screen coordinates into the actor's coordinate system.
1252 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1253 * @param[out] localX On return, the X-coordinate relative to the actor.
1254 * @param[out] localY On return, the Y-coordinate relative to the actor.
1255 * @param[in] screenX The screen X-coordinate.
1256 * @param[in] screenY The screen Y-coordinate.
1257 * @return True if the conversion succeeded.
1259 bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
1262 * Converts screen coordinates into the actor's coordinate system.
1263 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1264 * @param[in] renderTask The render-task used to display the actor.
1265 * @param[out] localX On return, the X-coordinate relative to the actor.
1266 * @param[out] localY On return, the Y-coordinate relative to the actor.
1267 * @param[in] screenX The screen X-coordinate.
1268 * @param[in] screenY The screen Y-coordinate.
1269 * @return True if the conversion succeeded.
1271 bool ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const;
1274 * Converts from the actor's coordinate system to screen coordinates.
1275 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1276 * @param[in] viewMatrix The view-matrix
1277 * @param[in] projectionMatrix The projection-matrix
1278 * @param[in] viewport The view-port
1279 * @param[out] localX On return, the X-coordinate relative to the actor.
1280 * @param[out] localY On return, the Y-coordinate relative to the actor.
1281 * @param[in] screenX The screen X-coordinate.
1282 * @param[in] screenY The screen Y-coordinate.
1283 * @return True if the conversion succeeded.
1285 bool ScreenToLocal(const Matrix& viewMatrix,
1286 const Matrix& projectionMatrix,
1287 const Viewport& viewport,
1291 float screenY) const;
1294 * Sets whether the actor should receive a notification when touch or hover motion events leave
1295 * the boundary of the actor.
1297 * @note By default, this is set to false as most actors do not require this.
1298 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1300 * @param[in] required Should be set to true if a Leave event is required
1302 void SetLeaveRequired(bool required)
1304 mLeaveRequired = required;
1308 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1309 * the boundary of the actor.
1310 * @return true if a Leave event is required, false otherwise.
1312 bool GetLeaveRequired() const
1314 return mLeaveRequired;
1318 * @copydoc Dali::Actor::SetKeyboardFocusable()
1320 void SetKeyboardFocusable(bool focusable)
1322 mKeyboardFocusable = focusable;
1326 * @copydoc Dali::Actor::IsKeyboardFocusable()
1328 bool IsKeyboardFocusable() const
1330 return mKeyboardFocusable;
1334 * @copydoc Dali::Actor::SetKeyboardFocusableChildren()
1336 void SetKeyboardFocusableChildren(bool focusable)
1338 mKeyboardFocusableChildren = focusable;
1342 * @copydoc Dali::Actor::AreChildrenKeyBoardFocusable()
1344 bool AreChildrenKeyBoardFocusable() const
1346 return mKeyboardFocusableChildren;
1350 * Set whether this view can focus by touch.
1351 * @param[in] focusable focuable by touch.
1353 void SetTouchFocusable(bool focusable)
1355 mTouchFocusable = focusable;
1359 * This returns whether this actor can focus by touch.
1360 * @return true if this actor can focus by touch.
1362 bool IsTouchFocusable() const
1364 return mTouchFocusable;
1368 * Query whether the application or derived actor type requires intercept touch events.
1369 * @return True if intercept touch events are required.
1371 bool GetInterceptTouchRequired() const
1373 return !mInterceptTouchedSignal.Empty();
1377 * Query whether the application or derived actor type requires touch events.
1378 * @return True if touch events are required.
1380 bool GetTouchRequired() const
1382 return !mTouchedSignal.Empty();
1386 * Query whether the application or derived actor type requires hover events.
1387 * @return True if hover events are required.
1389 bool GetHoverRequired() const
1391 return !mHoveredSignal.Empty();
1395 * Query whether the application or derived actor type requires wheel events.
1396 * @return True if wheel events are required.
1398 bool GetWheelEventRequired() const
1400 return !mWheelEventSignal.Empty();
1404 * Query whether the actor is actually hittable. This method checks whether the actor is
1405 * sensitive, has the visibility flag set to true and is not fully transparent.
1406 * @return true, if it can be hit, false otherwise.
1408 bool IsHittable() const
1410 return IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
1414 * Query whether the actor captures all touch after it starts even if touch leaves its boundary.
1415 * @return true, if it captures all touch after start
1417 bool CapturesAllTouchAfterStart() const
1419 return mCaptureAllTouchAfterStart;
1423 * Sets the touch area offset of an actor.
1424 * @param [in] offset The new offset of area (left, right, bottom, top).
1426 void SetTouchAreaOffset(Rect<int> offset)
1428 mTouchAreaOffset = offset;
1432 * Retrieve the Actor's touch area offset.
1433 * @return The Actor's touch area offset.
1435 const Rect<int>& GetTouchAreaOffset() const
1437 return mTouchAreaOffset;
1443 * Retrieve the gesture data associated with this actor. The first call to this method will
1444 * allocate space for the ActorGestureData so this should only be called if an actor really does
1446 * @return Reference to the ActorGestureData for this actor.
1447 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1448 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1450 ActorGestureData& GetGestureData();
1453 * Queries whether the actor requires the gesture type.
1454 * @param[in] type The gesture type.
1455 * @return True if the gesture is required, false otherwise.
1457 bool IsGestureRequired(GestureType::Value type) const;
1462 * Used by the EventProcessor to emit intercept touch event signals.
1463 * @param[in] touch The touch data.
1464 * @return True if the event was intercepted.
1466 bool EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch);
1469 * Used by the EventProcessor to emit touch event signals.
1470 * @param[in] touch The touch data.
1471 * @return True if the event was consumed.
1473 bool EmitTouchEventSignal(const Dali::TouchEvent& touch);
1476 * Used by the EventProcessor to emit hover event signals.
1477 * @param[in] event The hover event.
1478 * @return True if the event was consumed.
1480 bool EmitHoverEventSignal(const Dali::HoverEvent& event);
1483 * Used by the EventProcessor to emit wheel event signals.
1484 * @param[in] event The wheel event.
1485 * @return True if the event was consumed.
1487 bool EmitWheelEventSignal(const Dali::WheelEvent& event);
1490 * @brief Emits the visibility change signal for this actor and all its children.
1491 * @param[in] visible Whether the actor has become visible or not.
1492 * @param[in] type Whether the actor's visible property has changed or a parent's.
1494 void EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type);
1497 * @brief Emits the layout direction change signal for this actor and all its children.
1498 * @param[in] type Whether the actor's layout direction property has changed or a parent's.
1500 void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type);
1503 * @copydoc DevelActor::InterceptTouchedSignal()
1505 Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
1507 return mInterceptTouchedSignal;
1511 * @copydoc Dali::Actor::TouchedSignal()
1513 Dali::Actor::TouchEventSignalType& TouchedSignal()
1515 return mTouchedSignal;
1519 * @copydoc Dali::Actor::HoveredSignal()
1521 Dali::Actor::HoverSignalType& HoveredSignal()
1523 return mHoveredSignal;
1527 * @copydoc Dali::Actor::WheelEventSignal()
1529 Dali::Actor::WheelEventSignalType& WheelEventSignal()
1531 return mWheelEventSignal;
1535 * @copydoc Dali::Actor::OnSceneSignal()
1537 Dali::Actor::OnSceneSignalType& OnSceneSignal()
1539 return mOnSceneSignal;
1543 * @copydoc Dali::Actor::OffSceneSignal()
1545 Dali::Actor::OffSceneSignalType& OffSceneSignal()
1547 return mOffSceneSignal;
1551 * @copydoc Dali::Actor::OnRelayoutSignal()
1553 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal()
1555 return mOnRelayoutSignal;
1559 * @copydoc DevelActor::VisibilityChangedSignal
1561 DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal()
1563 return mVisibilityChangedSignal;
1567 * @copydoc LayoutDirectionChangedSignal
1569 Dali::Actor::LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal()
1571 return mLayoutDirectionChangedSignal;
1575 * @copydoc DevelActor::ChildAddedSignal
1577 DevelActor::ChildChangedSignalType& ChildAddedSignal();
1580 * @copydoc DevelActor::ChildRemovedSignal
1582 DevelActor::ChildChangedSignalType& ChildRemovedSignal();
1585 * @copydoc DevelActor::ChildOrderChangedSignal
1587 DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal();
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.
1654 * @param[in] notify Emits notification if set to true.
1656 void ConnectToScene(uint32_t parentDepth, bool notify);
1659 * Helper for ConnectToScene, to recursively connect a tree of actors.
1660 * This is atomic i.e. not interrupted by user callbacks.
1661 * @param[in] depth The depth in the hierarchy of the actor
1662 * @param[out] connectionList On return, the list of connected actors which require notification.
1664 void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
1667 * Connect the Node associated with this Actor to the scene-graph.
1669 void ConnectToSceneGraph();
1672 * Helper for ConnectToScene, to notify a connected actor through the public API.
1673 * @param[in] notify Emits notification if set to true.
1675 void NotifyStageConnection(bool notify);
1678 * Called on a child during Remove() when the actor was previously on the Stage.
1679 * @param[in] notify Emits notification if set to true.
1681 void DisconnectFromStage(bool notify);
1684 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1685 * This is atomic i.e. not interrupted by user callbacks.
1686 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1688 void RecursiveDisconnectFromStage(ActorContainer& disconnectionList);
1691 * Disconnect the Node associated with this Actor from the scene-graph.
1693 void DisconnectFromSceneGraph();
1696 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1697 * @param[in] notify Emits notification if set to true.
1699 void NotifyStageDisconnection(bool notify);
1702 * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph.
1703 * @return True if the Actor is OnScene & has a Node connected to the scene graph.
1705 bool IsNodeConnected() const;
1709 * Trigger a rebuild of the actor depth tree from this root
1710 * If a Layer3D is encountered, then this doesn't descend any further.
1711 * The mSortedDepth of each actor is set appropriately.
1713 void RebuildDepthTree();
1717 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1718 * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
1719 * @param[in,out] depthIndex The current depth index (traversal index)
1721 void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
1724 // Default property extensions from Object
1727 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1729 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
1732 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1734 void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value) override;
1737 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1739 Property::Value GetDefaultProperty(Property::Index index) const override;
1742 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1744 Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
1747 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
1749 void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
1752 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1754 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
1757 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1759 const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
1762 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1764 int32_t GetPropertyComponentIndex(Property::Index index) const override;
1767 * @copydoc Dali::Internal::Object::IsAnimationPossible()
1769 bool IsAnimationPossible() const override
1775 * Retrieve the actor's node.
1776 * @return The node used by this actor
1778 const SceneGraph::Node& GetNode() const;
1781 * @copydoc Dali::DevelActor::Raise()
1786 * @copydoc Dali::DevelActor::Lower()
1791 * @copydoc Dali::DevelActor::RaiseToTop()
1796 * @copydoc Dali::DevelActor::LowerToBottom()
1798 void LowerToBottom();
1801 * @copydoc Dali::DevelActor::RaiseAbove()
1803 void RaiseAbove(Internal::Actor& target);
1806 * @copydoc Dali::DevelActor::LowerBelow()
1808 void LowerBelow(Internal::Actor& target);
1812 * Sets the scene which this actor is added to.
1813 * @param[in] scene The scene
1815 void SetScene(Scene& scene)
1821 * Gets the scene which this actor is added to.
1824 Scene& GetScene() const
1829 LayoutDirection::Type GetLayoutDirection() const
1831 return mLayoutDirection;
1844 struct AnimatedSizeFlag
1857 // Remove default constructor and copy constructor
1859 Actor(const Actor&) = delete;
1860 Actor& operator=(const Actor& rhs) = delete;
1863 * Set the actor's parent.
1864 * @param[in] parent The new parent.
1865 * @param[in] notify Emits notification if set to true. Default is true.
1867 void SetParent(ActorParent* parent, bool notify = true);
1870 * For use in derived classes, called after Initialize()
1872 virtual void OnInitialize()
1877 * For use in internal derived classes.
1878 * This is called during ConnectToScene(), after the actor has finished adding its node to the scene-graph.
1879 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1881 virtual void OnSceneConnectionInternal()
1886 * For use in internal derived classes.
1887 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1888 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1890 virtual void OnSceneDisconnectionInternal()
1895 * For use in external (CustomActor) derived classes.
1896 * This is called after the atomic ConnectToScene() traversal has been completed.
1898 virtual void OnSceneConnectionExternal(int depth)
1903 * For use in external (CustomActor) derived classes.
1904 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1906 virtual void OnSceneDisconnectionExternal()
1911 * For use in derived classes; this is called after Add() has added a child.
1912 * @param[in] child The child that was added.
1914 virtual void OnChildAdd(Actor& child)
1919 * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1920 * @param[in] child The child that was removed.
1922 virtual void OnChildRemove(Actor& child)
1927 * For use in derived classes.
1928 * This is called after SizeSet() has been called.
1930 virtual void OnSizeSet(const Vector3& targetSize)
1935 * @brief Retrieves the cached event side value of a default property.
1936 * @param[in] index The index of the property
1937 * @param[out] value Is set with the cached value of the property if found.
1938 * @return True if value set, false otherwise.
1940 bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const;
1943 * @brief Retrieves the current value of a default property from the scene-graph.
1944 * @param[in] index The index of the property
1945 * @param[out] value Is set with the current scene-graph value of the property
1946 * @return True if value set, false otherwise.
1948 bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
1951 * @brief Ensure the relayouter is allocated
1953 Relayouter& EnsureRelayouter();
1956 * @brief Apply the size set policy to the input size
1958 * @param[in] size The size to apply the policy to
1959 * @return Return the adjusted size
1961 Vector2 ApplySizeSetPolicy(const Vector2& size);
1964 * Retrieve the parent object of an Actor.
1965 * @return The parent object, or NULL if the Actor does not have a parent.
1967 Object* GetParentObject() const override
1969 return static_cast<Actor*>(mParent);
1973 * @brief Get the current position of the actor in screen coordinates.
1975 * @return Returns the screen position of actor
1977 const Vector2 GetCurrentScreenPosition() const;
1980 * Sets the visibility flag of an actor.
1981 * @param[in] visible The new visibility flag.
1982 * @param[in] sendMessage Whether to send a message to the update thread or not.
1984 void SetVisibleInternal(bool visible, SendMessage::Type sendMessage);
1987 * @copydoc ActorParent::SetSiblingOrderOfChild
1989 void SetSiblingOrderOfChild(Actor& child, uint32_t order) override;
1992 * @copydoc ActorParent::GetSiblingOrderOfChild
1994 uint32_t GetSiblingOrderOfChild(const Actor& child) const override;
1997 * @copydoc ActorParent::RaiseChild
1999 void RaiseChild(Actor& child) override;
2002 * @copydoc ActorParent::LowerChild
2004 void LowerChild(Actor& child) override;
2007 * @copydoc ActorParent::RaiseChildToTop
2009 void RaiseChildToTop(Actor& child) override;
2012 * @copydoc ActorParent::LowerChildToBottom
2014 void LowerChildToBottom(Actor& child) override;
2017 * @copydoc ActorParent::RaiseChildAbove
2019 void RaiseChildAbove(Actor& child, Actor& target) override;
2022 * @copydoc ActorParent::LowerChildBelow()
2024 void LowerChildBelow(Actor& child, Actor& target) override;
2027 * Set whether a child actor inherits it's parent's layout direction. Default is to inherit.
2028 * @param[in] inherit - true if the actor should inherit layout direction, false otherwise.
2030 void SetInheritLayoutDirection(bool inherit);
2033 * Returns whether the actor inherits it's parent's layout direction.
2034 * @return true if the actor inherits it's parent's layout direction, false otherwise.
2036 bool IsLayoutDirectionInherited() const
2038 return mInheritLayoutDirection;
2042 * @brief Propagates layout direction recursively.
2043 * @param[in] direction New layout direction.
2045 void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
2048 * @brief Sets the update size hint of an actor.
2049 * @param [in] updateSizeHint The update size hint.
2051 void SetUpdateSizeHint(const Vector2& updateSizeHint);
2054 * @brief Recursively emits the visibility-changed-signal on the actor tree.
2056 * @param[in] visible The new visibility of the actor
2057 * @param[in] type Whether the actor's visible property has changed or a parent's
2059 void EmitVisibilityChangedSignalRecursively(bool visible,
2060 DevelActor::VisibilityChange::Type type);
2063 ActorParentImpl mParentImpl; ///< Implementation of ActorParent;
2064 ActorParent* mParent; ///< Each actor (except the root) can have one parent
2065 Scene* mScene; ///< The scene the actor is added to
2066 RendererContainer* mRenderers; ///< Renderer container
2067 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
2068 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
2069 Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
2070 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
2073 Dali::Actor::TouchEventSignalType mInterceptTouchedSignal;
2074 Dali::Actor::TouchEventSignalType mTouchedSignal;
2075 Dali::Actor::HoverSignalType mHoveredSignal;
2076 Dali::Actor::WheelEventSignalType mWheelEventSignal;
2077 Dali::Actor::OnSceneSignalType mOnSceneSignal;
2078 Dali::Actor::OffSceneSignalType mOffSceneSignal;
2079 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
2080 DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal;
2081 Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal;
2083 Quaternion mTargetOrientation; ///< Event-side storage for orientation
2084 Vector4 mTargetColor; ///< Event-side storage for color
2085 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
2086 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
2087 Vector3 mTargetScale; ///< Event-side storage for scale
2088 Vector3 mAnimatedSize; ///< Event-side storage for size animation
2089 Rect<int> mTouchAreaOffset; ///< touch area offset (left, right, bottom, top)
2091 ConstString mName; ///< Name of the actor
2092 uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
2093 int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
2094 uint16_t mUseAnimatedSize; ///< Whether the size is animated.
2096 const bool mIsRoot : 1; ///< Flag to identify the root actor
2097 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
2098 bool mIsOnScene : 1; ///< Flag to identify whether the actor is on-scene
2099 bool mSensitive : 1; ///< Whether the actor emits touch event signals
2100 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
2101 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
2102 bool mKeyboardFocusableChildren : 1; ///< Whether the children of this actor can be focusable by keyboard navigation.
2103 bool mTouchFocusable : 1; ///< Whether the actor should be focusable by touch
2104 bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection
2105 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
2106 bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited.
2107 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
2108 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
2109 bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not.
2110 bool mVisible : 1; ///< Cached: Whether the actor is visible or not.
2111 bool mInheritLayoutDirection : 1; ///< Whether the actor inherits the layout direction from parent.
2112 bool mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area.
2113 bool mIsBlendEquationSet : 1; ///< Flag to identify whether the Blend equation is set
2114 bool mNeedGesturePropagation : 1; ///< Whether the parent listens for gesture events or not
2115 LayoutDirection::Type mLayoutDirection : 2; ///< Layout direction, Left to Right or Right to Left.
2116 DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn
2117 ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited
2118 ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use.
2119 DevelBlendEquation::Type mBlendEquation : 16; ///< Cached: Determines which blend equation will be used to render renderers.
2122 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
2124 struct PropertyHandler;
2125 struct SiblingHandler;
2127 friend class ActorParentImpl; // Allow impl to call private methods on actor
2130 } // namespace Internal
2132 // Helpers for public-api forwarding methods
2134 inline Internal::Actor& GetImplementation(Dali::Actor& actor)
2136 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2138 BaseObject& handle = actor.GetBaseObject();
2140 return static_cast<Internal::Actor&>(handle);
2143 inline const Internal::Actor& GetImplementation(const Dali::Actor& actor)
2145 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2147 const BaseObject& handle = actor.GetBaseObject();
2149 return static_cast<const Internal::Actor&>(handle);
2154 #endif // DALI_INTERNAL_ACTOR_H