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::Type 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::Type 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 update size for an actor.
307 * @param[in] size The size to set.
309 void SetSizeInternal( const Vector2& size );
312 * Sets the size of an actor.
313 * ActorAttachments attached to the actor, can be scaled to fit within this area.
314 * This does not interfere with the actors scale factor.
315 * @param [in] size The new size.
317 void SetSize( const Vector3& size );
320 * Sets the update size for an actor.
322 * @param[in] size The size to set.
324 void SetSizeInternal( const Vector3& size );
327 * Set the width component of the Actor's size.
328 * @param [in] width The new width component.
330 void SetWidth( float width );
333 * Set the height component of the Actor's size.
334 * @param [in] height The new height component.
336 void SetHeight( float height );
339 * Set the depth component of the Actor's size.
340 * @param [in] depth The new depth component.
342 void SetDepth( float depth );
345 * Retrieve the Actor's size from event side.
346 * This size will be the size set or if animating then the target size.
347 * @return The Actor's size.
349 const Vector3& GetTargetSize() const;
352 * Retrieve the Actor's size from update side.
353 * This size will be the size set or animating but will be a frame behind.
354 * @return The Actor's size.
356 const Vector3& GetCurrentSize() const;
359 * Return the natural size of the actor
361 * @return The actor's natural size
363 virtual Vector3 GetNaturalSize() const;
366 * Set the origin of an actor, within its parent's area.
367 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
368 * and (1.0, 1.0, 0.5) is the bottom-right corner.
369 * The default parent-origin is top-left (0.0, 0.0, 0.5).
370 * An actor position is the distance between this origin, and the actors anchor-point.
371 * @param [in] origin The new parent-origin.
373 void SetParentOrigin( const Vector3& origin );
376 * Set the x component of the parent-origin
377 * @param [in] x The new x value.
379 void SetParentOriginX( float x );
382 * Set the y component of the parent-origin
383 * @param [in] y The new y value.
385 void SetParentOriginY( float y );
388 * Set the z component of the parent-origin
389 * @param [in] z The new z value.
391 void SetParentOriginZ( float z );
394 * Retrieve the parent-origin of an actor.
395 * @return The parent-origin.
397 const Vector3& GetCurrentParentOrigin() const;
400 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
401 * (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.
402 * The default anchor point is top-left (0.0, 0.0, 0.5).
403 * An actor position is the distance between its parent-origin, and this anchor-point.
404 * An actor's rotation is centered around its anchor-point.
405 * @param [in] anchorPoint The new anchor-point.
407 void SetAnchorPoint( const Vector3& anchorPoint );
410 * Set the x component of the anchor-point.
411 * @param [in] x The new x value.
413 void SetAnchorPointX( float x );
416 * Set the y component of the anchor-point.
417 * @param [in] y The new y value.
419 void SetAnchorPointY( float y );
422 * Set the z component of the anchor-point.
423 * @param [in] z The new z value.
425 void SetAnchorPointZ( float z );
428 * Retrieve the anchor-point of an actor.
429 * @return The anchor-point.
431 const Vector3& GetCurrentAnchorPoint() const;
434 * Sets the position of the Actor.
435 * The coordinates are relative to the Actor's parent.
436 * The Actor's z position will be set to 0.0f.
437 * @param [in] x The new x position
438 * @param [in] y The new y position
440 void SetPosition( float x, float y );
443 * Sets the position of the Actor.
444 * The coordinates are relative to the Actor's parent.
445 * @param [in] x The new x position
446 * @param [in] y The new y position
447 * @param [in] z The new z position
449 void SetPosition( float x, float y, float z );
452 * Sets the position of the Actor.
453 * The coordinates are relative to the Actor's parent.
454 * @param [in] position The new position.
456 void SetPosition( const Vector3& position );
459 * Set the position of an actor along the X-axis.
460 * @param [in] x The new x position
462 void SetX( float x );
465 * Set the position of an actor along the Y-axis.
466 * @param [in] y The new y position.
468 void SetY( float y );
471 * Set the position of an actor along the Z-axis.
472 * @param [in] z The new z position
474 void SetZ( float z );
477 * Translate an actor relative to its existing position.
478 * @param[in] distance The actor will move by this distance.
480 void TranslateBy( const Vector3& distance );
483 * Retrieve the position of the Actor.
484 * The coordinates are relative to the Actor's parent.
485 * @return the Actor's position.
487 const Vector3& GetCurrentPosition() const;
490 * Retrieve the target position of the Actor.
491 * The coordinates are relative to the Actor's parent.
492 * @return the Actor's position.
494 const Vector3& GetTargetPosition() const;
497 * @copydoc Dali::Actor::GetCurrentWorldPosition()
499 const Vector3& GetCurrentWorldPosition() const;
502 * @copydoc Dali::Actor::SetPositionInheritanceMode()
504 void SetPositionInheritanceMode( PositionInheritanceMode mode );
507 * @copydoc Dali::Actor::GetPositionInheritanceMode()
509 PositionInheritanceMode GetPositionInheritanceMode() const;
512 * Sets the orientation of the Actor.
513 * @param [in] angleRadians The new orientation angle in radians.
514 * @param [in] axis The new axis of orientation.
516 void SetOrientation( const Radian& angleRadians, const Vector3& axis );
519 * Sets the orientation of the Actor.
520 * @param [in] orientation The new orientation.
522 void SetOrientation( const Quaternion& orientation );
525 * Rotate an actor around its existing rotation axis.
526 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
527 * @param[in] axis The axis of the rotation to combine with the existing rotation.
529 void RotateBy( const Radian& angleRadians, const Vector3& axis );
532 * Apply a relative rotation to an actor.
533 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
535 void RotateBy( const Quaternion& relativeRotation );
538 * Retreive the Actor's orientation.
539 * @return the orientation.
541 const Quaternion& GetCurrentOrientation() const;
544 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
545 * Switching this off means that using SetOrientation() sets the actor's world orientation.
546 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
548 void SetInheritOrientation( bool inherit );
551 * Returns whether the actor inherit's it's parent's orientation.
552 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
554 bool IsOrientationInherited() const;
557 * Sets the factor of the parents size used for the child actor.
558 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
559 * @param[in] factor The vector to multiply the parents size by to get the childs size.
561 void SetSizeModeFactor( const Vector3& factor );
564 * Gets the factor of the parents size used for the child actor.
565 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
566 * @return The vector being used to multiply the parents size by to get the childs size.
568 const Vector3& GetSizeModeFactor() const;
571 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
573 const Quaternion& GetCurrentWorldOrientation() const;
576 * Sets a scale factor applied to an actor.
577 * @param [in] scale The scale factor applied on all axes.
579 void SetScale( float scale );
582 * Sets a scale factor applied to an actor.
583 * @param [in] scaleX The scale factor applied along the x-axis.
584 * @param [in] scaleY The scale factor applied along the y-axis.
585 * @param [in] scaleZ The scale factor applied along the z-axis.
587 void SetScale( float scaleX, float scaleY, float scaleZ );
590 * Sets a scale factor applied to an actor.
591 * @param [in] scale A vector representing the scale factor for each axis.
593 void SetScale( const Vector3& scale );
596 * Set the x component of the scale factor.
597 * @param [in] x The new x value.
599 void SetScaleX( float x );
602 * Set the y component of the scale factor.
603 * @param [in] y The new y value.
605 void SetScaleY( float y );
608 * Set the z component of the scale factor.
609 * @param [in] z The new z value.
611 void SetScaleZ( float z );
614 * Apply a relative scale to an actor.
615 * @param[in] relativeScale The scale to combine with the actors existing scale.
617 void ScaleBy( const Vector3& relativeScale );
620 * Retrieve the scale factor applied to an actor.
621 * @return A vector representing the scale factor for each axis.
623 const Vector3& GetCurrentScale() const;
626 * @copydoc Dali::Actor::GetCurrentWorldScale()
628 const Vector3& GetCurrentWorldScale() const;
631 * @copydoc Dali::Actor::SetInheritScale()
633 void SetInheritScale( bool inherit );
636 * @copydoc Dali::Actor::IsScaleInherited()
638 bool IsScaleInherited() const;
641 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
643 Matrix GetCurrentWorldMatrix() const;
648 * Sets the visibility flag of an actor.
649 * @param [in] visible The new visibility flag.
651 void SetVisible( bool visible );
654 * Retrieve the visibility flag of an actor.
655 * @return The visibility flag.
657 bool IsVisible() const;
660 * Sets the opacity of an actor.
661 * @param [in] opacity The new opacity.
663 void SetOpacity( float opacity );
666 * Retrieve the actor's opacity.
667 * @return The actor's opacity.
669 float GetCurrentOpacity() const;
672 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
673 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
674 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
675 * hover event signal will be emitted.
677 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
679 * actor.SetSensitive(false);
682 * Then, to re-enable the touch or hover event signal emission, the application should call:
684 * actor.SetSensitive(true);
687 * @see SignalTouch() and SignalHover().
688 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
689 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
691 void SetSensitive( bool sensitive )
693 mSensitive = sensitive;
697 * Query whether an actor emits touch or hover event signals.
698 * @see SetSensitive(bool)
699 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
701 bool IsSensitive() const
707 * @copydoc Dali::Actor::SetDrawMode
709 void SetDrawMode( DrawMode::Type drawMode );
712 * @copydoc Dali::Actor::GetDrawMode
714 DrawMode::Type GetDrawMode() const;
717 * @copydoc Dali::Actor::SetOverlay
719 void SetOverlay( bool enable );
722 * @copydoc Dali::Actor::IsOverlay
724 bool IsOverlay() const;
727 * Sets whether an actor transmits geometry scaling to it's children.
728 * The default value is for it not to transmit scaling.
729 * @param[in] transmitGeometryScaling True to transmit scaling.
731 void SetTransmitGeometryScaling( bool transmitGeometryScaling );
734 * Get the TransmitGeometryScaling property for this actor.
735 * @return True if geometry scaling is applied to the inherited scale.
737 bool GetTransmitGeometryScaling() const;
740 * Sets the initial volume of the actor. Used for scaling the
741 * actor appropriately as the actor is sized when transmitGeometryScaling
744 * @param[in] volume the volume of the model and it's children
746 void SetInitialVolume( const Vector3& volume );
749 * Sets the actor's color. The final color of actor depends on its color mode.
750 * This final color is applied to the drawable elements of an actor.
751 * @param [in] color The new color.
753 void SetColor( const Vector4& color );
756 * Set the red component of the color.
757 * @param [in] red The new red component.
759 void SetColorRed( float red );
762 * Set the green component of the color.
763 * @param [in] green The new green component.
765 void SetColorGreen( float green );
768 * Set the blue component of the scale factor.
769 * @param [in] blue The new blue value.
771 void SetColorBlue( float blue );
774 * Retrieve the actor's color.
777 const Vector4& GetCurrentColor() const;
780 * Sets the actor's color mode.
781 * Color mode specifies whether Actor uses its own color or inherits its parent color
782 * @param [in] colorMode to use.
784 void SetColorMode( ColorMode colorMode );
787 * Returns the actor's color mode.
788 * @return currently used colorMode.
790 ColorMode GetColorMode() const;
793 * @copydoc Dali::Actor::GetCurrentWorldColor()
795 const Vector4& GetCurrentWorldColor() const;
799 // Size negotiation virtual functions
802 * @brief Called after the size negotiation has been finished for this control.
804 * The control is expected to assign this given size to itself/its children.
806 * Should be overridden by derived classes if they need to layout
807 * actors differently after certain operations like add or remove
808 * actors, resize or after changing specific properties.
810 * Note! As this function is called from inside the size negotiation algorithm, you cannot
811 * call RequestRelayout (the call would just be ignored)
813 * @param[in] size The allocated size.
814 * @param[in,out] container The control should add actors to this container that it is not able
815 * to allocate a size for.
817 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
822 * @brief Notification for deriving classes when the resize policy is set
824 * @param[in] policy The policy being set
825 * @param[in] dimension The dimension the policy is being set for
827 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
830 * @brief Virtual method to notify deriving classes that relayout dependencies have been
831 * met and the size for this object is about to be calculated for the given dimension
833 * @param dimension The dimension that is about to be calculated
835 virtual void OnCalculateRelayoutSize( Dimension::Type dimension );
838 * @brief Virtual method to notify deriving classes that the size for a dimension
839 * has just been negotiated
841 * @param[in] size The new size for the given dimension
842 * @param[in] dimension The dimension that was just negotiated
844 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension );
847 * @brief Determine if this actor is dependent on it's children for relayout
849 * @param dimension The dimension(s) to check for
850 * @return Return if the actor is dependent on it's children
852 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
855 * @brief Determine if this actor is dependent on it's children for relayout.
857 * Called from deriving classes
859 * @param dimension The dimension(s) to check for
860 * @return Return if the actor is dependent on it's children
862 virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
865 * @brief Calculate the size for a child
867 * @param[in] child The child actor to calculate the size for
868 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
869 * @return Return the calculated size for the given dimension
871 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
874 * @brief This method is called during size negotiation when a height is required for a given width.
876 * Derived classes should override this if they wish to customize the height returned.
878 * @param width to use.
879 * @return the height based on the width.
881 virtual float GetHeightForWidth( float width );
884 * @brief This method is called during size negotiation when a width is required for a given height.
886 * Derived classes should override this if they wish to customize the width returned.
888 * @param height to use.
889 * @return the width based on the width.
891 virtual float GetWidthForHeight( float height );
898 * @brief Called by the RelayoutController to negotiate the size of an actor.
900 * The size allocated by the the algorithm is passed in which the
901 * actor must adhere to. A container is passed in as well which
902 * the actor should populate with actors it has not / or does not
903 * need to handle in its size negotiation.
905 * @param[in] size The allocated size.
906 * @param[in,out] container The container that holds actors that are fed back into the
907 * RelayoutController algorithm.
909 void NegotiateSize( const Vector2& size, RelayoutContainer& container );
912 * @copydoc Dali::Actor::SetResizePolicy()
914 void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
917 * @copydoc Dali::Actor::GetResizePolicy()
919 ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
922 * @copydoc Dali::Actor::SetSizeScalePolicy()
924 void SetSizeScalePolicy( SizeScalePolicy::Type policy );
927 * @copydoc Dali::Actor::GetSizeScalePolicy()
929 SizeScalePolicy::Type GetSizeScalePolicy() const;
932 * @copydoc Dali::Actor::SetDimensionDependency()
934 void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
937 * @copydoc Dali::Actor::GetDimensionDependency()
939 Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
942 * @brief Set the size negotiation relayout enabled on this actor
944 * @param[in] relayoutEnabled Boolean to enable or disable relayout
946 void SetRelayoutEnabled( bool relayoutEnabled );
949 * @brief Return if relayout is enabled
951 * @return Return if relayout is enabled or not for this actor
953 bool IsRelayoutEnabled() const;
956 * @brief Mark an actor as having it's layout dirty
958 * @param dirty Whether to mark actor as dirty or not
959 * @param dimension The dimension(s) to mark as dirty
961 void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
964 * @brief Return if any of an actor's dimensions are marked as dirty
966 * @param dimension The dimension(s) to check
967 * @return Return if any of the requested dimensions are dirty
969 bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
972 * @brief Returns if relayout is enabled and the actor is not dirty
974 * @return Return if it is possible to relayout the actor
976 bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
979 * @brief Returns if relayout is enabled and the actor is dirty
981 * @return Return if it is required to relayout the actor
983 bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
986 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
988 * This method is automatically called from OnStageConnection(), OnChildAdd(),
989 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
991 * This method can also be called from a derived class every time it needs a different size.
992 * At the end of event processing, the relayout process starts and
993 * all controls which requested Relayout will have their sizes (re)negotiated.
995 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
996 * only performed once, i.e. there is no need to keep track of this in the calling side.
998 void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1001 * @copydoc Dali::Actor::PropagateRelayoutFlags
1003 void PropagateRelayoutFlags();
1006 * @brief Determine if this actor is dependent on it's parent for relayout
1008 * @param dimension The dimension(s) to check for
1009 * @return Return if the actor is dependent on it's parent
1011 bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1014 * @brief Determine if this actor has another dimension depedent on the specified one
1016 * @param dimension The dimension to check for
1017 * @param dependentDimension The dimension to check for dependency with
1018 * @return Return if the actor is dependent on this dimension
1020 bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
1023 * Negotiate sizes for a control in all dimensions
1025 * @param[in] allocatedSize The size constraint that the control must respect
1027 void NegotiateDimensions( const Vector2& allocatedSize );
1030 * Negotiate size for a specific dimension
1032 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1033 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1034 * LayoutDimensionNegotiated flags being filled in on the actor.
1036 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1037 * calculated and set as well as the LayoutDimensionNegotiated flags.
1039 * @param[in] dimension The dimension to negotiate on
1040 * @param[in] allocatedSize The size constraint that the actor must respect
1042 void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1045 * @brief Calculate the size of a dimension
1047 * @param[in] dimension The dimension to calculate the size for
1048 * @param[in] maximumSize The upper bounds on the size
1049 * @return Return the calculated size for the dimension
1051 float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1054 * @brief Clamp a dimension given the relayout constraints on this actor
1056 * @param[in] size The size to constrain
1057 * @param[in] dimension The dimension the size exists in
1058 * @return Return the clamped size
1060 float ClampDimension( float size, Dimension::Type dimension );
1063 * Negotiate a dimension based on the size of the parent
1065 * @param[in] dimension The dimension to negotiate on
1066 * @return Return the negotiated size
1068 float NegotiateFromParent( Dimension::Type dimension );
1071 * Negotiate a dimension based on the size of the parent. Fitting inside.
1073 * @param[in] dimension The dimension to negotiate on
1074 * @return Return the negotiated size
1076 float NegotiateFromParentFit( Dimension::Type dimension );
1079 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1081 * @param[in] dimension The dimension to negotiate on
1082 * @return Return the negotiated size
1084 float NegotiateFromParentFlood( Dimension::Type dimension );
1087 * @brief Negotiate a dimension based on the size of the children
1089 * @param[in] dimension The dimension to negotiate on
1090 * @return Return the negotiated size
1092 float NegotiateFromChildren( Dimension::Type dimension );
1095 * Set the negotiated dimension value for the given dimension(s)
1097 * @param negotiatedDimension The value to set
1098 * @param dimension The dimension(s) to set the value for
1100 void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1103 * Return the value of negotiated dimension for the given dimension
1105 * @param dimension The dimension to retrieve
1106 * @return Return the value of the negotiated dimension
1108 float GetNegotiatedDimension( Dimension::Type dimension ) const;
1111 * @brief Set the padding for a dimension
1113 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1114 * @param[in] dimension The dimension to set
1116 void SetPadding( const Vector2& padding, Dimension::Type dimension );
1119 * Return the value of padding for the given dimension
1121 * @param dimension The dimension to retrieve
1122 * @return Return the value of padding for the dimension
1124 Vector2 GetPadding( Dimension::Type dimension ) const;
1127 * Return the actor size for a given dimension
1129 * @param[in] dimension The dimension to retrieve the size for
1130 * @return Return the size for the given dimension
1132 float GetSize( Dimension::Type dimension ) const;
1135 * Return the natural size of the actor for a given dimension
1137 * @param[in] dimension The dimension to retrieve the size for
1138 * @return Return the natural size for the given dimension
1140 float GetNaturalSize( Dimension::Type dimension ) const;
1143 * @brief Return the amount of size allocated for relayout
1145 * May include padding
1147 * @param[in] dimension The dimension to retrieve
1148 * @return Return the size
1150 float GetRelayoutSize( Dimension::Type dimension ) const;
1153 * @brief If the size has been negotiated return that else return normal size
1155 * @param[in] dimension The dimension to retrieve
1156 * @return Return the size
1158 float GetLatestSize( Dimension::Type dimension ) const;
1161 * Apply the negotiated size to the actor
1163 * @param[in] container The container to fill with actors that require further relayout
1165 void SetNegotiatedSize( RelayoutContainer& container );
1168 * @brief Flag the actor as having it's layout dimension negotiated.
1170 * @param[in] negotiated The status of the flag to set.
1171 * @param[in] dimension The dimension to set the flag for
1173 void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1176 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1178 * @param[in] dimension The dimension to determine the value of the flag for
1179 * @return Return if the layout dimension is negotiated or not.
1181 bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1184 * @brief Calculate the size for a child
1186 * @param[in] child The child actor to calculate the size for
1187 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1188 * @return Return the calculated size for the given dimension
1190 float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1193 * @brief Set the preferred size for size negotiation
1195 * @param[in] size The preferred size to set
1197 void SetPreferredSize( const Vector2& size );
1200 * @brief Return the preferred size used for size negotiation
1202 * @return Return the preferred size
1204 Vector2 GetPreferredSize() const;
1207 * @copydoc Dali::Actor::SetMinimumSize
1209 void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1212 * @copydoc Dali::Actor::GetMinimumSize
1214 float GetMinimumSize( Dimension::Type dimension ) const;
1217 * @copydoc Dali::Actor::SetMaximumSize
1219 void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1222 * @copydoc Dali::Actor::GetMaximumSize
1224 float GetMaximumSize( Dimension::Type dimension ) const;
1226 #ifdef DYNAMICS_SUPPORT
1230 /// @copydoc Dali::Actor::DisableDynamics
1231 void DisableDynamics();
1233 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
1234 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
1236 /// @copydoc Dali::Actor::GetDynamicsBody
1237 DynamicsBodyPtr GetDynamicsBody() const;
1239 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
1240 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
1242 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
1243 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
1245 /// @copydoc Dali::Actor::GetNumberOfJoints
1246 const int GetNumberOfJoints() const;
1248 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
1249 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
1251 /// @copydoc Dali::Actor::GetDynamicsJoint
1252 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
1254 /// @copydoc Dali::Actor::RemoveDynamicsJoint
1255 void RemoveDynamicsJoint( DynamicsJointPtr joint );
1258 * Hold a reference to a DynamicsJoint
1259 * @param[in] joint The joint
1261 void ReferenceJoint( DynamicsJointPtr joint );
1264 * Release a reference to a DynamicsJoint
1265 * @param[in] joint The joint
1267 void ReleaseJoint( DynamicsJointPtr joint );
1270 * Set this actor to be the root actor in the dynamics simulation
1271 * All children of the actor are added/removed from the simulation.
1272 * @param[in] flag When true sets this actor to be the simulation world root actor and
1273 * if OnStage() all dynamics enabled child actors are added to the simulation,
1274 * when false stops this actor being the simulation root and if OnStage() all
1275 * dynamics enabled child actors are removed from the simulation.
1277 void SetDynamicsRoot(bool flag);
1281 * Check if this actor is the root actor in the dynamics simulation
1282 * @return true if this is the dynamics root actor.
1284 bool IsDynamicsRoot() const;
1287 * Add actor to the dynamics simulation
1288 * Invoked when the actor is staged, or it's parent becomes the simulation root
1290 void ConnectDynamics();
1293 * Remove actor from the dynamics simulation
1294 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
1296 void DisconnectDynamics();
1299 * An actor in a DynamicsJoint relationship has been staged
1300 * @param[in] actor The actor passed into AddDynamicsJoint()
1302 void AttachedActorOnStage( Dali::Actor actor );
1305 * An actor in a DynamicsJoint relationship has been unstaged
1306 * @param[in] actor The actor passed into AddDynamicsJoint()
1308 void AttachedActorOffStage( Dali::Actor actor );
1310 #endif // DYNAMICS_SUPPORT
1314 * Converts screen coordinates into the actor's coordinate system.
1315 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1316 * @param[out] localX On return, the X-coordinate relative to the actor.
1317 * @param[out] localY On return, the Y-coordinate relative to the actor.
1318 * @param[in] screenX The screen X-coordinate.
1319 * @param[in] screenY The screen Y-coordinate.
1320 * @return True if the conversion succeeded.
1322 bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const;
1325 * Converts screen coordinates into the actor's coordinate system.
1326 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1327 * @param[in] renderTask The render-task used to display the actor.
1328 * @param[out] localX On return, the X-coordinate relative to the actor.
1329 * @param[out] localY On return, the Y-coordinate relative to the actor.
1330 * @param[in] screenX The screen X-coordinate.
1331 * @param[in] screenY The screen Y-coordinate.
1332 * @return True if the conversion succeeded.
1334 bool ScreenToLocal( RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1337 * Converts from the actor's coordinate system to screen coordinates.
1338 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1339 * @param[in] viewMatrix The view-matrix
1340 * @param[in] projectionMatrix The projection-matrix
1341 * @param[in] viewport The view-port
1342 * @param[out] localX On return, the X-coordinate relative to the actor.
1343 * @param[out] localY On return, the Y-coordinate relative to the actor.
1344 * @param[in] screenX The screen X-coordinate.
1345 * @param[in] screenY The screen Y-coordinate.
1346 * @return True if the conversion succeeded.
1348 bool ScreenToLocal( const Matrix& viewMatrix,
1349 const Matrix& projectionMatrix,
1350 const Viewport& viewport,
1354 float screenY ) const;
1357 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1358 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1359 * @param[in] rayOrigin The ray origin in the world's reference system.
1360 * @param[in] rayDir The ray director vector in the world's reference system.
1361 * @return True if the ray intersects the actor's bounding sphere.
1363 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1366 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1367 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1368 * @param[in] rayOrigin The ray origin in the world's reference system.
1369 * @param[in] rayDir The ray director vector in the world's reference system.
1370 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1371 * @param[out] distance The distance from the hit point to the camera.
1372 * @return True if the ray intersects the actor's geometry.
1374 bool RayActorTest( const Vector4& rayOrigin,
1375 const Vector4& rayDir,
1376 Vector4& hitPointLocal,
1377 float& distance ) const;
1380 * Sets whether the actor should receive a notification when touch or hover motion events leave
1381 * the boundary of the actor.
1383 * @note By default, this is set to false as most actors do not require this.
1384 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1386 * @param[in] required Should be set to true if a Leave event is required
1388 void SetLeaveRequired( bool required );
1391 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1392 * the boundary of the actor.
1393 * @return true if a Leave event is required, false otherwise.
1395 bool GetLeaveRequired() const;
1398 * @copydoc Dali::Actor::SetKeyboardFocusable()
1400 void SetKeyboardFocusable( bool focusable );
1403 * @copydoc Dali::Actor::IsKeyboardFocusable()
1405 bool IsKeyboardFocusable() const;
1408 * Query whether the application or derived actor type requires touch events.
1409 * @return True if touch events are required.
1411 bool GetTouchRequired() const;
1414 * Query whether the application or derived actor type requires hover events.
1415 * @return True if hover events are required.
1417 bool GetHoverRequired() const;
1420 * Query whether the application or derived actor type requires mouse wheel events.
1421 * @return True if mouse wheel events are required.
1423 bool GetMouseWheelEventRequired() const;
1426 * Query whether the actor is actually hittable. This method checks whether the actor is
1427 * sensitive, has the visibility flag set to true and is not fully transparent.
1428 * @return true, if it can be hit, false otherwise.
1430 bool IsHittable() const;
1435 * Retrieve the gesture data associated with this actor. The first call to this method will
1436 * allocate space for the ActorGestureData so this should only be called if an actor really does
1438 * @return Reference to the ActorGestureData for this actor.
1439 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1440 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1442 ActorGestureData& GetGestureData();
1445 * Queries whether the actor requires the gesture type.
1446 * @param[in] type The gesture type.
1448 bool IsGestureRequred( Gesture::Type type ) const;
1453 * Used by the EventProcessor to emit touch event signals.
1454 * @param[in] event The touch event.
1455 * @return True if the event was consumed.
1457 bool EmitTouchEventSignal( const TouchEvent& event );
1460 * Used by the EventProcessor to emit hover event signals.
1461 * @param[in] event The hover event.
1462 * @return True if the event was consumed.
1464 bool EmitHoverEventSignal( const HoverEvent& event );
1467 * Used by the EventProcessor to emit mouse wheel event signals.
1468 * @param[in] event The mouse wheel event.
1469 * @return True if the event was consumed.
1471 bool EmitMouseWheelEventSignal( const MouseWheelEvent& event );
1474 * @copydoc Dali::Actor::TouchedSignal()
1476 Dali::Actor::TouchSignalType& TouchedSignal();
1479 * @copydoc Dali::Actor::HoveredSignal()
1481 Dali::Actor::HoverSignalType& HoveredSignal();
1484 * @copydoc Dali::Actor::MouseWheelEventSignal()
1486 Dali::Actor::MouseWheelEventSignalType& MouseWheelEventSignal();
1489 * @copydoc Dali::Actor::OnStageSignal()
1491 Dali::Actor::OnStageSignalType& OnStageSignal();
1494 * @copydoc Dali::Actor::OffStageSignal()
1496 Dali::Actor::OffStageSignalType& OffStageSignal();
1499 * @copydoc Dali::Actor::OnRelayoutSignal()
1501 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1504 * Connects a callback function with the object's signals.
1505 * @param[in] object The object providing the signal.
1506 * @param[in] tracker Used to disconnect the signal.
1507 * @param[in] signalName The signal to connect to.
1508 * @param[in] functor A newly allocated FunctorDelegate.
1509 * @return True if the signal was connected.
1510 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1512 static bool DoConnectSignal( BaseObject* object,
1513 ConnectionTrackerInterface* tracker,
1514 const std::string& signalName,
1515 FunctorDelegate* functor );
1518 * Performs actions as requested using the action name.
1519 * @param[in] object The object on which to perform the action.
1520 * @param[in] actionName The action to perform.
1521 * @param[in] attributes The attributes with which to perfrom this action.
1522 * @return true if the action was done.
1524 static bool DoAction( BaseObject* object,
1525 const std::string& actionName,
1526 const std::vector< Property::Value >& attributes );
1532 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1534 * @param[in] animation The animation that resized the actor
1535 * @param[in] targetSize The new target size of the actor
1537 void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1540 * For use in derived classes.
1541 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1543 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1551 BASIC, RENDERABLE, LAYER, ROOT_LAYER
1555 * Protected Constructor. See Actor::New().
1556 * The second-phase construction Initialize() member should be called immediately after this.
1557 * @param[in] derivedType The derived type of actor (if any).
1559 Actor( DerivedType derivedType );
1562 * Second-phase constructor. Must be called immediately after creating a new Actor;
1564 void Initialize( void );
1567 * A reference counted object may only be deleted by calling Unreference()
1572 * Called on a child during Add() when the parent actor is connected to the Stage.
1573 * @param[in] stage The stage.
1574 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1576 void ConnectToStage( int index = -1 );
1579 * Helper for ConnectToStage, to recursively connect a tree of actors.
1580 * This is atomic i.e. not interrupted by user callbacks.
1581 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1582 * @param[out] connectionList On return, the list of connected actors which require notification.
1584 void RecursiveConnectToStage( ActorContainer& connectionList, int index = -1 );
1587 * Connect the Node associated with this Actor to the scene-graph.
1588 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1590 void ConnectToSceneGraph( int index = -1 );
1593 * Helper for ConnectToStage, to notify a connected actor through the public API.
1595 void NotifyStageConnection();
1598 * Called on a child during Remove() when the actor was previously on the Stage.
1600 void DisconnectFromStage();
1603 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1604 * This is atomic i.e. not interrupted by user callbacks.
1605 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1607 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1610 * Disconnect the Node associated with this Actor from the scene-graph.
1612 void DisconnectFromSceneGraph();
1615 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1617 void NotifyStageDisconnection();
1620 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1621 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1623 bool IsNodeConnected() const;
1626 * Calculate the size of the z dimension for a 2D size
1628 * @param[in] size The 2D size (X, Y) to calculate Z from
1630 * @return Return the Z dimension for this size
1632 float CalculateSizeZ( const Vector2& size ) const;
1635 // Default property extensions from Object
1638 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1640 virtual unsigned int GetDefaultPropertyCount() const;
1643 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1645 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1648 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1650 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1653 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1655 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1658 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1660 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1663 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1665 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1668 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1670 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1673 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1675 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1678 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1680 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1683 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1685 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1688 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1690 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1693 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1695 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1698 * @copydoc Dali::Internal::Object::GetSceneObject()
1700 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1703 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1705 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1708 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1710 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1713 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1715 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1723 Actor( const Actor& );
1726 Actor& operator=( const Actor& rhs );
1729 * Set the actors parent.
1730 * @param[in] parent The new parent.
1731 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1733 void SetParent( Actor* parent, int index = -1 );
1736 * Helper to create a Node for this Actor.
1737 * To be overriden in derived classes.
1738 * @return A newly allocated node.
1740 virtual SceneGraph::Node* CreateNode() const;
1743 * For use in derived classes, called after Initialize()
1745 virtual void OnInitialize()
1750 * For use in internal derived classes.
1751 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1752 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1754 virtual void OnStageConnectionInternal()
1759 * For use in internal derived classes.
1760 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1761 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1763 virtual void OnStageDisconnectionInternal()
1768 * For use in external (CustomActor) derived classes.
1769 * This is called after the atomic ConnectToStage() traversal has been completed.
1771 virtual void OnStageConnectionExternal()
1776 * For use in external (CustomActor) derived classes.
1777 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1779 virtual void OnStageDisconnectionExternal()
1784 * For use in derived classes; this is called after Add() has added a child.
1785 * @param[in] child The child that was added.
1787 virtual void OnChildAdd( Actor& child )
1792 * For use in derived classes; this is called after Remove() has removed a child.
1793 * @param[in] child The child that was removed.
1795 virtual void OnChildRemove( Actor& child )
1800 * For use in derived classes.
1801 * This is called after SizeSet() has been called.
1803 virtual void OnSizeSet( const Vector3& targetSize )
1808 * For use in derived classes.
1809 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1810 * @param[in] event The touch event.
1811 * @return True if the event should be consumed.
1813 virtual bool OnTouchEvent( const TouchEvent& event )
1819 * For use in derived classes.
1820 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1821 * @param[in] event The hover event.
1822 * @return True if the event should be consumed.
1824 virtual bool OnHoverEvent( const HoverEvent& event )
1830 * For use in derived classes.
1831 * This is only called if the mouse wheel signal was not consumed.
1832 * @param[in] event The mouse event.
1833 * @return True if the event should be consumed.
1835 virtual bool OnMouseWheelEvent( const MouseWheelEvent& event )
1841 * @brief Ensure the relayout data is allocated
1843 void EnsureRelayoutData() const;
1846 * @brief Apply the size set policy to the input size
1848 * @param[in] size The size to apply the policy to
1849 * @return Return the adjusted size
1851 Vector2 ApplySizeSetPolicy( const Vector2 size );
1855 StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
1856 Actor* mParent; ///< Each actor (except the root) can have one parent
1857 ActorContainer* mChildren; ///< Container of referenced actors
1858 const SceneGraph::Node* mNode; ///< Not owned
1859 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1860 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1862 struct RelayoutData;
1863 mutable RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1865 #ifdef DYNAMICS_SUPPORT
1866 DynamicsData* mDynamicsData; ///< optional physics data
1869 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1871 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1874 Dali::Actor::TouchSignalType mTouchedSignal;
1875 Dali::Actor::HoverSignalType mHoveredSignal;
1876 Dali::Actor::MouseWheelEventSignalType mMouseWheelEventSignal;
1877 Dali::Actor::OnStageSignalType mOnStageSignal;
1878 Dali::Actor::OffStageSignalType mOffStageSignal;
1879 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1881 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1882 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
1884 std::string mName; ///< Name of the actor
1885 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1887 const bool mIsRoot : 1; ///< Flag to identify the root actor
1888 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1889 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1890 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1891 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1892 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1893 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1894 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1895 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1896 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1897 bool mDerivedRequiresMouseWheelEvent : 1; ///< Whether the derived actor type requires mouse wheel event signals
1898 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1899 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1900 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1901 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1902 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1903 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1907 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1908 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1912 } // namespace Internal
1914 // Helpers for public-api forwarding methods
1916 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
1918 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1920 BaseObject& handle = actor.GetBaseObject();
1922 return static_cast< Internal::Actor& >( handle );
1925 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
1927 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1929 const BaseObject& handle = actor.GetBaseObject();
1931 return static_cast< const Internal::Actor& >( handle );
1936 #endif // __DALI_INTERNAL_ACTOR_H__