1 #ifndef DALI_INTERNAL_ACTOR_H
2 #define DALI_INTERNAL_ACTOR_H
5 * Copyright (c) 2020 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/actors/actor-parent-impl.h>
30 #include <dali/internal/event/actors/actor-parent.h>
31 #include <dali/internal/event/common/object-impl.h>
32 #include <dali/internal/event/common/stage-def.h>
33 #include <dali/internal/event/rendering/renderer-impl.h>
34 #include <dali/internal/update/manager/update-manager.h>
35 #include <dali/internal/update/nodes/node-declarations.h>
36 #include <dali/public-api/actors/actor.h>
37 #include <dali/public-api/common/dali-common.h>
38 #include <dali/public-api/common/vector-wrapper.h>
39 #include <dali/public-api/events/gesture.h>
40 #include <dali/public-api/math/viewport.h>
41 #include <dali/public-api/object/ref-object.h>
42 #include <dali/public-api/size-negotiation/relayout-container.h>
54 class ActorGestureData;
60 using RendererContainer = std::vector<RendererPtr>;
61 using RendererIter = RendererContainer::iterator;
63 class ActorDepthTreeNode;
64 using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator<ActorDepthTreeNode>;
67 * Actor is the primary object with which Dali applications interact.
68 * UI controls can be built by combining multiple actors.
69 * Multi-Touch events are received through signals emitted by the actor tree.
71 * An Actor is a proxy for a Node in the scene graph.
72 * When an Actor is added to the Stage, it creates a node and connects it to the scene graph.
73 * The scene-graph can be updated in a separate thread, so the connection is done using an asynchronous message.
74 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
76 class Actor : public Object, public ActorParent
80 * @brief Struct to hold an actor and a dimension
82 struct ActorDimensionPair
87 * @param[in] newActor The actor to assign
88 * @param[in] newDimension The dimension to assign
90 ActorDimensionPair(Actor* newActor, Dimension::Type newDimension)
92 dimension(newDimension)
97 * @brief Equality operator
99 * @param[in] lhs The left hand side argument
100 * @param[in] rhs The right hand side argument
102 bool operator==(const ActorDimensionPair& rhs)
104 return (actor == rhs.actor) && (dimension == rhs.dimension);
107 Actor* actor; ///< The actor to hold
108 Dimension::Type dimension; ///< The dimension to hold
111 using ActorDimensionStack = std::vector<ActorDimensionPair>;
115 * Create a new actor.
116 * @return A smart-pointer to the newly allocated Actor.
118 static ActorPtr New();
121 * Helper to create node for derived classes who don't have their own node type
122 * @return pointer to newly created unique node
124 static const SceneGraph::Node* CreateNode();
127 * Retrieve the name of the actor.
130 const std::string& GetName() const
136 * Set the name of the actor.
137 * @param[in] name The new name.
139 void SetName(const std::string& name);
142 * @copydoc Dali::Actor::GetId
144 uint32_t GetId() const;
149 * Query whether an actor is the root actor, which is owned by the Stage.
150 * @return True if the actor is a root actor.
158 * Query whether the actor is connected to the Scene.
166 * Query whether the actor has any renderers.
167 * @return True if the actor is renderable.
169 bool IsRenderable() const
171 // inlined as this is called a lot in hit testing
172 return mRenderers && !mRenderers->empty();
176 * Query whether the actor is of class Dali::Layer
177 * @return True if the actor is a layer.
181 // inlined as this is called a lot in hit testing
186 * Gets the layer in which the actor is present
187 * @return The layer, which will be uninitialized if the actor is off-stage.
189 Dali::Layer GetLayer();
192 * @copydoc Dali::Internal::ActorParent::Add()
194 void Add(Actor& child) override;
197 * @copydoc Dali::Internal::ActorParent::Remove()
199 void Remove(Actor& child) override;
202 * @copydoc Dali::Actor::Unparent
207 * @copydoc Dali::Internal::ActorParent::GetChildCount()
209 uint32_t GetChildCount() const override;
212 * @copydoc Dali::Internal::ActorParent::GetChildAt
214 ActorPtr GetChildAt(uint32_t index) const override;
217 * Retrieve a reference to Actor's children.
218 * @note Not for public use.
219 * @return A reference to the container of children.
220 * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method.
222 ActorContainer& GetChildrenInternal();
225 * @copydoc Dali::Internal::ActorParent::FindChildByName
227 ActorPtr FindChildByName(const std::string& actorName) override;
230 * @copydoc Dali::Internal::ActorParent::FindChildById
232 ActorPtr FindChildById(const uint32_t id) override;
235 * @copydoc Dali::Internal::ActorParent::UnparentChildren
237 void UnparentChildren() override;
240 * Retrieve the parent of an Actor.
241 * @return The parent actor, or NULL if the Actor does not have a parent.
243 Actor* GetParent() const
245 return static_cast<Actor*>(mParent);
249 * Calculates screen position and size.
251 * @return pair of two values, position of top-left corner on screen and size respectively.
253 Rect<> CalculateScreenExtents() const;
256 * Sets the size of an actor.
257 * This does not interfere with the actors scale factor.
258 * @param [in] width The new width.
259 * @param [in] height The new height.
261 void SetSize(float width, float height);
264 * Sets the size of an actor.
265 * This does not interfere with the actors scale factor.
266 * @param [in] width The size of the actor along the x-axis.
267 * @param [in] height The size of the actor along the y-axis.
268 * @param [in] depth The size of the actor along the z-axis.
270 void SetSize(float width, float height, float depth);
273 * Sets the size of an actor.
274 * This does not interfere with the actors scale factor.
275 * @param [in] size The new size.
277 void SetSize(const Vector2& size);
280 * Sets the update size for an actor.
282 * @param[in] size The size to set.
284 void SetSizeInternal(const Vector2& size);
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 Vector3& size);
294 * Sets the update size for an actor.
296 * @param[in] size The size to set.
298 void SetSizeInternal(const Vector3& size);
301 * Set the width component of the Actor's size.
302 * @param [in] width The new width component.
304 void SetWidth(float width);
307 * Set the height component of the Actor's size.
308 * @param [in] height The new height component.
310 void SetHeight(float height);
313 * Set the depth component of the Actor's size.
314 * @param [in] depth The new depth component.
316 void SetDepth(float depth);
319 * Retrieve the Actor's size from event side.
320 * This size will be the size set or if animating then the target size.
321 * @return The Actor's size.
323 Vector3 GetTargetSize() const;
326 * Retrieve the Actor's size from update side.
327 * This size will be the size set or animating but will be a frame behind.
328 * @return The Actor's size.
330 const Vector3& GetCurrentSize() const;
333 * Return the natural size of the actor
335 * @return The actor's natural size
337 virtual Vector3 GetNaturalSize() const;
340 * Set the origin of an actor, within its parent's area.
341 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
342 * and (1.0, 1.0, 0.5) is the bottom-right corner.
343 * The default parent-origin is top-left (0.0, 0.0, 0.5).
344 * An actor position is the distance between this origin, and the actors anchor-point.
345 * @param [in] origin The new parent-origin.
347 void SetParentOrigin(const Vector3& origin);
350 * Retrieve the parent-origin of an actor.
351 * @return The parent-origin.
353 const Vector3& GetCurrentParentOrigin() const;
356 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
357 * (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.
358 * The default anchor point is top-left (0.0, 0.0, 0.5).
359 * An actor position is the distance between its parent-origin, and this anchor-point.
360 * An actor's rotation is centered around its anchor-point.
361 * @param [in] anchorPoint The new anchor-point.
363 void SetAnchorPoint(const Vector3& anchorPoint);
366 * Retrieve the anchor-point of an actor.
367 * @return The anchor-point.
369 const Vector3& GetCurrentAnchorPoint() const;
372 * Sets the position of the Actor.
373 * The coordinates are relative to the Actor's parent.
374 * The Actor's z position will be set to 0.0f.
375 * @param [in] x The new x position
376 * @param [in] y The new y position
378 void SetPosition(float x, float y);
381 * Sets the position of the Actor.
382 * The coordinates are relative to the Actor's parent.
383 * @param [in] x The new x position
384 * @param [in] y The new y position
385 * @param [in] z The new z position
387 void SetPosition(float x, float y, float z);
390 * Sets the position of the Actor.
391 * The coordinates are relative to the Actor's parent.
392 * @param [in] position The new position.
394 void SetPosition(const Vector3& position);
397 * Set the position of an actor along the X-axis.
398 * @param [in] x The new x position
403 * Set the position of an actor along the Y-axis.
404 * @param [in] y The new y position.
409 * Set the position of an actor along the Z-axis.
410 * @param [in] z The new z position
415 * Translate an actor relative to its existing position.
416 * @param[in] distance The actor will move by this distance.
418 void TranslateBy(const Vector3& distance);
421 * Retrieve the position of the Actor.
422 * The coordinates are relative to the Actor's parent.
423 * @return the Actor's position.
425 const Vector3& GetCurrentPosition() const;
428 * Retrieve the target position of the Actor.
429 * The coordinates are relative to the Actor's parent.
430 * @return the Actor's position.
432 const Vector3& GetTargetPosition() const
434 return mTargetPosition;
438 * @copydoc Dali::Actor::GetCurrentWorldPosition()
440 const Vector3& GetCurrentWorldPosition() const;
443 * @copydoc Dali::Actor::SetInheritPosition()
445 void SetInheritPosition(bool inherit);
448 * @copydoc Dali::Actor::IsPositionInherited()
450 bool IsPositionInherited() const
452 return mInheritPosition;
456 * Sets the orientation of the Actor.
457 * @param [in] angleRadians The new orientation angle in radians.
458 * @param [in] axis The new axis of orientation.
460 void SetOrientation(const Radian& angleRadians, const Vector3& axis);
463 * Sets the orientation of the Actor.
464 * @param [in] orientation The new orientation.
466 void SetOrientation(const Quaternion& orientation);
469 * Rotate an actor around its existing rotation axis.
470 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
471 * @param[in] axis The axis of the rotation to combine with the existing rotation.
473 void RotateBy(const Radian& angleRadians, const Vector3& axis);
476 * Apply a relative rotation to an actor.
477 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
479 void RotateBy(const Quaternion& relativeRotation);
482 * Retreive the Actor's orientation.
483 * @return the orientation.
485 const Quaternion& GetCurrentOrientation() const;
488 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
489 * Switching this off means that using SetOrientation() sets the actor's world orientation.
490 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
492 void SetInheritOrientation(bool inherit);
495 * Returns whether the actor inherit's it's parent's orientation.
496 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
498 bool IsOrientationInherited() const
500 return mInheritOrientation;
504 * Sets the factor of the parents size used for the child actor.
505 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
506 * @param[in] factor The vector to multiply the parents size by to get the childs size.
508 void SetSizeModeFactor(const Vector3& factor);
511 * Gets 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 * @return The vector being used to multiply the parents size by to get the childs size.
515 const Vector3& GetSizeModeFactor() const;
518 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
520 const Quaternion& GetCurrentWorldOrientation() const;
523 * Sets a scale factor applied to an actor.
524 * @param [in] scale The scale factor applied on all axes.
526 void SetScale(float scale);
529 * Sets a scale factor applied to an actor.
530 * @param [in] scaleX The scale factor applied along the x-axis.
531 * @param [in] scaleY The scale factor applied along the y-axis.
532 * @param [in] scaleZ The scale factor applied along the z-axis.
534 void SetScale(float scaleX, float scaleY, float scaleZ);
537 * Sets a scale factor applied to an actor.
538 * @param [in] scale A vector representing the scale factor for each axis.
540 void SetScale(const Vector3& scale);
543 * Set the x component of the scale factor.
544 * @param [in] x The new x value.
546 void SetScaleX(float x);
549 * Set the y component of the scale factor.
550 * @param [in] y The new y value.
552 void SetScaleY(float y);
555 * Set the z component of the scale factor.
556 * @param [in] z The new z value.
558 void SetScaleZ(float z);
561 * Apply a relative scale to an actor.
562 * @param[in] relativeScale The scale to combine with the actors existing scale.
564 void ScaleBy(const Vector3& relativeScale);
567 * Retrieve the scale factor applied to an actor.
568 * @return A vector representing the scale factor for each axis.
570 const Vector3& GetCurrentScale() const;
573 * @copydoc Dali::Actor::GetCurrentWorldScale()
575 const Vector3& GetCurrentWorldScale() const;
578 * @copydoc Dali::Actor::SetInheritScale()
580 void SetInheritScale(bool inherit);
583 * @copydoc Dali::Actor::IsScaleInherited()
585 bool IsScaleInherited() const
587 return mInheritScale;
591 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
593 Matrix GetCurrentWorldMatrix() const;
598 * Sets the visibility flag of an actor.
599 * @param[in] visible The new visibility flag.
601 void SetVisible(bool visible);
604 * Retrieve the visibility flag of an actor.
605 * @return The visibility flag.
607 bool IsVisible() const;
610 * Sets the opacity of an actor.
611 * @param [in] opacity The new opacity.
613 void SetOpacity(float opacity);
616 * Retrieve the actor's opacity.
617 * @return The actor's opacity.
619 float GetCurrentOpacity() const;
622 * Retrieve the actor's clipping mode.
623 * @return The actor's clipping mode (cached)
625 ClippingMode::Type GetClippingMode() const
627 return mClippingMode;
631 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
632 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
633 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
634 * hover event signal will be emitted.
636 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
638 * actor.SetSensitive(false);
641 * Then, to re-enable the touch or hover event signal emission, the application should call:
643 * actor.SetSensitive(true);
646 * @see SignalTouch() and SignalHover().
647 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
648 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
650 void SetSensitive(bool sensitive)
652 mSensitive = sensitive;
656 * Query whether an actor emits touch or hover event signals.
657 * @see SetSensitive(bool)
658 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
660 bool IsSensitive() const
666 * @copydoc Dali::Actor::SetDrawMode
668 void SetDrawMode(DrawMode::Type drawMode);
671 * @copydoc Dali::Actor::GetDrawMode
673 DrawMode::Type GetDrawMode() const
679 * @copydoc Dali::Actor::IsOverlay
681 bool IsOverlay() const
683 return (DrawMode::OVERLAY_2D == mDrawMode);
687 * Sets the actor's color. The final color of actor depends on its color mode.
688 * This final color is applied to the drawable elements of an actor.
689 * @param [in] color The new color.
691 void SetColor(const Vector4& color);
694 * Set the red component of the color.
695 * @param [in] red The new red component.
697 void SetColorRed(float red);
700 * Set the green component of the color.
701 * @param [in] green The new green component.
703 void SetColorGreen(float green);
706 * Set the blue component of the scale factor.
707 * @param [in] blue The new blue value.
709 void SetColorBlue(float blue);
712 * Retrieve the actor's color.
715 const Vector4& GetCurrentColor() const;
718 * Sets the actor's color mode.
719 * Color mode specifies whether Actor uses its own color or inherits its parent color
720 * @param [in] colorMode to use.
722 void SetColorMode(ColorMode colorMode);
725 * Returns the actor's color mode.
726 * @return currently used colorMode.
728 ColorMode GetColorMode() const
734 * @copydoc Dali::Actor::GetCurrentWorldColor()
736 const Vector4& GetCurrentWorldColor() const;
739 * @copydoc Dali::Actor::GetHierarchyDepth()
741 inline int32_t GetHierarchyDepth() const
752 * Get the actor's sorting depth
754 * @return The depth used for hit-testing and renderer sorting
756 uint32_t GetSortingDepth()
762 // Size negotiation virtual functions
765 * @brief Called after the size negotiation has been finished for this control.
767 * The control is expected to assign this given size to itself/its children.
769 * Should be overridden by derived classes if they need to layout
770 * actors differently after certain operations like add or remove
771 * actors, resize or after changing specific properties.
773 * Note! As this function is called from inside the size negotiation algorithm, you cannot
774 * call RequestRelayout (the call would just be ignored)
776 * @param[in] size The allocated size.
777 * @param[in,out] container The control should add actors to this container that it is not able
778 * to allocate a size for.
780 virtual void OnRelayout(const Vector2& size, RelayoutContainer& container)
785 * @brief Notification for deriving classes when the resize policy is set
787 * @param[in] policy The policy being set
788 * @param[in] dimension The dimension the policy is being set for
790 virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
795 * @brief Virtual method to notify deriving classes that relayout dependencies have been
796 * met and the size for this object is about to be calculated for the given dimension
798 * @param dimension The dimension that is about to be calculated
800 virtual void OnCalculateRelayoutSize(Dimension::Type dimension)
805 * @brief Virtual method to notify deriving classes that the size for a dimension
806 * has just been negotiated
808 * @param[in] size The new size for the given dimension
809 * @param[in] dimension The dimension that was just negotiated
811 virtual void OnLayoutNegotiated(float size, Dimension::Type dimension)
816 * @brief Determine if this actor is dependent on it's children for relayout
818 * @param dimension The dimension(s) to check for
819 * @return Return if the actor is dependent on it's children
821 virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
824 * @brief Determine if this actor is dependent on it's children for relayout.
826 * Called from deriving classes
828 * @param dimension The dimension(s) to check for
829 * @return Return if the actor is dependent on it's children
831 virtual bool RelayoutDependentOnChildrenBase(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
834 * @brief Calculate the size for a child
836 * @param[in] child The child actor to calculate the size for
837 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
838 * @return Return the calculated size for the given dimension
840 virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension);
843 * @brief This method is called during size negotiation when a height is required for a given width.
845 * Derived classes should override this if they wish to customize the height returned.
847 * @param width to use.
848 * @return the height based on the width.
850 virtual float GetHeightForWidth(float width);
853 * @brief This method is called during size negotiation when a width is required for a given height.
855 * Derived classes should override this if they wish to customize the width returned.
857 * @param height to use.
858 * @return the width based on the width.
860 virtual float GetWidthForHeight(float height);
866 * @brief Called by the RelayoutController to negotiate the size of an actor.
868 * The size allocated by the the algorithm is passed in which the
869 * actor must adhere to. A container is passed in as well which
870 * the actor should populate with actors it has not / or does not
871 * need to handle in its size negotiation.
873 * @param[in] size The allocated size.
874 * @param[in,out] container The container that holds actors that are fed back into the
875 * RelayoutController algorithm.
877 void NegotiateSize(const Vector2& size, RelayoutContainer& container);
880 * @brief Set whether size negotiation should use the assigned size of the actor
881 * during relayout for the given dimension(s)
883 * @param[in] use Whether the assigned size of the actor should be used
884 * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions
886 void SetUseAssignedSize(bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
889 * @brief Returns whether size negotiation should use the assigned size of the actor
890 * during relayout for a single dimension
892 * @param[in] dimension The dimension to get
893 * @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
895 bool GetUseAssignedSize(Dimension::Type dimension) const;
898 * @copydoc Dali::Actor::SetResizePolicy()
900 void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
903 * @copydoc Dali::Actor::GetResizePolicy()
905 ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
908 * @copydoc Dali::Actor::SetSizeScalePolicy()
910 void SetSizeScalePolicy(SizeScalePolicy::Type policy);
913 * @copydoc Dali::Actor::GetSizeScalePolicy()
915 SizeScalePolicy::Type GetSizeScalePolicy() const;
918 * @copydoc Dali::Actor::SetDimensionDependency()
920 void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
923 * @copydoc Dali::Actor::GetDimensionDependency()
925 Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
928 * @brief Set the size negotiation relayout enabled on this actor
930 * @param[in] relayoutEnabled Boolean to enable or disable relayout
932 void SetRelayoutEnabled(bool relayoutEnabled);
935 * @brief Return if relayout is enabled
937 * @return Return if relayout is enabled or not for this actor
939 bool IsRelayoutEnabled() const;
942 * @brief Mark an actor as having it's layout dirty
944 * @param dirty Whether to mark actor as dirty or not
945 * @param dimension The dimension(s) to mark as dirty
947 void SetLayoutDirty(bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
950 * @brief Return if any of an actor's dimensions are marked as dirty
952 * @param dimension The dimension(s) to check
953 * @return Return if any of the requested dimensions are dirty
955 bool IsLayoutDirty(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
958 * @brief Returns if relayout is enabled and the actor is not dirty
960 * @return Return if it is possible to relayout the actor
962 bool RelayoutPossible(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
965 * @brief Returns if relayout is enabled and the actor is dirty
967 * @return Return if it is required to relayout the actor
969 bool RelayoutRequired(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
972 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
974 * This method is automatically called from OnSceneConnection(), OnChildAdd(),
975 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
977 * This method can also be called from a derived class every time it needs a different size.
978 * At the end of event processing, the relayout process starts and
979 * all controls which requested Relayout will have their sizes (re)negotiated.
981 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
982 * only performed once, i.e. there is no need to keep track of this in the calling side.
984 void RelayoutRequest(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
987 * @brief Determine if this actor is dependent on it's parent for relayout
989 * @param dimension The dimension(s) to check for
990 * @return Return if the actor is dependent on it's parent
992 bool RelayoutDependentOnParent(Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
995 * @brief Determine if this actor has another dimension depedent on the specified one
997 * @param dimension The dimension to check for
998 * @param dependentDimension The dimension to check for dependency with
999 * @return Return if the actor is dependent on this dimension
1001 bool RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension);
1004 * @brief Calculate the size of a dimension
1006 * @param[in] dimension The dimension to calculate the size for
1007 * @param[in] maximumSize The upper bounds on the size
1008 * @return Return the calculated size for the dimension
1010 float CalculateSize(Dimension::Type dimension, const Vector2& maximumSize);
1013 * Negotiate a dimension based on the size of the parent
1015 * @param[in] dimension The dimension to negotiate on
1016 * @return Return the negotiated size
1018 float NegotiateFromParent(Dimension::Type dimension);
1021 * Negotiate a dimension based on the size of the parent. Fitting inside.
1023 * @param[in] dimension The dimension to negotiate on
1024 * @return Return the negotiated size
1026 float NegotiateFromParentFit(Dimension::Type dimension);
1029 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1031 * @param[in] dimension The dimension to negotiate on
1032 * @return Return the negotiated size
1034 float NegotiateFromParentFlood(Dimension::Type dimension);
1037 * @brief Negotiate a dimension based on the size of the children
1039 * @param[in] dimension The dimension to negotiate on
1040 * @return Return the negotiated size
1042 float NegotiateFromChildren(Dimension::Type dimension);
1045 * Set the negotiated dimension value for the given dimension(s)
1047 * @param negotiatedDimension The value to set
1048 * @param dimension The dimension(s) to set the value for
1050 void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1053 * Return the value of negotiated dimension for the given dimension
1055 * @param dimension The dimension to retrieve
1056 * @return Return the value of the negotiated dimension
1058 float GetNegotiatedDimension(Dimension::Type dimension) const;
1061 * @brief Set the padding for a dimension
1063 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1064 * @param[in] dimension The dimension to set
1066 void SetPadding(const Vector2& padding, Dimension::Type dimension);
1069 * Return the value of padding for the given dimension
1071 * @param dimension The dimension to retrieve
1072 * @return Return the value of padding for the dimension
1074 Vector2 GetPadding(Dimension::Type dimension) const;
1077 * Return the actor size for a given dimension
1079 * @param[in] dimension The dimension to retrieve the size for
1080 * @return Return the size for the given dimension
1082 float GetSize(Dimension::Type dimension) const;
1085 * Return the natural size of the actor for a given dimension
1087 * @param[in] dimension The dimension to retrieve the size for
1088 * @return Return the natural size for the given dimension
1090 float GetNaturalSize(Dimension::Type dimension) const;
1093 * @brief Return the amount of size allocated for relayout
1095 * May include padding
1097 * @param[in] dimension The dimension to retrieve
1098 * @return Return the size
1100 float GetRelayoutSize(Dimension::Type dimension) const;
1103 * @brief If the size has been negotiated return that else return normal size
1105 * @param[in] dimension The dimension to retrieve
1106 * @return Return the size
1108 float GetLatestSize(Dimension::Type dimension) const;
1111 * Apply the negotiated size to the actor
1113 * @param[in] container The container to fill with actors that require further relayout
1115 void SetNegotiatedSize(RelayoutContainer& container);
1118 * @brief Flag the actor as having it's layout dimension negotiated.
1120 * @param[in] negotiated The status of the flag to set.
1121 * @param[in] dimension The dimension to set the flag for
1123 void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1126 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1128 * @param[in] dimension The dimension to determine the value of the flag for
1129 * @return Return if the layout dimension is negotiated or not.
1131 bool IsLayoutNegotiated(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const;
1134 * @brief provides the Actor implementation of GetHeightForWidth
1135 * @param width to use.
1136 * @return the height based on the width.
1138 float GetHeightForWidthBase(float width);
1141 * @brief provides the Actor implementation of GetWidthForHeight
1142 * @param height to use.
1143 * @return the width based on the height.
1145 float GetWidthForHeightBase(float height);
1148 * @brief Calculate the size for a child
1150 * @param[in] child The child actor to calculate the size for
1151 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1152 * @return Return the calculated size for the given dimension
1154 float CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension);
1157 * @brief Set the preferred size for size negotiation
1159 * @param[in] size The preferred size to set
1161 void SetPreferredSize(const Vector2& size);
1164 * @brief Return the preferred size used for size negotiation
1166 * @return Return the preferred size
1168 Vector2 GetPreferredSize() const;
1171 * @copydoc Dali::Actor::SetMinimumSize
1173 void SetMinimumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1176 * @copydoc Dali::Actor::GetMinimumSize
1178 float GetMinimumSize(Dimension::Type dimension) const;
1181 * @copydoc Dali::Actor::SetMaximumSize
1183 void SetMaximumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
1186 * @copydoc Dali::Actor::GetMaximumSize
1188 float GetMaximumSize(Dimension::Type dimension) const;
1191 * @copydoc Dali::Actor::AddRenderer()
1193 uint32_t AddRenderer(Renderer& renderer);
1196 * @copydoc Dali::Actor::GetRendererCount()
1198 uint32_t GetRendererCount() const;
1201 * @copydoc Dali::Actor::GetRendererAt()
1203 RendererPtr GetRendererAt(uint32_t index);
1206 * @copydoc Dali::Actor::RemoveRenderer()
1208 void RemoveRenderer(Renderer& renderer);
1211 * @copydoc Dali::Actor::RemoveRenderer()
1213 void RemoveRenderer(uint32_t index);
1216 * Set BlendEquation at each renderer that added on this Actor.
1218 void SetBlendEquation(DevelBlendEquation::Type blendEquation);
1221 * @brief Get Blend Equation that applied to this Actor
1223 DevelBlendEquation::Type GetBlendEquation() const;
1227 * Converts screen coordinates into the actor's coordinate system.
1228 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1229 * @param[out] localX On return, the X-coordinate relative to the actor.
1230 * @param[out] localY On return, the Y-coordinate relative to the actor.
1231 * @param[in] screenX The screen X-coordinate.
1232 * @param[in] screenY The screen Y-coordinate.
1233 * @return True if the conversion succeeded.
1235 bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
1238 * Converts screen coordinates into the actor's coordinate system.
1239 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1240 * @param[in] renderTask The render-task used to display the actor.
1241 * @param[out] localX On return, the X-coordinate relative to the actor.
1242 * @param[out] localY On return, the Y-coordinate relative to the actor.
1243 * @param[in] screenX The screen X-coordinate.
1244 * @param[in] screenY The screen Y-coordinate.
1245 * @return True if the conversion succeeded.
1247 bool ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const;
1250 * Converts from the actor's coordinate system to screen coordinates.
1251 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1252 * @param[in] viewMatrix The view-matrix
1253 * @param[in] projectionMatrix The projection-matrix
1254 * @param[in] viewport The view-port
1255 * @param[out] localX On return, the X-coordinate relative to the actor.
1256 * @param[out] localY On return, the Y-coordinate relative to the actor.
1257 * @param[in] screenX The screen X-coordinate.
1258 * @param[in] screenY The screen Y-coordinate.
1259 * @return True if the conversion succeeded.
1261 bool ScreenToLocal(const Matrix& viewMatrix,
1262 const Matrix& projectionMatrix,
1263 const Viewport& viewport,
1267 float screenY) const;
1270 * Sets whether the actor should receive a notification when touch or hover motion events leave
1271 * the boundary of the actor.
1273 * @note By default, this is set to false as most actors do not require this.
1274 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1276 * @param[in] required Should be set to true if a Leave event is required
1278 void SetLeaveRequired(bool required)
1280 mLeaveRequired = required;
1284 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1285 * the boundary of the actor.
1286 * @return true if a Leave event is required, false otherwise.
1288 bool GetLeaveRequired() const
1290 return mLeaveRequired;
1294 * @copydoc Dali::Actor::SetKeyboardFocusable()
1296 void SetKeyboardFocusable(bool focusable)
1298 mKeyboardFocusable = focusable;
1302 * @copydoc Dali::Actor::IsKeyboardFocusable()
1304 bool IsKeyboardFocusable() const
1306 return mKeyboardFocusable;
1310 * Query whether the application or derived actor type requires intercept touch events.
1311 * @return True if intercept touch events are required.
1313 bool GetInterceptTouchRequired() const
1315 return !mInterceptTouchedSignal.Empty();
1319 * Query whether the application or derived actor type requires touch events.
1320 * @return True if touch events are required.
1322 bool GetTouchRequired() const
1324 return !mTouchedSignal.Empty();
1328 * Query whether the application or derived actor type requires hover events.
1329 * @return True if hover events are required.
1331 bool GetHoverRequired() const
1333 return !mHoveredSignal.Empty();
1337 * Query whether the application or derived actor type requires wheel events.
1338 * @return True if wheel events are required.
1340 bool GetWheelEventRequired() const
1342 return !mWheelEventSignal.Empty();
1346 * Query whether the actor is actually hittable. This method checks whether the actor is
1347 * sensitive, has the visibility flag set to true and is not fully transparent.
1348 * @return true, if it can be hit, false otherwise.
1350 bool IsHittable() const
1352 return IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
1356 * Query whether the actor captures all touch after it starts even if touch leaves its boundary.
1357 * @return true, if it captures all touch after start
1359 bool CapturesAllTouchAfterStart() const
1361 return mCaptureAllTouchAfterStart;
1365 * Sets the touch area of an actor.
1366 * @param [in] area The new area.
1368 void SetTouchArea(Vector2 area)
1374 * Retrieve the Actor's touch area.
1375 * @return The Actor's touch area.
1377 const Vector2& GetTouchArea() const
1385 * Retrieve the gesture data associated with this actor. The first call to this method will
1386 * allocate space for the ActorGestureData so this should only be called if an actor really does
1388 * @return Reference to the ActorGestureData for this actor.
1389 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1390 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1392 ActorGestureData& GetGestureData();
1395 * Queries whether the actor requires the gesture type.
1396 * @param[in] type The gesture type.
1397 * @return True if the gesture is required, false otherwise.
1399 bool IsGestureRequired(GestureType::Value type) const;
1404 * Used by the EventProcessor to emit intercept touch event signals.
1405 * @param[in] touch The touch data.
1406 * @return True if the event was intercepted.
1408 bool EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch);
1411 * Used by the EventProcessor to emit touch event signals.
1412 * @param[in] touch The touch data.
1413 * @return True if the event was consumed.
1415 bool EmitTouchEventSignal(const Dali::TouchEvent& touch);
1418 * Used by the EventProcessor to emit hover event signals.
1419 * @param[in] event The hover event.
1420 * @return True if the event was consumed.
1422 bool EmitHoverEventSignal(const Dali::HoverEvent& event);
1425 * Used by the EventProcessor to emit wheel event signals.
1426 * @param[in] event The wheel event.
1427 * @return True if the event was consumed.
1429 bool EmitWheelEventSignal(const Dali::WheelEvent& event);
1432 * @brief Emits the visibility change signal for this actor and all its children.
1433 * @param[in] visible Whether the actor has become visible or not.
1434 * @param[in] type Whether the actor's visible property has changed or a parent's.
1436 void EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type);
1439 * @brief Emits the layout direction change signal for this actor and all its children.
1440 * @param[in] type Whether the actor's layout direction property has changed or a parent's.
1442 void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type);
1445 * @copydoc DevelActor::InterceptTouchedSignal()
1447 Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
1449 return mInterceptTouchedSignal;
1453 * @copydoc Dali::Actor::TouchedSignal()
1455 Dali::Actor::TouchEventSignalType& TouchedSignal()
1457 return mTouchedSignal;
1461 * @copydoc Dali::Actor::HoveredSignal()
1463 Dali::Actor::HoverSignalType& HoveredSignal()
1465 return mHoveredSignal;
1469 * @copydoc Dali::Actor::WheelEventSignal()
1471 Dali::Actor::WheelEventSignalType& WheelEventSignal()
1473 return mWheelEventSignal;
1477 * @copydoc Dali::Actor::OnSceneSignal()
1479 Dali::Actor::OnSceneSignalType& OnSceneSignal()
1481 return mOnSceneSignal;
1485 * @copydoc Dali::Actor::OffSceneSignal()
1487 Dali::Actor::OffSceneSignalType& OffSceneSignal()
1489 return mOffSceneSignal;
1493 * @copydoc Dali::Actor::OnRelayoutSignal()
1495 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal()
1497 return mOnRelayoutSignal;
1501 * @copydoc DevelActor::VisibilityChangedSignal
1503 DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal()
1505 return mVisibilityChangedSignal;
1509 * @copydoc LayoutDirectionChangedSignal
1511 Dali::Actor::LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal()
1513 return mLayoutDirectionChangedSignal;
1517 * @copydoc DevelActor::ChildAddedSignal
1519 DevelActor::ChildChangedSignalType& ChildAddedSignal();
1522 * @copydoc DevelActor::ChildRemovedSignal
1524 DevelActor::ChildChangedSignalType& ChildRemovedSignal();
1527 * @copydoc DevelActor::ChildOrderChangedSignal
1529 DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal();
1532 * Connects a callback function with the object's signals.
1533 * @param[in] object The object providing the signal.
1534 * @param[in] tracker Used to disconnect the signal.
1535 * @param[in] signalName The signal to connect to.
1536 * @param[in] functor A newly allocated FunctorDelegate.
1537 * @return True if the signal was connected.
1538 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1540 static bool DoConnectSignal(BaseObject* object,
1541 ConnectionTrackerInterface* tracker,
1542 const std::string& signalName,
1543 FunctorDelegate* functor);
1546 * Performs actions as requested using the action name.
1547 * @param[in] object The object on which to perform the action.
1548 * @param[in] actionName The action to perform.
1549 * @param[in] attributes The attributes with which to perfrom this action.
1550 * @return true if the action was done.
1552 static bool DoAction(BaseObject* object,
1553 const std::string& actionName,
1554 const Property::Map& attributes);
1560 * For use in derived classes.
1561 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1563 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
1576 * Protected Constructor. See Actor::New().
1577 * The second-phase construction Initialize() member should be called immediately after this.
1578 * @param[in] derivedType The derived type of actor (if any).
1579 * @param[in] reference to the node
1581 Actor(DerivedType derivedType, const SceneGraph::Node& node);
1584 * Second-phase constructor. Must be called immediately after creating a new Actor;
1586 void Initialize(void);
1589 * A reference counted object may only be deleted by calling Unreference()
1594 * Called on a child during Add() when the parent actor is connected to the Scene.
1595 * @param[in] parentDepth The depth of the parent in the hierarchy.
1597 void ConnectToScene(uint32_t parentDepth);
1600 * Helper for ConnectToScene, to recursively connect a tree of actors.
1601 * This is atomic i.e. not interrupted by user callbacks.
1602 * @param[in] depth The depth in the hierarchy of the actor
1603 * @param[out] connectionList On return, the list of connected actors which require notification.
1605 void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
1608 * Connect the Node associated with this Actor to the scene-graph.
1610 void ConnectToSceneGraph();
1613 * Helper for ConnectToScene, to notify a connected actor through the public API.
1615 void NotifyStageConnection();
1618 * Called on a child during Remove() when the actor was previously on the Stage.
1620 void DisconnectFromStage();
1623 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1624 * This is atomic i.e. not interrupted by user callbacks.
1625 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1627 void RecursiveDisconnectFromStage(ActorContainer& disconnectionList);
1630 * Disconnect the Node associated with this Actor from the scene-graph.
1632 void DisconnectFromSceneGraph();
1635 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1637 void NotifyStageDisconnection();
1640 * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph.
1641 * @return True if the Actor is OnScene & has a Node connected to the scene graph.
1643 bool IsNodeConnected() const;
1647 * Trigger a rebuild of the actor depth tree from this root
1648 * If a Layer3D is encountered, then this doesn't descend any further.
1649 * The mSortedDepth of each actor is set appropriately.
1651 void RebuildDepthTree();
1655 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1656 * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
1657 * @param[in,out] depthIndex The current depth index (traversal index)
1659 void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
1662 // Default property extensions from Object
1665 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1667 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
1670 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1672 void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value) override;
1675 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1677 Property::Value GetDefaultProperty(Property::Index index) const override;
1680 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1682 Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
1685 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
1687 void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
1690 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1692 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
1695 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1697 const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
1700 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1702 int32_t GetPropertyComponentIndex(Property::Index index) const override;
1705 * @copydoc Dali::Internal::Object::IsAnimationPossible()
1707 bool IsAnimationPossible() const override
1713 * Retrieve the actor's node.
1714 * @return The node used by this actor
1716 const SceneGraph::Node& GetNode() const
1718 return *static_cast<const SceneGraph::Node*>(mUpdateObject);
1722 * @copydoc Dali::DevelActor::Raise()
1727 * @copydoc Dali::DevelActor::Lower()
1732 * @copydoc Dali::DevelActor::RaiseToTop()
1737 * @copydoc Dali::DevelActor::LowerToBottom()
1739 void LowerToBottom();
1742 * @copydoc Dali::DevelActor::RaiseAbove()
1744 void RaiseAbove(Internal::Actor& target);
1747 * @copydoc Dali::DevelActor::LowerBelow()
1749 void LowerBelow(Internal::Actor& target);
1753 * Sets the scene which this actor is added to.
1754 * @param[in] scene The scene
1756 void SetScene(Scene& scene)
1762 * Gets the scene which this actor is added to.
1765 Scene& GetScene() const
1770 LayoutDirection::Type GetLayoutDirection() const
1772 return mLayoutDirection;
1785 struct AnimatedSizeFlag
1798 // Remove default constructor and copy constructor
1800 Actor(const Actor&) = delete;
1801 Actor& operator=(const Actor& rhs) = delete;
1804 * Set the actor's parent.
1805 * @param[in] parent The new parent.
1807 void SetParent(ActorParent* parent);
1810 * For use in derived classes, called after Initialize()
1812 virtual void OnInitialize()
1817 * For use in internal derived classes.
1818 * This is called during ConnectToScene(), after the actor has finished adding its node to the scene-graph.
1819 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1821 virtual void OnSceneConnectionInternal()
1826 * For use in internal derived classes.
1827 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1828 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1830 virtual void OnSceneDisconnectionInternal()
1835 * For use in external (CustomActor) derived classes.
1836 * This is called after the atomic ConnectToScene() traversal has been completed.
1838 virtual void OnSceneConnectionExternal(int depth)
1843 * For use in external (CustomActor) derived classes.
1844 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1846 virtual void OnSceneDisconnectionExternal()
1851 * For use in derived classes; this is called after Add() has added a child.
1852 * @param[in] child The child that was added.
1854 virtual void OnChildAdd(Actor& child)
1859 * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1860 * @param[in] child The child that was removed.
1862 virtual void OnChildRemove(Actor& child)
1867 * For use in derived classes.
1868 * This is called after SizeSet() has been called.
1870 virtual void OnSizeSet(const Vector3& targetSize)
1875 * @brief Retrieves the cached event side value of a default property.
1876 * @param[in] index The index of the property
1877 * @param[out] value Is set with the cached value of the property if found.
1878 * @return True if value set, false otherwise.
1880 bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const;
1883 * @brief Retrieves the current value of a default property from the scene-graph.
1884 * @param[in] index The index of the property
1885 * @param[out] value Is set with the current scene-graph value of the property
1886 * @return True if value set, false otherwise.
1888 bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
1891 * @brief Ensure the relayouter is allocated
1893 Relayouter& EnsureRelayouter();
1896 * @brief Apply the size set policy to the input size
1898 * @param[in] size The size to apply the policy to
1899 * @return Return the adjusted size
1901 Vector2 ApplySizeSetPolicy(const Vector2& size);
1904 * Retrieve the parent object of an Actor.
1905 * @return The parent object, or NULL if the Actor does not have a parent.
1907 Object* GetParentObject() const override
1909 return static_cast<Actor*>(mParent);
1913 * @brief Get the current position of the actor in screen coordinates.
1915 * @return Returns the screen position of actor
1917 const Vector2 GetCurrentScreenPosition() const;
1920 * Sets the visibility flag of an actor.
1921 * @param[in] visible The new visibility flag.
1922 * @param[in] sendMessage Whether to send a message to the update thread or not.
1924 void SetVisibleInternal(bool visible, SendMessage::Type sendMessage);
1927 * @copydoc ActorParent::SetSiblingOrderOfChild
1929 void SetSiblingOrderOfChild(Actor& child, uint32_t order) override;
1932 * @copydoc ActorParent::GetSiblingOrderOfChild
1934 uint32_t GetSiblingOrderOfChild(const Actor& child) const override;
1937 * @copydoc ActorParent::RaiseChild
1939 void RaiseChild(Actor& child) override;
1942 * @copydoc ActorParent::LowerChild
1944 void LowerChild(Actor& child) override;
1947 * @copydoc ActorParent::RaiseChildToTop
1949 void RaiseChildToTop(Actor& child) override;
1952 * @copydoc ActorParent::LowerChildToBottom
1954 void LowerChildToBottom(Actor& child) override;
1957 * @copydoc ActorParent::RaiseChildAbove
1959 void RaiseChildAbove(Actor& child, Actor& target) override;
1962 * @copydoc ActorParent::LowerChildBelow()
1964 void LowerChildBelow(Actor& child, Actor& target) override;
1967 * Set whether a child actor inherits it's parent's layout direction. Default is to inherit.
1968 * @param[in] inherit - true if the actor should inherit layout direction, false otherwise.
1970 void SetInheritLayoutDirection(bool inherit);
1973 * Returns whether the actor inherits it's parent's layout direction.
1974 * @return true if the actor inherits it's parent's layout direction, false otherwise.
1976 bool IsLayoutDirectionInherited() const
1978 return mInheritLayoutDirection;
1982 * @brief Propagates layout direction recursively.
1983 * @param[in] direction New layout direction.
1985 void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
1988 * @brief Sets the update size hint of an actor.
1989 * @param [in] updateSizeHint The update size hint.
1991 void SetUpdateSizeHint(const Vector2& updateSizeHint);
1994 * @brief Recursively emits the visibility-changed-signal on the actor tree.
1996 * @param[in] visible The new visibility of the actor
1997 * @param[in] type Whether the actor's visible property has changed or a parent's
1999 void EmitVisibilityChangedSignalRecursively(bool visible,
2000 DevelActor::VisibilityChange::Type type);
2003 ActorParentImpl mParentImpl; ///< Implementation of ActorParent;
2004 ActorParent* mParent; ///< Each actor (except the root) can have one parent
2005 Scene* mScene; ///< The scene the actor is added to
2006 RendererContainer* mRenderers; ///< Renderer container
2007 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
2008 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
2009 Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
2010 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
2013 Dali::Actor::TouchEventSignalType mInterceptTouchedSignal;
2014 Dali::Actor::TouchEventSignalType mTouchedSignal;
2015 Dali::Actor::HoverSignalType mHoveredSignal;
2016 Dali::Actor::WheelEventSignalType mWheelEventSignal;
2017 Dali::Actor::OnSceneSignalType mOnSceneSignal;
2018 Dali::Actor::OffSceneSignalType mOffSceneSignal;
2019 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
2020 DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal;
2021 Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal;
2023 Quaternion mTargetOrientation; ///< Event-side storage for orientation
2024 Vector4 mTargetColor; ///< Event-side storage for color
2025 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
2026 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
2027 Vector3 mTargetScale; ///< Event-side storage for scale
2028 Vector3 mAnimatedSize; ///< Event-side storage for size animation
2029 Vector2 mTouchArea; ///< touch area
2031 std::string mName; ///< Name of the actor
2032 uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
2033 int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
2034 uint16_t mUseAnimatedSize; ///< Whether the size is animated.
2036 const bool mIsRoot : 1; ///< Flag to identify the root actor
2037 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
2038 bool mIsOnScene : 1; ///< Flag to identify whether the actor is on-scene
2039 bool mSensitive : 1; ///< Whether the actor emits touch event signals
2040 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
2041 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
2042 bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection
2043 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
2044 bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited.
2045 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
2046 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
2047 bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not.
2048 bool mVisible : 1; ///< Cached: Whether the actor is visible or not.
2049 bool mInheritLayoutDirection : 1; ///< Whether the actor inherits the layout direction from parent.
2050 bool mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area.
2051 LayoutDirection::Type mLayoutDirection : 2; ///< Layout direction, Left to Right or Right to Left.
2052 DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn
2053 ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited
2054 ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use.
2055 DevelBlendEquation::Type mBlendEquation : 16; ///< Cached: Determines which blend equation will be used to render renderers.
2056 bool mIsBlendEquationSet : 1; ///< Flag to identify whether the Blend equation is set
2059 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
2061 struct PropertyHandler;
2062 struct SiblingHandler;
2064 friend class ActorParentImpl; // Allow impl to call private methods on actor
2067 } // namespace Internal
2069 // Helpers for public-api forwarding methods
2071 inline Internal::Actor& GetImplementation(Dali::Actor& actor)
2073 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2075 BaseObject& handle = actor.GetBaseObject();
2077 return static_cast<Internal::Actor&>(handle);
2080 inline const Internal::Actor& GetImplementation(const Dali::Actor& actor)
2082 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
2084 const BaseObject& handle = actor.GetBaseObject();
2086 return static_cast<const Internal::Actor&>(handle);
2091 #endif // DALI_INTERNAL_ACTOR_H