1 #ifndef __DALI_INTERNAL_ACTOR_H__
2 #define __DALI_INTERNAL_ACTOR_H__
5 * Copyright (c) 2014 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/common/vector-wrapper.h>
26 #include <dali/public-api/object/ref-object.h>
27 #include <dali/public-api/actors/actor.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/internal/event/common/object-impl.h>
32 #include <dali/public-api/size-negotiation/relayout-container.h>
33 #include <dali/internal/event/common/stage-def.h>
34 #include <dali/internal/event/actors/actor-declarations.h>
35 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
36 #include <dali/internal/update/nodes/node-declarations.h>
38 #ifdef DYNAMICS_SUPPORT
39 #include <dali/internal/event/dynamics/dynamics-declarations.h>
48 struct MouseWheelEvent;
54 class ActorGestureData;
59 typedef IntrusivePtr< Actor > ActorPtr;
60 typedef Dali::ActorContainer ActorContainer; // Store handles to return via public-api
61 typedef ActorContainer::iterator ActorIter;
62 typedef ActorContainer::const_iterator ActorConstIter;
65 * Actor is the primary object which Dali applications interact with.
66 * UI controls can be built by combining multiple actors.
67 * Multi-Touch events are received through signals emitted by the actor tree.
69 * An Actor is a proxy for a Node in the scene graph.
70 * When an Actor is added to the Stage, it creates a node and attaches it to the scene graph.
71 * The scene-graph can be updated in a separate thread, so the attachment is done using an asynchronous message.
72 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
74 class Actor : public Object
79 * @brief Struct to hold an actor and a dimension
81 struct ActorDimensionPair
86 * @param[in] newActor The actor to assign
87 * @param[in] newDimension The dimension to assign
89 ActorDimensionPair( Actor* newActor, Dimension newDimension )
91 dimension( newDimension )
96 * @brief Equality operator
98 * @param[in] lhs The left hand side argument
99 * @param[in] rhs The right hand side argument
101 bool operator== ( const ActorDimensionPair& rhs )
103 return ( actor == rhs.actor ) && ( dimension == rhs.dimension );
106 Actor* actor; ///< The actor to hold
107 Dimension dimension; ///< The dimension to hold
110 typedef std::vector< ActorDimensionPair > ActorDimensionStack;
115 * Create a new actor.
116 * @return A smart-pointer to the newly allocated Actor.
118 static ActorPtr New();
121 * Retrieve the name of the actor.
124 const std::string& GetName() const;
127 * Set the name of the actor.
128 * @param[in] name The new name.
130 void SetName( const std::string& name );
133 * @copydoc Dali::Actor::GetId
135 unsigned int GetId() const;
140 * Attach an object to an actor.
141 * @pre The actor does not already have an attachment.
142 * @param[in] attachment The object to attach.
144 void Attach( ActorAttachment& attachment );
147 * Retreive the object attached to an actor.
148 * @return The attachment.
150 ActorAttachmentPtr GetAttachment();
155 * Query whether an actor is the root actor, which is owned by the Stage.
156 * @return True if the actor is a root actor.
164 * Query whether the actor is connected to the Stage.
166 bool OnStage() const;
169 * Query whether the actor is a RenderableActor derived type.
170 * @return True if the actor is renderable.
172 bool IsRenderable() const
174 // inlined as this is called a lot in hit testing
175 return mIsRenderable;
179 * Query whether the actor is of class Dali::Layer
180 * @return True if the actor is a layer.
184 // inlined as this is called a lot in hit testing
189 * Gets the layer in which the actor is present
190 * @return The layer, which will be uninitialized if the actor is off-stage.
192 Dali::Layer GetLayer();
195 * Adds a child Actor to this Actor.
196 * @pre The child actor is not the same as the parent actor.
197 * @pre The child actor does not already have a parent.
198 * @param [in] child The child.
199 * @post The child will be referenced by its parent.
201 void Add( Actor& child );
204 * Inserts a child Actor to this Actor's child list
205 * @pre The child actor is not the same as the parent actor.
206 * @pre The child actor does not already have a parent.
207 * @param [in] index in childlist to insert child at
208 * @param [in] child The child.
209 * @post The child will be referenced by its parent.
211 void Insert( unsigned int index, Actor& child );
214 * Removes a child Actor from this Actor.
215 * @param [in] child The child.
216 * @post The child will be unreferenced.
218 void Remove( Actor& child );
221 * @copydoc Dali::Actor::Unparent
226 * Retrieve the number of children held by the actor.
227 * @return The number of children
229 unsigned int GetChildCount() const;
232 * @copydoc Dali::Actor::GetChildAt
234 Dali::Actor GetChildAt( unsigned int index ) const;
237 * Retrieve the Actor's children.
238 * @return A copy of the container of children.
240 ActorContainer GetChildren();
243 * Retrieve the Actor's children.
244 * @return A const reference to the container of children.
246 const ActorContainer& GetChildren() const;
249 * Retrieve a reference to Actor's children.
250 * @note Not for public use.
251 * @return A reference to the container of children.
253 ActorContainer& GetChildrenInternal()
259 * @copydoc Dali::Actor::FindChildByName
261 ActorPtr FindChildByName( const std::string& actorName );
264 * @copydoc Dali::Actor::FindChildById
266 ActorPtr FindChildById( const unsigned int id );
269 * Retrieve the parent of an Actor.
270 * @return The parent actor, or NULL if the Actor does not have a parent.
272 Actor* GetParent() const
278 * Sets the size of an actor.
279 * ActorAttachments attached to the actor, can be scaled to fit within this area.
280 * This does not interfere with the actors scale factor.
281 * @param [in] width The new width.
282 * @param [in] height The new height.
284 void SetSize( float width, float height );
287 * Sets the size of an actor.
288 * ActorAttachments attached to the actor, can be scaled to fit within this area.
289 * This does not interfere with the actors scale factor.
290 * @param [in] width The size of the actor along the x-axis.
291 * @param [in] height The size of the actor along the y-axis.
292 * @param [in] depth The size of the actor along the z-axis.
294 void SetSize( float width, float height, float depth );
297 * Sets the size of an actor.
298 * ActorAttachments attached to the actor, can be scaled to fit within this area.
299 * This does not interfere with the actors scale factor.
300 * @param [in] size The new size.
302 void SetSize( const Vector2& size );
305 * Sets the size of an actor.
306 * ActorAttachments attached to the actor, can be scaled to fit within this area.
307 * This does not interfere with the actors scale factor.
308 * @param [in] size The new size.
310 void SetSize( const Vector3& size );
313 * Set the width component of the Actor's size.
314 * @param [in] width The new width component.
316 void SetWidth( float width );
319 * Set the height component of the Actor's size.
320 * @param [in] height The new height component.
322 void SetHeight( float height );
325 * Set the depth component of the Actor's size.
326 * @param [in] depth The new depth component.
328 void SetDepth( float depth );
331 * Retrieve the Actor's size from event side.
332 * This size will be the size set or if animating then the target size.
333 * @return The Actor's size.
335 const Vector3& GetTargetSize() const;
338 * Retrieve the Actor's size from update side.
339 * This size will be the size set or animating but will be a frame behind.
340 * @return The Actor's size.
342 const Vector3& GetCurrentSize() const;
345 * Return the natural size of the actor
347 * @return The actor's natural size
349 virtual Vector3 GetNaturalSize() const;
352 * Set the origin of an actor, within its parent's area.
353 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
354 * and (1.0, 1.0, 0.5) is the bottom-right corner.
355 * The default parent-origin is top-left (0.0, 0.0, 0.5).
356 * An actor position is the distance between this origin, and the actors anchor-point.
357 * @param [in] origin The new parent-origin.
359 void SetParentOrigin( const Vector3& origin );
362 * Set the x component of the parent-origin
363 * @param [in] x The new x value.
365 void SetParentOriginX( float x );
368 * Set the y component of the parent-origin
369 * @param [in] y The new y value.
371 void SetParentOriginY( float y );
374 * Set the z component of the parent-origin
375 * @param [in] z The new z value.
377 void SetParentOriginZ( float z );
380 * Retrieve the parent-origin of an actor.
381 * @return The parent-origin.
383 const Vector3& GetCurrentParentOrigin() const;
386 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
387 * (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.
388 * The default anchor point is top-left (0.0, 0.0, 0.5).
389 * An actor position is the distance between its parent-origin, and this anchor-point.
390 * An actor's rotation is centered around its anchor-point.
391 * @param [in] anchorPoint The new anchor-point.
393 void SetAnchorPoint( const Vector3& anchorPoint );
396 * Set the x component of the anchor-point.
397 * @param [in] x The new x value.
399 void SetAnchorPointX( float x );
402 * Set the y component of the anchor-point.
403 * @param [in] y The new y value.
405 void SetAnchorPointY( float y );
408 * Set the z component of the anchor-point.
409 * @param [in] z The new z value.
411 void SetAnchorPointZ( float z );
414 * Retrieve the anchor-point of an actor.
415 * @return The anchor-point.
417 const Vector3& GetCurrentAnchorPoint() const;
420 * Sets the position of the Actor.
421 * The coordinates are relative to the Actor's parent.
422 * The Actor's z position will be set to 0.0f.
423 * @param [in] x The new x position
424 * @param [in] y The new y position
426 void SetPosition( float x, float y );
429 * Sets the position of the Actor.
430 * The coordinates are relative to the Actor's parent.
431 * @param [in] x The new x position
432 * @param [in] y The new y position
433 * @param [in] z The new z position
435 void SetPosition( float x, float y, float z );
438 * Sets the position of the Actor.
439 * The coordinates are relative to the Actor's parent.
440 * @param [in] position The new position.
442 void SetPosition( const Vector3& position );
445 * Set the position of an actor along the X-axis.
446 * @param [in] x The new x position
448 void SetX( float x );
451 * Set the position of an actor along the Y-axis.
452 * @param [in] y The new y position.
454 void SetY( float y );
457 * Set the position of an actor along the Z-axis.
458 * @param [in] z The new z position
460 void SetZ( float z );
463 * Translate an actor relative to its existing position.
464 * @param[in] distance The actor will move by this distance.
466 void TranslateBy( const Vector3& distance );
469 * Retrieve the position of the Actor.
470 * The coordinates are relative to the Actor's parent.
471 * @return the Actor's position.
473 const Vector3& GetCurrentPosition() const;
476 * @copydoc Dali::Actor::GetCurrentWorldPosition()
478 const Vector3& GetCurrentWorldPosition() const;
481 * @copydoc Dali::Actor::SetPositionInheritanceMode()
483 void SetPositionInheritanceMode( PositionInheritanceMode mode );
486 * @copydoc Dali::Actor::GetPositionInheritanceMode()
488 PositionInheritanceMode GetPositionInheritanceMode() const;
491 * Sets the orientation of the Actor.
492 * @param [in] angleRadians The new orientation angle in radians.
493 * @param [in] axis The new axis of orientation.
495 void SetOrientation( const Radian& angleRadians, const Vector3& axis );
498 * Sets the orientation of the Actor.
499 * @param [in] orientation The new orientation.
501 void SetOrientation( const Quaternion& orientation );
504 * Rotate an actor around its existing rotation axis.
505 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
506 * @param[in] axis The axis of the rotation to combine with the existing rotation.
508 void RotateBy( const Radian& angleRadians, const Vector3& axis );
511 * Apply a relative rotation to an actor.
512 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
514 void RotateBy( const Quaternion& relativeRotation );
517 * Retreive the Actor's orientation.
518 * @return the orientation.
520 const Quaternion& GetCurrentOrientation() const;
523 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
524 * Switching this off means that using SetOrientation() sets the actor's world orientation.
525 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
527 void SetInheritOrientation( bool inherit );
530 * Returns whether the actor inherit's it's parent's orientation.
531 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
533 bool IsOrientationInherited() const;
536 * Sets the factor of the parents size used for the child actor.
537 * Note: Only used if ResizePolicy is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT.
538 * @param[in] factor The vector to multiply the parents size by to get the childs size.
540 void SetSizeModeFactor( const Vector3& factor );
543 * Gets the factor of the parents size used for the child actor.
544 * Note: Only used if ResizePolicy is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT.
545 * @return The vector being used to multiply the parents size by to get the childs size.
547 const Vector3& GetSizeModeFactor() const;
550 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
552 const Quaternion& GetCurrentWorldOrientation() const;
555 * Sets a scale factor applied to an actor.
556 * @param [in] scale The scale factor applied on all axes.
558 void SetScale( float scale );
561 * Sets a scale factor applied to an actor.
562 * @param [in] scaleX The scale factor applied along the x-axis.
563 * @param [in] scaleY The scale factor applied along the y-axis.
564 * @param [in] scaleZ The scale factor applied along the z-axis.
566 void SetScale( float scaleX, float scaleY, float scaleZ );
569 * Sets a scale factor applied to an actor.
570 * @param [in] scale A vector representing the scale factor for each axis.
572 void SetScale( const Vector3& scale );
575 * Set the x component of the scale factor.
576 * @param [in] x The new x value.
578 void SetScaleX( float x );
581 * Set the y component of the scale factor.
582 * @param [in] y The new y value.
584 void SetScaleY( float y );
587 * Set the z component of the scale factor.
588 * @param [in] z The new z value.
590 void SetScaleZ( float z );
593 * Apply a relative scale to an actor.
594 * @param[in] relativeScale The scale to combine with the actors existing scale.
596 void ScaleBy( const Vector3& relativeScale );
599 * Retrieve the scale factor applied to an actor.
600 * @return A vector representing the scale factor for each axis.
602 const Vector3& GetCurrentScale() const;
605 * @copydoc Dali::Actor::GetCurrentWorldScale()
607 const Vector3& GetCurrentWorldScale() const;
610 * @copydoc Dali::Actor::SetInheritScale()
612 void SetInheritScale( bool inherit );
615 * @copydoc Dali::Actor::IsScaleInherited()
617 bool IsScaleInherited() const;
620 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
622 Matrix GetCurrentWorldMatrix() const;
627 * Sets the visibility flag of an actor.
628 * @param [in] visible The new visibility flag.
630 void SetVisible( bool visible );
633 * Retrieve the visibility flag of an actor.
634 * @return The visibility flag.
636 bool IsVisible() const;
639 * Sets the opacity of an actor.
640 * @param [in] opacity The new opacity.
642 void SetOpacity( float opacity );
645 * Retrieve the actor's opacity.
646 * @return The actor's opacity.
648 float GetCurrentOpacity() 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::SetOverlay
698 void SetOverlay( bool enable );
701 * @copydoc Dali::Actor::IsOverlay
703 bool IsOverlay() const;
706 * Sets whether an actor transmits geometry scaling to it's children.
707 * The default value is for it not to transmit scaling.
708 * @param[in] transmitGeometryScaling True to transmit scaling.
710 void SetTransmitGeometryScaling( bool transmitGeometryScaling );
713 * Get the TransmitGeometryScaling property for this actor.
714 * @return True if geometry scaling is applied to the inherited scale.
716 bool GetTransmitGeometryScaling() const;
719 * Sets the initial volume of the actor. Used for scaling the
720 * actor appropriately as the actor is sized when transmitGeometryScaling
723 * @param[in] volume the volume of the model and it's children
725 void SetInitialVolume( const Vector3& volume );
728 * Sets the actor's color. The final color of actor depends on its color mode.
729 * This final color is applied to the drawable elements of an actor.
730 * @param [in] color The new color.
732 void SetColor( const Vector4& color );
735 * Set the red component of the color.
736 * @param [in] red The new red component.
738 void SetColorRed( float red );
741 * Set the green component of the color.
742 * @param [in] green The new green component.
744 void SetColorGreen( float green );
747 * Set the blue component of the scale factor.
748 * @param [in] blue The new blue value.
750 void SetColorBlue( float blue );
753 * Retrieve the actor's color.
756 const Vector4& GetCurrentColor() const;
759 * Sets the actor's color mode.
760 * Color mode specifies whether Actor uses its own color or inherits its parent color
761 * @param [in] colorMode to use.
763 void SetColorMode( ColorMode colorMode );
766 * Returns the actor's color mode.
767 * @return currently used colorMode.
769 ColorMode GetColorMode() const;
772 * @copydoc Dali::Actor::GetCurrentWorldColor()
774 const Vector4& GetCurrentWorldColor() const;
778 // Size negotiation virtual functions
781 * @brief Called after the size negotiation has been finished for this control.
783 * The control is expected to assign this given size to itself/its children.
785 * Should be overridden by derived classes if they need to layout
786 * actors differently after certain operations like add or remove
787 * actors, resize or after changing specific properties.
789 * Note! As this function is called from inside the size negotiation algorithm, you cannot
790 * call RequestRelayout (the call would just be ignored)
792 * @param[in] size The allocated size.
793 * @param[in,out] container The control should add actors to this container that it is not able
794 * to allocate a size for.
796 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
801 * @brief Notification for deriving classes when the resize policy is set
803 * @param[in] policy The policy being set
804 * @param[in] dimension The dimension the policy is being set for
806 virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) {}
809 * @brief Virtual method to notify deriving classes that relayout dependencies have been
810 * met and the size for this object is about to be calculated for the given dimension
812 * @param dimension The dimension that is about to be calculated
814 virtual void OnCalculateRelayoutSize( Dimension dimension );
817 * @brief Virtual method to notify deriving classes that the size for a dimension
818 * has just been negotiated
820 * @param[in] size The new size for the given dimension
821 * @param[in] dimension The dimension that was just negotiated
823 virtual void OnLayoutNegotiated( float size, Dimension dimension );
826 * @brief Determine if this actor is dependent on it's children for relayout
828 * @param dimension The dimension(s) to check for
829 * @return Return if the actor is dependent on it's children
831 virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS );
834 * @brief Determine if this actor is dependent on it's children for relayout.
836 * Called from deriving classes
838 * @param dimension The dimension(s) to check for
839 * @return Return if the actor is dependent on it's children
841 virtual bool RelayoutDependentOnChildrenBase( Dimension dimension = ALL_DIMENSIONS );
844 * @brief Calculate the size for a child
846 * @param[in] child The child actor to calculate the size for
847 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
848 * @return Return the calculated size for the given dimension
850 virtual float CalculateChildSize( const Dali::Actor& child, Dimension dimension );
853 * @brief This method is called during size negotiation when a height is required for a given width.
855 * Derived classes should override this if they wish to customize the height returned.
857 * @param width to use.
858 * @return the height based on the width.
860 virtual float GetHeightForWidth( float width );
863 * @brief This method is called during size negotiation when a width is required for a given height.
865 * Derived classes should override this if they wish to customize the width returned.
867 * @param height to use.
868 * @return the width based on the width.
870 virtual float GetWidthForHeight( float height );
877 * @brief Called by the RelayoutController to negotiate the size of an actor.
879 * The size allocated by the the algorithm is passed in which the
880 * actor must adhere to. A container is passed in as well which
881 * the actor should populate with actors it has not / or does not
882 * need to handle in its size negotiation.
884 * @param[in] size The allocated size.
885 * @param[in,out] container The container that holds actors that are fed back into the
886 * RelayoutController algorithm.
888 void NegotiateSize( const Vector2& size, RelayoutContainer& container );
891 * @copydoc Dali::Actor::SetResizePolicy()
893 void SetResizePolicy( ResizePolicy policy, Dimension dimension = ALL_DIMENSIONS );
896 * @copydoc Dali::Actor::GetResizePolicy()
898 ResizePolicy GetResizePolicy( Dimension dimension ) const;
901 * @copydoc Dali::Actor::SetSizeScalePolicy()
903 void SetSizeScalePolicy( SizeScalePolicy policy );
906 * @copydoc Dali::Actor::GetSizeScalePolicy()
908 SizeScalePolicy GetSizeScalePolicy() const;
911 * @copydoc Dali::Actor::SetDimensionDependency()
913 void SetDimensionDependency( Dimension dimension, Dimension dependency );
916 * @copydoc Dali::Actor::GetDimensionDependency()
918 Dimension GetDimensionDependency( Dimension dimension ) const;
921 * @copydoc Dali::Actor::SetRelayoutEnabled()
923 void SetRelayoutEnabled( bool relayoutEnabled );
926 * @copydoc Dali::Actor::IsRelayoutEnabled()
928 bool IsRelayoutEnabled() const;
931 * @brief Mark an actor as having it's layout dirty
933 * @param dirty Whether to mark actor as dirty or not
934 * @param dimension The dimension(s) to mark as dirty
936 void SetLayoutDirty( bool dirty, Dimension dimension = ALL_DIMENSIONS );
939 * @brief Return if any of an actor's dimensions are marked as dirty
941 * @param dimension The dimension(s) to check
942 * @return Return if any of the requested dimensions are dirty
944 bool IsLayoutDirty( Dimension dimension = ALL_DIMENSIONS ) const;
947 * @brief Returns if relayout is enabled and the actor is not dirty
949 * @return Return if it is possible to relayout the actor
951 bool RelayoutPossible( Dimension dimension = ALL_DIMENSIONS ) const;
954 * @brief Returns if relayout is enabled and the actor is dirty
956 * @return Return if it is required to relayout the actor
958 bool RelayoutRequired( Dimension dimension = ALL_DIMENSIONS ) const;
961 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
963 * This method is automatically called from OnStageConnection(), OnChildAdd(),
964 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
966 * This method can also be called from a derived class every time it needs a different size.
967 * At the end of event processing, the relayout process starts and
968 * all controls which requested Relayout will have their sizes (re)negotiated.
970 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
971 * only performed once, i.e. there is no need to keep track of this in the calling side.
973 void RelayoutRequest( Dimension dimension = ALL_DIMENSIONS );
976 * @brief Request to relayout of all actors in the sub-tree below the given actor.
978 * This flags the actor and all actors below it for relayout. The actual
979 * relayout is performed at the end of the frame. This means that multiple calls to relayout
980 * will not cause multiple relayouts to occur.
982 void RelayoutRequestTree();
985 * @copydoc Dali::Actor::PropagateRelayoutFlags
987 void PropagateRelayoutFlags();
990 * @brief Determine if this actor is dependent on it's parent for relayout
992 * @param dimension The dimension(s) to check for
993 * @return Return if the actor is dependent on it's parent
995 bool RelayoutDependentOnParent( Dimension dimension = ALL_DIMENSIONS );
998 * @brief Determine if this actor has another dimension depedent on the specified one
1000 * @param dimension The dimension to check for
1001 * @param dependentDimension The dimension to check for dependency with
1002 * @return Return if the actor is dependent on this dimension
1004 bool RelayoutDependentOnDimension( Dimension dimension, Dimension dependentDimension );
1007 * Negotiate sizes for a control in all dimensions
1009 * @param[in] allocatedSize The size constraint that the control must respect
1011 void NegotiateDimensions( const Vector2& allocatedSize );
1014 * Negotiate size for a specific dimension
1016 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1017 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1018 * LayoutDimensionNegotiated flags being filled in on the actor.
1020 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1021 * calculated and set as well as the LayoutDimensionNegotiated flags.
1023 * @param[in] dimension The dimension to negotiate on
1024 * @param[in] allocatedSize The size constraint that the actor must respect
1026 void NegotiateDimension( Dimension dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1029 * @brief Calculate the size of a dimension
1031 * @param[in] dimension The dimension to calculate the size for
1032 * @param[in] maximumSize The upper bounds on the size
1033 * @return Return the calculated size for the dimension
1035 float CalculateSize( Dimension dimension, const Vector2& maximumSize );
1038 * @brief Constain a dimension given the relayout constraints on this actor
1040 * @param[in] size The size to constrain
1041 * @param[in] dimension The dimension the size exists in
1042 * @return Return the constrained size
1044 float ConstrainDimension( float size, Dimension dimension );
1047 * Negotiate a dimension based on the size of the parent
1049 * @param[in] dimension The dimension to negotiate on
1050 * @return Return the negotiated size
1052 float NegotiateFromParent( Dimension dimension );
1055 * Negotiate a dimension based on the size of the parent. Fitting inside.
1057 * @param[in] dimension The dimension to negotiate on
1058 * @return Return the negotiated size
1060 float NegotiateFromParentFit( Dimension dimension );
1063 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1065 * @param[in] dimension The dimension to negotiate on
1066 * @return Return the negotiated size
1068 float NegotiateFromParentFlood( Dimension dimension );
1071 * @brief Negotiate a dimension based on the size of the children
1073 * @param[in] dimension The dimension to negotiate on
1074 * @return Return the negotiated size
1076 float NegotiateFromChildren( Dimension dimension );
1079 * Set the negotiated dimension value for the given dimension(s)
1081 * @param negotiatedDimension The value to set
1082 * @param dimension The dimension(s) to set the value for
1084 void SetNegotiatedDimension( float negotiatedDimension, Dimension dimension = ALL_DIMENSIONS );
1087 * Return the value of negotiated dimension for the given dimension
1089 * @param dimension The dimension to retrieve
1090 * @return Return the value of the negotiated dimension
1092 float GetNegotiatedDimension( Dimension dimension ) const;
1095 * @brief Set the padding for a dimension
1097 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1098 * @param[in] dimension The dimension to set
1100 void SetPadding( const Vector2& padding, Dimension dimension );
1103 * Return the value of padding for the given dimension
1105 * @param dimension The dimension to retrieve
1106 * @return Return the value of padding for the dimension
1108 Vector2 GetPadding( Dimension dimension ) const;
1111 * Return the actor size for a given dimension
1113 * @param[in] dimension The dimension to retrieve the size for
1114 * @return Return the size for the given dimension
1116 float GetSize( Dimension dimension ) const;
1119 * Return the natural size of the actor for a given dimension
1121 * @param[in] dimension The dimension to retrieve the size for
1122 * @return Return the natural size for the given dimension
1124 float GetNaturalSize( Dimension dimension ) const;
1127 * @brief Return the amount of size allocated for relayout
1129 * May include padding
1131 * @param[in] dimension The dimension to retrieve
1132 * @return Return the size
1134 float GetRelayoutSize( Dimension dimension ) const;
1137 * @brief If the size has been negotiated return that else return normal size
1139 * @param[in] dimension The dimension to retrieve
1140 * @return Return the size
1142 float GetLatestSize( Dimension dimension ) const;
1145 * Apply the negotiated size to the actor
1147 * @param[in] container The container to fill with actors that require further relayout
1149 void SetNegotiatedSize( RelayoutContainer& container );
1152 * @brief Flag the actor as having it's layout dimension negotiated.
1154 * @param[in] negotiated The status of the flag to set.
1155 * @param[in] dimension The dimension to set the flag for
1157 void SetLayoutNegotiated( bool negotiated, Dimension dimension = ALL_DIMENSIONS );
1160 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1162 * @param[in] dimension The dimension to determine the value of the flag for
1163 * @return Return if the layout dimension is negotiated or not.
1165 bool IsLayoutNegotiated( Dimension dimension = ALL_DIMENSIONS ) const;
1168 * @brief Calculate the size for a child
1170 * @param[in] child The child actor to calculate the size for
1171 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1172 * @return Return the calculated size for the given dimension
1174 float CalculateChildSizeBase( const Dali::Actor& child, Dimension dimension );
1177 * @brief Set the preferred size for size negotiation
1179 * @param[in] size The preferred size to set
1181 void SetPreferredSize( const Vector2& size );
1184 * @brief Return the preferred size used for size negotiation
1186 * @return Return the preferred size
1188 Vector2 GetPreferredSize() const;
1191 * @copydoc Dali::Actor::SetMinimumSize
1193 void SetMinimumSize( float size, Dimension dimension = ALL_DIMENSIONS );
1196 * @copydoc Dali::Actor::GetMinimumSize
1198 float GetMinimumSize( Dimension dimension ) const;
1201 * @copydoc Dali::Actor::SetMaximumSize
1203 void SetMaximumSize( float size, Dimension dimension = ALL_DIMENSIONS );
1206 * @copydoc Dali::Actor::GetMaximumSize
1208 float GetMaximumSize( Dimension dimension ) const;
1210 #ifdef DYNAMICS_SUPPORT
1214 /// @copydoc Dali::Actor::DisableDynamics
1215 void DisableDynamics();
1217 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
1218 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
1220 /// @copydoc Dali::Actor::GetDynamicsBody
1221 DynamicsBodyPtr GetDynamicsBody() const;
1223 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
1224 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
1226 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
1227 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
1229 /// @copydoc Dali::Actor::GetNumberOfJoints
1230 const int GetNumberOfJoints() const;
1232 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
1233 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
1235 /// @copydoc Dali::Actor::GetDynamicsJoint
1236 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
1238 /// @copydoc Dali::Actor::RemoveDynamicsJoint
1239 void RemoveDynamicsJoint( DynamicsJointPtr joint );
1242 * Hold a reference to a DynamicsJoint
1243 * @param[in] joint The joint
1245 void ReferenceJoint( DynamicsJointPtr joint );
1248 * Release a reference to a DynamicsJoint
1249 * @param[in] joint The joint
1251 void ReleaseJoint( DynamicsJointPtr joint );
1254 * Set this actor to be the root actor in the dynamics simulation
1255 * All children of the actor are added/removed from the simulation.
1256 * @param[in] flag When true sets this actor to be the simulation world root actor and
1257 * if OnStage() all dynamics enabled child actors are added to the simulation,
1258 * when false stops this actor being the simulation root and if OnStage() all
1259 * dynamics enabled child actors are removed from the simulation.
1261 void SetDynamicsRoot(bool flag);
1265 * Check if this actor is the root actor in the dynamics simulation
1266 * @return true if this is the dynamics root actor.
1268 bool IsDynamicsRoot() const;
1271 * Add actor to the dynamics simulation
1272 * Invoked when the actor is staged, or it's parent becomes the simulation root
1274 void ConnectDynamics();
1277 * Remove actor from the dynamics simulation
1278 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
1280 void DisconnectDynamics();
1283 * An actor in a DynamicsJoint relationship has been staged
1284 * @param[in] actor The actor passed into AddDynamicsJoint()
1286 void AttachedActorOnStage( Dali::Actor actor );
1289 * An actor in a DynamicsJoint relationship has been unstaged
1290 * @param[in] actor The actor passed into AddDynamicsJoint()
1292 void AttachedActorOffStage( Dali::Actor actor );
1294 #endif // DYNAMICS_SUPPORT
1298 * Converts screen coordinates into the actor's coordinate system.
1299 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1300 * @param[out] localX On return, the X-coordinate relative to the actor.
1301 * @param[out] localY On return, the Y-coordinate relative to the actor.
1302 * @param[in] screenX The screen X-coordinate.
1303 * @param[in] screenY The screen Y-coordinate.
1304 * @return True if the conversion succeeded.
1306 bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const;
1309 * Converts screen coordinates into the actor's coordinate system.
1310 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1311 * @param[in] renderTask The render-task used to display the actor.
1312 * @param[out] localX On return, the X-coordinate relative to the actor.
1313 * @param[out] localY On return, the Y-coordinate relative to the actor.
1314 * @param[in] screenX The screen X-coordinate.
1315 * @param[in] screenY The screen Y-coordinate.
1316 * @return True if the conversion succeeded.
1318 bool ScreenToLocal( RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1321 * Converts from the actor's coordinate system to screen coordinates.
1322 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1323 * @param[in] viewMatrix The view-matrix
1324 * @param[in] projectionMatrix The projection-matrix
1325 * @param[in] viewport The view-port
1326 * @param[out] localX On return, the X-coordinate relative to the actor.
1327 * @param[out] localY On return, the Y-coordinate relative to the actor.
1328 * @param[in] screenX The screen X-coordinate.
1329 * @param[in] screenY The screen Y-coordinate.
1330 * @return True if the conversion succeeded.
1332 bool ScreenToLocal( const Matrix& viewMatrix,
1333 const Matrix& projectionMatrix,
1334 const Viewport& viewport,
1338 float screenY ) const;
1341 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1342 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1343 * @param[in] rayOrigin The ray origin in the world's reference system.
1344 * @param[in] rayDir The ray director vector in the world's reference system.
1345 * @return True if the ray intersects the actor's bounding sphere.
1347 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1350 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1351 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1352 * @param[in] rayOrigin The ray origin in the world's reference system.
1353 * @param[in] rayDir The ray director vector in the world's reference system.
1354 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1355 * @param[out] distance The distance from the hit point to the camera.
1356 * @return True if the ray intersects the actor's geometry.
1358 bool RayActorTest( const Vector4& rayOrigin,
1359 const Vector4& rayDir,
1360 Vector4& hitPointLocal,
1361 float& distance ) const;
1364 * Sets whether the actor should receive a notification when touch or hover motion events leave
1365 * the boundary of the actor.
1367 * @note By default, this is set to false as most actors do not require this.
1368 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1370 * @param[in] required Should be set to true if a Leave event is required
1372 void SetLeaveRequired( bool required );
1375 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1376 * the boundary of the actor.
1377 * @return true if a Leave event is required, false otherwise.
1379 bool GetLeaveRequired() const;
1382 * @copydoc Dali::Actor::SetKeyboardFocusable()
1384 void SetKeyboardFocusable( bool focusable );
1387 * @copydoc Dali::Actor::IsKeyboardFocusable()
1389 bool IsKeyboardFocusable() const;
1392 * Query whether the application or derived actor type requires touch events.
1393 * @return True if touch events are required.
1395 bool GetTouchRequired() const;
1398 * Query whether the application or derived actor type requires hover events.
1399 * @return True if hover events are required.
1401 bool GetHoverRequired() const;
1404 * Query whether the application or derived actor type requires mouse wheel events.
1405 * @return True if mouse wheel events are required.
1407 bool GetMouseWheelEventRequired() const;
1410 * Query whether the actor is actually hittable. This method checks whether the actor is
1411 * sensitive, has the visibility flag set to true and is not fully transparent.
1412 * @return true, if it can be hit, false otherwise.
1414 bool IsHittable() const;
1419 * Retrieve the gesture data associated with this actor. The first call to this method will
1420 * allocate space for the ActorGestureData so this should only be called if an actor really does
1422 * @return Reference to the ActorGestureData for this actor.
1423 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1424 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1426 ActorGestureData& GetGestureData();
1429 * Queries whether the actor requires the gesture type.
1430 * @param[in] type The gesture type.
1432 bool IsGestureRequred( Gesture::Type type ) const;
1437 * Used by the EventProcessor to emit touch event signals.
1438 * @param[in] event The touch event.
1439 * @return True if the event was consumed.
1441 bool EmitTouchEventSignal( const TouchEvent& event );
1444 * Used by the EventProcessor to emit hover event signals.
1445 * @param[in] event The hover event.
1446 * @return True if the event was consumed.
1448 bool EmitHoverEventSignal( const HoverEvent& event );
1451 * Used by the EventProcessor to emit mouse wheel event signals.
1452 * @param[in] event The mouse wheel event.
1453 * @return True if the event was consumed.
1455 bool EmitMouseWheelEventSignal( const MouseWheelEvent& event );
1458 * @copydoc Dali::Actor::TouchedSignal()
1460 Dali::Actor::TouchSignalType& TouchedSignal();
1463 * @copydoc Dali::Actor::HoveredSignal()
1465 Dali::Actor::HoverSignalType& HoveredSignal();
1468 * @copydoc Dali::Actor::MouseWheelEventSignal()
1470 Dali::Actor::MouseWheelEventSignalType& MouseWheelEventSignal();
1473 * @copydoc Dali::Actor::OnStageSignal()
1475 Dali::Actor::OnStageSignalType& OnStageSignal();
1478 * @copydoc Dali::Actor::OffStageSignal()
1480 Dali::Actor::OffStageSignalType& OffStageSignal();
1483 * @copydoc Dali::Actor::OnRelayoutSignal()
1485 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1488 * Connects a callback function with the object's signals.
1489 * @param[in] object The object providing the signal.
1490 * @param[in] tracker Used to disconnect the signal.
1491 * @param[in] signalName The signal to connect to.
1492 * @param[in] functor A newly allocated FunctorDelegate.
1493 * @return True if the signal was connected.
1494 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1496 static bool DoConnectSignal( BaseObject* object,
1497 ConnectionTrackerInterface* tracker,
1498 const std::string& signalName,
1499 FunctorDelegate* functor );
1502 * Performs actions as requested using the action name.
1503 * @param[in] object The object on which to perform the action.
1504 * @param[in] actionName The action to perform.
1505 * @param[in] attributes The attributes with which to perfrom this action.
1506 * @return true if the action was done.
1508 static bool DoAction( BaseObject* object,
1509 const std::string& actionName,
1510 const std::vector< Property::Value >& attributes );
1516 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1518 * @param[in] animation The animation that resized the actor
1519 * @param[in] targetSize The new target size of the actor
1521 void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1524 * For use in derived classes.
1525 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1527 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1535 BASIC, RENDERABLE, LAYER, ROOT_LAYER
1539 * Protected Constructor. See Actor::New().
1540 * The second-phase construction Initialize() member should be called immediately after this.
1541 * @param[in] derivedType The derived type of actor (if any).
1543 Actor( DerivedType derivedType );
1546 * Second-phase constructor. Must be called immediately after creating a new Actor;
1548 void Initialize( void );
1551 * A reference counted object may only be deleted by calling Unreference()
1556 * Called on a child during Add() when the parent actor is connected to the Stage.
1557 * @param[in] stage The stage.
1558 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1560 void ConnectToStage( int index = -1 );
1563 * Helper for ConnectToStage, to recursively connect a tree of actors.
1564 * This is atomic i.e. not interrupted by user callbacks.
1565 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1566 * @param[out] connectionList On return, the list of connected actors which require notification.
1568 void RecursiveConnectToStage( ActorContainer& connectionList, int index = -1 );
1571 * Connect the Node associated with this Actor to the scene-graph.
1572 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1574 void ConnectToSceneGraph( int index = -1 );
1577 * Helper for ConnectToStage, to notify a connected actor through the public API.
1579 void NotifyStageConnection();
1582 * Called on a child during Remove() when the actor was previously on the Stage.
1584 void DisconnectFromStage();
1587 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1588 * This is atomic i.e. not interrupted by user callbacks.
1589 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1591 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1594 * Disconnect the Node associated with this Actor from the scene-graph.
1596 void DisconnectFromSceneGraph();
1599 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1601 void NotifyStageDisconnection();
1604 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1605 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1607 bool IsNodeConnected() const;
1610 * Calculate the size of the z dimension for a 2D size
1612 * @param[in] size The 2D size (X, Y) to calculate Z from
1614 * @return Return the Z dimension for this size
1616 float CalculateSizeZ( const Vector2& size ) const;
1619 // Default property extensions from Object
1622 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1624 virtual unsigned int GetDefaultPropertyCount() const;
1627 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1629 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1632 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1634 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1637 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1639 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1642 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1644 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1647 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1649 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1652 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1654 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1657 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1659 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1662 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1664 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1667 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1669 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1672 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1674 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1677 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1679 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1682 * @copydoc Dali::Internal::Object::GetSceneObject()
1684 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1687 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1689 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1692 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1694 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1697 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1699 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1707 Actor( const Actor& );
1710 Actor& operator=( const Actor& rhs );
1713 * Set the actors parent.
1714 * @param[in] parent The new parent.
1715 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1717 void SetParent( Actor* parent, int index = -1 );
1720 * Helper to create a Node for this Actor.
1721 * To be overriden in derived classes.
1722 * @return A newly allocated node.
1724 virtual SceneGraph::Node* CreateNode() const;
1727 * For use in derived classes, called after Initialize()
1729 virtual void OnInitialize()
1734 * For use in internal derived classes.
1735 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1736 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1738 virtual void OnStageConnectionInternal()
1743 * For use in internal derived classes.
1744 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1745 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1747 virtual void OnStageDisconnectionInternal()
1752 * For use in external (CustomActor) derived classes.
1753 * This is called after the atomic ConnectToStage() traversal has been completed.
1755 virtual void OnStageConnectionExternal()
1760 * For use in external (CustomActor) derived classes.
1761 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1763 virtual void OnStageDisconnectionExternal()
1768 * For use in derived classes; this is called after Add() has added a child.
1769 * @param[in] child The child that was added.
1771 virtual void OnChildAdd( Actor& child )
1776 * For use in derived classes; this is called after Remove() has removed a child.
1777 * @param[in] child The child that was removed.
1779 virtual void OnChildRemove( Actor& child )
1784 * For use in derived classes.
1785 * This is called after SizeSet() has been called.
1787 virtual void OnSizeSet( const Vector3& targetSize )
1792 * For use in derived classes.
1793 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1794 * @param[in] event The touch event.
1795 * @return True if the event should be consumed.
1797 virtual bool OnTouchEvent( const TouchEvent& event )
1803 * For use in derived classes.
1804 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1805 * @param[in] event The hover event.
1806 * @return True if the event should be consumed.
1808 virtual bool OnHoverEvent( const HoverEvent& event )
1814 * For use in derived classes.
1815 * This is only called if the mouse wheel signal was not consumed.
1816 * @param[in] event The mouse event.
1817 * @return True if the event should be consumed.
1819 virtual bool OnMouseWheelEvent( const MouseWheelEvent& event )
1825 * @brief Ensure the relayout data is allocated
1827 void EnsureRelayoutData() const;
1830 * @brief Apply the size set policy to the input size
1832 * @param[in] size The size to apply the policy to
1833 * @return Return the adjusted size
1835 Vector2 ApplySizeSetPolicy( const Vector2 size );
1839 StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
1840 Actor* mParent; ///< Each actor (except the root) can have one parent
1841 ActorContainer* mChildren; ///< Container of referenced actors
1842 const SceneGraph::Node* mNode; ///< Not owned
1843 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1844 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1846 struct RelayoutData;
1847 mutable RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1849 #ifdef DYNAMICS_SUPPORT
1850 DynamicsData* mDynamicsData; ///< optional physics data
1853 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1855 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1858 Dali::Actor::TouchSignalType mTouchedSignal;
1859 Dali::Actor::HoverSignalType mHoveredSignal;
1860 Dali::Actor::MouseWheelEventSignalType mMouseWheelEventSignal;
1861 Dali::Actor::OnStageSignalType mOnStageSignal;
1862 Dali::Actor::OffStageSignalType mOffStageSignal;
1863 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1865 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1867 std::string mName; ///< Name of the actor
1868 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1870 const bool mIsRoot : 1; ///< Flag to identify the root actor
1871 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1872 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1873 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1874 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1875 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1876 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1877 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1878 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1879 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1880 bool mDerivedRequiresMouseWheelEvent : 1; ///< Whether the derived actor type requires mouse wheel event signals
1881 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1882 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1883 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1884 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1885 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1886 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1890 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1891 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1895 } // namespace Internal
1897 // Helpers for public-api forwarding methods
1899 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
1901 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1903 BaseObject& handle = actor.GetBaseObject();
1905 return static_cast< Internal::Actor& >( handle );
1908 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
1910 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1912 const BaseObject& handle = actor.GetBaseObject();
1914 return static_cast< const Internal::Actor& >( handle );
1919 #endif // __DALI_INTERNAL_ACTOR_H__