1 #ifndef DALI_INTERNAL_ACTOR_H
2 #define DALI_INTERNAL_ACTOR_H
5 * Copyright (c) 2017 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/public-api/actors/actor.h>
26 #include <dali/devel-api/actors/actor-devel.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/events/gesture.h>
30 #include <dali/public-api/math/viewport.h>
31 #include <dali/public-api/object/ref-object.h>
32 #include <dali/public-api/size-negotiation/relayout-container.h>
33 #include <dali/internal/common/memory-pool-object-allocator.h>
34 #include <dali/internal/event/actors/actor-declarations.h>
35 #include <dali/internal/event/common/object-impl.h>
36 #include <dali/internal/event/common/stage-def.h>
37 #include <dali/internal/event/rendering/renderer-impl.h>
38 #include <dali/internal/update/nodes/node-declarations.h>
52 class ActorGestureData;
57 typedef std::vector< ActorPtr > ActorContainer;
58 typedef ActorContainer::iterator ActorIter;
59 typedef ActorContainer::const_iterator ActorConstIter;
61 typedef std::vector< RendererPtr > RendererContainer;
62 typedef RendererContainer::iterator RendererIter;
64 class ActorDepthTreeNode;
65 typedef Dali::Internal::MemoryPoolObjectAllocator< ActorDepthTreeNode > DepthNodeMemoryPool;
68 * Actor is the primary object which Dali applications interact with.
69 * UI controls can be built by combining multiple actors.
70 * Multi-Touch events are received through signals emitted by the actor tree.
72 * An Actor is a proxy for a Node in the scene graph.
73 * When an Actor is added to the Stage, it creates a node and connects it to the scene graph.
74 * The scene-graph can be updated in a separate thread, so the connection is done using an asynchronous message.
75 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
77 class Actor : public Object
82 * @brief Struct to hold an actor and a dimension
84 struct ActorDimensionPair
89 * @param[in] newActor The actor to assign
90 * @param[in] newDimension The dimension to assign
92 ActorDimensionPair( Actor* newActor, Dimension::Type newDimension )
94 dimension( newDimension )
99 * @brief Equality operator
101 * @param[in] lhs The left hand side argument
102 * @param[in] rhs The right hand side argument
104 bool operator== ( const ActorDimensionPair& rhs )
106 return ( actor == rhs.actor ) && ( dimension == rhs.dimension );
109 Actor* actor; ///< The actor to hold
110 Dimension::Type dimension; ///< The dimension to hold
113 typedef std::vector< ActorDimensionPair > ActorDimensionStack;
118 * Create a new actor.
119 * @return A smart-pointer to the newly allocated Actor.
121 static ActorPtr New();
124 * Retrieve the name of the actor.
127 const std::string& GetName() const;
130 * Set the name of the actor.
131 * @param[in] name The new name.
133 void SetName( const std::string& name );
136 * @copydoc Dali::Actor::GetId
138 unsigned int GetId() const;
143 * Query whether an actor is the root actor, which is owned by the Stage.
144 * @return True if the actor is a root actor.
152 * Query whether the actor is connected to the Stage.
154 bool OnStage() const;
157 * Query whether the actor has any renderers.
158 * @return True if the actor is renderable.
160 bool IsRenderable() const
162 // inlined as this is called a lot in hit testing
163 return mRenderers && !mRenderers->empty();
167 * Query whether the actor is of class Dali::Layer
168 * @return True if the actor is a layer.
172 // inlined as this is called a lot in hit testing
177 * Gets the layer in which the actor is present
178 * @return The layer, which will be uninitialized if the actor is off-stage.
180 Dali::Layer GetLayer();
183 * Adds a child Actor to this Actor.
184 * @pre The child actor is not the same as the parent actor.
185 * @pre The child actor does not already have a parent.
186 * @param [in] child The child.
187 * @post The child will be referenced by its parent.
189 void Add( Actor& child );
192 * Removes a child Actor from this Actor.
193 * @param [in] child The child.
194 * @post The child will be unreferenced.
196 void Remove( Actor& child );
199 * @copydoc Dali::Actor::Unparent
204 * Retrieve the number of children held by the actor.
205 * @return The number of children
207 unsigned int GetChildCount() const;
210 * @copydoc Dali::Actor::GetChildAt
212 ActorPtr GetChildAt( unsigned int index ) const;
215 * Retrieve a reference to Actor's children.
216 * @note Not for public use.
217 * @return A reference to the container of children.
218 * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method.
220 ActorContainer& GetChildrenInternal()
226 * @copydoc Dali::Actor::FindChildByName
228 ActorPtr FindChildByName( const std::string& actorName );
231 * @copydoc Dali::Actor::FindChildById
233 ActorPtr FindChildById( const unsigned int id );
236 * Retrieve the parent of an Actor.
237 * @return The parent actor, or NULL if the Actor does not have a parent.
239 Actor* GetParent() const
245 * Sets the size of an actor.
246 * This does not interfere with the actors scale factor.
247 * @param [in] width The new width.
248 * @param [in] height The new height.
250 void SetSize( float width, float height );
253 * Sets the size of an actor.
254 * This does not interfere with the actors scale factor.
255 * @param [in] width The size of the actor along the x-axis.
256 * @param [in] height The size of the actor along the y-axis.
257 * @param [in] depth The size of the actor along the z-axis.
259 void SetSize( float width, float height, float depth );
262 * Sets the size of an actor.
263 * This does not interfere with the actors scale factor.
264 * @param [in] size The new size.
266 void SetSize( const Vector2& size );
269 * Sets the update size for an actor.
271 * @param[in] size The size to set.
273 void SetSizeInternal( const Vector2& size );
276 * Sets the size of an actor.
277 * This does not interfere with the actors scale factor.
278 * @param [in] size The new size.
280 void SetSize( const Vector3& size );
283 * Sets the update size for an actor.
285 * @param[in] size The size to set.
287 void SetSizeInternal( const Vector3& size );
290 * Set the width component of the Actor's size.
291 * @param [in] width The new width component.
293 void SetWidth( float width );
296 * Set the height component of the Actor's size.
297 * @param [in] height The new height component.
299 void SetHeight( float height );
302 * Set the depth component of the Actor's size.
303 * @param [in] depth The new depth component.
305 void SetDepth( float depth );
308 * Retrieve the Actor's size from event side.
309 * This size will be the size set or if animating then the target size.
310 * @return The Actor's size.
312 Vector3 GetTargetSize() const;
315 * Retrieve the Actor's size from update side.
316 * This size will be the size set or animating but will be a frame behind.
317 * @return The Actor's size.
319 const Vector3& GetCurrentSize() const;
322 * Return the natural size of the actor
324 * @return The actor's natural size
326 virtual Vector3 GetNaturalSize() const;
329 * Set the origin of an actor, within its parent's area.
330 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
331 * and (1.0, 1.0, 0.5) is the bottom-right corner.
332 * The default parent-origin is top-left (0.0, 0.0, 0.5).
333 * An actor position is the distance between this origin, and the actors anchor-point.
334 * @param [in] origin The new parent-origin.
336 void SetParentOrigin( const Vector3& origin );
339 * Set the x component of the parent-origin
340 * @param [in] x The new x value.
342 void SetParentOriginX( float x );
345 * Set the y component of the parent-origin
346 * @param [in] y The new y value.
348 void SetParentOriginY( float y );
351 * Set the z component of the parent-origin
352 * @param [in] z The new z value.
354 void SetParentOriginZ( float z );
357 * Retrieve the parent-origin of an actor.
358 * @return The parent-origin.
360 const Vector3& GetCurrentParentOrigin() const;
363 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
364 * (0.0, 0.0, 0.5) is the top-left corner of the actor, and (1.0, 1.0, 0.5) is the bottom-right corner.
365 * The default anchor point is top-left (0.0, 0.0, 0.5).
366 * An actor position is the distance between its parent-origin, and this anchor-point.
367 * An actor's rotation is centered around its anchor-point.
368 * @param [in] anchorPoint The new anchor-point.
370 void SetAnchorPoint( const Vector3& anchorPoint );
373 * Set the x component of the anchor-point.
374 * @param [in] x The new x value.
376 void SetAnchorPointX( float x );
379 * Set the y component of the anchor-point.
380 * @param [in] y The new y value.
382 void SetAnchorPointY( float y );
385 * Set the z component of the anchor-point.
386 * @param [in] z The new z value.
388 void SetAnchorPointZ( float z );
391 * Retrieve the anchor-point of an actor.
392 * @return The anchor-point.
394 const Vector3& GetCurrentAnchorPoint() const;
397 * Sets the position of the Actor.
398 * The coordinates are relative to the Actor's parent.
399 * The Actor's z position will be set to 0.0f.
400 * @param [in] x The new x position
401 * @param [in] y The new y position
403 void SetPosition( float x, float y );
406 * Sets the position of the Actor.
407 * The coordinates are relative to the Actor's parent.
408 * @param [in] x The new x position
409 * @param [in] y The new y position
410 * @param [in] z The new z position
412 void SetPosition( float x, float y, float z );
415 * Sets the position of the Actor.
416 * The coordinates are relative to the Actor's parent.
417 * @param [in] position The new position.
419 void SetPosition( const Vector3& position );
422 * Set the position of an actor along the X-axis.
423 * @param [in] x The new x position
425 void SetX( float x );
428 * Set the position of an actor along the Y-axis.
429 * @param [in] y The new y position.
431 void SetY( float y );
434 * Set the position of an actor along the Z-axis.
435 * @param [in] z The new z position
437 void SetZ( float z );
440 * Translate an actor relative to its existing position.
441 * @param[in] distance The actor will move by this distance.
443 void TranslateBy( const Vector3& distance );
446 * Retrieve the position of the Actor.
447 * The coordinates are relative to the Actor's parent.
448 * @return the Actor's position.
450 const Vector3& GetCurrentPosition() const;
453 * Retrieve the target position of the Actor.
454 * The coordinates are relative to the Actor's parent.
455 * @return the Actor's position.
457 const Vector3& GetTargetPosition() const;
460 * @copydoc Dali::Actor::GetCurrentWorldPosition()
462 const Vector3& GetCurrentWorldPosition() const;
465 * @copydoc Dali::Actor::SetPositionInheritanceMode()
467 void SetPositionInheritanceMode( PositionInheritanceMode mode );
470 * @copydoc Dali::Actor::GetPositionInheritanceMode()
472 PositionInheritanceMode GetPositionInheritanceMode() const;
475 * @copydoc Dali::Actor::SetInheritPosition()
477 void SetInheritPosition( bool inherit );
480 * @copydoc Dali::Actor::IsPositionInherited()
482 bool IsPositionInherited() const;
485 * Sets the orientation of the Actor.
486 * @param [in] angleRadians The new orientation angle in radians.
487 * @param [in] axis The new axis of orientation.
489 void SetOrientation( const Radian& angleRadians, const Vector3& axis );
492 * Sets the orientation of the Actor.
493 * @param [in] orientation The new orientation.
495 void SetOrientation( const Quaternion& orientation );
498 * Rotate an actor around its existing rotation axis.
499 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
500 * @param[in] axis The axis of the rotation to combine with the existing rotation.
502 void RotateBy( const Radian& angleRadians, const Vector3& axis );
505 * Apply a relative rotation to an actor.
506 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
508 void RotateBy( const Quaternion& relativeRotation );
511 * Retreive the Actor's orientation.
512 * @return the orientation.
514 const Quaternion& GetCurrentOrientation() const;
517 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
518 * Switching this off means that using SetOrientation() sets the actor's world orientation.
519 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
521 void SetInheritOrientation( bool inherit );
524 * Returns whether the actor inherit's it's parent's orientation.
525 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
527 bool IsOrientationInherited() const;
530 * Sets the factor of the parents size used for the child actor.
531 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
532 * @param[in] factor The vector to multiply the parents size by to get the childs size.
534 void SetSizeModeFactor( const Vector3& factor );
537 * Gets the factor of the parents size used for the child actor.
538 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
539 * @return The vector being used to multiply the parents size by to get the childs size.
541 const Vector3& GetSizeModeFactor() const;
544 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
546 const Quaternion& GetCurrentWorldOrientation() const;
549 * Sets a scale factor applied to an actor.
550 * @param [in] scale The scale factor applied on all axes.
552 void SetScale( float scale );
555 * Sets a scale factor applied to an actor.
556 * @param [in] scaleX The scale factor applied along the x-axis.
557 * @param [in] scaleY The scale factor applied along the y-axis.
558 * @param [in] scaleZ The scale factor applied along the z-axis.
560 void SetScale( float scaleX, float scaleY, float scaleZ );
563 * Sets a scale factor applied to an actor.
564 * @param [in] scale A vector representing the scale factor for each axis.
566 void SetScale( const Vector3& scale );
569 * Set the x component of the scale factor.
570 * @param [in] x The new x value.
572 void SetScaleX( float x );
575 * Set the y component of the scale factor.
576 * @param [in] y The new y value.
578 void SetScaleY( float y );
581 * Set the z component of the scale factor.
582 * @param [in] z The new z value.
584 void SetScaleZ( float z );
587 * Apply a relative scale to an actor.
588 * @param[in] relativeScale The scale to combine with the actors existing scale.
590 void ScaleBy( const Vector3& relativeScale );
593 * Retrieve the scale factor applied to an actor.
594 * @return A vector representing the scale factor for each axis.
596 const Vector3& GetCurrentScale() const;
599 * @copydoc Dali::Actor::GetCurrentWorldScale()
601 const Vector3& GetCurrentWorldScale() const;
604 * @copydoc Dali::Actor::SetInheritScale()
606 void SetInheritScale( bool inherit );
609 * @copydoc Dali::Actor::IsScaleInherited()
611 bool IsScaleInherited() const;
614 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
616 Matrix GetCurrentWorldMatrix() const;
621 * Sets the visibility flag of an actor.
622 * @param [in] visible The new visibility flag.
624 void SetVisible( bool visible );
627 * Retrieve the visibility flag of an actor.
628 * @return The visibility flag.
630 bool IsVisible() const;
633 * Sets the opacity of an actor.
634 * @param [in] opacity The new opacity.
636 void SetOpacity( float opacity );
639 * Retrieve the actor's opacity.
640 * @return The actor's opacity.
642 float GetCurrentOpacity() const;
645 * Retrieve the actor's clipping mode.
646 * @return The actor's clipping mode (cached)
648 ClippingMode::Type GetClippingMode() const;
651 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
652 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
653 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
654 * hover event signal will be emitted.
656 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
658 * actor.SetSensitive(false);
661 * Then, to re-enable the touch or hover event signal emission, the application should call:
663 * actor.SetSensitive(true);
666 * @see SignalTouch() and SignalHover().
667 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
668 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
670 void SetSensitive( bool sensitive )
672 mSensitive = sensitive;
676 * Query whether an actor emits touch or hover event signals.
677 * @see SetSensitive(bool)
678 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
680 bool IsSensitive() const
686 * @copydoc Dali::Actor::SetDrawMode
688 void SetDrawMode( DrawMode::Type drawMode );
691 * @copydoc Dali::Actor::GetDrawMode
693 DrawMode::Type GetDrawMode() const;
696 * @copydoc Dali::Actor::IsOverlay
698 bool IsOverlay() const;
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;
745 * @copydoc Dali::Actor::GetCurrentWorldColor()
747 const Vector4& GetCurrentWorldColor() const;
750 * @copydoc Dali::Actor::GetHierarchyDepth()
752 inline int GetHierarchyDepth() const
756 return static_cast<int>(mDepth);
763 * Get the actor's sorting depth
765 * @return The depth used for hit-testing and renderer sorting
767 unsigned int GetSortingDepth();
771 // Size negotiation virtual functions
774 * @brief Called after the size negotiation has been finished for this control.
776 * The control is expected to assign this given size to itself/its children.
778 * Should be overridden by derived classes if they need to layout
779 * actors differently after certain operations like add or remove
780 * actors, resize or after changing specific properties.
782 * Note! As this function is called from inside the size negotiation algorithm, you cannot
783 * call RequestRelayout (the call would just be ignored)
785 * @param[in] size The allocated size.
786 * @param[in,out] container The control should add actors to this container that it is not able
787 * to allocate a size for.
789 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
794 * @brief Notification for deriving classes when the resize policy is set
796 * @param[in] policy The policy being set
797 * @param[in] dimension The dimension the policy is being set for
799 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
802 * @brief Virtual method to notify deriving classes that relayout dependencies have been
803 * met and the size for this object is about to be calculated for the given dimension
805 * @param dimension The dimension that is about to be calculated
807 virtual void OnCalculateRelayoutSize( Dimension::Type dimension );
810 * @brief Virtual method to notify deriving classes that the size for a dimension
811 * has just been negotiated
813 * @param[in] size The new size for the given dimension
814 * @param[in] dimension The dimension that was just negotiated
816 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension );
819 * @brief Determine if this actor is dependent on it's children for relayout
821 * @param dimension The dimension(s) to check for
822 * @return Return if the actor is dependent on it's children
824 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
827 * @brief Determine if this actor is dependent on it's children for relayout.
829 * Called from deriving classes
831 * @param dimension The dimension(s) to check for
832 * @return Return if the actor is dependent on it's children
834 virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
837 * @brief Calculate the size for a child
839 * @param[in] child The child actor to calculate the size for
840 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
841 * @return Return the calculated size for the given dimension
843 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
846 * @brief This method is called during size negotiation when a height is required for a given width.
848 * Derived classes should override this if they wish to customize the height returned.
850 * @param width to use.
851 * @return the height based on the width.
853 virtual float GetHeightForWidth( float width );
856 * @brief This method is called during size negotiation when a width is required for a given height.
858 * Derived classes should override this if they wish to customize the width returned.
860 * @param height to use.
861 * @return the width based on the width.
863 virtual float GetWidthForHeight( float height );
870 * @brief Called by the RelayoutController to negotiate the size of an actor.
872 * The size allocated by the the algorithm is passed in which the
873 * actor must adhere to. A container is passed in as well which
874 * the actor should populate with actors it has not / or does not
875 * need to handle in its size negotiation.
877 * @param[in] size The allocated size.
878 * @param[in,out] container The container that holds actors that are fed back into the
879 * RelayoutController algorithm.
881 void NegotiateSize( const Vector2& size, RelayoutContainer& container );
884 * @copydoc Dali::Actor::SetResizePolicy()
886 void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
889 * @copydoc Dali::Actor::GetResizePolicy()
891 ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
894 * @copydoc Dali::Actor::SetSizeScalePolicy()
896 void SetSizeScalePolicy( SizeScalePolicy::Type policy );
899 * @copydoc Dali::Actor::GetSizeScalePolicy()
901 SizeScalePolicy::Type GetSizeScalePolicy() const;
904 * @copydoc Dali::Actor::SetDimensionDependency()
906 void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
909 * @copydoc Dali::Actor::GetDimensionDependency()
911 Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
914 * @brief Set the size negotiation relayout enabled on this actor
916 * @param[in] relayoutEnabled Boolean to enable or disable relayout
918 void SetRelayoutEnabled( bool relayoutEnabled );
921 * @brief Return if relayout is enabled
923 * @return Return if relayout is enabled or not for this actor
925 bool IsRelayoutEnabled() const;
928 * @brief Mark an actor as having it's layout dirty
930 * @param dirty Whether to mark actor as dirty or not
931 * @param dimension The dimension(s) to mark as dirty
933 void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
936 * @brief Return if any of an actor's dimensions are marked as dirty
938 * @param dimension The dimension(s) to check
939 * @return Return if any of the requested dimensions are dirty
941 bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
944 * @brief Returns if relayout is enabled and the actor is not dirty
946 * @return Return if it is possible to relayout the actor
948 bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
951 * @brief Returns if relayout is enabled and the actor is dirty
953 * @return Return if it is required to relayout the actor
955 bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
958 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
960 * This method is automatically called from OnStageConnection(), OnChildAdd(),
961 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
963 * This method can also be called from a derived class every time it needs a different size.
964 * At the end of event processing, the relayout process starts and
965 * all controls which requested Relayout will have their sizes (re)negotiated.
967 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
968 * only performed once, i.e. there is no need to keep track of this in the calling side.
970 void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
973 * @brief Determine if this actor is dependent on it's parent for relayout
975 * @param dimension The dimension(s) to check for
976 * @return Return if the actor is dependent on it's parent
978 bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
981 * @brief Determine if this actor has another dimension depedent on the specified one
983 * @param dimension The dimension to check for
984 * @param dependentDimension The dimension to check for dependency with
985 * @return Return if the actor is dependent on this dimension
987 bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
990 * Negotiate sizes for a control in all dimensions
992 * @param[in] allocatedSize The size constraint that the control must respect
994 void NegotiateDimensions( const Vector2& allocatedSize );
997 * Negotiate size for a specific dimension
999 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1000 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1001 * LayoutDimensionNegotiated flags being filled in on the actor.
1003 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1004 * calculated and set as well as the LayoutDimensionNegotiated flags.
1006 * @param[in] dimension The dimension to negotiate on
1007 * @param[in] allocatedSize The size constraint that the actor must respect
1009 void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1012 * @brief Calculate the size of a dimension
1014 * @param[in] dimension The dimension to calculate the size for
1015 * @param[in] maximumSize The upper bounds on the size
1016 * @return Return the calculated size for the dimension
1018 float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1021 * @brief Clamp a dimension given the relayout constraints on this actor
1023 * @param[in] size The size to constrain
1024 * @param[in] dimension The dimension the size exists in
1025 * @return Return the clamped size
1027 float ClampDimension( float size, Dimension::Type dimension );
1030 * Negotiate a dimension based on the size of the parent
1032 * @param[in] dimension The dimension to negotiate on
1033 * @return Return the negotiated size
1035 float NegotiateFromParent( Dimension::Type dimension );
1038 * Negotiate a dimension based on the size of the parent. Fitting inside.
1040 * @param[in] dimension The dimension to negotiate on
1041 * @return Return the negotiated size
1043 float NegotiateFromParentFit( Dimension::Type dimension );
1046 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1048 * @param[in] dimension The dimension to negotiate on
1049 * @return Return the negotiated size
1051 float NegotiateFromParentFlood( Dimension::Type dimension );
1054 * @brief Negotiate a dimension based on the size of the children
1056 * @param[in] dimension The dimension to negotiate on
1057 * @return Return the negotiated size
1059 float NegotiateFromChildren( Dimension::Type dimension );
1062 * Set the negotiated dimension value for the given dimension(s)
1064 * @param negotiatedDimension The value to set
1065 * @param dimension The dimension(s) to set the value for
1067 void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1070 * Return the value of negotiated dimension for the given dimension
1072 * @param dimension The dimension to retrieve
1073 * @return Return the value of the negotiated dimension
1075 float GetNegotiatedDimension( Dimension::Type dimension ) const;
1078 * @brief Set the padding for a dimension
1080 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1081 * @param[in] dimension The dimension to set
1083 void SetPadding( const Vector2& padding, Dimension::Type dimension );
1086 * Return the value of padding for the given dimension
1088 * @param dimension The dimension to retrieve
1089 * @return Return the value of padding for the dimension
1091 Vector2 GetPadding( Dimension::Type dimension ) const;
1094 * Return the actor size for a given dimension
1096 * @param[in] dimension The dimension to retrieve the size for
1097 * @return Return the size for the given dimension
1099 float GetSize( Dimension::Type dimension ) const;
1102 * Return the natural size of the actor for a given dimension
1104 * @param[in] dimension The dimension to retrieve the size for
1105 * @return Return the natural size for the given dimension
1107 float GetNaturalSize( Dimension::Type dimension ) const;
1110 * @brief Return the amount of size allocated for relayout
1112 * May include padding
1114 * @param[in] dimension The dimension to retrieve
1115 * @return Return the size
1117 float GetRelayoutSize( Dimension::Type dimension ) const;
1120 * @brief If the size has been negotiated return that else return normal size
1122 * @param[in] dimension The dimension to retrieve
1123 * @return Return the size
1125 float GetLatestSize( Dimension::Type dimension ) const;
1128 * Apply the negotiated size to the actor
1130 * @param[in] container The container to fill with actors that require further relayout
1132 void SetNegotiatedSize( RelayoutContainer& container );
1135 * @brief Flag the actor as having it's layout dimension negotiated.
1137 * @param[in] negotiated The status of the flag to set.
1138 * @param[in] dimension The dimension to set the flag for
1140 void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1143 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1145 * @param[in] dimension The dimension to determine the value of the flag for
1146 * @return Return if the layout dimension is negotiated or not.
1148 bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1151 * @brief provides the Actor implementation of GetHeightForWidth
1152 * @param width to use.
1153 * @return the height based on the width.
1155 float GetHeightForWidthBase( float width );
1158 * @brief provides the Actor implementation of GetWidthForHeight
1159 * @param height to use.
1160 * @return the width based on the height.
1162 float GetWidthForHeightBase( float height );
1165 * @brief Calculate the size for a child
1167 * @param[in] child The child actor to calculate the size for
1168 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1169 * @return Return the calculated size for the given dimension
1171 float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1174 * @brief Set the preferred size for size negotiation
1176 * @param[in] size The preferred size to set
1178 void SetPreferredSize( const Vector2& size );
1181 * @brief Return the preferred size used for size negotiation
1183 * @return Return the preferred size
1185 Vector2 GetPreferredSize() const;
1188 * @copydoc Dali::Actor::SetMinimumSize
1190 void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1193 * @copydoc Dali::Actor::GetMinimumSize
1195 float GetMinimumSize( Dimension::Type dimension ) const;
1198 * @copydoc Dali::Actor::SetMaximumSize
1200 void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1203 * @copydoc Dali::Actor::GetMaximumSize
1205 float GetMaximumSize( Dimension::Type dimension ) const;
1208 * @copydoc Dali::Actor::AddRenderer()
1210 unsigned int AddRenderer( Renderer& renderer );
1213 * @copydoc Dali::Actor::GetRendererCount()
1215 unsigned int GetRendererCount() const;
1218 * @copydoc Dali::Actor::GetRendererAt()
1220 RendererPtr GetRendererAt( unsigned int index );
1223 * @copydoc Dali::Actor::RemoveRenderer()
1225 void RemoveRenderer( Renderer& renderer );
1228 * @copydoc Dali::Actor::RemoveRenderer()
1230 void RemoveRenderer( unsigned int index );
1235 * Converts screen coordinates into the actor's coordinate system.
1236 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1237 * @param[out] localX On return, the X-coordinate relative to the actor.
1238 * @param[out] localY On return, the Y-coordinate relative to the actor.
1239 * @param[in] screenX The screen X-coordinate.
1240 * @param[in] screenY The screen Y-coordinate.
1241 * @return True if the conversion succeeded.
1243 bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const;
1246 * Converts screen coordinates into the actor's coordinate system.
1247 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1248 * @param[in] renderTask The render-task used to display the actor.
1249 * @param[out] localX On return, the X-coordinate relative to the actor.
1250 * @param[out] localY On return, the Y-coordinate relative to the actor.
1251 * @param[in] screenX The screen X-coordinate.
1252 * @param[in] screenY The screen Y-coordinate.
1253 * @return True if the conversion succeeded.
1255 bool ScreenToLocal( const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1258 * Converts from the actor's coordinate system to screen coordinates.
1259 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1260 * @param[in] viewMatrix The view-matrix
1261 * @param[in] projectionMatrix The projection-matrix
1262 * @param[in] viewport The view-port
1263 * @param[out] localX On return, the X-coordinate relative to the actor.
1264 * @param[out] localY On return, the Y-coordinate relative to the actor.
1265 * @param[in] screenX The screen X-coordinate.
1266 * @param[in] screenY The screen Y-coordinate.
1267 * @return True if the conversion succeeded.
1269 bool ScreenToLocal( const Matrix& viewMatrix,
1270 const Matrix& projectionMatrix,
1271 const Viewport& viewport,
1275 float screenY ) const;
1278 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1279 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1280 * @param[in] rayOrigin The ray origin in the world's reference system.
1281 * @param[in] rayDir The ray director vector in the world's reference system.
1282 * @return True if the ray intersects the actor's bounding sphere.
1284 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1287 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1288 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1289 * @param[in] rayOrigin The ray origin in the world's reference system.
1290 * @param[in] rayDir The ray director vector in the world's reference system.
1291 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1292 * @param[out] distance The distance from the hit point to the camera.
1293 * @return True if the ray intersects the actor's geometry.
1295 bool RayActorTest( const Vector4& rayOrigin,
1296 const Vector4& rayDir,
1297 Vector2& hitPointLocal,
1298 float& distance ) const;
1301 * Sets whether the actor should receive a notification when touch or hover motion events leave
1302 * the boundary of the actor.
1304 * @note By default, this is set to false as most actors do not require this.
1305 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1307 * @param[in] required Should be set to true if a Leave event is required
1309 void SetLeaveRequired( bool required );
1312 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1313 * the boundary of the actor.
1314 * @return true if a Leave event is required, false otherwise.
1316 bool GetLeaveRequired() const;
1319 * @copydoc Dali::Actor::SetKeyboardFocusable()
1321 void SetKeyboardFocusable( bool focusable );
1324 * @copydoc Dali::Actor::IsKeyboardFocusable()
1326 bool IsKeyboardFocusable() const;
1329 * Query whether the application or derived actor type requires touch events.
1330 * @return True if touch events are required.
1332 bool GetTouchRequired() const;
1335 * Query whether the application or derived actor type requires hover events.
1336 * @return True if hover events are required.
1338 bool GetHoverRequired() const;
1341 * Query whether the application or derived actor type requires wheel events.
1342 * @return True if wheel events are required.
1344 bool GetWheelEventRequired() const;
1347 * Query whether the actor is actually hittable. This method checks whether the actor is
1348 * sensitive, has the visibility flag set to true and is not fully transparent.
1349 * @return true, if it can be hit, false otherwise.
1351 bool IsHittable() const;
1356 * Retrieve the gesture data associated with this actor. The first call to this method will
1357 * allocate space for the ActorGestureData so this should only be called if an actor really does
1359 * @return Reference to the ActorGestureData for this actor.
1360 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1361 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1363 ActorGestureData& GetGestureData();
1366 * Queries whether the actor requires the gesture type.
1367 * @param[in] type The gesture type.
1369 bool IsGestureRequred( Gesture::Type type ) const;
1374 * Used by the EventProcessor to emit touch event signals.
1375 * @param[in] event The touch event (Old API).
1376 * @param[in] touch The touch data.
1377 * @return True if the event was consumed.
1379 bool EmitTouchEventSignal( const TouchEvent& event, const Dali::TouchData& touch );
1382 * Used by the EventProcessor to emit hover event signals.
1383 * @param[in] event The hover event.
1384 * @return True if the event was consumed.
1386 bool EmitHoverEventSignal( const HoverEvent& event );
1389 * Used by the EventProcessor to emit wheel event signals.
1390 * @param[in] event The wheel event.
1391 * @return True if the event was consumed.
1393 bool EmitWheelEventSignal( const WheelEvent& event );
1396 * @brief Emits the visibility change signal for this actor and all its children.
1397 * @param[in] visible Whether the actor has become visible or not.
1398 * @param[in] type Whether the actor's visible property has changed or a parent's.
1400 void EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityChange::Type type );
1403 * @copydoc Dali::Actor::TouchedSignal()
1405 Dali::Actor::TouchSignalType& TouchedSignal();
1408 * @copydoc Dali::Actor::TouchEventSignal()
1410 Dali::Actor::TouchDataSignalType& TouchSignal();
1413 * @copydoc Dali::Actor::HoveredSignal()
1415 Dali::Actor::HoverSignalType& HoveredSignal();
1418 * @copydoc Dali::Actor::WheelEventSignal()
1420 Dali::Actor::WheelEventSignalType& WheelEventSignal();
1423 * @copydoc Dali::Actor::OnStageSignal()
1425 Dali::Actor::OnStageSignalType& OnStageSignal();
1428 * @copydoc Dali::Actor::OffStageSignal()
1430 Dali::Actor::OffStageSignalType& OffStageSignal();
1433 * @copydoc Dali::Actor::OnRelayoutSignal()
1435 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1438 * @copydoc DevelActor::VisibilityChangedSignal
1440 DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal();
1443 * Connects a callback function with the object's signals.
1444 * @param[in] object The object providing the signal.
1445 * @param[in] tracker Used to disconnect the signal.
1446 * @param[in] signalName The signal to connect to.
1447 * @param[in] functor A newly allocated FunctorDelegate.
1448 * @return True if the signal was connected.
1449 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1451 static bool DoConnectSignal( BaseObject* object,
1452 ConnectionTrackerInterface* tracker,
1453 const std::string& signalName,
1454 FunctorDelegate* functor );
1457 * Performs actions as requested using the action name.
1458 * @param[in] object The object on which to perform the action.
1459 * @param[in] actionName The action to perform.
1460 * @param[in] attributes The attributes with which to perfrom this action.
1461 * @return true if the action was done.
1463 static bool DoAction( BaseObject* object,
1464 const std::string& actionName,
1465 const Property::Map& attributes );
1471 * This should only be called by Animation, when the actors SIZE property is animated.
1473 * @param[in] animation The animation that resized the actor
1474 * @param[in] targetSize The new target size of the actor
1476 void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1479 * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT or SIZE_DEPTH property is animated.
1481 * @param[in] animation The animation that resized the actor
1482 * @param[in] targetSize The new target size of the actor
1483 * @param[in] property The index of the property being animated
1485 void NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property );
1488 * For use in derived classes.
1489 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1491 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1496 * This should only be called by Animation, when the actors POSITION property is animated.
1498 * @param[in] animation The animation that repositioned the actor
1499 * @param[in] targetPosition The new target position of the actor
1501 void NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition );
1504 * This should only be called by Animation, when the actors POSITION_X or POSITION_Y or POSITION_Z property is animated.
1506 * @param[in] animation The animation that repositioned the actor
1507 * @param[in] targetPosition The new target position of the actor
1508 * @param[in] property The index of the property being animated
1510 void NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property );
1516 BASIC, LAYER, ROOT_LAYER
1520 * Protected Constructor. See Actor::New().
1521 * The second-phase construction Initialize() member should be called immediately after this.
1522 * @param[in] derivedType The derived type of actor (if any).
1524 Actor( DerivedType derivedType );
1527 * Second-phase constructor. Must be called immediately after creating a new Actor;
1529 void Initialize( void );
1532 * A reference counted object may only be deleted by calling Unreference()
1537 * Called on a child during Add() when the parent actor is connected to the Stage.
1538 * @param[in] parentDepth The depth of the parent in the hierarchy.
1540 void ConnectToStage( unsigned int parentDepth );
1543 * Helper for ConnectToStage, to recursively connect a tree of actors.
1544 * This is atomic i.e. not interrupted by user callbacks.
1545 * @param[in] depth The depth in the hierarchy of the actor
1546 * @param[out] connectionList On return, the list of connected actors which require notification.
1548 void RecursiveConnectToStage( ActorContainer& connectionList, unsigned int depth );
1551 * Connect the Node associated with this Actor to the scene-graph.
1553 void ConnectToSceneGraph();
1556 * Helper for ConnectToStage, to notify a connected actor through the public API.
1558 void NotifyStageConnection();
1561 * Called on a child during Remove() when the actor was previously on the Stage.
1563 void DisconnectFromStage();
1566 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1567 * This is atomic i.e. not interrupted by user callbacks.
1568 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1570 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1573 * Disconnect the Node associated with this Actor from the scene-graph.
1575 void DisconnectFromSceneGraph();
1578 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1580 void NotifyStageDisconnection();
1583 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1584 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1586 bool IsNodeConnected() const;
1590 * Trigger a rebuild of the actor depth tree from this root
1591 * If a Layer3D is encountered, then this doesn't descend any further.
1592 * The mSortedDepth of each actor is set appropriately.
1594 void RebuildDepthTree();
1599 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1600 * For all actors that share a sibling order, they also share a depth tree, for
1601 * optimal render performance.
1602 * @param[in] nodeMemoryPool The memory pool used to allocate depth nodes
1603 * @param[in,out] depthTreeNode The depth tree node to which to add this actor's children
1604 * @return The count of actors in this depth tree
1606 int BuildDepthTree( DepthNodeMemoryPool& nodeMemoryPool, ActorDepthTreeNode* depthTreeNode );
1610 // Default property extensions from Object
1613 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1615 virtual unsigned int GetDefaultPropertyCount() const;
1618 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1620 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1623 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1625 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1628 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1630 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1633 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1635 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1638 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1640 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1643 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1645 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1648 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1650 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1653 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1655 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1658 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1660 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1663 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1665 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1668 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1670 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
1673 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1675 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1678 * @copydoc Dali::Internal::Object::GetSceneObject()
1680 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1683 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1685 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1688 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1690 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1693 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1695 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1698 * @copydoc Dali::DevelActor::Raise()
1703 * @copydoc Dali::DevelActor::Lower()
1708 * @copydoc Dali::DevelActor::RaiseToTop()
1713 * @copydoc Dali::DevelActor::LowerToBottom()
1715 void LowerToBottom();
1718 * @copydoc Dali::DevelActor::RaiseAbove()
1720 void RaiseAbove( Internal::Actor& target );
1723 * @copydoc Dali::DevelActor::LowerBelow()
1725 void LowerBelow( Internal::Actor& target );
1733 Actor( const Actor& );
1736 Actor& operator=( const Actor& rhs );
1739 * Set the actors parent.
1740 * @param[in] parent The new parent.
1742 void SetParent( Actor* parent );
1745 * Helper to create a Node for this Actor.
1746 * To be overriden in derived classes.
1747 * @return A newly allocated node.
1749 virtual SceneGraph::Node* CreateNode() const;
1752 * For use in derived classes, called after Initialize()
1754 virtual void OnInitialize()
1759 * For use in internal derived classes.
1760 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1761 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1763 virtual void OnStageConnectionInternal()
1768 * For use in internal derived classes.
1769 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1770 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1772 virtual void OnStageDisconnectionInternal()
1777 * For use in external (CustomActor) derived classes.
1778 * This is called after the atomic ConnectToStage() traversal has been completed.
1780 virtual void OnStageConnectionExternal( int depth )
1785 * For use in external (CustomActor) derived classes.
1786 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1788 virtual void OnStageDisconnectionExternal()
1793 * For use in derived classes; this is called after Add() has added a child.
1794 * @param[in] child The child that was added.
1796 virtual void OnChildAdd( Actor& child )
1801 * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1802 * @param[in] child The child that was removed.
1804 virtual void OnChildRemove( Actor& child )
1809 * For use in derived classes.
1810 * This is called after SizeSet() has been called.
1812 virtual void OnSizeSet( const Vector3& targetSize )
1817 * For use in derived classes.
1818 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1819 * @param[in] event The touch event.
1820 * @return True if the event should be consumed.
1822 virtual bool OnTouchEvent( const TouchEvent& event )
1828 * For use in derived classes.
1829 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1830 * @param[in] event The hover event.
1831 * @return True if the event should be consumed.
1833 virtual bool OnHoverEvent( const HoverEvent& event )
1839 * For use in derived classes.
1840 * This is only called if the wheel signal was not consumed.
1841 * @param[in] event The wheel event.
1842 * @return True if the event should be consumed.
1844 virtual bool OnWheelEvent( const WheelEvent& event )
1850 * @brief Retrieves the cached event side value of a default property.
1851 * @param[in] index The index of the property
1852 * @param[out] value Is set with the cached value of the property if found.
1853 * @return True if value set, false otherwise.
1855 bool GetCachedPropertyValue( Property::Index index, Property::Value& value ) const;
1858 * @brief Retrieves the current value of a default property from the scene-graph.
1859 * @param[in] index The index of the property
1860 * @param[out] value Is set with the current scene-graph value of the property
1861 * @return True if value set, false otherwise.
1863 bool GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const;
1866 * @brief Ensure the relayout data is allocated
1868 void EnsureRelayoutData();
1871 * @brief Apply the size set policy to the input size
1873 * @param[in] size The size to apply the policy to
1874 * @return Return the adjusted size
1876 Vector2 ApplySizeSetPolicy( const Vector2 size );
1879 * Retrieve the parent object of an Actor.
1880 * @return The parent object, or NULL if the Actor does not have a parent.
1882 virtual Object* GetParentObject() const;
1886 * @param[in] order The sibling order this Actor should be
1888 void SetSiblingOrder( unsigned int order);
1891 * @brief Re-orders the sibling order when any actor raised to the max level
1892 * @param[in] siblings the container of sibling actors
1894 void DefragmentSiblingIndexes( ActorContainer& siblings );
1897 * @brief Shifts all siblings levels from the target level up by 1 to make space for a newly insert sibling
1898 * at an exclusive level.
1900 * @note Used with Raise and Lower API
1902 * @param[in] siblings the actor container of the siblings
1903 * @param[in] targetLevelToShiftFrom the sibling level to start shifting from
1905 bool ShiftSiblingsLevels( ActorContainer& siblings, int targetLevelToShiftFrom );
1909 * @brief Get the current position of the actor in screen coordinates.
1911 * @return Returns the screen position of actor
1913 const Vector2 GetCurrentScreenPosition() const;
1917 Actor* mParent; ///< Each actor (except the root) can have one parent
1918 ActorContainer* mChildren; ///< Container of referenced actors, lazily initialized
1919 RendererContainer* mRenderers; ///< Renderer container
1921 const SceneGraph::Node* mNode; ///< Not owned
1922 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1923 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1925 struct RelayoutData;
1926 RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1928 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1931 Dali::Actor::TouchSignalType mTouchedSignal;
1932 Dali::Actor::TouchDataSignalType mTouchSignal;
1933 Dali::Actor::HoverSignalType mHoveredSignal;
1934 Dali::Actor::WheelEventSignalType mWheelEventSignal;
1935 Dali::Actor::OnStageSignalType mOnStageSignal;
1936 Dali::Actor::OffStageSignalType mOffStageSignal;
1937 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1938 DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal;
1940 Quaternion mTargetOrientation; ///< Event-side storage for orientation
1941 Vector4 mTargetColor; ///< Event-side storage for color
1942 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1943 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
1944 Vector3 mTargetScale; ///< Event-side storage for scale
1946 std::string mName; ///< Name of the actor
1947 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1949 uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
1950 uint16_t mDepth; ///< The depth in the hierarchy of the actor. Only 4096 levels of depth are supported
1951 uint16_t mSiblingOrder; ///< The sibling order of the actor
1953 const bool mIsRoot : 1; ///< Flag to identify the root actor
1954 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1955 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1956 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1957 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1958 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1959 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1960 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1961 bool mDerivedRequiresWheelEvent : 1; ///< Whether the derived actor type requires wheel event signals
1962 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1963 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
1964 bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited.
1965 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1966 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1967 bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not.
1968 bool mVisible : 1; ///< Cached: Whether the actor is visible or not.
1969 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1970 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1971 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1972 ClippingMode::Type mClippingMode : 2; ///< Cached: Determines which clipping mode (if any) to use.
1976 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1977 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1981 * Helper class to create sorted depth index
1983 class ActorDepthTreeNode
1986 ActorDepthTreeNode()
1987 : mParentNode(NULL),
1988 mNextSiblingNode(NULL),
1989 mFirstChildNode(NULL),
1994 ActorDepthTreeNode( Actor* actor, uint16_t siblingOrder )
1995 : mParentNode(NULL),
1996 mNextSiblingNode(NULL),
1997 mFirstChildNode(NULL),
1998 mSiblingOrder( siblingOrder )
2000 mActors.push_back( actor );
2003 ~ActorDepthTreeNode()
2005 if( mFirstChildNode )
2007 delete mFirstChildNode;
2008 mFirstChildNode = NULL;
2010 if( mNextSiblingNode )
2012 delete mNextSiblingNode;
2013 mNextSiblingNode = NULL;
2018 uint16_t GetSiblingOrder()
2020 return mSiblingOrder;
2023 void AddActor( Actor* actor )
2025 mActors.push_back( actor );
2029 std::vector<Actor*> mActors; // Array of actors with the same sibling order and same ancestor sibling orders
2030 ActorDepthTreeNode* mParentNode;
2031 ActorDepthTreeNode* mNextSiblingNode;
2032 ActorDepthTreeNode* mFirstChildNode;
2033 uint16_t mSiblingOrder;
2036 ActorDepthTreeNode( ActorDepthTreeNode& );
2037 ActorDepthTreeNode& operator=(const ActorDepthTreeNode& );
2041 } // namespace Internal
2043 // Helpers for public-api forwarding methods
2045 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
2047 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2049 BaseObject& handle = actor.GetBaseObject();
2051 return static_cast< Internal::Actor& >( handle );
2054 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
2056 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2058 const BaseObject& handle = actor.GetBaseObject();
2060 return static_cast< const Internal::Actor& >( handle );
2065 #endif // DALI_INTERNAL_ACTOR_H