Always notify the derived class when removing child actor
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.h
1 #ifndef __DALI_INTERNAL_ACTOR_H__
2 #define __DALI_INTERNAL_ACTOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
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>
38
39 namespace Dali
40 {
41
42 struct KeyEvent;
43 struct TouchEvent;
44 struct HoverEvent;
45 struct WheelEvent;
46
47 namespace Internal
48 {
49
50 class Actor;
51 class ActorGestureData;
52 class Animation;
53 class RenderTask;
54 class Renderer;
55
56 typedef std::vector< ActorPtr > ActorContainer;
57 typedef ActorContainer::iterator ActorIter;
58 typedef ActorContainer::const_iterator ActorConstIter;
59
60 typedef std::vector< RendererPtr > RendererContainer;
61 typedef RendererContainer::iterator RendererIter;
62
63 /**
64  * Actor is the primary object which Dali applications interact with.
65  * UI controls can be built by combining multiple actors.
66  * Multi-Touch events are received through signals emitted by the actor tree.
67  *
68  * An Actor is a proxy for a Node in the scene graph.
69  * When an Actor is added to the Stage, it creates a node and attaches it to the scene graph.
70  * The scene-graph can be updated in a separate thread, so the attachment is done using an asynchronous message.
71  * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
72  */
73 class Actor : public Object
74 {
75 public:
76
77   /**
78    * @brief Struct to hold an actor and a dimension
79    */
80   struct ActorDimensionPair
81   {
82     /**
83      * @brief Constructor
84      *
85      * @param[in] newActor The actor to assign
86      * @param[in] newDimension The dimension to assign
87      */
88     ActorDimensionPair( Actor* newActor, Dimension::Type newDimension )
89     : actor( newActor ),
90       dimension( newDimension )
91     {
92     }
93
94     /**
95      * @brief Equality operator
96      *
97      * @param[in] lhs The left hand side argument
98      * @param[in] rhs The right hand side argument
99      */
100     bool operator== ( const ActorDimensionPair& rhs )
101     {
102       return ( actor == rhs.actor ) && ( dimension == rhs.dimension );
103     }
104
105     Actor* actor;           ///< The actor to hold
106     Dimension::Type dimension;    ///< The dimension to hold
107   };
108
109   typedef std::vector< ActorDimensionPair > ActorDimensionStack;
110
111 public:
112
113   /**
114    * Create a new actor.
115    * @return A smart-pointer to the newly allocated Actor.
116    */
117   static ActorPtr New();
118
119   /**
120    * Retrieve the name of the actor.
121    * @return The name.
122    */
123   const std::string& GetName() const;
124
125   /**
126    * Set the name of the actor.
127    * @param[in] name The new name.
128    */
129   void SetName( const std::string& name );
130
131   /**
132    * @copydoc Dali::Actor::GetId
133    */
134   unsigned int GetId() const;
135
136   // Attachments
137
138   /**
139    * Attach an object to an actor.
140    * @pre The actor does not already have an attachment.
141    * @param[in] attachment The object to attach.
142    */
143   void Attach( ActorAttachment& attachment );
144
145   /**
146    * Retreive the object attached to an actor.
147    * @return The attachment.
148    */
149   ActorAttachmentPtr GetAttachment();
150
151   // Containment
152
153   /**
154    * Query whether an actor is the root actor, which is owned by the Stage.
155    * @return True if the actor is a root actor.
156    */
157   bool IsRoot() const
158   {
159     return mIsRoot;
160   }
161
162   /**
163    * Query whether the actor is connected to the Stage.
164    */
165   bool OnStage() const;
166
167   /**
168    * Query whether the actor has any renderers.
169    * @return True if the actor is renderable.
170    */
171   bool IsRenderable() const
172   {
173     // inlined as this is called a lot in hit testing
174     return mRenderers && !mRenderers->empty();
175   }
176
177   /**
178    * Query whether the actor is of class Dali::Layer
179    * @return True if the actor is a layer.
180    */
181   bool IsLayer() const
182   {
183     // inlined as this is called a lot in hit testing
184     return mIsLayer;
185   }
186
187   /**
188    * Gets the layer in which the actor is present
189    * @return The layer, which will be uninitialized if the actor is off-stage.
190    */
191   Dali::Layer GetLayer();
192
193   /**
194    * Adds a child Actor to this Actor.
195    * @pre The child actor is not the same as the parent actor.
196    * @pre The child actor does not already have a parent.
197    * @param [in] child The child.
198    * @post The child will be referenced by its parent.
199    */
200   void Add( Actor& child );
201
202   /**
203    * Removes a child Actor from this Actor.
204    * @param [in] child The child.
205    * @post The child will be unreferenced.
206    */
207   void Remove( Actor& child );
208
209   /**
210    * @copydoc Dali::Actor::Unparent
211    */
212   void Unparent();
213
214   /**
215    * Retrieve the number of children held by the actor.
216    * @return The number of children
217    */
218   unsigned int GetChildCount() const;
219
220   /**
221    * @copydoc Dali::Actor::GetChildAt
222    */
223   ActorPtr GetChildAt( unsigned int index ) const;
224
225   /**
226    * Retrieve a reference to Actor's children.
227    * @note Not for public use.
228    * @return A reference to the container of children.
229    */
230   ActorContainer& GetChildrenInternal()
231   {
232     return *mChildren;
233   }
234
235   /**
236    * @copydoc Dali::Actor::FindChildByName
237    */
238   ActorPtr FindChildByName( const std::string& actorName );
239
240   /**
241    * @copydoc Dali::Actor::FindChildById
242    */
243   ActorPtr FindChildById( const unsigned int id );
244
245   /**
246    * Retrieve the parent of an Actor.
247    * @return The parent actor, or NULL if the Actor does not have a parent.
248    */
249   Actor* GetParent() const
250   {
251     return mParent;
252   }
253
254   /**
255    * Sets the size of an actor.
256    * ActorAttachments attached to the actor, can be scaled to fit within this area.
257    * This does not interfere with the actors scale factor.
258    * @param [in] width  The new width.
259    * @param [in] height The new height.
260    */
261   void SetSize( float width, float height );
262
263   /**
264    * Sets the size of an actor.
265    * ActorAttachments attached to the actor, can be scaled to fit within this area.
266    * This does not interfere with the actors scale factor.
267    * @param [in] width The size of the actor along the x-axis.
268    * @param [in] height The size of the actor along the y-axis.
269    * @param [in] depth The size of the actor along the z-axis.
270    */
271   void SetSize( float width, float height, float depth );
272
273   /**
274    * Sets the size of an actor.
275    * ActorAttachments attached to the actor, can be scaled to fit within this area.
276    * This does not interfere with the actors scale factor.
277    * @param [in] size The new size.
278    */
279   void SetSize( const Vector2& size );
280
281   /**
282    * Sets the update size for an actor.
283    *
284    * @param[in] size The size to set.
285    */
286   void SetSizeInternal( const Vector2& size );
287
288   /**
289    * Sets the size of an actor.
290    * ActorAttachments attached to the actor, can be scaled to fit within this area.
291    * This does not interfere with the actors scale factor.
292    * @param [in] size The new size.
293    */
294   void SetSize( const Vector3& size );
295
296   /**
297    * Sets the update size for an actor.
298    *
299    * @param[in] size The size to set.
300    */
301   void SetSizeInternal( const Vector3& size );
302
303   /**
304    * Set the width component of the Actor's size.
305    * @param [in] width The new width component.
306    */
307   void SetWidth( float width );
308
309   /**
310    * Set the height component of the Actor's size.
311    * @param [in] height The new height component.
312    */
313   void SetHeight( float height );
314
315   /**
316    * Set the depth component of the Actor's size.
317    * @param [in] depth The new depth component.
318    */
319   void SetDepth( float depth );
320
321   /**
322    * Retrieve the Actor's size from event side.
323    * This size will be the size set or if animating then the target size.
324    * @return The Actor's size.
325    */
326   const Vector3& GetTargetSize() const;
327
328   /**
329    * Retrieve the Actor's size from update side.
330    * This size will be the size set or animating but will be a frame behind.
331    * @return The Actor's size.
332    */
333   const Vector3& GetCurrentSize() const;
334
335   /**
336    * Return the natural size of the actor
337    *
338    * @return The actor's natural size
339    */
340   virtual Vector3 GetNaturalSize() const;
341
342   /**
343    * Set the origin of an actor, within its parent's area.
344    * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
345    * and (1.0, 1.0, 0.5) is the bottom-right corner.
346    * The default parent-origin is top-left (0.0, 0.0, 0.5).
347    * An actor position is the distance between this origin, and the actors anchor-point.
348    * @param [in] origin The new parent-origin.
349    */
350   void SetParentOrigin( const Vector3& origin );
351
352   /**
353    * Set the x component of the parent-origin
354    * @param [in] x The new x value.
355    */
356   void SetParentOriginX( float x );
357
358   /**
359    * Set the y component of the parent-origin
360    * @param [in] y The new y value.
361    */
362   void SetParentOriginY( float y );
363
364   /**
365    * Set the z component of the parent-origin
366    * @param [in] z The new z value.
367    */
368   void SetParentOriginZ( float z );
369
370   /**
371    * Retrieve the parent-origin of an actor.
372    * @return The parent-origin.
373    */
374   const Vector3& GetCurrentParentOrigin() const;
375
376   /**
377    * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
378    * (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.
379    * The default anchor point is top-left (0.0, 0.0, 0.5).
380    * An actor position is the distance between its parent-origin, and this anchor-point.
381    * An actor's rotation is centered around its anchor-point.
382    * @param [in] anchorPoint The new anchor-point.
383    */
384   void SetAnchorPoint( const Vector3& anchorPoint );
385
386   /**
387    * Set the x component of the anchor-point.
388    * @param [in] x The new x value.
389    */
390   void SetAnchorPointX( float x );
391
392   /**
393    * Set the y component of the anchor-point.
394    * @param [in] y The new y value.
395    */
396   void SetAnchorPointY( float y );
397
398   /**
399    * Set the z component of the anchor-point.
400    * @param [in] z The new z value.
401    */
402   void SetAnchorPointZ( float z );
403
404   /**
405    * Retrieve the anchor-point of an actor.
406    * @return The anchor-point.
407    */
408   const Vector3& GetCurrentAnchorPoint() const;
409
410   /**
411    * Sets the position of the Actor.
412    * The coordinates are relative to the Actor's parent.
413    * The Actor's z position will be set to 0.0f.
414    * @param [in] x The new x position
415    * @param [in] y The new y position
416    */
417   void SetPosition( float x, float y );
418
419   /**
420    * Sets the position of the Actor.
421    * The coordinates are relative to the Actor's parent.
422    * @param [in] x The new x position
423    * @param [in] y The new y position
424    * @param [in] z The new z position
425    */
426   void SetPosition( float x, float y, float z );
427
428   /**
429    * Sets the position of the Actor.
430    * The coordinates are relative to the Actor's parent.
431    * @param [in] position The new position.
432    */
433   void SetPosition( const Vector3& position );
434
435   /**
436    * Set the position of an actor along the X-axis.
437    * @param [in] x The new x position
438    */
439   void SetX( float x );
440
441   /**
442    * Set the position of an actor along the Y-axis.
443    * @param [in] y The new y position.
444    */
445   void SetY( float y );
446
447   /**
448    * Set the position of an actor along the Z-axis.
449    * @param [in] z The new z position
450    */
451   void SetZ( float z );
452
453   /**
454    * Translate an actor relative to its existing position.
455    * @param[in] distance The actor will move by this distance.
456    */
457   void TranslateBy( const Vector3& distance );
458
459   /**
460    * Retrieve the position of the Actor.
461    * The coordinates are relative to the Actor's parent.
462    * @return the Actor's position.
463    */
464   const Vector3& GetCurrentPosition() const;
465
466   /**
467    * Retrieve the target position of the Actor.
468    * The coordinates are relative to the Actor's parent.
469    * @return the Actor's position.
470    */
471   const Vector3& GetTargetPosition() const;
472
473   /**
474    * @copydoc Dali::Actor::GetCurrentWorldPosition()
475    */
476   const Vector3& GetCurrentWorldPosition() const;
477
478   /**
479    * @copydoc Dali::Actor::SetPositionInheritanceMode()
480    */
481   void SetPositionInheritanceMode( PositionInheritanceMode mode );
482
483   /**
484    * @copydoc Dali::Actor::GetPositionInheritanceMode()
485    */
486   PositionInheritanceMode GetPositionInheritanceMode() const;
487
488   /**
489    * @copydoc Dali::Actor::SetInheritPosition()
490    */
491   void SetInheritPosition( bool inherit );
492
493   /**
494    * @copydoc Dali::Actor::IsPositionInherited()
495    */
496   bool IsPositionInherited() const;
497
498   /**
499    * Sets the orientation of the Actor.
500    * @param [in] angleRadians The new orientation angle in radians.
501    * @param [in] axis The new axis of orientation.
502    */
503   void SetOrientation( const Radian& angleRadians, const Vector3& axis );
504
505   /**
506    * Sets the orientation of the Actor.
507    * @param [in] orientation The new orientation.
508    */
509   void SetOrientation( const Quaternion& orientation );
510
511   /**
512    * Rotate an actor around its existing rotation axis.
513    * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
514    * @param[in] axis The axis of the rotation to combine with the existing rotation.
515    */
516   void RotateBy( const Radian& angleRadians, const Vector3& axis );
517
518   /**
519    * Apply a relative rotation to an actor.
520    * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
521    */
522   void RotateBy( const Quaternion& relativeRotation );
523
524   /**
525    * Retreive the Actor's orientation.
526    * @return the orientation.
527    */
528   const Quaternion& GetCurrentOrientation() const;
529
530   /**
531    * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
532    * Switching this off means that using SetOrientation() sets the actor's world orientation.
533    * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
534    */
535   void SetInheritOrientation( bool inherit );
536
537   /**
538    * Returns whether the actor inherit's it's parent's orientation.
539    * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
540    */
541   bool IsOrientationInherited() const;
542
543   /**
544    * Sets the factor of the parents size used for the child actor.
545    * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
546    * @param[in] factor The vector to multiply the parents size by to get the childs size.
547    */
548   void SetSizeModeFactor( const Vector3& factor );
549
550   /**
551    * Gets the factor of the parents size used for the child actor.
552    * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
553    * @return The vector being used to multiply the parents size by to get the childs size.
554    */
555   const Vector3& GetSizeModeFactor() const;
556
557   /**
558    * @copydoc Dali::Actor::GetCurrentWorldOrientation()
559    */
560   const Quaternion& GetCurrentWorldOrientation() const;
561
562   /**
563    * Sets a scale factor applied to an actor.
564    * @param [in] scale The scale factor applied on all axes.
565    */
566   void SetScale( float scale );
567
568   /**
569    * Sets a scale factor applied to an actor.
570    * @param [in] scaleX The scale factor applied along the x-axis.
571    * @param [in] scaleY The scale factor applied along the y-axis.
572    * @param [in] scaleZ The scale factor applied along the z-axis.
573    */
574   void SetScale( float scaleX, float scaleY, float scaleZ );
575
576   /**
577    * Sets a scale factor applied to an actor.
578    * @param [in] scale A vector representing the scale factor for each axis.
579    */
580   void SetScale( const Vector3& scale );
581
582   /**
583    * Set the x component of the scale factor.
584    * @param [in] x The new x value.
585    */
586   void SetScaleX( float x );
587
588   /**
589    * Set the y component of the scale factor.
590    * @param [in] y The new y value.
591    */
592   void SetScaleY( float y );
593
594   /**
595    * Set the z component of the scale factor.
596    * @param [in] z The new z value.
597    */
598   void SetScaleZ( float z );
599
600   /**
601    * Apply a relative scale to an actor.
602    * @param[in] relativeScale The scale to combine with the actors existing scale.
603    */
604   void ScaleBy( const Vector3& relativeScale );
605
606   /**
607    * Retrieve the scale factor applied to an actor.
608    * @return A vector representing the scale factor for each axis.
609    */
610   const Vector3& GetCurrentScale() const;
611
612   /**
613    * @copydoc Dali::Actor::GetCurrentWorldScale()
614    */
615   const Vector3& GetCurrentWorldScale() const;
616
617   /**
618    * @copydoc Dali::Actor::SetInheritScale()
619    */
620   void SetInheritScale( bool inherit );
621
622   /**
623    * @copydoc Dali::Actor::IsScaleInherited()
624    */
625   bool IsScaleInherited() const;
626
627   /**
628    * @copydoc Dali::Actor::GetCurrentWorldMatrix()
629    */
630   Matrix GetCurrentWorldMatrix() const;
631
632   // Visibility
633
634   /**
635    * Sets the visibility flag of an actor.
636    * @param [in] visible The new visibility flag.
637    */
638   void SetVisible( bool visible );
639
640   /**
641    * Retrieve the visibility flag of an actor.
642    * @return The visibility flag.
643    */
644   bool IsVisible() const;
645
646   /**
647    * Sets the opacity of an actor.
648    * @param [in] opacity The new opacity.
649    */
650   void SetOpacity( float opacity );
651
652   /**
653    * Retrieve the actor's opacity.
654    * @return The actor's opacity.
655    */
656   float GetCurrentOpacity() const;
657
658   /**
659    * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
660    * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
661    * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
662    * hover event signal will be emitted.
663    *
664    * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
665    * @code
666    * actor.SetSensitive(false);
667    * @endcode
668    *
669    * Then, to re-enable the touch or hover event signal emission, the application should call:
670    * @code
671    * actor.SetSensitive(true);
672    * @endcode
673    *
674    * @see SignalTouch() and SignalHover().
675    * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
676    * @param[in]  sensitive  true to enable emission of the touch or hover event signals, false otherwise.
677    */
678   void SetSensitive( bool sensitive )
679   {
680     mSensitive = sensitive;
681   }
682
683   /**
684    * Query whether an actor emits touch or hover event signals.
685    * @see SetSensitive(bool)
686    * @return true, if emission of touch or hover event signals is enabled, false otherwise.
687    */
688   bool IsSensitive() const
689   {
690     return mSensitive;
691   }
692
693   /**
694    * @copydoc Dali::Actor::SetDrawMode
695    */
696   void SetDrawMode( DrawMode::Type drawMode );
697
698   /**
699    * @copydoc Dali::Actor::GetDrawMode
700    */
701   DrawMode::Type GetDrawMode() const;
702
703   /**
704    * @copydoc Dali::Actor::SetOverlay
705    */
706   void SetOverlay( bool enable );
707
708   /**
709    * @copydoc Dali::Actor::IsOverlay
710    */
711   bool IsOverlay() const;
712
713   /**
714    * Sets the actor's color.  The final color of actor depends on its color mode.
715    * This final color is applied to the drawable elements of an actor.
716    * @param [in] color The new color.
717    */
718   void SetColor( const Vector4& color );
719
720   /**
721    * Set the red component of the color.
722    * @param [in] red The new red component.
723    */
724   void SetColorRed( float red );
725
726   /**
727    * Set the green component of the color.
728    * @param [in] green The new green component.
729    */
730   void SetColorGreen( float green );
731
732   /**
733    * Set the blue component of the scale factor.
734    * @param [in] blue The new blue value.
735    */
736   void SetColorBlue( float blue );
737
738   /**
739    * Retrieve the actor's color.
740    * @return The color.
741    */
742   const Vector4& GetCurrentColor() const;
743
744   /**
745    * Sets the actor's color mode.
746    * Color mode specifies whether Actor uses its own color or inherits its parent color
747    * @param [in] colorMode to use.
748    */
749   void SetColorMode( ColorMode colorMode );
750
751   /**
752    * Returns the actor's color mode.
753    * @return currently used colorMode.
754    */
755   ColorMode GetColorMode() const;
756
757   /**
758    * @copydoc Dali::Actor::GetCurrentWorldColor()
759    */
760   const Vector4& GetCurrentWorldColor() const;
761
762   /**
763    * @copydoc Dali::Actor::GetHierarchyDepth()
764    */
765   int GetHierarchyDepth() const
766   {
767     if( mIsOnStage )
768     {
769       return static_cast<int>(mDepth);
770     }
771
772     return -1;
773   }
774
775 public:
776
777   // Size negotiation virtual functions
778
779   /**
780    * @brief Called after the size negotiation has been finished for this control.
781    *
782    * The control is expected to assign this given size to itself/its children.
783    *
784    * Should be overridden by derived classes if they need to layout
785    * actors differently after certain operations like add or remove
786    * actors, resize or after changing specific properties.
787    *
788    * Note! As this function is called from inside the size negotiation algorithm, you cannot
789    * call RequestRelayout (the call would just be ignored)
790    *
791    * @param[in]      size       The allocated size.
792    * @param[in,out]  container  The control should add actors to this container that it is not able
793    *                            to allocate a size for.
794    */
795   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
796   {
797   }
798
799   /**
800    * @brief Notification for deriving classes when the resize policy is set
801    *
802    * @param[in] policy The policy being set
803    * @param[in] dimension The dimension the policy is being set for
804    */
805   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
806
807   /**
808    * @brief Virtual method to notify deriving classes that relayout dependencies have been
809    * met and the size for this object is about to be calculated for the given dimension
810    *
811    * @param dimension The dimension that is about to be calculated
812    */
813   virtual void OnCalculateRelayoutSize( Dimension::Type dimension );
814
815   /**
816    * @brief Virtual method to notify deriving classes that the size for a dimension
817    * has just been negotiated
818    *
819    * @param[in] size The new size for the given dimension
820    * @param[in] dimension The dimension that was just negotiated
821    */
822   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension );
823
824   /**
825    * @brief Determine if this actor is dependent on it's children for relayout
826    *
827    * @param dimension The dimension(s) to check for
828    * @return Return if the actor is dependent on it's children
829    */
830   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
831
832   /**
833    * @brief Determine if this actor is dependent on it's children for relayout.
834    *
835    * Called from deriving classes
836    *
837    * @param dimension The dimension(s) to check for
838    * @return Return if the actor is dependent on it's children
839    */
840   virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
841
842   /**
843    * @brief Calculate the size for a child
844    *
845    * @param[in] child The child actor to calculate the size for
846    * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
847    * @return Return the calculated size for the given dimension
848    */
849   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
850
851   /**
852    * @brief This method is called during size negotiation when a height is required for a given width.
853    *
854    * Derived classes should override this if they wish to customize the height returned.
855    *
856    * @param width to use.
857    * @return the height based on the width.
858    */
859   virtual float GetHeightForWidth( float width );
860
861   /**
862    * @brief This method is called during size negotiation when a width is required for a given height.
863    *
864    * Derived classes should override this if they wish to customize the width returned.
865    *
866    * @param height to use.
867    * @return the width based on the width.
868    */
869   virtual float GetWidthForHeight( float height );
870
871 public:
872
873   // Size negotiation
874
875   /**
876    * @brief Called by the RelayoutController to negotiate the size of an actor.
877    *
878    * The size allocated by the the algorithm is passed in which the
879    * actor must adhere to.  A container is passed in as well which
880    * the actor should populate with actors it has not / or does not
881    * need to handle in its size negotiation.
882    *
883    * @param[in]      size       The allocated size.
884    * @param[in,out]  container  The container that holds actors that are fed back into the
885    *                            RelayoutController algorithm.
886    */
887   void NegotiateSize( const Vector2& size, RelayoutContainer& container );
888
889   /**
890    * @copydoc Dali::Actor::SetResizePolicy()
891    */
892   void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
893
894   /**
895    * @copydoc Dali::Actor::GetResizePolicy()
896    */
897   ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
898
899   /**
900    * @copydoc Dali::Actor::SetSizeScalePolicy()
901    */
902   void SetSizeScalePolicy( SizeScalePolicy::Type policy );
903
904   /**
905    * @copydoc Dali::Actor::GetSizeScalePolicy()
906    */
907   SizeScalePolicy::Type GetSizeScalePolicy() const;
908
909   /**
910    * @copydoc Dali::Actor::SetDimensionDependency()
911    */
912   void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
913
914   /**
915    * @copydoc Dali::Actor::GetDimensionDependency()
916    */
917   Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
918
919   /**
920    * @brief Set the size negotiation relayout enabled on this actor
921    *
922    * @param[in] relayoutEnabled Boolean to enable or disable relayout
923    */
924   void SetRelayoutEnabled( bool relayoutEnabled );
925
926   /**
927    * @brief Return if relayout is enabled
928    *
929    * @return Return if relayout is enabled or not for this actor
930    */
931   bool IsRelayoutEnabled() const;
932
933   /**
934    * @brief Mark an actor as having it's layout dirty
935    *
936    * @param dirty Whether to mark actor as dirty or not
937    * @param dimension The dimension(s) to mark as dirty
938    */
939   void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
940
941   /**
942    * @brief Return if any of an actor's dimensions are marked as dirty
943    *
944    * @param dimension The dimension(s) to check
945    * @return Return if any of the requested dimensions are dirty
946    */
947   bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
948
949   /**
950    * @brief Returns if relayout is enabled and the actor is not dirty
951    *
952    * @return Return if it is possible to relayout the actor
953    */
954   bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
955
956   /**
957    * @brief Returns if relayout is enabled and the actor is dirty
958    *
959    * @return Return if it is required to relayout the actor
960    */
961   bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
962
963   /**
964    * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
965    *
966    * This method is automatically called from OnStageConnection(), OnChildAdd(),
967    * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
968    *
969    * This method can also be called from a derived class every time it needs a different size.
970    * At the end of event processing, the relayout process starts and
971    * all controls which requested Relayout will have their sizes (re)negotiated.
972    *
973    * @note RelayoutRequest() can be called multiple times; the size negotiation is still
974    * only performed once, i.e. there is no need to keep track of this in the calling side.
975    */
976   void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
977
978   /**
979    * @brief Determine if this actor is dependent on it's parent for relayout
980    *
981    * @param dimension The dimension(s) to check for
982    * @return Return if the actor is dependent on it's parent
983    */
984   bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
985
986   /**
987    * @brief Determine if this actor has another dimension depedent on the specified one
988    *
989    * @param dimension The dimension to check for
990    * @param dependentDimension The dimension to check for dependency with
991    * @return Return if the actor is dependent on this dimension
992    */
993   bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
994
995   /**
996    * Negotiate sizes for a control in all dimensions
997    *
998    * @param[in] allocatedSize The size constraint that the control must respect
999    */
1000   void NegotiateDimensions( const Vector2& allocatedSize );
1001
1002   /**
1003    * Negotiate size for a specific dimension
1004    *
1005    * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1006    * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1007    * LayoutDimensionNegotiated flags being filled in on the actor.
1008    *
1009    * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1010    * calculated and set as well as the LayoutDimensionNegotiated flags.
1011    *
1012    * @param[in] dimension The dimension to negotiate on
1013    * @param[in] allocatedSize The size constraint that the actor must respect
1014    */
1015   void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1016
1017   /**
1018    * @brief Calculate the size of a dimension
1019    *
1020    * @param[in] dimension The dimension to calculate the size for
1021    * @param[in] maximumSize The upper bounds on the size
1022    * @return Return the calculated size for the dimension
1023    */
1024   float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1025
1026   /**
1027    * @brief Clamp a dimension given the relayout constraints on this actor
1028    *
1029    * @param[in] size The size to constrain
1030    * @param[in] dimension The dimension the size exists in
1031    * @return Return the clamped size
1032    */
1033   float ClampDimension( float size, Dimension::Type dimension );
1034
1035   /**
1036    * Negotiate a dimension based on the size of the parent
1037    *
1038    * @param[in] dimension The dimension to negotiate on
1039    * @return Return the negotiated size
1040    */
1041   float NegotiateFromParent( Dimension::Type dimension );
1042
1043   /**
1044    * Negotiate a dimension based on the size of the parent. Fitting inside.
1045    *
1046    * @param[in] dimension The dimension to negotiate on
1047    * @return Return the negotiated size
1048    */
1049   float NegotiateFromParentFit( Dimension::Type dimension );
1050
1051   /**
1052    * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1053    *
1054    * @param[in] dimension The dimension to negotiate on
1055    * @return Return the negotiated size
1056    */
1057   float NegotiateFromParentFlood( Dimension::Type dimension );
1058
1059   /**
1060    * @brief Negotiate a dimension based on the size of the children
1061    *
1062    * @param[in] dimension The dimension to negotiate on
1063    * @return Return the negotiated size
1064    */
1065   float NegotiateFromChildren( Dimension::Type dimension );
1066
1067   /**
1068    * Set the negotiated dimension value for the given dimension(s)
1069    *
1070    * @param negotiatedDimension The value to set
1071    * @param dimension The dimension(s) to set the value for
1072    */
1073   void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1074
1075   /**
1076    * Return the value of negotiated dimension for the given dimension
1077    *
1078    * @param dimension The dimension to retrieve
1079    * @return Return the value of the negotiated dimension
1080    */
1081   float GetNegotiatedDimension( Dimension::Type dimension ) const;
1082
1083   /**
1084    * @brief Set the padding for a dimension
1085    *
1086    * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1087    * @param[in] dimension The dimension to set
1088    */
1089   void SetPadding( const Vector2& padding, Dimension::Type dimension );
1090
1091   /**
1092    * Return the value of padding for the given dimension
1093    *
1094    * @param dimension The dimension to retrieve
1095    * @return Return the value of padding for the dimension
1096    */
1097   Vector2 GetPadding( Dimension::Type dimension ) const;
1098
1099   /**
1100    * Return the actor size for a given dimension
1101    *
1102    * @param[in] dimension The dimension to retrieve the size for
1103    * @return Return the size for the given dimension
1104    */
1105   float GetSize( Dimension::Type dimension ) const;
1106
1107   /**
1108    * Return the natural size of the actor for a given dimension
1109    *
1110    * @param[in] dimension The dimension to retrieve the size for
1111    * @return Return the natural size for the given dimension
1112    */
1113   float GetNaturalSize( Dimension::Type dimension ) const;
1114
1115   /**
1116    * @brief Return the amount of size allocated for relayout
1117    *
1118    * May include padding
1119    *
1120    * @param[in] dimension The dimension to retrieve
1121    * @return Return the size
1122    */
1123   float GetRelayoutSize( Dimension::Type dimension ) const;
1124
1125   /**
1126    * @brief If the size has been negotiated return that else return normal size
1127    *
1128    * @param[in] dimension The dimension to retrieve
1129    * @return Return the size
1130    */
1131   float GetLatestSize( Dimension::Type dimension ) const;
1132
1133   /**
1134    * Apply the negotiated size to the actor
1135    *
1136    * @param[in] container The container to fill with actors that require further relayout
1137    */
1138   void SetNegotiatedSize( RelayoutContainer& container );
1139
1140   /**
1141    * @brief Flag the actor as having it's layout dimension negotiated.
1142    *
1143    * @param[in] negotiated The status of the flag to set.
1144    * @param[in] dimension The dimension to set the flag for
1145    */
1146   void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1147
1148   /**
1149    * @brief Test whether the layout dimension for this actor has been negotiated or not.
1150    *
1151    * @param[in] dimension The dimension to determine the value of the flag for
1152    * @return Return if the layout dimension is negotiated or not.
1153    */
1154   bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1155
1156   /**
1157    * @brief provides the Actor implementation of GetHeightForWidth
1158    * @param width to use.
1159    * @return the height based on the width.
1160    */
1161   float GetHeightForWidthBase( float width );
1162
1163   /**
1164    * @brief provides the Actor implementation of GetWidthForHeight
1165    * @param height to use.
1166    * @return the width based on the height.
1167    */
1168   float GetWidthForHeightBase( float height );
1169
1170   /**
1171    * @brief Calculate the size for a child
1172    *
1173    * @param[in] child The child actor to calculate the size for
1174    * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1175    * @return Return the calculated size for the given dimension
1176    */
1177   float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1178
1179   /**
1180    * @brief Set the preferred size for size negotiation
1181    *
1182    * @param[in] size The preferred size to set
1183    */
1184   void SetPreferredSize( const Vector2& size );
1185
1186   /**
1187    * @brief Return the preferred size used for size negotiation
1188    *
1189    * @return Return the preferred size
1190    */
1191   Vector2 GetPreferredSize() const;
1192
1193   /**
1194    * @copydoc Dali::Actor::SetMinimumSize
1195    */
1196   void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1197
1198   /**
1199    * @copydoc Dali::Actor::GetMinimumSize
1200    */
1201   float GetMinimumSize( Dimension::Type dimension ) const;
1202
1203   /**
1204    * @copydoc Dali::Actor::SetMaximumSize
1205    */
1206   void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1207
1208   /**
1209    * @copydoc Dali::Actor::GetMaximumSize
1210    */
1211   float GetMaximumSize( Dimension::Type dimension ) const;
1212
1213   /**
1214    * @copydoc Dali::Actor::AddRenderer()
1215    */
1216   unsigned int AddRenderer( Renderer& renderer );
1217
1218   /**
1219    * @copydoc Dali::Actor::GetRendererCount()
1220    */
1221   unsigned int GetRendererCount() const;
1222
1223   /**
1224    * @copydoc Dali::Actor::GetRendererAt()
1225    */
1226   RendererPtr GetRendererAt( unsigned int index );
1227
1228   /**
1229    * @copydoc Dali::Actor::RemoveRenderer()
1230    */
1231   void RemoveRenderer( Renderer& renderer );
1232
1233   /**
1234    * @copydoc Dali::Actor::RemoveRenderer()
1235    */
1236   void RemoveRenderer( unsigned int index );
1237
1238 public:
1239
1240   /**
1241    * Converts screen coordinates into the actor's coordinate system.
1242    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1243    * @param[out] localX On return, the X-coordinate relative to the actor.
1244    * @param[out] localY On return, the Y-coordinate relative to the actor.
1245    * @param[in] screenX The screen X-coordinate.
1246    * @param[in] screenY The screen Y-coordinate.
1247    * @return True if the conversion succeeded.
1248    */
1249   bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const;
1250
1251   /**
1252    * Converts screen coordinates into the actor's coordinate system.
1253    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1254    * @param[in] renderTask The render-task used to display the actor.
1255    * @param[out] localX On return, the X-coordinate relative to the actor.
1256    * @param[out] localY On return, the Y-coordinate relative to the actor.
1257    * @param[in] screenX The screen X-coordinate.
1258    * @param[in] screenY The screen Y-coordinate.
1259    * @return True if the conversion succeeded.
1260    */
1261   bool ScreenToLocal( const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1262
1263   /**
1264    * Converts from the actor's coordinate system to screen coordinates.
1265    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1266    * @param[in] viewMatrix The view-matrix
1267    * @param[in] projectionMatrix The projection-matrix
1268    * @param[in] viewport The view-port
1269    * @param[out] localX On return, the X-coordinate relative to the actor.
1270    * @param[out] localY On return, the Y-coordinate relative to the actor.
1271    * @param[in] screenX The screen X-coordinate.
1272    * @param[in] screenY The screen Y-coordinate.
1273    * @return True if the conversion succeeded.
1274    */
1275   bool ScreenToLocal( const Matrix& viewMatrix,
1276                       const Matrix& projectionMatrix,
1277                       const Viewport& viewport,
1278                       float& localX,
1279                       float& localY,
1280                       float screenX,
1281                       float screenY ) const;
1282
1283   /**
1284    * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
1285    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1286    * @param[in] rayOrigin The ray origin in the world's reference system.
1287    * @param[in] rayDir The ray director vector in the world's reference system.
1288    * @return True if the ray intersects the actor's bounding sphere.
1289    */
1290   bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
1291
1292   /**
1293    * Performs a ray-actor test with the given pick-ray and the actor's geometry.
1294    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1295    * @param[in] rayOrigin The ray origin in the world's reference system.
1296    * @param[in] rayDir The ray director vector in the world's reference system.
1297    * @param[out] hitPointLocal The hit point in the Actor's local reference system.
1298    * @param[out] distance The distance from the hit point to the camera.
1299    * @return True if the ray intersects the actor's geometry.
1300    */
1301   bool RayActorTest( const Vector4& rayOrigin,
1302                      const Vector4& rayDir,
1303                      Vector4& hitPointLocal,
1304                      float& distance ) const;
1305
1306   /**
1307    * Sets whether the actor should receive a notification when touch or hover motion events leave
1308    * the boundary of the actor.
1309    *
1310    * @note By default, this is set to false as most actors do not require this.
1311    * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1312    *
1313    * @param[in]  required  Should be set to true if a Leave event is required
1314    */
1315   void SetLeaveRequired( bool required );
1316
1317   /**
1318    * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1319    * the boundary of the actor.
1320    * @return true if a Leave event is required, false otherwise.
1321    */
1322   bool GetLeaveRequired() const;
1323
1324   /**
1325    * @copydoc Dali::Actor::SetKeyboardFocusable()
1326    */
1327   void SetKeyboardFocusable( bool focusable );
1328
1329   /**
1330    * @copydoc Dali::Actor::IsKeyboardFocusable()
1331    */
1332   bool IsKeyboardFocusable() const;
1333
1334   /**
1335    * Query whether the application or derived actor type requires touch events.
1336    * @return True if touch events are required.
1337    */
1338   bool GetTouchRequired() const;
1339
1340   /**
1341    * Query whether the application or derived actor type requires hover events.
1342    * @return True if hover events are required.
1343    */
1344   bool GetHoverRequired() const;
1345
1346   /**
1347    * Query whether the application or derived actor type requires wheel events.
1348    * @return True if wheel events are required.
1349    */
1350   bool GetWheelEventRequired() const;
1351
1352   /**
1353    * Query whether the actor is actually hittable.  This method checks whether the actor is
1354    * sensitive, has the visibility flag set to true and is not fully transparent.
1355    * @return true, if it can be hit, false otherwise.
1356    */
1357   bool IsHittable() const;
1358
1359   // Gestures
1360
1361   /**
1362    * Retrieve the gesture data associated with this actor. The first call to this method will
1363    * allocate space for the ActorGestureData so this should only be called if an actor really does
1364    * require gestures.
1365    * @return Reference to the ActorGestureData for this actor.
1366    * @note Once the gesture-data is created for an actor it is likely that gestures are required
1367    * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1368    */
1369   ActorGestureData& GetGestureData();
1370
1371   /**
1372    * Queries whether the actor requires the gesture type.
1373    * @param[in] type The gesture type.
1374    */
1375   bool IsGestureRequred( Gesture::Type type ) const;
1376
1377   // Signals
1378
1379   /**
1380    * Used by the EventProcessor to emit touch event signals.
1381    * @param[in] event The touch event.
1382    * @return True if the event was consumed.
1383    */
1384   bool EmitTouchEventSignal( const TouchEvent& event );
1385
1386   /**
1387    * Used by the EventProcessor to emit hover event signals.
1388    * @param[in] event The hover event.
1389    * @return True if the event was consumed.
1390    */
1391   bool EmitHoverEventSignal( const HoverEvent& event );
1392
1393   /**
1394    * Used by the EventProcessor to emit wheel event signals.
1395    * @param[in] event The wheel event.
1396    * @return True if the event was consumed.
1397    */
1398   bool EmitWheelEventSignal( const WheelEvent& event );
1399
1400   /**
1401    * @copydoc Dali::Actor::TouchedSignal()
1402    */
1403   Dali::Actor::TouchSignalType& TouchedSignal();
1404
1405   /**
1406    * @copydoc Dali::Actor::HoveredSignal()
1407    */
1408   Dali::Actor::HoverSignalType& HoveredSignal();
1409
1410   /**
1411    * @copydoc Dali::Actor::WheelEventSignal()
1412    */
1413   Dali::Actor::WheelEventSignalType& WheelEventSignal();
1414
1415   /**
1416    * @copydoc Dali::Actor::OnStageSignal()
1417    */
1418   Dali::Actor::OnStageSignalType& OnStageSignal();
1419
1420   /**
1421    * @copydoc Dali::Actor::OffStageSignal()
1422    */
1423   Dali::Actor::OffStageSignalType& OffStageSignal();
1424
1425   /**
1426    * @copydoc Dali::Actor::OnRelayoutSignal()
1427    */
1428   Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal();
1429
1430   /**
1431    * Connects a callback function with the object's signals.
1432    * @param[in] object The object providing the signal.
1433    * @param[in] tracker Used to disconnect the signal.
1434    * @param[in] signalName The signal to connect to.
1435    * @param[in] functor A newly allocated FunctorDelegate.
1436    * @return True if the signal was connected.
1437    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1438    */
1439   static bool DoConnectSignal( BaseObject* object,
1440                                ConnectionTrackerInterface* tracker,
1441                                const std::string& signalName,
1442                                FunctorDelegate* functor );
1443
1444   /**
1445    * Performs actions as requested using the action name.
1446    * @param[in] object The object on which to perform the action.
1447    * @param[in] actionName The action to perform.
1448    * @param[in] attributes The attributes with which to perfrom this action.
1449    * @return true if the action was done.
1450    */
1451   static bool DoAction( BaseObject* object,
1452                         const std::string& actionName,
1453                         const Property::Map& attributes );
1454
1455 public:
1456   // For Animation
1457
1458   /**
1459    * This should only be called by Animation, when the actors SIZE property is animated.
1460    *
1461    * @param[in] animation The animation that resized the actor
1462    * @param[in] targetSize The new target size of the actor
1463    */
1464   void NotifySizeAnimation( Animation& animation, const Vector3& targetSize );
1465
1466   /**
1467    * This should only be called by Animation, when the actors SIZE_WIDTH or SIZE_HEIGHT or SIZE_DEPTH property is animated.
1468    *
1469    * @param[in] animation The animation that resized the actor
1470    * @param[in] targetSize The new target size of the actor
1471    * @param[in] property The index of the property being animated
1472    */
1473   void NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property );
1474
1475   /**
1476    * For use in derived classes.
1477    * This should only be called by Animation, when the actor is resized using Animation::Resize().
1478    */
1479   virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1480   {
1481   }
1482
1483   /**
1484    * This should only be called by Animation, when the actors POSITION property is animated.
1485    *
1486    * @param[in] animation The animation that repositioned the actor
1487    * @param[in] targetPosition The new target position of the actor
1488    */
1489   void NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition );
1490
1491   /**
1492    * This should only be called by Animation, when the actors POSITION_X or POSITION_Y or POSITION_Z property is animated.
1493    *
1494    * @param[in] animation The animation that repositioned the actor
1495    * @param[in] targetPosition The new target position of the actor
1496    * @param[in] property The index of the property being animated
1497    */
1498   void NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property );
1499
1500 protected:
1501
1502   enum DerivedType
1503   {
1504     BASIC, LAYER, ROOT_LAYER
1505   };
1506
1507   /**
1508    * Protected Constructor.  See Actor::New().
1509    * The second-phase construction Initialize() member should be called immediately after this.
1510    * @param[in] derivedType The derived type of actor (if any).
1511    */
1512   Actor( DerivedType derivedType );
1513
1514   /**
1515    * Second-phase constructor. Must be called immediately after creating a new Actor;
1516    */
1517   void Initialize( void );
1518
1519   /**
1520    * A reference counted object may only be deleted by calling Unreference()
1521    */
1522   virtual ~Actor();
1523
1524   /**
1525    * Called on a child during Add() when the parent actor is connected to the Stage.
1526    * @param[in] parentDepth The depth of the parent in the hierarchy.
1527    */
1528   void ConnectToStage( unsigned int parentDepth );
1529
1530   /**
1531    * Helper for ConnectToStage, to recursively connect a tree of actors.
1532    * This is atomic i.e. not interrupted by user callbacks.
1533    * @param[in]  depth The depth in the hierarchy of the actor
1534    * @param[out] connectionList On return, the list of connected actors which require notification.
1535    */
1536   void RecursiveConnectToStage( ActorContainer& connectionList, unsigned int depth );
1537
1538   /**
1539    * Connect the Node associated with this Actor to the scene-graph.
1540    */
1541   void ConnectToSceneGraph();
1542
1543   /**
1544    * Helper for ConnectToStage, to notify a connected actor through the public API.
1545    */
1546   void NotifyStageConnection();
1547
1548   /**
1549    * Called on a child during Remove() when the actor was previously on the Stage.
1550    */
1551   void DisconnectFromStage();
1552
1553   /**
1554    * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1555    * This is atomic i.e. not interrupted by user callbacks.
1556    * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1557    */
1558   void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1559
1560   /**
1561    * Disconnect the Node associated with this Actor from the scene-graph.
1562    */
1563   void DisconnectFromSceneGraph();
1564
1565   /**
1566    * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1567    */
1568   void NotifyStageDisconnection();
1569
1570   /**
1571    * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1572    * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1573    */
1574   bool IsNodeConnected() const;
1575
1576 public:
1577
1578   // Default property extensions from Object
1579
1580   /**
1581    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
1582    */
1583   virtual unsigned int GetDefaultPropertyCount() const;
1584
1585   /**
1586    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
1587    */
1588   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1589
1590   /**
1591    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
1592    */
1593   virtual const char* GetDefaultPropertyName( Property::Index index ) const;
1594
1595   /**
1596    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
1597    */
1598   virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const;
1599
1600   /**
1601    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
1602    */
1603   virtual bool IsDefaultPropertyWritable( Property::Index index ) const;
1604
1605   /**
1606    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
1607    */
1608   virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
1609
1610   /**
1611    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
1612    */
1613   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1614
1615   /**
1616    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
1617    */
1618   virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
1619
1620   /**
1621    * @copydoc Dali::Internal::Object::SetDefaultProperty()
1622    */
1623   virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
1624
1625   /**
1626    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1627    */
1628   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
1629
1630   /**
1631    * @copydoc Dali::Internal::Object::GetDefaultProperty()
1632    */
1633   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1634
1635   /**
1636    * @copydoc Dali::Internal::Object::GetPropertyOwner()
1637    */
1638   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
1639
1640   /**
1641    * @copydoc Dali::Internal::Object::GetSceneObject()
1642    */
1643   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1644
1645   /**
1646    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1647    */
1648   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1649
1650   /**
1651    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1652    */
1653   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1654
1655   /**
1656    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1657    */
1658   virtual int GetPropertyComponentIndex( Property::Index index ) const;
1659
1660 private:
1661
1662   // Undefined
1663   Actor();
1664
1665   // Undefined
1666   Actor( const Actor& );
1667
1668   // Undefined
1669   Actor& operator=( const Actor& rhs );
1670
1671   /**
1672    * Set the actors parent.
1673    * @param[in] parent The new parent.
1674    */
1675   void SetParent( Actor* parent );
1676
1677   /**
1678    * Helper to create a Node for this Actor.
1679    * To be overriden in derived classes.
1680    * @return A newly allocated node.
1681    */
1682   virtual SceneGraph::Node* CreateNode() const;
1683
1684   /**
1685    * For use in derived classes, called after Initialize()
1686    */
1687   virtual void OnInitialize()
1688   {
1689   }
1690
1691   /**
1692    * For use in internal derived classes.
1693    * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1694    * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1695    */
1696   virtual void OnStageConnectionInternal()
1697   {
1698   }
1699
1700   /**
1701    * For use in internal derived classes.
1702    * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1703    * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1704    */
1705   virtual void OnStageDisconnectionInternal()
1706   {
1707   }
1708
1709   /**
1710    * For use in external (CustomActor) derived classes.
1711    * This is called after the atomic ConnectToStage() traversal has been completed.
1712    */
1713   virtual void OnStageConnectionExternal( int depth )
1714   {
1715   }
1716
1717   /**
1718    * For use in external (CustomActor) derived classes.
1719    * This is called after the atomic DisconnectFromStage() traversal has been completed.
1720    */
1721   virtual void OnStageDisconnectionExternal()
1722   {
1723   }
1724
1725   /**
1726    * For use in derived classes; this is called after Add() has added a child.
1727    * @param[in] child The child that was added.
1728    */
1729   virtual void OnChildAdd( Actor& child )
1730   {
1731   }
1732
1733   /**
1734    * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1735    * @param[in] child The child that was removed.
1736    */
1737   virtual void OnChildRemove( Actor& child )
1738   {
1739   }
1740
1741   /**
1742    * For use in derived classes.
1743    * This is called after SizeSet() has been called.
1744    */
1745   virtual void OnSizeSet( const Vector3& targetSize )
1746   {
1747   }
1748
1749   /**
1750    * For use in derived classes.
1751    * This is only called if mDerivedRequiresTouch is true, and the touch-signal was not consumed.
1752    * @param[in] event The touch event.
1753    * @return True if the event should be consumed.
1754    */
1755   virtual bool OnTouchEvent( const TouchEvent& event )
1756   {
1757     return false;
1758   }
1759
1760   /**
1761    * For use in derived classes.
1762    * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
1763    * @param[in] event The hover event.
1764    * @return True if the event should be consumed.
1765    */
1766   virtual bool OnHoverEvent( const HoverEvent& event )
1767   {
1768     return false;
1769   }
1770
1771   /**
1772    * For use in derived classes.
1773    * This is only called if the wheel signal was not consumed.
1774    * @param[in] event The wheel event.
1775    * @return True if the event should be consumed.
1776    */
1777   virtual bool OnWheelEvent( const WheelEvent& event )
1778   {
1779     return false;
1780   }
1781
1782   /**
1783    * @brief Ensure the relayout data is allocated
1784    */
1785   void EnsureRelayoutData();
1786
1787   /**
1788    * @brief Apply the size set policy to the input size
1789    *
1790    * @param[in] size The size to apply the policy to
1791    * @return Return the adjusted size
1792    */
1793   Vector2 ApplySizeSetPolicy( const Vector2 size );
1794
1795 protected:
1796
1797   Actor* mParent;                 ///< Each actor (except the root) can have one parent
1798   ActorContainer* mChildren;      ///< Container of referenced actors
1799   RendererContainer* mRenderers;   ///< Renderer container
1800
1801   const SceneGraph::Node* mNode;  ///< Not owned
1802   Vector3* mParentOrigin;         ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1803   Vector3* mAnchorPoint;          ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1804
1805   struct RelayoutData;
1806   RelayoutData* mRelayoutData; ///< Struct to hold optional collection of relayout variables
1807
1808   ActorGestureData* mGestureData;   ///< Optional Gesture data. Only created when actor requires gestures
1809
1810   ActorAttachmentPtr mAttachment;   ///< Optional referenced attachment
1811
1812   // Signals
1813   Dali::Actor::TouchSignalType             mTouchedSignal;
1814   Dali::Actor::HoverSignalType             mHoveredSignal;
1815   Dali::Actor::WheelEventSignalType        mWheelEventSignal;
1816   Dali::Actor::OnStageSignalType           mOnStageSignal;
1817   Dali::Actor::OffStageSignalType          mOffStageSignal;
1818   Dali::Actor::OnRelayoutSignalType        mOnRelayoutSignal;
1819
1820   Vector3         mTargetSize;       ///< Event-side storage for size (not a pointer as most actors will have a size)
1821   Vector3         mTargetPosition;   ///< Event-side storage for position (not a pointer as most actors will have a position)
1822
1823   std::string     mName;      ///< Name of the actor
1824   unsigned int    mId;        ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1825
1826   unsigned short mDepth                            :12; ///< Cached: The depth in the hierarchy of the actor. Only 4096 levels of depth are supported
1827   const bool mIsRoot                               : 1; ///< Flag to identify the root actor
1828   const bool mIsLayer                              : 1; ///< Flag to identify that this is a layer
1829   bool mIsOnStage                                  : 1; ///< Flag to identify whether the actor is on-stage
1830   bool mSensitive                                  : 1; ///< Whether the actor emits touch event signals
1831   bool mLeaveRequired                              : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1832   bool mKeyboardFocusable                          : 1; ///< Whether the actor should be focusable by keyboard navigation
1833   bool mDerivedRequiresTouch                       : 1; ///< Whether the derived actor type requires touch event signals
1834   bool mDerivedRequiresHover                       : 1; ///< Whether the derived actor type requires hover event signals
1835   bool mDerivedRequiresWheelEvent                  : 1; ///< Whether the derived actor type requires wheel event signals
1836   bool mOnStageSignalled                           : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1837   bool mInsideOnSizeSet                            : 1; ///< Whether we are inside OnSizeSet
1838   bool mInheritPosition                            : 1; ///< Cached: Whether the parent's position should be inherited.
1839   bool mInheritOrientation                         : 1; ///< Cached: Whether the parent's orientation should be inherited.
1840   bool mInheritScale                               : 1; ///< Cached: Whether the parent's scale should be inherited.
1841   DrawMode::Type mDrawMode                         : 2; ///< Cached: How the actor and its children should be drawn
1842   PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1843   ColorMode mColorMode                             : 2; ///< Cached: Determines whether mWorldColor is inherited
1844
1845 private:
1846
1847   static ActorContainer mNullChildren;  ///< Empty container (shared by all actors, returned by GetChildren() const)
1848   static unsigned int mActorCounter;    ///< A counter to track the actor instance creation
1849
1850 };
1851
1852 } // namespace Internal
1853
1854 // Helpers for public-api forwarding methods
1855
1856 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
1857 {
1858   DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1859
1860   BaseObject& handle = actor.GetBaseObject();
1861
1862   return static_cast< Internal::Actor& >( handle );
1863 }
1864
1865 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
1866 {
1867   DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
1868
1869   const BaseObject& handle = actor.GetBaseObject();
1870
1871   return static_cast< const Internal::Actor& >( handle );
1872 }
1873
1874 } // namespace Dali
1875
1876 #endif // __DALI_INTERNAL_ACTOR_H__