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