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 a reference to Actor's children.
238 * @note Not for public use.
239 * @return A reference to the container of children.
241 ActorContainer& GetChildrenInternal()
247 * @copydoc Dali::Actor::FindChildByName
249 ActorPtr FindChildByName( const std::string& actorName );
252 * @copydoc Dali::Actor::FindChildById
254 ActorPtr FindChildById( const unsigned int id );
257 * Retrieve the parent of an Actor.
258 * @return The parent actor, or NULL if the Actor does not have a parent.
260 Actor* GetParent() const
266 * Sets the size of an actor.
267 * ActorAttachments attached to the actor, can be scaled to fit within this area.
268 * This does not interfere with the actors scale factor.
269 * @param [in] width The new width.
270 * @param [in] height The new height.
272 void SetSize( float width, float height );
275 * Sets the size of an actor.
276 * ActorAttachments attached to the actor, can be scaled to fit within this area.
277 * This does not interfere with the actors scale factor.
278 * @param [in] width The size of the actor along the x-axis.
279 * @param [in] height The size of the actor along the y-axis.
280 * @param [in] depth The size of the actor along the z-axis.
282 void SetSize( float width, float height, float depth );
285 * Sets the size of an actor.
286 * ActorAttachments attached to the actor, can be scaled to fit within this area.
287 * This does not interfere with the actors scale factor.
288 * @param [in] size The new size.
290 void SetSize( const Vector2& size );
293 * Sets the update size for an actor.
295 * @param[in] size The size to set.
297 void SetSizeInternal( const Vector2& size );
300 * Sets the size of an actor.
301 * ActorAttachments attached to the actor, can be scaled to fit within this area.
302 * This does not interfere with the actors scale factor.
303 * @param [in] size The new size.
305 void SetSize( const Vector3& size );
308 * Sets the update size for an actor.
310 * @param[in] size The size to set.
312 void SetSizeInternal( const Vector3& size );
315 * Set the width component of the Actor's size.
316 * @param [in] width The new width component.
318 void SetWidth( float width );
321 * Set the height component of the Actor's size.
322 * @param [in] height The new height component.
324 void SetHeight( float height );
327 * Set the depth component of the Actor's size.
328 * @param [in] depth The new depth component.
330 void SetDepth( float depth );
333 * Retrieve the Actor's size from event side.
334 * This size will be the size set or if animating then the target size.
335 * @return The Actor's size.
337 const Vector3& GetTargetSize() const;
340 * Retrieve the Actor's size from update side.
341 * This size will be the size set or animating but will be a frame behind.
342 * @return The Actor's size.
344 const Vector3& GetCurrentSize() const;
347 * Return the natural size of the actor
349 * @return The actor's natural size
351 virtual Vector3 GetNaturalSize() const;
354 * Set the origin of an actor, within its parent's area.
355 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
356 * and (1.0, 1.0, 0.5) is the bottom-right corner.
357 * The default parent-origin is top-left (0.0, 0.0, 0.5).
358 * An actor position is the distance between this origin, and the actors anchor-point.
359 * @param [in] origin The new parent-origin.
361 void SetParentOrigin( const Vector3& origin );
364 * Set the x component of the parent-origin
365 * @param [in] x The new x value.
367 void SetParentOriginX( float x );
370 * Set the y component of the parent-origin
371 * @param [in] y The new y value.
373 void SetParentOriginY( float y );
376 * Set the z component of the parent-origin
377 * @param [in] z The new z value.
379 void SetParentOriginZ( float z );
382 * Retrieve the parent-origin of an actor.
383 * @return The parent-origin.
385 const Vector3& GetCurrentParentOrigin() const;
388 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
389 * (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.
390 * The default anchor point is top-left (0.0, 0.0, 0.5).
391 * An actor position is the distance between its parent-origin, and this anchor-point.
392 * An actor's rotation is centered around its anchor-point.
393 * @param [in] anchorPoint The new anchor-point.
395 void SetAnchorPoint( const Vector3& anchorPoint );
398 * Set the x component of the anchor-point.
399 * @param [in] x The new x value.
401 void SetAnchorPointX( float x );
404 * Set the y component of the anchor-point.
405 * @param [in] y The new y value.
407 void SetAnchorPointY( float y );
410 * Set the z component of the anchor-point.
411 * @param [in] z The new z value.
413 void SetAnchorPointZ( float z );
416 * Retrieve the anchor-point of an actor.
417 * @return The anchor-point.
419 const Vector3& GetCurrentAnchorPoint() const;
422 * Sets the position of the Actor.
423 * The coordinates are relative to the Actor's parent.
424 * The Actor's z position will be set to 0.0f.
425 * @param [in] x The new x position
426 * @param [in] y The new y position
428 void SetPosition( float x, float y );
431 * Sets the position of the Actor.
432 * The coordinates are relative to the Actor's parent.
433 * @param [in] x The new x position
434 * @param [in] y The new y position
435 * @param [in] z The new z position
437 void SetPosition( float x, float y, float z );
440 * Sets the position of the Actor.
441 * The coordinates are relative to the Actor's parent.
442 * @param [in] position The new position.
444 void SetPosition( const Vector3& position );
447 * Set the position of an actor along the X-axis.
448 * @param [in] x The new x position
450 void SetX( float x );
453 * Set the position of an actor along the Y-axis.
454 * @param [in] y The new y position.
456 void SetY( float y );
459 * Set the position of an actor along the Z-axis.
460 * @param [in] z The new z position
462 void SetZ( float z );
465 * Translate an actor relative to its existing position.
466 * @param[in] distance The actor will move by this distance.
468 void TranslateBy( const Vector3& distance );
471 * Retrieve the position of the Actor.
472 * The coordinates are relative to the Actor's parent.
473 * @return the Actor's position.
475 const Vector3& GetCurrentPosition() const;
478 * Retrieve the target position of the Actor.
479 * The coordinates are relative to the Actor's parent.
480 * @return the Actor's position.
482 const Vector3& GetTargetPosition() const;
485 * @copydoc Dali::Actor::GetCurrentWorldPosition()
487 const Vector3& GetCurrentWorldPosition() const;
490 * @copydoc Dali::Actor::SetPositionInheritanceMode()
492 void SetPositionInheritanceMode( PositionInheritanceMode mode );
495 * @copydoc Dali::Actor::GetPositionInheritanceMode()
497 PositionInheritanceMode GetPositionInheritanceMode() const;
500 * Sets the orientation of the Actor.
501 * @param [in] angleRadians The new orientation angle in radians.
502 * @param [in] axis The new axis of orientation.
504 void SetOrientation( const Radian& angleRadians, const Vector3& axis );
507 * Sets the orientation of the Actor.
508 * @param [in] orientation The new orientation.
510 void SetOrientation( const Quaternion& orientation );
513 * Rotate an actor around its existing rotation axis.
514 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
515 * @param[in] axis The axis of the rotation to combine with the existing rotation.
517 void RotateBy( const Radian& angleRadians, const Vector3& axis );
520 * Apply a relative rotation to an actor.
521 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
523 void RotateBy( const Quaternion& relativeRotation );
526 * Retreive the Actor's orientation.
527 * @return the orientation.
529 const Quaternion& GetCurrentOrientation() const;
532 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
533 * Switching this off means that using SetOrientation() sets the actor's world orientation.
534 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
536 void SetInheritOrientation( bool inherit );
539 * Returns whether the actor inherit's it's parent's orientation.
540 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
542 bool IsOrientationInherited() const;
545 * Sets the factor of the parents size used for the child actor.
546 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
547 * @param[in] factor The vector to multiply the parents size by to get the childs size.
549 void SetSizeModeFactor( const Vector3& factor );
552 * Gets the factor of the parents size used for the child actor.
553 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
554 * @return The vector being used to multiply the parents size by to get the childs size.
556 const Vector3& GetSizeModeFactor() const;
559 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
561 const Quaternion& GetCurrentWorldOrientation() const;
564 * Sets a scale factor applied to an actor.
565 * @param [in] scale The scale factor applied on all axes.
567 void SetScale( float scale );
570 * Sets a scale factor applied to an actor.
571 * @param [in] scaleX The scale factor applied along the x-axis.
572 * @param [in] scaleY The scale factor applied along the y-axis.
573 * @param [in] scaleZ The scale factor applied along the z-axis.
575 void SetScale( float scaleX, float scaleY, float scaleZ );
578 * Sets a scale factor applied to an actor.
579 * @param [in] scale A vector representing the scale factor for each axis.
581 void SetScale( const Vector3& scale );
584 * Set the x component of the scale factor.
585 * @param [in] x The new x value.
587 void SetScaleX( float x );
590 * Set the y component of the scale factor.
591 * @param [in] y The new y value.
593 void SetScaleY( float y );
596 * Set the z component of the scale factor.
597 * @param [in] z The new z value.
599 void SetScaleZ( float z );
602 * Apply a relative scale to an actor.
603 * @param[in] relativeScale The scale to combine with the actors existing scale.
605 void ScaleBy( const Vector3& relativeScale );
608 * Retrieve the scale factor applied to an actor.
609 * @return A vector representing the scale factor for each axis.
611 const Vector3& GetCurrentScale() const;
614 * @copydoc Dali::Actor::GetCurrentWorldScale()
616 const Vector3& GetCurrentWorldScale() const;
619 * @copydoc Dali::Actor::SetInheritScale()
621 void SetInheritScale( bool inherit );
624 * @copydoc Dali::Actor::IsScaleInherited()
626 bool IsScaleInherited() const;
629 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
631 Matrix GetCurrentWorldMatrix() const;
636 * Sets the visibility flag of an actor.
637 * @param [in] visible The new visibility flag.
639 void SetVisible( bool visible );
642 * Retrieve the visibility flag of an actor.
643 * @return The visibility flag.
645 bool IsVisible() const;
648 * Sets the opacity of an actor.
649 * @param [in] opacity The new opacity.
651 void SetOpacity( float opacity );
654 * Retrieve the actor's opacity.
655 * @return The actor's opacity.
657 float GetCurrentOpacity() const;
660 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
661 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
662 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
663 * hover event signal will be emitted.
665 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
667 * actor.SetSensitive(false);
670 * Then, to re-enable the touch or hover event signal emission, the application should call:
672 * actor.SetSensitive(true);
675 * @see SignalTouch() and SignalHover().
676 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
677 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
679 void SetSensitive( bool sensitive )
681 mSensitive = sensitive;
685 * Query whether an actor emits touch or hover event signals.
686 * @see SetSensitive(bool)
687 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
689 bool IsSensitive() const
695 * @copydoc Dali::Actor::SetDrawMode
697 void SetDrawMode( DrawMode::Type drawMode );
700 * @copydoc Dali::Actor::GetDrawMode
702 DrawMode::Type GetDrawMode() const;
705 * @copydoc Dali::Actor::SetOverlay
707 void SetOverlay( bool enable );
710 * @copydoc Dali::Actor::IsOverlay
712 bool IsOverlay() const;
715 * Sets whether an actor transmits geometry scaling to it's children.
716 * The default value is for it not to transmit scaling.
717 * @param[in] transmitGeometryScaling True to transmit scaling.
719 void SetTransmitGeometryScaling( bool transmitGeometryScaling );
722 * Get the TransmitGeometryScaling property for this actor.
723 * @return True if geometry scaling is applied to the inherited scale.
725 bool GetTransmitGeometryScaling() const;
728 * Sets the initial volume of the actor. Used for scaling the
729 * actor appropriately as the actor is sized when transmitGeometryScaling
732 * @param[in] volume the volume of the model and it's children
734 void SetInitialVolume( const Vector3& volume );
737 * Sets the actor's color. The final color of actor depends on its color mode.
738 * This final color is applied to the drawable elements of an actor.
739 * @param [in] color The new color.
741 void SetColor( const Vector4& color );
744 * Set the red component of the color.
745 * @param [in] red The new red component.
747 void SetColorRed( float red );
750 * Set the green component of the color.
751 * @param [in] green The new green component.
753 void SetColorGreen( float green );
756 * Set the blue component of the scale factor.
757 * @param [in] blue The new blue value.
759 void SetColorBlue( float blue );
762 * Retrieve the actor's color.
765 const Vector4& GetCurrentColor() const;
768 * Sets the actor's color mode.
769 * Color mode specifies whether Actor uses its own color or inherits its parent color
770 * @param [in] colorMode to use.
772 void SetColorMode( ColorMode colorMode );
775 * Returns the actor's color mode.
776 * @return currently used colorMode.
778 ColorMode GetColorMode() const;
781 * @copydoc Dali::Actor::GetCurrentWorldColor()
783 const Vector4& GetCurrentWorldColor() const;
787 // Size negotiation virtual functions
790 * @brief Called after the size negotiation has been finished for this control.
792 * The control is expected to assign this given size to itself/its children.
794 * Should be overridden by derived classes if they need to layout
795 * actors differently after certain operations like add or remove
796 * actors, resize or after changing specific properties.
798 * Note! As this function is called from inside the size negotiation algorithm, you cannot
799 * call RequestRelayout (the call would just be ignored)
801 * @param[in] size The allocated size.
802 * @param[in,out] container The control should add actors to this container that it is not able
803 * to allocate a size for.
805 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
810 * @brief Notification for deriving classes when the resize policy is set
812 * @param[in] policy The policy being set
813 * @param[in] dimension The dimension the policy is being set for
815 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
818 * @brief Virtual method to notify deriving classes that relayout dependencies have been
819 * met and the size for this object is about to be calculated for the given dimension
821 * @param dimension The dimension that is about to be calculated
823 virtual void OnCalculateRelayoutSize( Dimension::Type dimension );
826 * @brief Virtual method to notify deriving classes that the size for a dimension
827 * has just been negotiated
829 * @param[in] size The new size for the given dimension
830 * @param[in] dimension The dimension that was just negotiated
832 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension );
835 * @brief Determine if this actor is dependent on it's children for relayout
837 * @param dimension The dimension(s) to check for
838 * @return Return if the actor is dependent on it's children
840 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
843 * @brief Determine if this actor is dependent on it's children for relayout.
845 * Called from deriving classes
847 * @param dimension The dimension(s) to check for
848 * @return Return if the actor is dependent on it's children
850 virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
853 * @brief Calculate the size for a child
855 * @param[in] child The child actor to calculate the size for
856 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
857 * @return Return the calculated size for the given dimension
859 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
862 * @brief This method is called during size negotiation when a height is required for a given width.
864 * Derived classes should override this if they wish to customize the height returned.
866 * @param width to use.
867 * @return the height based on the width.
869 virtual float GetHeightForWidth( float width );
872 * @brief This method is called during size negotiation when a width is required for a given height.
874 * Derived classes should override this if they wish to customize the width returned.
876 * @param height to use.
877 * @return the width based on the width.
879 virtual float GetWidthForHeight( float height );
886 * @brief Called by the RelayoutController to negotiate the size of an actor.
888 * The size allocated by the the algorithm is passed in which the
889 * actor must adhere to. A container is passed in as well which
890 * the actor should populate with actors it has not / or does not
891 * need to handle in its size negotiation.
893 * @param[in] size The allocated size.
894 * @param[in,out] container The container that holds actors that are fed back into the
895 * RelayoutController algorithm.
897 void NegotiateSize( const Vector2& size, RelayoutContainer& container );
900 * @copydoc Dali::Actor::SetResizePolicy()
902 void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
905 * @copydoc Dali::Actor::GetResizePolicy()
907 ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
910 * @copydoc Dali::Actor::SetSizeScalePolicy()
912 void SetSizeScalePolicy( SizeScalePolicy::Type policy );
915 * @copydoc Dali::Actor::GetSizeScalePolicy()
917 SizeScalePolicy::Type GetSizeScalePolicy() const;
920 * @copydoc Dali::Actor::SetDimensionDependency()
922 void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
925 * @copydoc Dali::Actor::GetDimensionDependency()
927 Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
930 * @brief Set the size negotiation relayout enabled on this actor
932 * @param[in] relayoutEnabled Boolean to enable or disable relayout
934 void SetRelayoutEnabled( bool relayoutEnabled );
937 * @brief Return if relayout is enabled
939 * @return Return if relayout is enabled or not for this actor
941 bool IsRelayoutEnabled() const;
944 * @brief Mark an actor as having it's layout dirty
946 * @param dirty Whether to mark actor as dirty or not
947 * @param dimension The dimension(s) to mark as dirty
949 void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
952 * @brief Return if any of an actor's dimensions are marked as dirty
954 * @param dimension The dimension(s) to check
955 * @return Return if any of the requested dimensions are dirty
957 bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
960 * @brief Returns if relayout is enabled and the actor is not dirty
962 * @return Return if it is possible to relayout the actor
964 bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
967 * @brief Returns if relayout is enabled and the actor is dirty
969 * @return Return if it is required to relayout the actor
971 bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
974 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
976 * This method is automatically called from OnStageConnection(), OnChildAdd(),
977 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
979 * This method can also be called from a derived class every time it needs a different size.
980 * At the end of event processing, the relayout process starts and
981 * all controls which requested Relayout will have their sizes (re)negotiated.
983 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
984 * only performed once, i.e. there is no need to keep track of this in the calling side.
986 void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
989 * @copydoc Dali::Actor::PropagateRelayoutFlags
991 void PropagateRelayoutFlags();
994 * @brief Determine if this actor is dependent on it's parent for relayout
996 * @param dimension The dimension(s) to check for
997 * @return Return if the actor is dependent on it's parent
999 bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1002 * @brief Determine if this actor has another dimension depedent on the specified one
1004 * @param dimension The dimension to check for
1005 * @param dependentDimension The dimension to check for dependency with
1006 * @return Return if the actor is dependent on this dimension
1008 bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
1011 * Negotiate sizes for a control in all dimensions
1013 * @param[in] allocatedSize The size constraint that the control must respect
1015 void NegotiateDimensions( const Vector2& allocatedSize );
1018 * Negotiate size for a specific dimension
1020 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1021 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1022 * LayoutDimensionNegotiated flags being filled in on the actor.
1024 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1025 * calculated and set as well as the LayoutDimensionNegotiated flags.
1027 * @param[in] dimension The dimension to negotiate on
1028 * @param[in] allocatedSize The size constraint that the actor must respect
1030 void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1033 * @brief Calculate the size of a dimension
1035 * @param[in] dimension The dimension to calculate the size for
1036 * @param[in] maximumSize The upper bounds on the size
1037 * @return Return the calculated size for the dimension
1039 float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1042 * @brief Clamp a dimension given the relayout constraints on this actor
1044 * @param[in] size The size to constrain
1045 * @param[in] dimension The dimension the size exists in
1046 * @return Return the clamped size
1048 float ClampDimension( float size, Dimension::Type dimension );
1051 * Negotiate a dimension based on the size of the parent
1053 * @param[in] dimension The dimension to negotiate on
1054 * @return Return the negotiated size
1056 float NegotiateFromParent( Dimension::Type dimension );
1059 * Negotiate a dimension based on the size of the parent. Fitting inside.
1061 * @param[in] dimension The dimension to negotiate on
1062 * @return Return the negotiated size
1064 float NegotiateFromParentFit( Dimension::Type dimension );
1067 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1069 * @param[in] dimension The dimension to negotiate on
1070 * @return Return the negotiated size
1072 float NegotiateFromParentFlood( Dimension::Type dimension );
1075 * @brief Negotiate a dimension based on the size of the children
1077 * @param[in] dimension The dimension to negotiate on
1078 * @return Return the negotiated size
1080 float NegotiateFromChildren( Dimension::Type dimension );
1083 * Set the negotiated dimension value for the given dimension(s)
1085 * @param negotiatedDimension The value to set
1086 * @param dimension The dimension(s) to set the value for
1088 void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1091 * Return the value of negotiated dimension for the given dimension
1093 * @param dimension The dimension to retrieve
1094 * @return Return the value of the negotiated dimension
1096 float GetNegotiatedDimension( Dimension::Type dimension ) const;
1099 * @brief Set the padding for a dimension
1101 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1102 * @param[in] dimension The dimension to set
1104 void SetPadding( const Vector2& padding, Dimension::Type dimension );
1107 * Return the value of padding for the given dimension
1109 * @param dimension The dimension to retrieve
1110 * @return Return the value of padding for the dimension
1112 Vector2 GetPadding( Dimension::Type dimension ) const;
1115 * Return the actor size for a given dimension
1117 * @param[in] dimension The dimension to retrieve the size for
1118 * @return Return the size for the given dimension
1120 float GetSize( Dimension::Type dimension ) const;
1123 * Return the natural size of the actor for a given dimension
1125 * @param[in] dimension The dimension to retrieve the size for
1126 * @return Return the natural size for the given dimension
1128 float GetNaturalSize( Dimension::Type dimension ) const;
1131 * @brief Return the amount of size allocated for relayout
1133 * May include padding
1135 * @param[in] dimension The dimension to retrieve
1136 * @return Return the size
1138 float GetRelayoutSize( Dimension::Type dimension ) const;
1141 * @brief If the size has been negotiated return that else return normal size
1143 * @param[in] dimension The dimension to retrieve
1144 * @return Return the size
1146 float GetLatestSize( Dimension::Type dimension ) const;
1149 * Apply the negotiated size to the actor
1151 * @param[in] container The container to fill with actors that require further relayout
1153 void SetNegotiatedSize( RelayoutContainer& container );
1156 * @brief Flag the actor as having it's layout dimension negotiated.
1158 * @param[in] negotiated The status of the flag to set.
1159 * @param[in] dimension The dimension to set the flag for
1161 void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1164 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1166 * @param[in] dimension The dimension to determine the value of the flag for
1167 * @return Return if the layout dimension is negotiated or not.
1169 bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1172 * @brief Calculate the size for a child
1174 * @param[in] child The child actor to calculate the size for
1175 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1176 * @return Return the calculated size for the given dimension
1178 float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1181 * @brief Set the preferred size for size negotiation
1183 * @param[in] size The preferred size to set
1185 void SetPreferredSize( const Vector2& size );
1188 * @brief Return the preferred size used for size negotiation
1190 * @return Return the preferred size
1192 Vector2 GetPreferredSize() const;
1195 * @copydoc Dali::Actor::SetMinimumSize
1197 void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1200 * @copydoc Dali::Actor::GetMinimumSize
1202 float GetMinimumSize( Dimension::Type dimension ) const;
1205 * @copydoc Dali::Actor::SetMaximumSize
1207 void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1210 * @copydoc Dali::Actor::GetMaximumSize
1212 float GetMaximumSize( Dimension::Type dimension ) const;
1214 #ifdef DYNAMICS_SUPPORT
1218 /// @copydoc Dali::Actor::DisableDynamics
1219 void DisableDynamics();
1221 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
1222 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
1224 /// @copydoc Dali::Actor::GetDynamicsBody
1225 DynamicsBodyPtr GetDynamicsBody() const;
1227 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
1228 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
1230 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
1231 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
1233 /// @copydoc Dali::Actor::GetNumberOfJoints
1234 const int GetNumberOfJoints() const;
1236 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
1237 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
1239 /// @copydoc Dali::Actor::GetDynamicsJoint
1240 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
1242 /// @copydoc Dali::Actor::RemoveDynamicsJoint
1243 void RemoveDynamicsJoint( DynamicsJointPtr joint );
1246 * Hold a reference to a DynamicsJoint
1247 * @param[in] joint The joint
1249 void ReferenceJoint( DynamicsJointPtr joint );
1252 * Release a reference to a DynamicsJoint
1253 * @param[in] joint The joint
1255 void ReleaseJoint( DynamicsJointPtr joint );
1258 * Set this actor to be the root actor in the dynamics simulation
1259 * All children of the actor are added/removed from the simulation.
1260 * @param[in] flag When true sets this actor to be the simulation world root actor and
1261 * if OnStage() all dynamics enabled child actors are added to the simulation,
1262 * when false stops this actor being the simulation root and if OnStage() all
1263 * dynamics enabled child actors are removed from the simulation.
1265 void SetDynamicsRoot(bool flag);
1269 * Check if this actor is the root actor in the dynamics simulation
1270 * @return true if this is the dynamics root actor.
1272 bool IsDynamicsRoot() const;
1275 * Add actor to the dynamics simulation
1276 * Invoked when the actor is staged, or it's parent becomes the simulation root
1278 void ConnectDynamics();
1281 * Remove actor from the dynamics simulation
1282 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
1284 void DisconnectDynamics();
1287 * An actor in a DynamicsJoint relationship has been staged
1288 * @param[in] actor The actor passed into AddDynamicsJoint()
1290 void AttachedActorOnStage( Dali::Actor actor );
1293 * An actor in a DynamicsJoint relationship has been unstaged
1294 * @param[in] actor The actor passed into AddDynamicsJoint()
1296 void AttachedActorOffStage( Dali::Actor actor );
1298 #endif // DYNAMICS_SUPPORT
1302 * Converts screen coordinates into the actor's coordinate system.
1303 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1304 * @param[out] localX On return, the X-coordinate relative to the actor.
1305 * @param[out] localY On return, the Y-coordinate relative to the actor.
1306 * @param[in] screenX The screen X-coordinate.
1307 * @param[in] screenY The screen Y-coordinate.
1308 * @return True if the conversion succeeded.
1310 bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const;
1313 * Converts screen coordinates into the actor's coordinate system.
1314 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1315 * @param[in] renderTask The render-task used to display the actor.
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( RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1325 * Converts from the actor's coordinate system to screen coordinates.
1326 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1327 * @param[in] viewMatrix The view-matrix
1328 * @param[in] projectionMatrix The projection-matrix
1329 * @param[in] viewport The view-port
1330 * @param[out] localX On return, the X-coordinate relative to the actor.
1331 * @param[out] localY On return, the Y-coordinate relative to the actor.
1332 * @param[in] screenX The screen X-coordinate.
1333 * @param[in] screenY The screen Y-coordinate.
1334 * @return True if the conversion succeeded.
1336 bool ScreenToLocal( const Matrix& viewMatrix,
1337 const Matrix& projectionMatrix,
1338 const Viewport& viewport,
1342 float screenY ) const;
1345 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1346 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1347 * @param[in] rayOrigin The ray origin in the world's reference system.
1348 * @param[in] rayDir The ray director vector in the world's reference system.
1349 * @return True if the ray intersects the actor's bounding sphere.
1351 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1354 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1355 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1356 * @param[in] rayOrigin The ray origin in the world's reference system.
1357 * @param[in] rayDir The ray director vector in the world's reference system.
1358 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1359 * @param[out] distance The distance from the hit point to the camera.
1360 * @return True if the ray intersects the actor's geometry.
1362 bool RayActorTest( const Vector4& rayOrigin,
1363 const Vector4& rayDir,
1364 Vector4& hitPointLocal,
1365 float& distance ) const;
1368 * Sets whether the actor should receive a notification when touch or hover motion events leave
1369 * the boundary of the actor.
1371 * @note By default, this is set to false as most actors do not require this.
1372 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1374 * @param[in] required Should be set to true if a Leave event is required
1376 void SetLeaveRequired( bool required );
1379 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1380 * the boundary of the actor.
1381 * @return true if a Leave event is required, false otherwise.
1383 bool GetLeaveRequired() const;
1386 * @copydoc Dali::Actor::SetKeyboardFocusable()
1388 void SetKeyboardFocusable( bool focusable );
1391 * @copydoc Dali::Actor::IsKeyboardFocusable()
1393 bool IsKeyboardFocusable() const;
1396 * Query whether the application or derived actor type requires touch events.
1397 * @return True if touch events are required.
1399 bool GetTouchRequired() const;
1402 * Query whether the application or derived actor type requires hover events.
1403 * @return True if hover events are required.
1405 bool GetHoverRequired() const;
1408 * Query whether the application or derived actor type requires mouse wheel events.
1409 * @return True if mouse wheel events are required.
1411 bool GetMouseWheelEventRequired() const;
1414 * Query whether the actor is actually hittable. This method checks whether the actor is
1415 * sensitive, has the visibility flag set to true and is not fully transparent.
1416 * @return true, if it can be hit, false otherwise.
1418 bool IsHittable() const;
1423 * Retrieve the gesture data associated with this actor. The first call to this method will
1424 * allocate space for the ActorGestureData so this should only be called if an actor really does
1426 * @return Reference to the ActorGestureData for this actor.
1427 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1428 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1430 ActorGestureData& GetGestureData();
1433 * Queries whether the actor requires the gesture type.
1434 * @param[in] type The gesture type.
1436 bool IsGestureRequred( Gesture::Type type ) const;
1441 * Used by the EventProcessor to emit touch event signals.
1442 * @param[in] event The touch event.
1443 * @return True if the event was consumed.
1445 bool EmitTouchEventSignal( const TouchEvent& event );
1448 * Used by the EventProcessor to emit hover event signals.
1449 * @param[in] event The hover event.
1450 * @return True if the event was consumed.
1452 bool EmitHoverEventSignal( const HoverEvent& event );
1455 * Used by the EventProcessor to emit mouse wheel event signals.
1456 * @param[in] event The mouse wheel event.
1457 * @return True if the event was consumed.
1459 bool EmitMouseWheelEventSignal( const MouseWheelEvent& event );
1462 * @copydoc Dali::Actor::TouchedSignal()
1464 Dali::Actor::TouchSignalType& TouchedSignal();
1467 * @copydoc Dali::Actor::HoveredSignal()
1469 Dali::Actor::HoverSignalType& HoveredSignal();
1472 * @copydoc Dali::Actor::MouseWheelEventSignal()
1474 Dali::Actor::MouseWheelEventSignalType& MouseWheelEventSignal();
1477 * @copydoc Dali::Actor::OnStageSignal()
1479 Dali::Actor::OnStageSignalType& OnStageSignal();
1482 * @copydoc Dali::Actor::OffStageSignal()
1484 Dali::Actor::OffStageSignalType& OffStageSignal();
1487 * @copydoc Dali::Actor::OnRelayoutSignal()
1489 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1492 * Connects a callback function with the object's signals.
1493 * @param[in] object The object providing the signal.
1494 * @param[in] tracker Used to disconnect the signal.
1495 * @param[in] signalName The signal to connect to.
1496 * @param[in] functor A newly allocated FunctorDelegate.
1497 * @return True if the signal was connected.
1498 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1500 static bool DoConnectSignal( BaseObject* object,
1501 ConnectionTrackerInterface* tracker,
1502 const std::string& signalName,
1503 FunctorDelegate* functor );
1506 * Performs actions as requested using the action name.
1507 * @param[in] object The object on which to perform the action.
1508 * @param[in] actionName The action to perform.
1509 * @param[in] attributes The attributes with which to perfrom this action.
1510 * @return true if the action was done.
1512 static bool DoAction( BaseObject* object,
1513 const std::string& actionName,
1514 const std::vector< Property::Value >& attributes );
1520 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1522 * @param[in] animation The animation that resized the actor
1523 * @param[in] targetSize The new target size of the actor
1525 void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1528 * For use in derived classes.
1529 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1531 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1539 BASIC, RENDERABLE, LAYER, ROOT_LAYER
1543 * Protected Constructor. See Actor::New().
1544 * The second-phase construction Initialize() member should be called immediately after this.
1545 * @param[in] derivedType The derived type of actor (if any).
1547 Actor( DerivedType derivedType );
1550 * Second-phase constructor. Must be called immediately after creating a new Actor;
1552 void Initialize( void );
1555 * A reference counted object may only be deleted by calling Unreference()
1560 * Called on a child during Add() when the parent actor is connected to the Stage.
1561 * @param[in] stage The stage.
1562 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1564 void ConnectToStage( int index = -1 );
1567 * Helper for ConnectToStage, to recursively connect a tree of actors.
1568 * This is atomic i.e. not interrupted by user callbacks.
1569 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1570 * @param[out] connectionList On return, the list of connected actors which require notification.
1572 void RecursiveConnectToStage( ActorContainer& connectionList, int index = -1 );
1575 * Connect the Node associated with this Actor to the scene-graph.
1576 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1578 void ConnectToSceneGraph( int index = -1 );
1581 * Helper for ConnectToStage, to notify a connected actor through the public API.
1583 void NotifyStageConnection();
1586 * Called on a child during Remove() when the actor was previously on the Stage.
1588 void DisconnectFromStage();
1591 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1592 * This is atomic i.e. not interrupted by user callbacks.
1593 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1595 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1598 * Disconnect the Node associated with this Actor from the scene-graph.
1600 void DisconnectFromSceneGraph();
1603 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1605 void NotifyStageDisconnection();
1608 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1609 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1611 bool IsNodeConnected() const;
1614 * Calculate the size of the z dimension for a 2D size
1616 * @param[in] size The 2D size (X, Y) to calculate Z from
1618 * @return Return the Z dimension for this size
1620 float CalculateSizeZ( const Vector2& size ) const;
1623 // Default property extensions from Object
1626 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1628 virtual unsigned int GetDefaultPropertyCount() const;
1631 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1633 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1636 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1638 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1641 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1643 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1646 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1648 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1651 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1653 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1656 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1658 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1661 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1663 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1666 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1668 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1671 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1673 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1676 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1678 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1681 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1683 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1686 * @copydoc Dali::Internal::Object::GetSceneObject()
1688 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1691 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1693 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1696 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1698 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1701 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1703 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1711 Actor( const Actor& );
1714 Actor& operator=( const Actor& rhs );
1717 * Set the actors parent.
1718 * @param[in] parent The new parent.
1719 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1721 void SetParent( Actor* parent, int index = -1 );
1724 * Helper to create a Node for this Actor.
1725 * To be overriden in derived classes.
1726 * @return A newly allocated node.
1728 virtual SceneGraph::Node* CreateNode() const;
1731 * For use in derived classes, called after Initialize()
1733 virtual void OnInitialize()
1738 * For use in internal derived classes.
1739 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1740 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1742 virtual void OnStageConnectionInternal()
1747 * For use in internal derived classes.
1748 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1749 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1751 virtual void OnStageDisconnectionInternal()
1756 * For use in external (CustomActor) derived classes.
1757 * This is called after the atomic ConnectToStage() traversal has been completed.
1759 virtual void OnStageConnectionExternal()
1764 * For use in external (CustomActor) derived classes.
1765 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1767 virtual void OnStageDisconnectionExternal()
1772 * For use in derived classes; this is called after Add() has added a child.
1773 * @param[in] child The child that was added.
1775 virtual void OnChildAdd( Actor& child )
1780 * For use in derived classes; this is called after Remove() has removed a child.
1781 * @param[in] child The child that was removed.
1783 virtual void OnChildRemove( Actor& child )
1788 * For use in derived classes.
1789 * This is called after SizeSet() has been called.
1791 virtual void OnSizeSet( const Vector3& targetSize )
1796 * For use in derived classes.
1797 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1798 * @param[in] event The touch event.
1799 * @return True if the event should be consumed.
1801 virtual bool OnTouchEvent( const TouchEvent& event )
1807 * For use in derived classes.
1808 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1809 * @param[in] event The hover event.
1810 * @return True if the event should be consumed.
1812 virtual bool OnHoverEvent( const HoverEvent& event )
1818 * For use in derived classes.
1819 * This is only called if the mouse wheel signal was not consumed.
1820 * @param[in] event The mouse event.
1821 * @return True if the event should be consumed.
1823 virtual bool OnMouseWheelEvent( const MouseWheelEvent& event )
1829 * @brief Ensure the relayout data is allocated
1831 void EnsureRelayoutData() const;
1834 * @brief Apply the size set policy to the input size
1836 * @param[in] size The size to apply the policy to
1837 * @return Return the adjusted size
1839 Vector2 ApplySizeSetPolicy( const Vector2 size );
1843 StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
1844 Actor* mParent; ///< Each actor (except the root) can have one parent
1845 ActorContainer* mChildren; ///< Container of referenced actors
1846 const SceneGraph::Node* mNode; ///< Not owned
1847 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1848 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1850 struct RelayoutData;
1851 mutable RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1853 #ifdef DYNAMICS_SUPPORT
1854 DynamicsData* mDynamicsData; ///< optional physics data
1857 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1859 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1862 Dali::Actor::TouchSignalType mTouchedSignal;
1863 Dali::Actor::HoverSignalType mHoveredSignal;
1864 Dali::Actor::MouseWheelEventSignalType mMouseWheelEventSignal;
1865 Dali::Actor::OnStageSignalType mOnStageSignal;
1866 Dali::Actor::OffStageSignalType mOffStageSignal;
1867 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1869 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1870 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
1872 std::string mName; ///< Name of the actor
1873 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1875 const bool mIsRoot : 1; ///< Flag to identify the root actor
1876 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1877 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1878 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1879 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1880 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1881 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1882 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1883 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1884 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1885 bool mDerivedRequiresMouseWheelEvent : 1; ///< Whether the derived actor type requires mouse wheel event signals
1886 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1887 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1888 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1889 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1890 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1891 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1895 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1896 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1900 } // namespace Internal
1902 // Helpers for public-api forwarding methods
1904 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
1906 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1908 BaseObject& handle = actor.GetBaseObject();
1910 return static_cast< Internal::Actor& >( handle );
1913 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
1915 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1917 const BaseObject& handle = actor.GetBaseObject();
1919 return static_cast< const Internal::Actor& >( handle );
1924 #endif // __DALI_INTERNAL_ACTOR_H__