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 * @brief Set whether size negotiation should use the assigned size of the actor
885 * during relayout for the given dimension(s)
887 * @param[in] use Whether the assigned size of the actor should be used
888 * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions
890 void SetUseAssignedSize( bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
893 * @brief Returns whether size negotiation should use the assigned size of the actor
894 * during relayout for a single dimension
896 * @param[in] dimension The dimension to get
897 * @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
899 bool GetUseAssignedSize( Dimension::Type dimension ) const;
902 * @copydoc Dali::Actor::SetResizePolicy()
904 void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
907 * @copydoc Dali::Actor::GetResizePolicy()
909 ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
912 * @copydoc Dali::Actor::SetSizeScalePolicy()
914 void SetSizeScalePolicy( SizeScalePolicy::Type policy );
917 * @copydoc Dali::Actor::GetSizeScalePolicy()
919 SizeScalePolicy::Type GetSizeScalePolicy() const;
922 * @copydoc Dali::Actor::SetDimensionDependency()
924 void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
927 * @copydoc Dali::Actor::GetDimensionDependency()
929 Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
932 * @brief Set the size negotiation relayout enabled on this actor
934 * @param[in] relayoutEnabled Boolean to enable or disable relayout
936 void SetRelayoutEnabled( bool relayoutEnabled );
939 * @brief Return if relayout is enabled
941 * @return Return if relayout is enabled or not for this actor
943 bool IsRelayoutEnabled() const;
946 * @brief Mark an actor as having it's layout dirty
948 * @param dirty Whether to mark actor as dirty or not
949 * @param dimension The dimension(s) to mark as dirty
951 void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
954 * @brief Return if any of an actor's dimensions are marked as dirty
956 * @param dimension The dimension(s) to check
957 * @return Return if any of the requested dimensions are dirty
959 bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
962 * @brief Returns if relayout is enabled and the actor is not dirty
964 * @return Return if it is possible to relayout the actor
966 bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
969 * @brief Returns if relayout is enabled and the actor is dirty
971 * @return Return if it is required to relayout the actor
973 bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
976 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
978 * This method is automatically called from OnStageConnection(), OnChildAdd(),
979 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
981 * This method can also be called from a derived class every time it needs a different size.
982 * At the end of event processing, the relayout process starts and
983 * all controls which requested Relayout will have their sizes (re)negotiated.
985 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
986 * only performed once, i.e. there is no need to keep track of this in the calling side.
988 void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
991 * @brief Determine if this actor is dependent on it's parent for relayout
993 * @param dimension The dimension(s) to check for
994 * @return Return if the actor is dependent on it's parent
996 bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
999 * @brief Determine if this actor has another dimension depedent on the specified one
1001 * @param dimension The dimension to check for
1002 * @param dependentDimension The dimension to check for dependency with
1003 * @return Return if the actor is dependent on this dimension
1005 bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
1008 * Negotiate sizes for a control in all dimensions
1010 * @param[in] allocatedSize The size constraint that the control must respect
1012 void NegotiateDimensions( const Vector2& allocatedSize );
1015 * Negotiate size for a specific dimension
1017 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1018 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1019 * LayoutDimensionNegotiated flags being filled in on the actor.
1021 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1022 * calculated and set as well as the LayoutDimensionNegotiated flags.
1024 * @param[in] dimension The dimension to negotiate on
1025 * @param[in] allocatedSize The size constraint that the actor must respect
1027 void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1030 * @brief Calculate the size of a dimension
1032 * @param[in] dimension The dimension to calculate the size for
1033 * @param[in] maximumSize The upper bounds on the size
1034 * @return Return the calculated size for the dimension
1036 float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1039 * @brief Clamp a dimension given the relayout constraints on this actor
1041 * @param[in] size The size to constrain
1042 * @param[in] dimension The dimension the size exists in
1043 * @return Return the clamped size
1045 float ClampDimension( float size, Dimension::Type dimension );
1048 * Negotiate a dimension based on the size of the parent
1050 * @param[in] dimension The dimension to negotiate on
1051 * @return Return the negotiated size
1053 float NegotiateFromParent( Dimension::Type dimension );
1056 * Negotiate a dimension based on the size of the parent. Fitting inside.
1058 * @param[in] dimension The dimension to negotiate on
1059 * @return Return the negotiated size
1061 float NegotiateFromParentFit( Dimension::Type dimension );
1064 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1066 * @param[in] dimension The dimension to negotiate on
1067 * @return Return the negotiated size
1069 float NegotiateFromParentFlood( Dimension::Type dimension );
1072 * @brief Negotiate a dimension based on the size of the children
1074 * @param[in] dimension The dimension to negotiate on
1075 * @return Return the negotiated size
1077 float NegotiateFromChildren( Dimension::Type dimension );
1080 * Set the negotiated dimension value for the given dimension(s)
1082 * @param negotiatedDimension The value to set
1083 * @param dimension The dimension(s) to set the value for
1085 void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1088 * Return the value of negotiated dimension for the given dimension
1090 * @param dimension The dimension to retrieve
1091 * @return Return the value of the negotiated dimension
1093 float GetNegotiatedDimension( Dimension::Type dimension ) const;
1096 * @brief Set the padding for a dimension
1098 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1099 * @param[in] dimension The dimension to set
1101 void SetPadding( const Vector2& padding, Dimension::Type dimension );
1104 * Return the value of padding for the given dimension
1106 * @param dimension The dimension to retrieve
1107 * @return Return the value of padding for the dimension
1109 Vector2 GetPadding( Dimension::Type dimension ) const;
1112 * Return the actor size for a given dimension
1114 * @param[in] dimension The dimension to retrieve the size for
1115 * @return Return the size for the given dimension
1117 float GetSize( Dimension::Type dimension ) const;
1120 * Return the natural size of the actor for a given dimension
1122 * @param[in] dimension The dimension to retrieve the size for
1123 * @return Return the natural size for the given dimension
1125 float GetNaturalSize( Dimension::Type dimension ) const;
1128 * @brief Return the amount of size allocated for relayout
1130 * May include padding
1132 * @param[in] dimension The dimension to retrieve
1133 * @return Return the size
1135 float GetRelayoutSize( Dimension::Type dimension ) const;
1138 * @brief If the size has been negotiated return that else return normal size
1140 * @param[in] dimension The dimension to retrieve
1141 * @return Return the size
1143 float GetLatestSize( Dimension::Type dimension ) const;
1146 * Apply the negotiated size to the actor
1148 * @param[in] container The container to fill with actors that require further relayout
1150 void SetNegotiatedSize( RelayoutContainer& container );
1153 * @brief Flag the actor as having it's layout dimension negotiated.
1155 * @param[in] negotiated The status of the flag to set.
1156 * @param[in] dimension The dimension to set the flag for
1158 void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1161 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1163 * @param[in] dimension The dimension to determine the value of the flag for
1164 * @return Return if the layout dimension is negotiated or not.
1166 bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1169 * @brief provides the Actor implementation of GetHeightForWidth
1170 * @param width to use.
1171 * @return the height based on the width.
1173 float GetHeightForWidthBase( float width );
1176 * @brief provides the Actor implementation of GetWidthForHeight
1177 * @param height to use.
1178 * @return the width based on the height.
1180 float GetWidthForHeightBase( float height );
1183 * @brief Calculate the size for a child
1185 * @param[in] child The child actor to calculate the size for
1186 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1187 * @return Return the calculated size for the given dimension
1189 float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1192 * @brief Set the preferred size for size negotiation
1194 * @param[in] size The preferred size to set
1196 void SetPreferredSize( const Vector2& size );
1199 * @brief Return the preferred size used for size negotiation
1201 * @return Return the preferred size
1203 Vector2 GetPreferredSize() const;
1206 * @copydoc Dali::Actor::SetMinimumSize
1208 void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1211 * @copydoc Dali::Actor::GetMinimumSize
1213 float GetMinimumSize( Dimension::Type dimension ) const;
1216 * @copydoc Dali::Actor::SetMaximumSize
1218 void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1221 * @copydoc Dali::Actor::GetMaximumSize
1223 float GetMaximumSize( Dimension::Type dimension ) const;
1226 * @copydoc Dali::Actor::AddRenderer()
1228 unsigned int AddRenderer( Renderer& renderer );
1231 * @copydoc Dali::Actor::GetRendererCount()
1233 unsigned int GetRendererCount() const;
1236 * @copydoc Dali::Actor::GetRendererAt()
1238 RendererPtr GetRendererAt( unsigned int index );
1241 * @copydoc Dali::Actor::RemoveRenderer()
1243 void RemoveRenderer( Renderer& renderer );
1246 * @copydoc Dali::Actor::RemoveRenderer()
1248 void RemoveRenderer( unsigned int index );
1253 * Converts screen coordinates into the actor's coordinate system.
1254 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
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( float& localX, float& localY, float screenX, float screenY ) const;
1264 * Converts screen coordinates into the actor's coordinate system.
1265 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1266 * @param[in] renderTask The render-task used to display the actor.
1267 * @param[out] localX On return, the X-coordinate relative to the actor.
1268 * @param[out] localY On return, the Y-coordinate relative to the actor.
1269 * @param[in] screenX The screen X-coordinate.
1270 * @param[in] screenY The screen Y-coordinate.
1271 * @return True if the conversion succeeded.
1273 bool ScreenToLocal( const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1276 * Converts from the actor's coordinate system to screen coordinates.
1277 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1278 * @param[in] viewMatrix The view-matrix
1279 * @param[in] projectionMatrix The projection-matrix
1280 * @param[in] viewport The view-port
1281 * @param[out] localX On return, the X-coordinate relative to the actor.
1282 * @param[out] localY On return, the Y-coordinate relative to the actor.
1283 * @param[in] screenX The screen X-coordinate.
1284 * @param[in] screenY The screen Y-coordinate.
1285 * @return True if the conversion succeeded.
1287 bool ScreenToLocal( const Matrix& viewMatrix,
1288 const Matrix& projectionMatrix,
1289 const Viewport& viewport,
1293 float screenY ) const;
1296 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1297 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1298 * @param[in] rayOrigin The ray origin in the world's reference system.
1299 * @param[in] rayDir The ray director vector in the world's reference system.
1300 * @return True if the ray intersects the actor's bounding sphere.
1302 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1305 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1306 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1307 * @param[in] rayOrigin The ray origin in the world's reference system.
1308 * @param[in] rayDir The ray director vector in the world's reference system.
1309 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1310 * @param[out] distance The distance from the hit point to the camera.
1311 * @return True if the ray intersects the actor's geometry.
1313 bool RayActorTest( const Vector4& rayOrigin,
1314 const Vector4& rayDir,
1315 Vector2& hitPointLocal,
1316 float& distance ) const;
1319 * Sets whether the actor should receive a notification when touch or hover motion events leave
1320 * the boundary of the actor.
1322 * @note By default, this is set to false as most actors do not require this.
1323 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1325 * @param[in] required Should be set to true if a Leave event is required
1327 void SetLeaveRequired( bool required );
1330 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1331 * the boundary of the actor.
1332 * @return true if a Leave event is required, false otherwise.
1334 bool GetLeaveRequired() const;
1337 * @copydoc Dali::Actor::SetKeyboardFocusable()
1339 void SetKeyboardFocusable( bool focusable );
1342 * @copydoc Dali::Actor::IsKeyboardFocusable()
1344 bool IsKeyboardFocusable() const;
1347 * Query whether the application or derived actor type requires touch events.
1348 * @return True if touch events are required.
1350 bool GetTouchRequired() const;
1353 * Query whether the application or derived actor type requires hover events.
1354 * @return True if hover events are required.
1356 bool GetHoverRequired() const;
1359 * Query whether the application or derived actor type requires wheel events.
1360 * @return True if wheel events are required.
1362 bool GetWheelEventRequired() const;
1365 * Query whether the actor is actually hittable. This method checks whether the actor is
1366 * sensitive, has the visibility flag set to true and is not fully transparent.
1367 * @return true, if it can be hit, false otherwise.
1369 bool IsHittable() const;
1374 * Retrieve the gesture data associated with this actor. The first call to this method will
1375 * allocate space for the ActorGestureData so this should only be called if an actor really does
1377 * @return Reference to the ActorGestureData for this actor.
1378 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1379 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1381 ActorGestureData& GetGestureData();
1384 * Queries whether the actor requires the gesture type.
1385 * @param[in] type The gesture type.
1387 bool IsGestureRequred( Gesture::Type type ) const;
1392 * Used by the EventProcessor to emit touch event signals.
1393 * @param[in] event The touch event (Old API).
1394 * @param[in] touch The touch data.
1395 * @return True if the event was consumed.
1397 bool EmitTouchEventSignal( const TouchEvent& event, const Dali::TouchData& touch );
1400 * Used by the EventProcessor to emit hover event signals.
1401 * @param[in] event The hover event.
1402 * @return True if the event was consumed.
1404 bool EmitHoverEventSignal( const HoverEvent& event );
1407 * Used by the EventProcessor to emit wheel event signals.
1408 * @param[in] event The wheel event.
1409 * @return True if the event was consumed.
1411 bool EmitWheelEventSignal( const WheelEvent& event );
1414 * @brief Emits the visibility change signal for this actor and all its children.
1415 * @param[in] visible Whether the actor has become visible or not.
1416 * @param[in] type Whether the actor's visible property has changed or a parent's.
1418 void EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityChange::Type type );
1421 * @copydoc Dali::Actor::TouchedSignal()
1423 Dali::Actor::TouchSignalType& TouchedSignal();
1426 * @copydoc Dali::Actor::TouchEventSignal()
1428 Dali::Actor::TouchDataSignalType& TouchSignal();
1431 * @copydoc Dali::Actor::HoveredSignal()
1433 Dali::Actor::HoverSignalType& HoveredSignal();
1436 * @copydoc Dali::Actor::WheelEventSignal()
1438 Dali::Actor::WheelEventSignalType& WheelEventSignal();
1441 * @copydoc Dali::Actor::OnStageSignal()
1443 Dali::Actor::OnStageSignalType& OnStageSignal();
1446 * @copydoc Dali::Actor::OffStageSignal()
1448 Dali::Actor::OffStageSignalType& OffStageSignal();
1451 * @copydoc Dali::Actor::OnRelayoutSignal()
1453 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1456 * @copydoc DevelActor::VisibilityChangedSignal
1458 DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal();
1461 * Connects a callback function with the object's signals.
1462 * @param[in] object The object providing the signal.
1463 * @param[in] tracker Used to disconnect the signal.
1464 * @param[in] signalName The signal to connect to.
1465 * @param[in] functor A newly allocated FunctorDelegate.
1466 * @return True if the signal was connected.
1467 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1469 static bool DoConnectSignal( BaseObject* object,
1470 ConnectionTrackerInterface* tracker,
1471 const std::string& signalName,
1472 FunctorDelegate* functor );
1475 * Performs actions as requested using the action name.
1476 * @param[in] object The object on which to perform the action.
1477 * @param[in] actionName The action to perform.
1478 * @param[in] attributes The attributes with which to perfrom this action.
1479 * @return true if the action was done.
1481 static bool DoAction( BaseObject* object,
1482 const std::string& actionName,
1483 const Property::Map& attributes );
1489 * For use in derived classes.
1490 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1492 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1500 BASIC, LAYER, ROOT_LAYER
1504 * Protected Constructor. See Actor::New().
1505 * The second-phase construction Initialize() member should be called immediately after this.
1506 * @param[in] derivedType The derived type of actor (if any).
1508 Actor( DerivedType derivedType );
1511 * Second-phase constructor. Must be called immediately after creating a new Actor;
1513 void Initialize( void );
1516 * A reference counted object may only be deleted by calling Unreference()
1521 * Called on a child during Add() when the parent actor is connected to the Stage.
1522 * @param[in] parentDepth The depth of the parent in the hierarchy.
1524 void ConnectToStage( unsigned int parentDepth );
1527 * Helper for ConnectToStage, to recursively connect a tree of actors.
1528 * This is atomic i.e. not interrupted by user callbacks.
1529 * @param[in] depth The depth in the hierarchy of the actor
1530 * @param[out] connectionList On return, the list of connected actors which require notification.
1532 void RecursiveConnectToStage( ActorContainer& connectionList, unsigned int depth );
1535 * Connect the Node associated with this Actor to the scene-graph.
1537 void ConnectToSceneGraph();
1540 * Helper for ConnectToStage, to notify a connected actor through the public API.
1542 void NotifyStageConnection();
1545 * Called on a child during Remove() when the actor was previously on the Stage.
1547 void DisconnectFromStage();
1550 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1551 * This is atomic i.e. not interrupted by user callbacks.
1552 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1554 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1557 * Disconnect the Node associated with this Actor from the scene-graph.
1559 void DisconnectFromSceneGraph();
1562 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1564 void NotifyStageDisconnection();
1567 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1568 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1570 bool IsNodeConnected() const;
1574 * Trigger a rebuild of the actor depth tree from this root
1575 * If a Layer3D is encountered, then this doesn't descend any further.
1576 * The mSortedDepth of each actor is set appropriately.
1578 void RebuildDepthTree();
1583 * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1584 * For all actors that share a sibling order, they also share a depth tree, for
1585 * optimal render performance.
1586 * @param[in] nodeMemoryPool The memory pool used to allocate depth nodes
1587 * @param[in,out] depthTreeNode The depth tree node to which to add this actor's children
1588 * @return The count of actors in this depth tree
1590 int BuildDepthTree( DepthNodeMemoryPool& nodeMemoryPool, ActorDepthTreeNode* depthTreeNode );
1594 // Default property extensions from Object
1597 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1599 virtual unsigned int GetDefaultPropertyCount() const;
1602 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1604 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1607 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1609 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1612 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1614 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1617 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1619 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1622 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1624 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1627 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1629 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1632 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1634 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1637 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1639 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1642 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1644 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1647 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1649 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1652 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1654 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
1657 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
1659 virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value );
1662 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1664 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1667 * @copydoc Dali::Internal::Object::GetSceneObject()
1669 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1672 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1674 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1677 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1679 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1682 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1684 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1687 * @copydoc Dali::DevelActor::Raise()
1692 * @copydoc Dali::DevelActor::Lower()
1697 * @copydoc Dali::DevelActor::RaiseToTop()
1702 * @copydoc Dali::DevelActor::LowerToBottom()
1704 void LowerToBottom();
1707 * @copydoc Dali::DevelActor::RaiseAbove()
1709 void RaiseAbove( Internal::Actor& target );
1712 * @copydoc Dali::DevelActor::LowerBelow()
1714 void LowerBelow( Internal::Actor& target );
1731 Actor( const Actor& );
1734 Actor& operator=( const Actor& rhs );
1737 * Set the actors parent.
1738 * @param[in] parent The new parent.
1740 void SetParent( Actor* parent );
1743 * Helper to create a Node for this Actor.
1744 * To be overriden in derived classes.
1745 * @return A newly allocated node.
1747 virtual SceneGraph::Node* CreateNode() const;
1750 * For use in derived classes, called after Initialize()
1752 virtual void OnInitialize()
1757 * For use in internal derived classes.
1758 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1759 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1761 virtual void OnStageConnectionInternal()
1766 * For use in internal derived classes.
1767 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1768 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1770 virtual void OnStageDisconnectionInternal()
1775 * For use in external (CustomActor) derived classes.
1776 * This is called after the atomic ConnectToStage() traversal has been completed.
1778 virtual void OnStageConnectionExternal( int depth )
1783 * For use in external (CustomActor) derived classes.
1784 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1786 virtual void OnStageDisconnectionExternal()
1791 * For use in derived classes; this is called after Add() has added a child.
1792 * @param[in] child The child that was added.
1794 virtual void OnChildAdd( Actor& child )
1799 * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1800 * @param[in] child The child that was removed.
1802 virtual void OnChildRemove( Actor& child )
1807 * For use in derived classes.
1808 * This is called after SizeSet() has been called.
1810 virtual void OnSizeSet( const Vector3& targetSize )
1815 * For use in derived classes.
1816 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1817 * @param[in] event The touch event.
1818 * @return True if the event should be consumed.
1820 virtual bool OnTouchEvent( const TouchEvent& event )
1826 * For use in derived classes.
1827 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1828 * @param[in] event The hover event.
1829 * @return True if the event should be consumed.
1831 virtual bool OnHoverEvent( const HoverEvent& event )
1837 * For use in derived classes.
1838 * This is only called if the wheel signal was not consumed.
1839 * @param[in] event The wheel event.
1840 * @return True if the event should be consumed.
1842 virtual bool OnWheelEvent( const WheelEvent& event )
1848 * @brief Retrieves the cached event side value of a default property.
1849 * @param[in] index The index of the property
1850 * @param[out] value Is set with the cached value of the property if found.
1851 * @return True if value set, false otherwise.
1853 bool GetCachedPropertyValue( Property::Index index, Property::Value& value ) const;
1856 * @brief Retrieves the current value of a default property from the scene-graph.
1857 * @param[in] index The index of the property
1858 * @param[out] value Is set with the current scene-graph value of the property
1859 * @return True if value set, false otherwise.
1861 bool GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const;
1864 * @brief Ensure the relayout data is allocated
1866 void EnsureRelayoutData();
1869 * @brief Apply the size set policy to the input size
1871 * @param[in] size The size to apply the policy to
1872 * @return Return the adjusted size
1874 Vector2 ApplySizeSetPolicy( const Vector2 size );
1877 * Retrieve the parent object of an Actor.
1878 * @return The parent object, or NULL if the Actor does not have a parent.
1880 virtual Object* GetParentObject() const;
1884 * @param[in] order The sibling order this Actor should be
1886 void SetSiblingOrder( unsigned int order);
1889 * @brief Re-orders the sibling order when any actor raised to the max level
1890 * @param[in] siblings the container of sibling actors
1892 void DefragmentSiblingIndexes( ActorContainer& siblings );
1895 * @brief Shifts all siblings levels from the target level up by 1 to make space for a newly insert sibling
1896 * at an exclusive level.
1898 * @note Used with Raise and Lower API
1900 * @param[in] siblings the actor container of the siblings
1901 * @param[in] targetLevelToShiftFrom the sibling level to start shifting from
1903 bool ShiftSiblingsLevels( ActorContainer& siblings, int targetLevelToShiftFrom );
1906 * @brief Get the current position of the actor in screen coordinates.
1908 * @return Returns the screen position of actor
1910 const Vector2 GetCurrentScreenPosition() const;
1913 * Sets the visibility flag of an actor.
1914 * @param[in] visible The new visibility flag.
1915 * @param[in] sendMessage Whether to send a message to the update thread or not.
1917 void SetVisibleInternal( bool visible, SendMessage::Type sendMessage );
1921 Actor* mParent; ///< Each actor (except the root) can have one parent
1922 ActorContainer* mChildren; ///< Container of referenced actors, lazily initialized
1923 RendererContainer* mRenderers; ///< Renderer container
1925 const SceneGraph::Node* mNode; ///< Not owned
1926 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1927 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1929 struct RelayoutData;
1930 RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1932 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1935 Dali::Actor::TouchSignalType mTouchedSignal;
1936 Dali::Actor::TouchDataSignalType mTouchSignal;
1937 Dali::Actor::HoverSignalType mHoveredSignal;
1938 Dali::Actor::WheelEventSignalType mWheelEventSignal;
1939 Dali::Actor::OnStageSignalType mOnStageSignal;
1940 Dali::Actor::OffStageSignalType mOffStageSignal;
1941 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1942 DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal;
1944 Quaternion mTargetOrientation; ///< Event-side storage for orientation
1945 Vector4 mTargetColor; ///< Event-side storage for color
1946 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1947 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
1948 Vector3 mTargetScale; ///< Event-side storage for scale
1950 std::string mName; ///< Name of the actor
1951 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1953 uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
1954 uint16_t mDepth; ///< The depth in the hierarchy of the actor. Only 4096 levels of depth are supported
1955 uint16_t mSiblingOrder; ///< The sibling order of the actor
1957 const bool mIsRoot : 1; ///< Flag to identify the root actor
1958 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1959 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1960 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1961 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1962 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1963 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1964 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1965 bool mDerivedRequiresWheelEvent : 1; ///< Whether the derived actor type requires wheel event signals
1966 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1967 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
1968 bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited.
1969 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1970 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1971 bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not.
1972 bool mVisible : 1; ///< Cached: Whether the actor is visible or not.
1973 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1974 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1975 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1976 ClippingMode::Type mClippingMode : 2; ///< Cached: Determines which clipping mode (if any) to use.
1980 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1981 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1985 * Helper class to create sorted depth index
1987 class ActorDepthTreeNode
1990 ActorDepthTreeNode()
1991 : mParentNode(NULL),
1992 mNextSiblingNode(NULL),
1993 mFirstChildNode(NULL),
1998 ActorDepthTreeNode( Actor* actor, uint16_t siblingOrder )
1999 : mParentNode(NULL),
2000 mNextSiblingNode(NULL),
2001 mFirstChildNode(NULL),
2002 mSiblingOrder( siblingOrder )
2004 mActors.push_back( actor );
2007 ~ActorDepthTreeNode()
2009 if( mFirstChildNode )
2011 delete mFirstChildNode;
2012 mFirstChildNode = NULL;
2014 if( mNextSiblingNode )
2016 delete mNextSiblingNode;
2017 mNextSiblingNode = NULL;
2022 uint16_t GetSiblingOrder()
2024 return mSiblingOrder;
2027 void AddActor( Actor* actor )
2029 mActors.push_back( actor );
2033 std::vector<Actor*> mActors; // Array of actors with the same sibling order and same ancestor sibling orders
2034 ActorDepthTreeNode* mParentNode;
2035 ActorDepthTreeNode* mNextSiblingNode;
2036 ActorDepthTreeNode* mFirstChildNode;
2037 uint16_t mSiblingOrder;
2040 ActorDepthTreeNode( ActorDepthTreeNode& );
2041 ActorDepthTreeNode& operator=(const ActorDepthTreeNode& );
2045 } // namespace Internal
2047 // Helpers for public-api forwarding methods
2049 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
2051 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2053 BaseObject& handle = actor.GetBaseObject();
2055 return static_cast< Internal::Actor& >( handle );
2058 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
2060 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2062 const BaseObject& handle = actor.GetBaseObject();
2064 return static_cast< const Internal::Actor& >( handle );
2069 #endif // DALI_INTERNAL_ACTOR_H