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/actors/actor.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/public-api/events/gesture.h>
29 #include <dali/public-api/math/viewport.h>
30 #include <dali/public-api/object/ref-object.h>
31 #include <dali/public-api/size-negotiation/relayout-container.h>
32 #include <dali/internal/event/actors/actor-declarations.h>
33 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
34 #include <dali/internal/event/common/object-impl.h>
35 #include <dali/internal/event/common/stage-def.h>
36 #include <dali/internal/event/rendering/renderer-impl.h>
37 #include <dali/internal/update/nodes/node-declarations.h>
39 #ifdef DALI_DYNAMICS_SUPPORT
40 #include <dali/internal/event/dynamics/dynamics-declarations.h>
55 class ActorGestureData;
61 typedef std::vector< ActorPtr > ActorContainer;
62 typedef ActorContainer::iterator ActorIter;
63 typedef ActorContainer::const_iterator ActorConstIter;
66 * Actor is the primary object which Dali applications interact with.
67 * UI controls can be built by combining multiple actors.
68 * Multi-Touch events are received through signals emitted by the actor tree.
70 * An Actor is a proxy for a Node in the scene graph.
71 * When an Actor is added to the Stage, it creates a node and attaches it to the scene graph.
72 * The scene-graph can be updated in a separate thread, so the attachment is done using an asynchronous message.
73 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
75 class Actor : public Object
80 * @brief Struct to hold an actor and a dimension
82 struct ActorDimensionPair
87 * @param[in] newActor The actor to assign
88 * @param[in] newDimension The dimension to assign
90 ActorDimensionPair( Actor* newActor, Dimension::Type newDimension )
92 dimension( newDimension )
97 * @brief Equality operator
99 * @param[in] lhs The left hand side argument
100 * @param[in] rhs The right hand side argument
102 bool operator== ( const ActorDimensionPair& rhs )
104 return ( actor == rhs.actor ) && ( dimension == rhs.dimension );
107 Actor* actor; ///< The actor to hold
108 Dimension::Type dimension; ///< The dimension to hold
111 typedef std::vector< ActorDimensionPair > ActorDimensionStack;
116 * Create a new actor.
117 * @return A smart-pointer to the newly allocated Actor.
119 static ActorPtr New();
122 * Retrieve the name of the actor.
125 const std::string& GetName() const;
128 * Set the name of the actor.
129 * @param[in] name The new name.
131 void SetName( const std::string& name );
134 * @copydoc Dali::Actor::GetId
136 unsigned int GetId() const;
141 * Attach an object to an actor.
142 * @pre The actor does not already have an attachment.
143 * @param[in] attachment The object to attach.
145 void Attach( ActorAttachment& attachment );
148 * Retreive the object attached to an actor.
149 * @return The attachment.
151 ActorAttachmentPtr GetAttachment();
156 * Query whether an actor is the root actor, which is owned by the Stage.
157 * @return True if the actor is a root actor.
165 * Query whether the actor is connected to the Stage.
167 bool OnStage() const;
170 * Query whether the actor is a RenderableActor derived type.
171 * @return True if the actor is renderable.
173 bool IsRenderable() const
175 // inlined as this is called a lot in hit testing
176 return mIsRenderable;
180 * Query whether the actor is of class Dali::Layer
181 * @return True if the actor is a layer.
185 // inlined as this is called a lot in hit testing
190 * Gets the layer in which the actor is present
191 * @return The layer, which will be uninitialized if the actor is off-stage.
193 Dali::Layer GetLayer();
196 * Adds a child Actor to this Actor.
197 * @pre The child actor is not the same as the parent actor.
198 * @pre The child actor does not already have a parent.
199 * @param [in] child The child.
200 * @post The child will be referenced by its parent.
202 void Add( Actor& child );
205 * Inserts a child Actor to this Actor's child list
206 * @pre The child actor is not the same as the parent actor.
207 * @pre The child actor does not already have a parent.
208 * @param [in] index in childlist to insert child at
209 * @param [in] child The child.
210 * @post The child will be referenced by its parent.
212 void Insert( unsigned int index, Actor& child );
215 * Removes a child Actor from this Actor.
216 * @param [in] child The child.
217 * @post The child will be unreferenced.
219 void Remove( Actor& child );
222 * @copydoc Dali::Actor::Unparent
227 * Retrieve the number of children held by the actor.
228 * @return The number of children
230 unsigned int GetChildCount() const;
233 * @copydoc Dali::Actor::GetChildAt
235 ActorPtr GetChildAt( unsigned int index ) const;
238 * Retrieve a reference to Actor's children.
239 * @note Not for public use.
240 * @return A reference to the container of children.
242 ActorContainer& GetChildrenInternal()
248 * @copydoc Dali::Actor::FindChildByName
250 ActorPtr FindChildByName( const std::string& actorName );
253 * @copydoc Dali::Actor::FindChildById
255 ActorPtr FindChildById( const unsigned int id );
258 * Retrieve the parent of an Actor.
259 * @return The parent actor, or NULL if the Actor does not have a parent.
261 Actor* GetParent() const
267 * Sets the size of an actor.
268 * ActorAttachments attached to the actor, can be scaled to fit within this area.
269 * This does not interfere with the actors scale factor.
270 * @param [in] width The new width.
271 * @param [in] height The new height.
273 void SetSize( float width, float height );
276 * Sets the size of an actor.
277 * ActorAttachments attached to the actor, can be scaled to fit within this area.
278 * This does not interfere with the actors scale factor.
279 * @param [in] width The size of the actor along the x-axis.
280 * @param [in] height The size of the actor along the y-axis.
281 * @param [in] depth The size of the actor along the z-axis.
283 void SetSize( float width, float height, float depth );
286 * Sets the size of an actor.
287 * ActorAttachments attached to the actor, can be scaled to fit within this area.
288 * This does not interfere with the actors scale factor.
289 * @param [in] size The new size.
291 void SetSize( const Vector2& size );
294 * Sets the update size for an actor.
296 * @param[in] size The size to set.
298 void SetSizeInternal( const Vector2& size );
301 * Sets the size of an actor.
302 * ActorAttachments attached to the actor, can be scaled to fit within this area.
303 * This does not interfere with the actors scale factor.
304 * @param [in] size The new size.
306 void SetSize( const Vector3& size );
309 * Sets the update size for an actor.
311 * @param[in] size The size to set.
313 void SetSizeInternal( const Vector3& size );
316 * Set the width component of the Actor's size.
317 * @param [in] width The new width component.
319 void SetWidth( float width );
322 * Set the height component of the Actor's size.
323 * @param [in] height The new height component.
325 void SetHeight( float height );
328 * Set the depth component of the Actor's size.
329 * @param [in] depth The new depth component.
331 void SetDepth( float depth );
334 * Retrieve the Actor's size from event side.
335 * This size will be the size set or if animating then the target size.
336 * @return The Actor's size.
338 const Vector3& GetTargetSize() const;
341 * Retrieve the Actor's size from update side.
342 * This size will be the size set or animating but will be a frame behind.
343 * @return The Actor's size.
345 const Vector3& GetCurrentSize() const;
348 * Return the natural size of the actor
350 * @return The actor's natural size
352 virtual Vector3 GetNaturalSize() const;
355 * Set the origin of an actor, within its parent's area.
356 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
357 * and (1.0, 1.0, 0.5) is the bottom-right corner.
358 * The default parent-origin is top-left (0.0, 0.0, 0.5).
359 * An actor position is the distance between this origin, and the actors anchor-point.
360 * @param [in] origin The new parent-origin.
362 void SetParentOrigin( const Vector3& origin );
365 * Set the x component of the parent-origin
366 * @param [in] x The new x value.
368 void SetParentOriginX( float x );
371 * Set the y component of the parent-origin
372 * @param [in] y The new y value.
374 void SetParentOriginY( float y );
377 * Set the z component of the parent-origin
378 * @param [in] z The new z value.
380 void SetParentOriginZ( float z );
383 * Retrieve the parent-origin of an actor.
384 * @return The parent-origin.
386 const Vector3& GetCurrentParentOrigin() const;
389 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
390 * (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.
391 * The default anchor point is top-left (0.0, 0.0, 0.5).
392 * An actor position is the distance between its parent-origin, and this anchor-point.
393 * An actor's rotation is centered around its anchor-point.
394 * @param [in] anchorPoint The new anchor-point.
396 void SetAnchorPoint( const Vector3& anchorPoint );
399 * Set the x component of the anchor-point.
400 * @param [in] x The new x value.
402 void SetAnchorPointX( float x );
405 * Set the y component of the anchor-point.
406 * @param [in] y The new y value.
408 void SetAnchorPointY( float y );
411 * Set the z component of the anchor-point.
412 * @param [in] z The new z value.
414 void SetAnchorPointZ( float z );
417 * Retrieve the anchor-point of an actor.
418 * @return The anchor-point.
420 const Vector3& GetCurrentAnchorPoint() const;
423 * Sets the position of the Actor.
424 * The coordinates are relative to the Actor's parent.
425 * The Actor's z position will be set to 0.0f.
426 * @param [in] x The new x position
427 * @param [in] y The new y position
429 void SetPosition( float x, float y );
432 * Sets the position of the Actor.
433 * The coordinates are relative to the Actor's parent.
434 * @param [in] x The new x position
435 * @param [in] y The new y position
436 * @param [in] z The new z position
438 void SetPosition( float x, float y, float z );
441 * Sets the position of the Actor.
442 * The coordinates are relative to the Actor's parent.
443 * @param [in] position The new position.
445 void SetPosition( const Vector3& position );
448 * Set the position of an actor along the X-axis.
449 * @param [in] x The new x position
451 void SetX( float x );
454 * Set the position of an actor along the Y-axis.
455 * @param [in] y The new y position.
457 void SetY( float y );
460 * Set the position of an actor along the Z-axis.
461 * @param [in] z The new z position
463 void SetZ( float z );
466 * Translate an actor relative to its existing position.
467 * @param[in] distance The actor will move by this distance.
469 void TranslateBy( const Vector3& distance );
472 * Retrieve the position of the Actor.
473 * The coordinates are relative to the Actor's parent.
474 * @return the Actor's position.
476 const Vector3& GetCurrentPosition() const;
479 * Retrieve the target position of the Actor.
480 * The coordinates are relative to the Actor's parent.
481 * @return the Actor's position.
483 const Vector3& GetTargetPosition() const;
486 * @copydoc Dali::Actor::GetCurrentWorldPosition()
488 const Vector3& GetCurrentWorldPosition() const;
491 * @copydoc Dali::Actor::SetPositionInheritanceMode()
493 void SetPositionInheritanceMode( PositionInheritanceMode mode );
496 * @copydoc Dali::Actor::GetPositionInheritanceMode()
498 PositionInheritanceMode GetPositionInheritanceMode() const;
501 * Sets the orientation of the Actor.
502 * @param [in] angleRadians The new orientation angle in radians.
503 * @param [in] axis The new axis of orientation.
505 void SetOrientation( const Radian& angleRadians, const Vector3& axis );
508 * Sets the orientation of the Actor.
509 * @param [in] orientation The new orientation.
511 void SetOrientation( const Quaternion& orientation );
514 * Rotate an actor around its existing rotation axis.
515 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
516 * @param[in] axis The axis of the rotation to combine with the existing rotation.
518 void RotateBy( const Radian& angleRadians, const Vector3& axis );
521 * Apply a relative rotation to an actor.
522 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
524 void RotateBy( const Quaternion& relativeRotation );
527 * Retreive the Actor's orientation.
528 * @return the orientation.
530 const Quaternion& GetCurrentOrientation() const;
533 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
534 * Switching this off means that using SetOrientation() sets the actor's world orientation.
535 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
537 void SetInheritOrientation( bool inherit );
540 * Returns whether the actor inherit's it's parent's orientation.
541 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
543 bool IsOrientationInherited() const;
546 * Sets the factor of the parents size used for the child actor.
547 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
548 * @param[in] factor The vector to multiply the parents size by to get the childs size.
550 void SetSizeModeFactor( const Vector3& factor );
553 * Gets the factor of the parents size used for the child actor.
554 * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
555 * @return The vector being used to multiply the parents size by to get the childs size.
557 const Vector3& GetSizeModeFactor() const;
560 * @copydoc Dali::Actor::GetCurrentWorldOrientation()
562 const Quaternion& GetCurrentWorldOrientation() const;
565 * Sets a scale factor applied to an actor.
566 * @param [in] scale The scale factor applied on all axes.
568 void SetScale( float scale );
571 * Sets a scale factor applied to an actor.
572 * @param [in] scaleX The scale factor applied along the x-axis.
573 * @param [in] scaleY The scale factor applied along the y-axis.
574 * @param [in] scaleZ The scale factor applied along the z-axis.
576 void SetScale( float scaleX, float scaleY, float scaleZ );
579 * Sets a scale factor applied to an actor.
580 * @param [in] scale A vector representing the scale factor for each axis.
582 void SetScale( const Vector3& scale );
585 * Set the x component of the scale factor.
586 * @param [in] x The new x value.
588 void SetScaleX( float x );
591 * Set the y component of the scale factor.
592 * @param [in] y The new y value.
594 void SetScaleY( float y );
597 * Set the z component of the scale factor.
598 * @param [in] z The new z value.
600 void SetScaleZ( float z );
603 * Apply a relative scale to an actor.
604 * @param[in] relativeScale The scale to combine with the actors existing scale.
606 void ScaleBy( const Vector3& relativeScale );
609 * Retrieve the scale factor applied to an actor.
610 * @return A vector representing the scale factor for each axis.
612 const Vector3& GetCurrentScale() const;
615 * @copydoc Dali::Actor::GetCurrentWorldScale()
617 const Vector3& GetCurrentWorldScale() const;
620 * @copydoc Dali::Actor::SetInheritScale()
622 void SetInheritScale( bool inherit );
625 * @copydoc Dali::Actor::IsScaleInherited()
627 bool IsScaleInherited() const;
630 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
632 Matrix GetCurrentWorldMatrix() const;
637 * Sets the visibility flag of an actor.
638 * @param [in] visible The new visibility flag.
640 void SetVisible( bool visible );
643 * Retrieve the visibility flag of an actor.
644 * @return The visibility flag.
646 bool IsVisible() const;
649 * Sets the opacity of an actor.
650 * @param [in] opacity The new opacity.
652 void SetOpacity( float opacity );
655 * Retrieve the actor's opacity.
656 * @return The actor's opacity.
658 float GetCurrentOpacity() const;
661 * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
662 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
663 * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
664 * hover event signal will be emitted.
666 * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
668 * actor.SetSensitive(false);
671 * Then, to re-enable the touch or hover event signal emission, the application should call:
673 * actor.SetSensitive(true);
676 * @see SignalTouch() and SignalHover().
677 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
678 * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
680 void SetSensitive( bool sensitive )
682 mSensitive = sensitive;
686 * Query whether an actor emits touch or hover event signals.
687 * @see SetSensitive(bool)
688 * @return true, if emission of touch or hover event signals is enabled, false otherwise.
690 bool IsSensitive() const
696 * @copydoc Dali::Actor::SetDrawMode
698 void SetDrawMode( DrawMode::Type drawMode );
701 * @copydoc Dali::Actor::GetDrawMode
703 DrawMode::Type GetDrawMode() const;
706 * @copydoc Dali::Actor::SetOverlay
708 void SetOverlay( bool enable );
711 * @copydoc Dali::Actor::IsOverlay
713 bool IsOverlay() const;
716 * Sets the actor's color. The final color of actor depends on its color mode.
717 * This final color is applied to the drawable elements of an actor.
718 * @param [in] color The new color.
720 void SetColor( const Vector4& color );
723 * Set the red component of the color.
724 * @param [in] red The new red component.
726 void SetColorRed( float red );
729 * Set the green component of the color.
730 * @param [in] green The new green component.
732 void SetColorGreen( float green );
735 * Set the blue component of the scale factor.
736 * @param [in] blue The new blue value.
738 void SetColorBlue( float blue );
741 * Retrieve the actor's color.
744 const Vector4& GetCurrentColor() const;
747 * Sets the actor's color mode.
748 * Color mode specifies whether Actor uses its own color or inherits its parent color
749 * @param [in] colorMode to use.
751 void SetColorMode( ColorMode colorMode );
754 * Returns the actor's color mode.
755 * @return currently used colorMode.
757 ColorMode GetColorMode() const;
760 * @copydoc Dali::Actor::GetCurrentWorldColor()
762 const Vector4& GetCurrentWorldColor() const;
765 * @copydoc Dali::Actor::GetHierarchyDepth()
767 int GetHierarchyDepth() const
771 return static_cast<int>(mDepth);
779 // Size negotiation virtual functions
782 * @brief Called after the size negotiation has been finished for this control.
784 * The control is expected to assign this given size to itself/its children.
786 * Should be overridden by derived classes if they need to layout
787 * actors differently after certain operations like add or remove
788 * actors, resize or after changing specific properties.
790 * Note! As this function is called from inside the size negotiation algorithm, you cannot
791 * call RequestRelayout (the call would just be ignored)
793 * @param[in] size The allocated size.
794 * @param[in,out] container The control should add actors to this container that it is not able
795 * to allocate a size for.
797 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
802 * @brief Notification for deriving classes when the resize policy is set
804 * @param[in] policy The policy being set
805 * @param[in] dimension The dimension the policy is being set for
807 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
810 * @brief Virtual method to notify deriving classes that relayout dependencies have been
811 * met and the size for this object is about to be calculated for the given dimension
813 * @param dimension The dimension that is about to be calculated
815 virtual void OnCalculateRelayoutSize( Dimension::Type dimension );
818 * @brief Virtual method to notify deriving classes that the size for a dimension
819 * has just been negotiated
821 * @param[in] size The new size for the given dimension
822 * @param[in] dimension The dimension that was just negotiated
824 virtual void OnLayoutNegotiated( float size, Dimension::Type dimension );
827 * @brief Determine if this actor is dependent on it's children for relayout
829 * @param dimension The dimension(s) to check for
830 * @return Return if the actor is dependent on it's children
832 virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
835 * @brief Determine if this actor is dependent on it's children for relayout.
837 * Called from deriving classes
839 * @param dimension The dimension(s) to check for
840 * @return Return if the actor is dependent on it's children
842 virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
845 * @brief Calculate the size for a child
847 * @param[in] child The child actor to calculate the size for
848 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
849 * @return Return the calculated size for the given dimension
851 virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
854 * @brief This method is called during size negotiation when a height is required for a given width.
856 * Derived classes should override this if they wish to customize the height returned.
858 * @param width to use.
859 * @return the height based on the width.
861 virtual float GetHeightForWidth( float width );
864 * @brief This method is called during size negotiation when a width is required for a given height.
866 * Derived classes should override this if they wish to customize the width returned.
868 * @param height to use.
869 * @return the width based on the width.
871 virtual float GetWidthForHeight( float height );
878 * @brief Called by the RelayoutController to negotiate the size of an actor.
880 * The size allocated by the the algorithm is passed in which the
881 * actor must adhere to. A container is passed in as well which
882 * the actor should populate with actors it has not / or does not
883 * need to handle in its size negotiation.
885 * @param[in] size The allocated size.
886 * @param[in,out] container The container that holds actors that are fed back into the
887 * RelayoutController algorithm.
889 void NegotiateSize( const Vector2& size, RelayoutContainer& container );
892 * @copydoc Dali::Actor::SetResizePolicy()
894 void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
897 * @copydoc Dali::Actor::GetResizePolicy()
899 ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
902 * @copydoc Dali::Actor::SetSizeScalePolicy()
904 void SetSizeScalePolicy( SizeScalePolicy::Type policy );
907 * @copydoc Dali::Actor::GetSizeScalePolicy()
909 SizeScalePolicy::Type GetSizeScalePolicy() const;
912 * @copydoc Dali::Actor::SetDimensionDependency()
914 void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
917 * @copydoc Dali::Actor::GetDimensionDependency()
919 Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
922 * @brief Set the size negotiation relayout enabled on this actor
924 * @param[in] relayoutEnabled Boolean to enable or disable relayout
926 void SetRelayoutEnabled( bool relayoutEnabled );
929 * @brief Return if relayout is enabled
931 * @return Return if relayout is enabled or not for this actor
933 bool IsRelayoutEnabled() const;
936 * @brief Mark an actor as having it's layout dirty
938 * @param dirty Whether to mark actor as dirty or not
939 * @param dimension The dimension(s) to mark as dirty
941 void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
944 * @brief Return if any of an actor's dimensions are marked as dirty
946 * @param dimension The dimension(s) to check
947 * @return Return if any of the requested dimensions are dirty
949 bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
952 * @brief Returns if relayout is enabled and the actor is not dirty
954 * @return Return if it is possible to relayout the actor
956 bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
959 * @brief Returns if relayout is enabled and the actor is dirty
961 * @return Return if it is required to relayout the actor
963 bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
966 * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
968 * This method is automatically called from OnStageConnection(), OnChildAdd(),
969 * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
971 * This method can also be called from a derived class every time it needs a different size.
972 * At the end of event processing, the relayout process starts and
973 * all controls which requested Relayout will have their sizes (re)negotiated.
975 * @note RelayoutRequest() can be called multiple times; the size negotiation is still
976 * only performed once, i.e. there is no need to keep track of this in the calling side.
978 void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
981 * @brief Determine if this actor is dependent on it's parent for relayout
983 * @param dimension The dimension(s) to check for
984 * @return Return if the actor is dependent on it's parent
986 bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
989 * @brief Determine if this actor has another dimension depedent on the specified one
991 * @param dimension The dimension to check for
992 * @param dependentDimension The dimension to check for dependency with
993 * @return Return if the actor is dependent on this dimension
995 bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
998 * Negotiate sizes for a control in all dimensions
1000 * @param[in] allocatedSize The size constraint that the control must respect
1002 void NegotiateDimensions( const Vector2& allocatedSize );
1005 * Negotiate size for a specific dimension
1007 * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1008 * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1009 * LayoutDimensionNegotiated flags being filled in on the actor.
1011 * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1012 * calculated and set as well as the LayoutDimensionNegotiated flags.
1014 * @param[in] dimension The dimension to negotiate on
1015 * @param[in] allocatedSize The size constraint that the actor must respect
1017 void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1020 * @brief Calculate the size of a dimension
1022 * @param[in] dimension The dimension to calculate the size for
1023 * @param[in] maximumSize The upper bounds on the size
1024 * @return Return the calculated size for the dimension
1026 float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1029 * @brief Clamp a dimension given the relayout constraints on this actor
1031 * @param[in] size The size to constrain
1032 * @param[in] dimension The dimension the size exists in
1033 * @return Return the clamped size
1035 float ClampDimension( float size, Dimension::Type dimension );
1038 * Negotiate a dimension based on the size of the parent
1040 * @param[in] dimension The dimension to negotiate on
1041 * @return Return the negotiated size
1043 float NegotiateFromParent( Dimension::Type dimension );
1046 * Negotiate a dimension based on the size of the parent. Fitting inside.
1048 * @param[in] dimension The dimension to negotiate on
1049 * @return Return the negotiated size
1051 float NegotiateFromParentFit( Dimension::Type dimension );
1054 * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1056 * @param[in] dimension The dimension to negotiate on
1057 * @return Return the negotiated size
1059 float NegotiateFromParentFlood( Dimension::Type dimension );
1062 * @brief Negotiate a dimension based on the size of the children
1064 * @param[in] dimension The dimension to negotiate on
1065 * @return Return the negotiated size
1067 float NegotiateFromChildren( Dimension::Type dimension );
1070 * Set the negotiated dimension value for the given dimension(s)
1072 * @param negotiatedDimension The value to set
1073 * @param dimension The dimension(s) to set the value for
1075 void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1078 * Return the value of negotiated dimension for the given dimension
1080 * @param dimension The dimension to retrieve
1081 * @return Return the value of the negotiated dimension
1083 float GetNegotiatedDimension( Dimension::Type dimension ) const;
1086 * @brief Set the padding for a dimension
1088 * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1089 * @param[in] dimension The dimension to set
1091 void SetPadding( const Vector2& padding, Dimension::Type dimension );
1094 * Return the value of padding for the given dimension
1096 * @param dimension The dimension to retrieve
1097 * @return Return the value of padding for the dimension
1099 Vector2 GetPadding( Dimension::Type dimension ) const;
1102 * Return the actor size for a given dimension
1104 * @param[in] dimension The dimension to retrieve the size for
1105 * @return Return the size for the given dimension
1107 float GetSize( Dimension::Type dimension ) const;
1110 * Return the natural size of the actor for a given dimension
1112 * @param[in] dimension The dimension to retrieve the size for
1113 * @return Return the natural size for the given dimension
1115 float GetNaturalSize( Dimension::Type dimension ) const;
1118 * @brief Return the amount of size allocated for relayout
1120 * May include padding
1122 * @param[in] dimension The dimension to retrieve
1123 * @return Return the size
1125 float GetRelayoutSize( Dimension::Type dimension ) const;
1128 * @brief If the size has been negotiated return that else return normal size
1130 * @param[in] dimension The dimension to retrieve
1131 * @return Return the size
1133 float GetLatestSize( Dimension::Type dimension ) const;
1136 * Apply the negotiated size to the actor
1138 * @param[in] container The container to fill with actors that require further relayout
1140 void SetNegotiatedSize( RelayoutContainer& container );
1143 * @brief Flag the actor as having it's layout dimension negotiated.
1145 * @param[in] negotiated The status of the flag to set.
1146 * @param[in] dimension The dimension to set the flag for
1148 void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1151 * @brief Test whether the layout dimension for this actor has been negotiated or not.
1153 * @param[in] dimension The dimension to determine the value of the flag for
1154 * @return Return if the layout dimension is negotiated or not.
1156 bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1159 * @brief provides the Actor implementation of GetHeightForWidth
1160 * @param width to use.
1161 * @return the height based on the width.
1163 float GetHeightForWidthBase( float width );
1166 * @brief provides the Actor implementation of GetWidthForHeight
1167 * @param height to use.
1168 * @return the width based on the height.
1170 float GetWidthForHeightBase( float height );
1173 * @brief Calculate the size for a child
1175 * @param[in] child The child actor to calculate the size for
1176 * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1177 * @return Return the calculated size for the given dimension
1179 float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1182 * @brief Set the preferred size for size negotiation
1184 * @param[in] size The preferred size to set
1186 void SetPreferredSize( const Vector2& size );
1189 * @brief Return the preferred size used for size negotiation
1191 * @return Return the preferred size
1193 Vector2 GetPreferredSize() const;
1196 * @copydoc Dali::Actor::SetMinimumSize
1198 void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1201 * @copydoc Dali::Actor::GetMinimumSize
1203 float GetMinimumSize( Dimension::Type dimension ) const;
1206 * @copydoc Dali::Actor::SetMaximumSize
1208 void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1211 * @copydoc Dali::Actor::GetMaximumSize
1213 float GetMaximumSize( Dimension::Type dimension ) const;
1216 * @copydoc Dali::Actor::AddRenderer()
1218 unsigned int AddRenderer( Renderer& renderer );
1221 * @copydoc Dali::Actor::GetRendererCount()
1223 unsigned int GetRendererCount() const;
1226 * @copydoc Dali::Actor::GetRendererAt()
1228 Renderer& GetRendererAt( unsigned int index );
1231 * @copydoc Dali::Actor::RemoveRenderer()
1233 void RemoveRenderer( Renderer& renderer );
1236 * @copydoc Dali::Actor::RemoveRenderer()
1238 void RemoveRenderer( unsigned int index );
1240 #ifdef DALI_DYNAMICS_SUPPORT
1244 /// @copydoc Dali::Actor::DisableDynamics
1245 void DisableDynamics();
1247 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
1248 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
1250 /// @copydoc Dali::Actor::GetDynamicsBody
1251 DynamicsBodyPtr GetDynamicsBody() const;
1253 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
1254 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
1256 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
1257 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
1259 /// @copydoc Dali::Actor::GetNumberOfJoints
1260 const int GetNumberOfJoints() const;
1262 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
1263 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
1265 /// @copydoc Dali::Actor::GetDynamicsJoint
1266 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
1268 /// @copydoc Dali::Actor::RemoveDynamicsJoint
1269 void RemoveDynamicsJoint( DynamicsJointPtr joint );
1272 * Hold a reference to a DynamicsJoint
1273 * @param[in] joint The joint
1275 void ReferenceJoint( DynamicsJointPtr joint );
1278 * Release a reference to a DynamicsJoint
1279 * @param[in] joint The joint
1281 void ReleaseJoint( DynamicsJointPtr joint );
1284 * Set this actor to be the root actor in the dynamics simulation
1285 * All children of the actor are added/removed from the simulation.
1286 * @param[in] flag When true sets this actor to be the simulation world root actor and
1287 * if OnStage() all dynamics enabled child actors are added to the simulation,
1288 * when false stops this actor being the simulation root and if OnStage() all
1289 * dynamics enabled child actors are removed from the simulation.
1291 void SetDynamicsRoot(bool flag);
1295 * Check if this actor is the root actor in the dynamics simulation
1296 * @return true if this is the dynamics root actor.
1298 bool IsDynamicsRoot() const;
1301 * Add actor to the dynamics simulation
1302 * Invoked when the actor is staged, or it's parent becomes the simulation root
1304 void ConnectDynamics();
1307 * Remove actor from the dynamics simulation
1308 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
1310 void DisconnectDynamics();
1313 * An actor in a DynamicsJoint relationship has been staged
1314 * @param[in] actor The actor passed into AddDynamicsJoint()
1316 void AttachedActorOnStage( Dali::Actor actor );
1319 * An actor in a DynamicsJoint relationship has been unstaged
1320 * @param[in] actor The actor passed into AddDynamicsJoint()
1322 void AttachedActorOffStage( Dali::Actor actor );
1324 #endif // DALI_DYNAMICS_SUPPORT
1328 * Converts screen coordinates into the actor's coordinate system.
1329 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
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( float& localX, float& localY, float screenX, float screenY ) const;
1339 * Converts screen coordinates into the actor's coordinate system.
1340 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1341 * @param[in] renderTask The render-task used to display the actor.
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( RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1351 * Converts from the actor's coordinate system to screen coordinates.
1352 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1353 * @param[in] viewMatrix The view-matrix
1354 * @param[in] projectionMatrix The projection-matrix
1355 * @param[in] viewport The view-port
1356 * @param[out] localX On return, the X-coordinate relative to the actor.
1357 * @param[out] localY On return, the Y-coordinate relative to the actor.
1358 * @param[in] screenX The screen X-coordinate.
1359 * @param[in] screenY The screen Y-coordinate.
1360 * @return True if the conversion succeeded.
1362 bool ScreenToLocal( const Matrix& viewMatrix,
1363 const Matrix& projectionMatrix,
1364 const Viewport& viewport,
1368 float screenY ) const;
1371 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1372 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1373 * @param[in] rayOrigin The ray origin in the world's reference system.
1374 * @param[in] rayDir The ray director vector in the world's reference system.
1375 * @return True if the ray intersects the actor's bounding sphere.
1377 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1380 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1381 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1382 * @param[in] rayOrigin The ray origin in the world's reference system.
1383 * @param[in] rayDir The ray director vector in the world's reference system.
1384 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1385 * @param[out] distance The distance from the hit point to the camera.
1386 * @return True if the ray intersects the actor's geometry.
1388 bool RayActorTest( const Vector4& rayOrigin,
1389 const Vector4& rayDir,
1390 Vector4& hitPointLocal,
1391 float& distance ) const;
1394 * Sets whether the actor should receive a notification when touch or hover motion events leave
1395 * the boundary of the actor.
1397 * @note By default, this is set to false as most actors do not require this.
1398 * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1400 * @param[in] required Should be set to true if a Leave event is required
1402 void SetLeaveRequired( bool required );
1405 * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1406 * the boundary of the actor.
1407 * @return true if a Leave event is required, false otherwise.
1409 bool GetLeaveRequired() const;
1412 * @copydoc Dali::Actor::SetKeyboardFocusable()
1414 void SetKeyboardFocusable( bool focusable );
1417 * @copydoc Dali::Actor::IsKeyboardFocusable()
1419 bool IsKeyboardFocusable() const;
1422 * Query whether the application or derived actor type requires touch events.
1423 * @return True if touch events are required.
1425 bool GetTouchRequired() const;
1428 * Query whether the application or derived actor type requires hover events.
1429 * @return True if hover events are required.
1431 bool GetHoverRequired() const;
1434 * Query whether the application or derived actor type requires wheel events.
1435 * @return True if wheel events are required.
1437 bool GetWheelEventRequired() const;
1440 * Query whether the actor is actually hittable. This method checks whether the actor is
1441 * sensitive, has the visibility flag set to true and is not fully transparent.
1442 * @return true, if it can be hit, false otherwise.
1444 bool IsHittable() const;
1449 * Retrieve the gesture data associated with this actor. The first call to this method will
1450 * allocate space for the ActorGestureData so this should only be called if an actor really does
1452 * @return Reference to the ActorGestureData for this actor.
1453 * @note Once the gesture-data is created for an actor it is likely that gestures are required
1454 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1456 ActorGestureData& GetGestureData();
1459 * Queries whether the actor requires the gesture type.
1460 * @param[in] type The gesture type.
1462 bool IsGestureRequred( Gesture::Type type ) const;
1467 * Used by the EventProcessor to emit touch event signals.
1468 * @param[in] event The touch event.
1469 * @return True if the event was consumed.
1471 bool EmitTouchEventSignal( const TouchEvent& event );
1474 * Used by the EventProcessor to emit hover event signals.
1475 * @param[in] event The hover event.
1476 * @return True if the event was consumed.
1478 bool EmitHoverEventSignal( const HoverEvent& event );
1481 * Used by the EventProcessor to emit wheel event signals.
1482 * @param[in] event The wheel event.
1483 * @return True if the event was consumed.
1485 bool EmitWheelEventSignal( const WheelEvent& event );
1488 * @copydoc Dali::Actor::TouchedSignal()
1490 Dali::Actor::TouchSignalType& TouchedSignal();
1493 * @copydoc Dali::Actor::HoveredSignal()
1495 Dali::Actor::HoverSignalType& HoveredSignal();
1498 * @copydoc Dali::Actor::WheelEventSignal()
1500 Dali::Actor::WheelEventSignalType& WheelEventSignal();
1503 * @copydoc Dali::Actor::OnStageSignal()
1505 Dali::Actor::OnStageSignalType& OnStageSignal();
1508 * @copydoc Dali::Actor::OffStageSignal()
1510 Dali::Actor::OffStageSignalType& OffStageSignal();
1513 * @copydoc Dali::Actor::OnRelayoutSignal()
1515 Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1518 * Connects a callback function with the object's signals.
1519 * @param[in] object The object providing the signal.
1520 * @param[in] tracker Used to disconnect the signal.
1521 * @param[in] signalName The signal to connect to.
1522 * @param[in] functor A newly allocated FunctorDelegate.
1523 * @return True if the signal was connected.
1524 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1526 static bool DoConnectSignal( BaseObject* object,
1527 ConnectionTrackerInterface* tracker,
1528 const std::string& signalName,
1529 FunctorDelegate* functor );
1532 * Performs actions as requested using the action name.
1533 * @param[in] object The object on which to perform the action.
1534 * @param[in] actionName The action to perform.
1535 * @param[in] attributes The attributes with which to perfrom this action.
1536 * @return true if the action was done.
1538 static bool DoAction( BaseObject* object,
1539 const std::string& actionName,
1540 const Property::Map& attributes );
1546 * This should only be called by Animation, when the actors SIZE property is animated.
1548 * @param[in] animation The animation that resized the actor
1549 * @param[in] targetSize The new target size of the actor
1551 void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1554 * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT property is animated.
1556 * @param[in] animation The animation that resized the actor
1557 * @param[in] targetSize The new target size of the actor
1559 void NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property );
1562 * For use in derived classes.
1563 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1565 virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1573 BASIC, RENDERABLE, LAYER, ROOT_LAYER
1577 * Protected Constructor. See Actor::New().
1578 * The second-phase construction Initialize() member should be called immediately after this.
1579 * @param[in] derivedType The derived type of actor (if any).
1581 Actor( DerivedType derivedType );
1584 * Second-phase constructor. Must be called immediately after creating a new Actor;
1586 void Initialize( void );
1589 * A reference counted object may only be deleted by calling Unreference()
1594 * Called on a child during Add() when the parent actor is connected to the Stage.
1595 * @param[in] stage The stage.
1596 * @param[in] parentDepth The depth of the parent in the hierarchy
1597 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1599 void ConnectToStage( unsigned int parentDepth, int index = -1 );
1602 * Helper for ConnectToStage, to recursively connect a tree of actors.
1603 * This is atomic i.e. not interrupted by user callbacks.
1604 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1605 * @param[in] depth The depth in the hierarchy of the actor
1606 * @param[out] connectionList On return, the list of connected actors which require notification.
1608 void RecursiveConnectToStage( ActorContainer& connectionList, unsigned int depth, int index = -1 );
1611 * Connect the Node associated with this Actor to the scene-graph.
1612 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1614 void ConnectToSceneGraph( int index = -1 );
1617 * Helper for ConnectToStage, to notify a connected actor through the public API.
1619 void NotifyStageConnection();
1622 * Called on a child during Remove() when the actor was previously on the Stage.
1624 void DisconnectFromStage();
1627 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1628 * This is atomic i.e. not interrupted by user callbacks.
1629 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1631 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1634 * Disconnect the Node associated with this Actor from the scene-graph.
1636 void DisconnectFromSceneGraph();
1639 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1641 void NotifyStageDisconnection();
1644 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1645 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1647 bool IsNodeConnected() const;
1650 * Calculate the size of the z dimension for a 2D size
1652 * @param[in] size The 2D size (X, Y) to calculate Z from
1654 * @return Return the Z dimension for this size
1656 float CalculateSizeZ( const Vector2& size ) const;
1659 // Default property extensions from Object
1662 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1664 virtual unsigned int GetDefaultPropertyCount() const;
1667 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1669 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1672 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1674 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1677 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1679 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1682 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1684 virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1687 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1689 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1692 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1694 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1697 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1699 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1702 * @copydoc Dali::Internal::Object::SetDefaultProperty()
1704 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1707 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1709 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1712 * @copydoc Dali::Internal::Object::GetDefaultProperty()
1714 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1717 * @copydoc Dali::Internal::Object::GetPropertyOwner()
1719 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1722 * @copydoc Dali::Internal::Object::GetSceneObject()
1724 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1727 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1729 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1732 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1734 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1737 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1739 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1747 Actor( const Actor& );
1750 Actor& operator=( const Actor& rhs );
1753 * Set the actors parent.
1754 * @param[in] parent The new parent.
1755 * @param[in] index If set, it is only used for positioning the actor within the parent's child list.
1757 void SetParent( Actor* parent, int index = -1 );
1760 * Helper to create a Node for this Actor.
1761 * To be overriden in derived classes.
1762 * @return A newly allocated node.
1764 virtual SceneGraph::Node* CreateNode() const;
1767 * For use in derived classes, called after Initialize()
1769 virtual void OnInitialize()
1774 * For use in internal derived classes.
1775 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1776 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1778 virtual void OnStageConnectionInternal()
1783 * For use in internal derived classes.
1784 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1785 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1787 virtual void OnStageDisconnectionInternal()
1792 * For use in external (CustomActor) derived classes.
1793 * This is called after the atomic ConnectToStage() traversal has been completed.
1795 virtual void OnStageConnectionExternal( int depth )
1800 * For use in external (CustomActor) derived classes.
1801 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1803 virtual void OnStageDisconnectionExternal()
1808 * For use in derived classes; this is called after Add() has added a child.
1809 * @param[in] child The child that was added.
1811 virtual void OnChildAdd( Actor& child )
1816 * For use in derived classes; this is called after Remove() has removed a child.
1817 * @param[in] child The child that was removed.
1819 virtual void OnChildRemove( Actor& child )
1824 * For use in derived classes.
1825 * This is called after SizeSet() has been called.
1827 virtual void OnSizeSet( const Vector3& targetSize )
1832 * For use in derived classes.
1833 * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1834 * @param[in] event The touch event.
1835 * @return True if the event should be consumed.
1837 virtual bool OnTouchEvent( const TouchEvent& event )
1843 * For use in derived classes.
1844 * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1845 * @param[in] event The hover event.
1846 * @return True if the event should be consumed.
1848 virtual bool OnHoverEvent( const HoverEvent& event )
1854 * For use in derived classes.
1855 * This is only called if the wheel signal was not consumed.
1856 * @param[in] event The wheel event.
1857 * @return True if the event should be consumed.
1859 virtual bool OnWheelEvent( const WheelEvent& event )
1865 * @brief Ensure the relayout data is allocated
1867 void EnsureRelayoutData();
1870 * @brief Apply the size set policy to the input size
1872 * @param[in] size The size to apply the policy to
1873 * @return Return the adjusted size
1875 Vector2 ApplySizeSetPolicy( const Vector2 size );
1879 Actor* mParent; ///< Each actor (except the root) can have one parent
1880 ActorContainer* mChildren; ///< Container of referenced actors
1881 const SceneGraph::Node* mNode; ///< Not owned
1882 Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1883 Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1885 struct RelayoutData;
1886 RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1888 #ifdef DALI_DYNAMICS_SUPPORT
1889 DynamicsData* mDynamicsData; ///< optional physics data
1892 ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
1894 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1897 Dali::Actor::TouchSignalType mTouchedSignal;
1898 Dali::Actor::HoverSignalType mHoveredSignal;
1899 Dali::Actor::WheelEventSignalType mWheelEventSignal;
1900 Dali::Actor::OnStageSignalType mOnStageSignal;
1901 Dali::Actor::OffStageSignalType mOffStageSignal;
1902 Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal;
1904 Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
1905 Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position)
1907 std::string mName; ///< Name of the actor
1908 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1910 unsigned short mDepth :12; ///< The depth in the hierarchy of the actor. Only 4096 levels of depth are supported
1911 const bool mIsRoot : 1; ///< Flag to identify the root actor
1912 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1913 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1914 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1915 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1916 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1917 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1918 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1919 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1920 bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
1921 bool mDerivedRequiresWheelEvent : 1; ///< Whether the derived actor type requires wheel event signals
1922 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1923 bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet
1924 bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited.
1925 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1926 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1927 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1928 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1932 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1933 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1937 } // namespace Internal
1939 // Helpers for public-api forwarding methods
1941 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
1943 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1945 BaseObject& handle = actor.GetBaseObject();
1947 return static_cast< Internal::Actor& >( handle );
1950 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
1952 DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1954 const BaseObject& handle = actor.GetBaseObject();
1956 return static_cast< const Internal::Actor& >( handle );
1961 #endif // __DALI_INTERNAL_ACTOR_H__