Moved sibling order algorithms out of actor-impl
[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) 2020 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/devel-api/actors/actor-devel.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/events/gesture.h>
30 #include <dali/public-api/math/viewport.h>
31 #include <dali/public-api/object/ref-object.h>
32 #include <dali/public-api/size-negotiation/relayout-container.h>
33 #include <dali/internal/common/internal-constants.h>
34 #include <dali/internal/common/memory-pool-object-allocator.h>
35 #include <dali/internal/event/actors/actor-declarations.h>
36 #include <dali/internal/event/common/object-impl.h>
37 #include <dali/internal/event/common/stage-def.h>
38 #include <dali/internal/event/rendering/renderer-impl.h>
39 #include <dali/internal/update/nodes/node-declarations.h>
40 #include <dali/internal/update/manager/update-manager.h>
41
42 namespace Dali
43 {
44
45 class KeyEvent;
46 class TouchData;
47 class TouchEvent;
48 class WheelEvent;
49
50 namespace Internal
51 {
52
53 class Actor;
54 class ActorGestureData;
55 class Animation;
56 class RenderTask;
57 class Renderer;
58 class Scene;
59
60 using RendererContainer = std::vector<RendererPtr>;
61 using RendererIter      = RendererContainer::iterator;
62
63 class ActorDepthTreeNode;
64 using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator<ActorDepthTreeNode>;
65
66 /**
67  * Actor is the primary object which Dali applications interact with.
68  * UI controls can be built by combining multiple actors.
69  * Multi-Touch events are received through signals emitted by the actor tree.
70  *
71  * An Actor is a proxy for a Node in the scene graph.
72  * When an Actor is added to the Stage, it creates a node and connects it to the scene graph.
73  * The scene-graph can be updated in a separate thread, so the connection is done using an asynchronous message.
74  * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
75  */
76 class Actor : public Object
77 {
78 public:
79
80   /**
81    * @brief Struct to hold an actor and a dimension
82    */
83   struct ActorDimensionPair
84   {
85     /**
86      * @brief Constructor
87      *
88      * @param[in] newActor The actor to assign
89      * @param[in] newDimension The dimension to assign
90      */
91     ActorDimensionPair( Actor* newActor, Dimension::Type newDimension )
92     : actor( newActor ),
93       dimension( newDimension )
94     {
95     }
96
97     /**
98      * @brief Equality operator
99      *
100      * @param[in] lhs The left hand side argument
101      * @param[in] rhs The right hand side argument
102      */
103     bool operator== ( const ActorDimensionPair& rhs )
104     {
105       return ( actor == rhs.actor ) && ( dimension == rhs.dimension );
106     }
107
108     Actor* actor;           ///< The actor to hold
109     Dimension::Type dimension;    ///< The dimension to hold
110   };
111
112   using ActorDimensionStack = std::vector<ActorDimensionPair>;
113
114 public:
115
116   /**
117    * Create a new actor.
118    * @return A smart-pointer to the newly allocated Actor.
119    */
120   static ActorPtr New();
121
122   /**
123    * Helper to create node for derived classes who don't have their own node type
124    * @return pointer to newly created unique node
125    */
126   static const SceneGraph::Node* CreateNode();
127
128   /**
129    * Retrieve the name of the actor.
130    * @return The name.
131    */
132   const std::string& GetName() const
133   {
134     return mName;
135   }
136
137   /**
138    * Set the name of the actor.
139    * @param[in] name The new name.
140    */
141   void SetName( const std::string& name );
142
143   /**
144    * @copydoc Dali::Actor::GetId
145    */
146   uint32_t GetId() const;
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 Scene.
161    */
162   bool OnScene() const
163   {
164     return mIsOnScene;
165   }
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   uint32_t GetChildCount() const;
219
220   /**
221    * @copydoc Dali::Actor::GetChildAt
222    */
223   ActorPtr GetChildAt( uint32_t 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    * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method.
230    */
231   ActorContainer& GetChildrenInternal()
232   {
233     return *mChildren;
234   }
235
236   /**
237    * @copydoc Dali::Actor::FindChildByName
238    */
239   ActorPtr FindChildByName( const std::string& actorName );
240
241   /**
242    * @copydoc Dali::Actor::FindChildById
243    */
244   ActorPtr FindChildById( const uint32_t id );
245
246   /**
247    * Retrieve the parent of an Actor.
248    * @return The parent actor, or NULL if the Actor does not have a parent.
249    */
250   Actor* GetParent() const
251   {
252     return mParent;
253   }
254
255   /**
256    * Calculates screen position and size.
257    *
258    * @return pair of two values, position of top-left corner on screen and size respectively.
259    */
260   Rect<> CalculateScreenExtents( ) const;
261
262   /**
263    * Sets the size of an actor.
264    * This does not interfere with the actors scale factor.
265    * @param [in] width  The new width.
266    * @param [in] height The new height.
267    */
268   void SetSize( float width, float height );
269
270   /**
271    * Sets the size of an actor.
272    * This does not interfere with the actors scale factor.
273    * @param [in] width The size of the actor along the x-axis.
274    * @param [in] height The size of the actor along the y-axis.
275    * @param [in] depth The size of the actor along the z-axis.
276    */
277   void SetSize( float width, float height, float depth );
278
279   /**
280    * Sets the size of an actor.
281    * This does not interfere with the actors scale factor.
282    * @param [in] size The new size.
283    */
284   void SetSize( const Vector2& size );
285
286   /**
287    * Sets the update size for an actor.
288    *
289    * @param[in] size The size to set.
290    */
291   void SetSizeInternal( const Vector2& size );
292
293   /**
294    * Sets the size of an actor.
295    * This does not interfere with the actors scale factor.
296    * @param [in] size The new size.
297    */
298   void SetSize( const Vector3& size );
299
300   /**
301    * Sets the update size for an actor.
302    *
303    * @param[in] size The size to set.
304    */
305   void SetSizeInternal( const Vector3& size );
306
307   /**
308    * Set the width component of the Actor's size.
309    * @param [in] width The new width component.
310    */
311   void SetWidth( float width );
312
313   /**
314    * Set the height component of the Actor's size.
315    * @param [in] height The new height component.
316    */
317   void SetHeight( float height );
318
319   /**
320    * Set the depth component of the Actor's size.
321    * @param [in] depth The new depth component.
322    */
323   void SetDepth( float depth );
324
325   /**
326    * Retrieve the Actor's size from event side.
327    * This size will be the size set or if animating then the target size.
328    * @return The Actor's size.
329    */
330   Vector3 GetTargetSize() const;
331
332   /**
333    * Retrieve the Actor's size from update side.
334    * This size will be the size set or animating but will be a frame behind.
335    * @return The Actor's size.
336    */
337   const Vector3& GetCurrentSize() const;
338
339   /**
340    * Return the natural size of the actor
341    *
342    * @return The actor's natural size
343    */
344   virtual Vector3 GetNaturalSize() const;
345
346   /**
347    * Set the origin of an actor, within its parent's area.
348    * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
349    * and (1.0, 1.0, 0.5) is the bottom-right corner.
350    * The default parent-origin is top-left (0.0, 0.0, 0.5).
351    * An actor position is the distance between this origin, and the actors anchor-point.
352    * @param [in] origin The new parent-origin.
353    */
354   void SetParentOrigin( const Vector3& origin );
355
356   /**
357    * Retrieve the parent-origin of an actor.
358    * @return The parent-origin.
359    */
360   const Vector3& GetCurrentParentOrigin() const;
361
362   /**
363    * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
364    * (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.
365    * The default anchor point is top-left (0.0, 0.0, 0.5).
366    * An actor position is the distance between its parent-origin, and this anchor-point.
367    * An actor's rotation is centered around its anchor-point.
368    * @param [in] anchorPoint The new anchor-point.
369    */
370   void SetAnchorPoint( const Vector3& anchorPoint );
371
372   /**
373    * Retrieve the anchor-point of an actor.
374    * @return The anchor-point.
375    */
376   const Vector3& GetCurrentAnchorPoint() const;
377
378   /**
379    * Sets the position of the Actor.
380    * The coordinates are relative to the Actor's parent.
381    * The Actor's z position will be set to 0.0f.
382    * @param [in] x The new x position
383    * @param [in] y The new y position
384    */
385   void SetPosition( float x, float y );
386
387   /**
388    * Sets the position of the Actor.
389    * The coordinates are relative to the Actor's parent.
390    * @param [in] x The new x position
391    * @param [in] y The new y position
392    * @param [in] z The new z position
393    */
394   void SetPosition( float x, float y, float z );
395
396   /**
397    * Sets the position of the Actor.
398    * The coordinates are relative to the Actor's parent.
399    * @param [in] position The new position.
400    */
401   void SetPosition( const Vector3& position );
402
403   /**
404    * Set the position of an actor along the X-axis.
405    * @param [in] x The new x position
406    */
407   void SetX( float x );
408
409   /**
410    * Set the position of an actor along the Y-axis.
411    * @param [in] y The new y position.
412    */
413   void SetY( float y );
414
415   /**
416    * Set the position of an actor along the Z-axis.
417    * @param [in] z The new z position
418    */
419   void SetZ( float z );
420
421   /**
422    * Translate an actor relative to its existing position.
423    * @param[in] distance The actor will move by this distance.
424    */
425   void TranslateBy( const Vector3& distance );
426
427   /**
428    * Retrieve the position of the Actor.
429    * The coordinates are relative to the Actor's parent.
430    * @return the Actor's position.
431    */
432   const Vector3& GetCurrentPosition() const;
433
434   /**
435    * Retrieve the target position of the Actor.
436    * The coordinates are relative to the Actor's parent.
437    * @return the Actor's position.
438    */
439   const Vector3& GetTargetPosition() const
440   {
441     return mTargetPosition;
442   }
443
444   /**
445    * @copydoc Dali::Actor::GetCurrentWorldPosition()
446    */
447   const Vector3& GetCurrentWorldPosition() const;
448
449   /**
450    * @copydoc Dali::Actor::SetInheritPosition()
451    */
452   void SetInheritPosition( bool inherit );
453
454   /**
455    * @copydoc Dali::Actor::IsPositionInherited()
456    */
457   bool IsPositionInherited() const
458   {
459     return mInheritPosition;
460   }
461
462   /**
463    * Sets the orientation of the Actor.
464    * @param [in] angleRadians The new orientation angle in radians.
465    * @param [in] axis The new axis of orientation.
466    */
467   void SetOrientation( const Radian& angleRadians, const Vector3& axis );
468
469   /**
470    * Sets the orientation of the Actor.
471    * @param [in] orientation The new orientation.
472    */
473   void SetOrientation( const Quaternion& orientation );
474
475   /**
476    * Rotate an actor around its existing rotation axis.
477    * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
478    * @param[in] axis The axis of the rotation to combine with the existing rotation.
479    */
480   void RotateBy( const Radian& angleRadians, const Vector3& axis );
481
482   /**
483    * Apply a relative rotation to an actor.
484    * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
485    */
486   void RotateBy( const Quaternion& relativeRotation );
487
488   /**
489    * Retreive the Actor's orientation.
490    * @return the orientation.
491    */
492   const Quaternion& GetCurrentOrientation() const;
493
494   /**
495    * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
496    * Switching this off means that using SetOrientation() sets the actor's world orientation.
497    * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
498    */
499   void SetInheritOrientation( bool inherit );
500
501   /**
502    * Returns whether the actor inherit's it's parent's orientation.
503    * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
504    */
505   bool IsOrientationInherited() const
506   {
507     return mInheritOrientation;
508   }
509
510   /**
511    * Sets the factor of the parents size used for the child actor.
512    * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
513    * @param[in] factor The vector to multiply the parents size by to get the childs size.
514    */
515   void SetSizeModeFactor( const Vector3& factor );
516
517   /**
518    * Gets the factor of the parents size used for the child actor.
519    * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.
520    * @return The vector being used to multiply the parents size by to get the childs size.
521    */
522   const Vector3& GetSizeModeFactor() const;
523
524   /**
525    * @copydoc Dali::Actor::GetCurrentWorldOrientation()
526    */
527   const Quaternion& GetCurrentWorldOrientation() const;
528
529   /**
530    * Sets a scale factor applied to an actor.
531    * @param [in] scale The scale factor applied on all axes.
532    */
533   void SetScale( float scale );
534
535   /**
536    * Sets a scale factor applied to an actor.
537    * @param [in] scaleX The scale factor applied along the x-axis.
538    * @param [in] scaleY The scale factor applied along the y-axis.
539    * @param [in] scaleZ The scale factor applied along the z-axis.
540    */
541   void SetScale( float scaleX, float scaleY, float scaleZ );
542
543   /**
544    * Sets a scale factor applied to an actor.
545    * @param [in] scale A vector representing the scale factor for each axis.
546    */
547   void SetScale( const Vector3& scale );
548
549   /**
550    * Set the x component of the scale factor.
551    * @param [in] x The new x value.
552    */
553   void SetScaleX( float x );
554
555   /**
556    * Set the y component of the scale factor.
557    * @param [in] y The new y value.
558    */
559   void SetScaleY( float y );
560
561   /**
562    * Set the z component of the scale factor.
563    * @param [in] z The new z value.
564    */
565   void SetScaleZ( float z );
566
567   /**
568    * Apply a relative scale to an actor.
569    * @param[in] relativeScale The scale to combine with the actors existing scale.
570    */
571   void ScaleBy( const Vector3& relativeScale );
572
573   /**
574    * Retrieve the scale factor applied to an actor.
575    * @return A vector representing the scale factor for each axis.
576    */
577   const Vector3& GetCurrentScale() const;
578
579   /**
580    * @copydoc Dali::Actor::GetCurrentWorldScale()
581    */
582   const Vector3& GetCurrentWorldScale() const;
583
584   /**
585    * @copydoc Dali::Actor::SetInheritScale()
586    */
587   void SetInheritScale( bool inherit );
588
589   /**
590    * @copydoc Dali::Actor::IsScaleInherited()
591    */
592   bool IsScaleInherited() const
593   {
594     return mInheritScale;
595   }
596
597   /**
598    * @copydoc Dali::Actor::GetCurrentWorldMatrix()
599    */
600   Matrix GetCurrentWorldMatrix() const;
601
602   // Visibility
603
604   /**
605    * Sets the visibility flag of an actor.
606    * @param[in] visible The new visibility flag.
607    */
608   void SetVisible( bool visible );
609
610   /**
611    * Retrieve the visibility flag of an actor.
612    * @return The visibility flag.
613    */
614   bool IsVisible() const;
615
616   /**
617    * Sets the opacity of an actor.
618    * @param [in] opacity The new opacity.
619    */
620   void SetOpacity( float opacity );
621
622   /**
623    * Retrieve the actor's opacity.
624    * @return The actor's opacity.
625    */
626   float GetCurrentOpacity() const;
627
628   /**
629    * Retrieve the actor's clipping mode.
630    * @return The actor's clipping mode (cached)
631    */
632   ClippingMode::Type GetClippingMode() const
633   {
634     return mClippingMode;
635   }
636
637   /**
638    * Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
639    * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
640    * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
641    * hover event signal will be emitted.
642    *
643    * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
644    * @code
645    * actor.SetSensitive(false);
646    * @endcode
647    *
648    * Then, to re-enable the touch or hover event signal emission, the application should call:
649    * @code
650    * actor.SetSensitive(true);
651    * @endcode
652    *
653    * @see SignalTouch() and SignalHover().
654    * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either.
655    * @param[in]  sensitive  true to enable emission of the touch or hover event signals, false otherwise.
656    */
657   void SetSensitive( bool sensitive )
658   {
659     mSensitive = sensitive;
660   }
661
662   /**
663    * Query whether an actor emits touch or hover event signals.
664    * @see SetSensitive(bool)
665    * @return true, if emission of touch or hover event signals is enabled, false otherwise.
666    */
667   bool IsSensitive() const
668   {
669     return mSensitive;
670   }
671
672   /**
673    * @copydoc Dali::Actor::SetDrawMode
674    */
675   void SetDrawMode( DrawMode::Type drawMode );
676
677   /**
678    * @copydoc Dali::Actor::GetDrawMode
679    */
680   DrawMode::Type GetDrawMode() const
681   {
682     return mDrawMode;
683   }
684
685   /**
686    * @copydoc Dali::Actor::IsOverlay
687    */
688   bool IsOverlay() const
689   {
690     return ( DrawMode::OVERLAY_2D == mDrawMode );
691   }
692
693   /**
694    * Sets the actor's color.  The final color of actor depends on its color mode.
695    * This final color is applied to the drawable elements of an actor.
696    * @param [in] color The new color.
697    */
698   void SetColor( const Vector4& color );
699
700   /**
701    * Set the red component of the color.
702    * @param [in] red The new red component.
703    */
704   void SetColorRed( float red );
705
706   /**
707    * Set the green component of the color.
708    * @param [in] green The new green component.
709    */
710   void SetColorGreen( float green );
711
712   /**
713    * Set the blue component of the scale factor.
714    * @param [in] blue The new blue value.
715    */
716   void SetColorBlue( float blue );
717
718   /**
719    * Retrieve the actor's color.
720    * @return The color.
721    */
722   const Vector4& GetCurrentColor() const;
723
724   /**
725    * Sets the actor's color mode.
726    * Color mode specifies whether Actor uses its own color or inherits its parent color
727    * @param [in] colorMode to use.
728    */
729   void SetColorMode( ColorMode colorMode );
730
731   /**
732    * Returns the actor's color mode.
733    * @return currently used colorMode.
734    */
735   ColorMode GetColorMode() const
736   {
737     return mColorMode;
738   }
739
740   /**
741    * @copydoc Dali::Actor::GetCurrentWorldColor()
742    */
743   const Vector4& GetCurrentWorldColor() const;
744
745   /**
746    * @copydoc Dali::Actor::GetHierarchyDepth()
747    */
748   inline int32_t GetHierarchyDepth() const
749   {
750     if( mIsOnScene )
751     {
752       return mDepth;
753     }
754
755     return -1;
756   }
757
758   /**
759    * Get the actor's sorting depth
760    *
761    * @return The depth used for hit-testing and renderer sorting
762    */
763   uint32_t GetSortingDepth()
764   {
765     return mSortedDepth;
766   }
767
768 public:
769
770   // Size negotiation virtual functions
771
772   /**
773    * @brief Called after the size negotiation has been finished for this control.
774    *
775    * The control is expected to assign this given size to itself/its children.
776    *
777    * Should be overridden by derived classes if they need to layout
778    * actors differently after certain operations like add or remove
779    * actors, resize or after changing specific properties.
780    *
781    * Note! As this function is called from inside the size negotiation algorithm, you cannot
782    * call RequestRelayout (the call would just be ignored)
783    *
784    * @param[in]      size       The allocated size.
785    * @param[in,out]  container  The control should add actors to this container that it is not able
786    *                            to allocate a size for.
787    */
788   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
789   {
790   }
791
792   /**
793    * @brief Notification for deriving classes when the resize policy is set
794    *
795    * @param[in] policy The policy being set
796    * @param[in] dimension The dimension the policy is being set for
797    */
798   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {}
799
800   /**
801    * @brief Virtual method to notify deriving classes that relayout dependencies have been
802    * met and the size for this object is about to be calculated for the given dimension
803    *
804    * @param dimension The dimension that is about to be calculated
805    */
806   virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) {}
807
808   /**
809    * @brief Virtual method to notify deriving classes that the size for a dimension
810    * has just been negotiated
811    *
812    * @param[in] size The new size for the given dimension
813    * @param[in] dimension The dimension that was just negotiated
814    */
815   virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) {}
816
817   /**
818    * @brief Determine if this actor is dependent on it's children for relayout
819    *
820    * @param dimension The dimension(s) to check for
821    * @return Return if the actor is dependent on it's children
822    */
823   virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
824
825   /**
826    * @brief Determine if this actor is dependent on it's children for relayout.
827    *
828    * Called from deriving classes
829    *
830    * @param dimension The dimension(s) to check for
831    * @return Return if the actor is dependent on it's children
832    */
833   virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
834
835   /**
836    * @brief Calculate the size for a child
837    *
838    * @param[in] child The child actor to calculate the size for
839    * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
840    * @return Return the calculated size for the given dimension
841    */
842   virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension );
843
844   /**
845    * @brief This method is called during size negotiation when a height is required for a given width.
846    *
847    * Derived classes should override this if they wish to customize the height returned.
848    *
849    * @param width to use.
850    * @return the height based on the width.
851    */
852   virtual float GetHeightForWidth( float width );
853
854   /**
855    * @brief This method is called during size negotiation when a width is required for a given height.
856    *
857    * Derived classes should override this if they wish to customize the width returned.
858    *
859    * @param height to use.
860    * @return the width based on the width.
861    */
862   virtual float GetWidthForHeight( float height );
863
864 public:
865
866   // Size negotiation
867
868   /**
869    * @brief Called by the RelayoutController to negotiate the size of an actor.
870    *
871    * The size allocated by the the algorithm is passed in which the
872    * actor must adhere to.  A container is passed in as well which
873    * the actor should populate with actors it has not / or does not
874    * need to handle in its size negotiation.
875    *
876    * @param[in]      size       The allocated size.
877    * @param[in,out]  container  The container that holds actors that are fed back into the
878    *                            RelayoutController algorithm.
879    */
880   void NegotiateSize( const Vector2& size, RelayoutContainer& container );
881
882   /**
883    * @brief Set whether size negotiation should use the assigned size of the actor
884    * during relayout for the given dimension(s)
885    *
886    * @param[in] use Whether the assigned size of the actor should be used
887    * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions
888    */
889   void SetUseAssignedSize( bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
890
891   /**
892    * @brief Returns whether size negotiation should use the assigned size of the actor
893    * during relayout for a single dimension
894    *
895    * @param[in] dimension The dimension to get
896    * @return Return whether the assigned size of the actor should be used. If more than one dimension is requested, just return the first one found
897    */
898   bool GetUseAssignedSize( Dimension::Type dimension ) const;
899
900   /**
901    * @copydoc Dali::Actor::SetResizePolicy()
902    */
903   void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
904
905   /**
906    * @copydoc Dali::Actor::GetResizePolicy()
907    */
908   ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
909
910   /**
911    * @copydoc Dali::Actor::SetSizeScalePolicy()
912    */
913   void SetSizeScalePolicy( SizeScalePolicy::Type policy );
914
915   /**
916    * @copydoc Dali::Actor::GetSizeScalePolicy()
917    */
918   SizeScalePolicy::Type GetSizeScalePolicy() const;
919
920   /**
921    * @copydoc Dali::Actor::SetDimensionDependency()
922    */
923   void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
924
925   /**
926    * @copydoc Dali::Actor::GetDimensionDependency()
927    */
928   Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
929
930   /**
931    * @brief Set the size negotiation relayout enabled on this actor
932    *
933    * @param[in] relayoutEnabled Boolean to enable or disable relayout
934    */
935   void SetRelayoutEnabled( bool relayoutEnabled );
936
937   /**
938    * @brief Return if relayout is enabled
939    *
940    * @return Return if relayout is enabled or not for this actor
941    */
942   bool IsRelayoutEnabled() const;
943
944   /**
945    * @brief Mark an actor as having it's layout dirty
946    *
947    * @param dirty Whether to mark actor as dirty or not
948    * @param dimension The dimension(s) to mark as dirty
949    */
950   void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
951
952   /**
953    * @brief Return if any of an actor's dimensions are marked as dirty
954    *
955    * @param dimension The dimension(s) to check
956    * @return Return if any of the requested dimensions are dirty
957    */
958   bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
959
960   /**
961    * @brief Returns if relayout is enabled and the actor is not dirty
962    *
963    * @return Return if it is possible to relayout the actor
964    */
965   bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
966
967   /**
968    * @brief Returns if relayout is enabled and the actor is dirty
969    *
970    * @return Return if it is required to relayout the actor
971    */
972   bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
973
974   /**
975    * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
976    *
977    * This method is automatically called from OnSceneConnection(), OnChildAdd(),
978    * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
979    *
980    * This method can also be called from a derived class every time it needs a different size.
981    * At the end of event processing, the relayout process starts and
982    * all controls which requested Relayout will have their sizes (re)negotiated.
983    *
984    * @note RelayoutRequest() can be called multiple times; the size negotiation is still
985    * only performed once, i.e. there is no need to keep track of this in the calling side.
986    */
987   void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
988
989   /**
990    * @brief Determine if this actor is dependent on it's parent for relayout
991    *
992    * @param dimension The dimension(s) to check for
993    * @return Return if the actor is dependent on it's parent
994    */
995   bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
996
997   /**
998    * @brief Determine if this actor has another dimension depedent on the specified one
999    *
1000    * @param dimension The dimension to check for
1001    * @param dependentDimension The dimension to check for dependency with
1002    * @return Return if the actor is dependent on this dimension
1003    */
1004   bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension );
1005
1006   /**
1007    * Negotiate sizes for a control in all dimensions
1008    *
1009    * @param[in] allocatedSize The size constraint that the control must respect
1010    */
1011   void NegotiateDimensions( const Vector2& allocatedSize );
1012
1013   /**
1014    * Negotiate size for a specific dimension
1015    *
1016    * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies
1017    * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and
1018    * LayoutDimensionNegotiated flags being filled in on the actor.
1019    *
1020    * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions
1021    * calculated and set as well as the LayoutDimensionNegotiated flags.
1022    *
1023    * @param[in] dimension The dimension to negotiate on
1024    * @param[in] allocatedSize The size constraint that the actor must respect
1025    */
1026   void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack );
1027
1028   /**
1029    * @brief Calculate the size of a dimension
1030    *
1031    * @param[in] dimension The dimension to calculate the size for
1032    * @param[in] maximumSize The upper bounds on the size
1033    * @return Return the calculated size for the dimension
1034    */
1035   float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
1036
1037   /**
1038    * Negotiate a dimension based on the size of the parent
1039    *
1040    * @param[in] dimension The dimension to negotiate on
1041    * @return Return the negotiated size
1042    */
1043   float NegotiateFromParent( Dimension::Type dimension );
1044
1045   /**
1046    * Negotiate a dimension based on the size of the parent. Fitting inside.
1047    *
1048    * @param[in] dimension The dimension to negotiate on
1049    * @return Return the negotiated size
1050    */
1051   float NegotiateFromParentFit( Dimension::Type dimension );
1052
1053   /**
1054    * Negotiate a dimension based on the size of the parent. Flooding the whole space.
1055    *
1056    * @param[in] dimension The dimension to negotiate on
1057    * @return Return the negotiated size
1058    */
1059   float NegotiateFromParentFlood( Dimension::Type dimension );
1060
1061   /**
1062    * @brief Negotiate a dimension based on the size of the children
1063    *
1064    * @param[in] dimension The dimension to negotiate on
1065    * @return Return the negotiated size
1066    */
1067   float NegotiateFromChildren( Dimension::Type dimension );
1068
1069   /**
1070    * Set the negotiated dimension value for the given dimension(s)
1071    *
1072    * @param negotiatedDimension The value to set
1073    * @param dimension The dimension(s) to set the value for
1074    */
1075   void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1076
1077   /**
1078    * Return the value of negotiated dimension for the given dimension
1079    *
1080    * @param dimension The dimension to retrieve
1081    * @return Return the value of the negotiated dimension
1082    */
1083   float GetNegotiatedDimension( Dimension::Type dimension ) const;
1084
1085   /**
1086    * @brief Set the padding for a dimension
1087    *
1088    * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
1089    * @param[in] dimension The dimension to set
1090    */
1091   void SetPadding( const Vector2& padding, Dimension::Type dimension );
1092
1093   /**
1094    * Return the value of padding for the given dimension
1095    *
1096    * @param dimension The dimension to retrieve
1097    * @return Return the value of padding for the dimension
1098    */
1099   Vector2 GetPadding( Dimension::Type dimension ) const;
1100
1101   /**
1102    * Return the actor size for a given dimension
1103    *
1104    * @param[in] dimension The dimension to retrieve the size for
1105    * @return Return the size for the given dimension
1106    */
1107   float GetSize( Dimension::Type dimension ) const;
1108
1109   /**
1110    * Return the natural size of the actor for a given dimension
1111    *
1112    * @param[in] dimension The dimension to retrieve the size for
1113    * @return Return the natural size for the given dimension
1114    */
1115   float GetNaturalSize( Dimension::Type dimension ) const;
1116
1117   /**
1118    * @brief Return the amount of size allocated for relayout
1119    *
1120    * May include padding
1121    *
1122    * @param[in] dimension The dimension to retrieve
1123    * @return Return the size
1124    */
1125   float GetRelayoutSize( Dimension::Type dimension ) const;
1126
1127   /**
1128    * @brief If the size has been negotiated return that else return normal size
1129    *
1130    * @param[in] dimension The dimension to retrieve
1131    * @return Return the size
1132    */
1133   float GetLatestSize( Dimension::Type dimension ) const;
1134
1135   /**
1136    * Apply the negotiated size to the actor
1137    *
1138    * @param[in] container The container to fill with actors that require further relayout
1139    */
1140   void SetNegotiatedSize( RelayoutContainer& container );
1141
1142   /**
1143    * @brief Flag the actor as having it's layout dimension negotiated.
1144    *
1145    * @param[in] negotiated The status of the flag to set.
1146    * @param[in] dimension The dimension to set the flag for
1147    */
1148   void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1149
1150   /**
1151    * @brief Test whether the layout dimension for this actor has been negotiated or not.
1152    *
1153    * @param[in] dimension The dimension to determine the value of the flag for
1154    * @return Return if the layout dimension is negotiated or not.
1155    */
1156   bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const;
1157
1158   /**
1159    * @brief provides the Actor implementation of GetHeightForWidth
1160    * @param width to use.
1161    * @return the height based on the width.
1162    */
1163   float GetHeightForWidthBase( float width );
1164
1165   /**
1166    * @brief provides the Actor implementation of GetWidthForHeight
1167    * @param height to use.
1168    * @return the width based on the height.
1169    */
1170   float GetWidthForHeightBase( float height );
1171
1172   /**
1173    * @brief Calculate the size for a child
1174    *
1175    * @param[in] child The child actor to calculate the size for
1176    * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
1177    * @return Return the calculated size for the given dimension
1178    */
1179   float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension );
1180
1181   /**
1182    * @brief Set the preferred size for size negotiation
1183    *
1184    * @param[in] size The preferred size to set
1185    */
1186   void SetPreferredSize( const Vector2& size );
1187
1188   /**
1189    * @brief Return the preferred size used for size negotiation
1190    *
1191    * @return Return the preferred size
1192    */
1193   Vector2 GetPreferredSize() const;
1194
1195   /**
1196    * @copydoc Dali::Actor::SetMinimumSize
1197    */
1198   void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1199
1200   /**
1201    * @copydoc Dali::Actor::GetMinimumSize
1202    */
1203   float GetMinimumSize( Dimension::Type dimension ) const;
1204
1205   /**
1206    * @copydoc Dali::Actor::SetMaximumSize
1207    */
1208   void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
1209
1210   /**
1211    * @copydoc Dali::Actor::GetMaximumSize
1212    */
1213   float GetMaximumSize( Dimension::Type dimension ) const;
1214
1215   /**
1216    * @copydoc Dali::Actor::AddRenderer()
1217    */
1218   uint32_t AddRenderer( Renderer& renderer );
1219
1220   /**
1221    * @copydoc Dali::Actor::GetRendererCount()
1222    */
1223   uint32_t GetRendererCount() const;
1224
1225   /**
1226    * @copydoc Dali::Actor::GetRendererAt()
1227    */
1228   RendererPtr GetRendererAt( uint32_t index );
1229
1230   /**
1231    * @copydoc Dali::Actor::RemoveRenderer()
1232    */
1233   void RemoveRenderer( Renderer& renderer );
1234
1235   /**
1236    * @copydoc Dali::Actor::RemoveRenderer()
1237    */
1238   void RemoveRenderer( uint32_t index );
1239
1240   /**
1241    * Set BlendEquation at each renderer that added on this Actor.
1242    */
1243   void SetBlendEquation( DevelBlendEquation::Type blendEquation );
1244
1245   /**
1246    * @brief Get Blend Equation that applied to this Actor
1247    */
1248   DevelBlendEquation::Type GetBlendEquation() const;
1249
1250 public:
1251
1252   /**
1253    * Converts screen coordinates into the actor's coordinate system.
1254    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
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( float& localX, float& localY, float screenX, float screenY ) const;
1262
1263   /**
1264    * Converts screen coordinates into the actor's coordinate system.
1265    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1266    * @param[in] renderTask The render-task used to display the actor.
1267    * @param[out] localX On return, the X-coordinate relative to the actor.
1268    * @param[out] localY On return, the Y-coordinate relative to the actor.
1269    * @param[in] screenX The screen X-coordinate.
1270    * @param[in] screenY The screen Y-coordinate.
1271    * @return True if the conversion succeeded.
1272    */
1273   bool ScreenToLocal( const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const;
1274
1275   /**
1276    * Converts from the actor's coordinate system to screen coordinates.
1277    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
1278    * @param[in] viewMatrix The view-matrix
1279    * @param[in] projectionMatrix The projection-matrix
1280    * @param[in] viewport The view-port
1281    * @param[out] localX On return, the X-coordinate relative to the actor.
1282    * @param[out] localY On return, the Y-coordinate relative to the actor.
1283    * @param[in] screenX The screen X-coordinate.
1284    * @param[in] screenY The screen Y-coordinate.
1285    * @return True if the conversion succeeded.
1286    */
1287   bool ScreenToLocal( const Matrix& viewMatrix,
1288                       const Matrix& projectionMatrix,
1289                       const Viewport& viewport,
1290                       float& localX,
1291                       float& localY,
1292                       float screenX,
1293                       float screenY ) const;
1294
1295   /**
1296    * Sets whether the actor should receive a notification when touch or hover motion events leave
1297    * the boundary of the actor.
1298    *
1299    * @note By default, this is set to false as most actors do not require this.
1300    * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
1301    *
1302    * @param[in]  required  Should be set to true if a Leave event is required
1303    */
1304   void SetLeaveRequired( bool required )
1305   {
1306     mLeaveRequired = required;
1307   }
1308
1309   /**
1310    * This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
1311    * the boundary of the actor.
1312    * @return true if a Leave event is required, false otherwise.
1313    */
1314   bool GetLeaveRequired() const
1315   {
1316     return mLeaveRequired;
1317   }
1318
1319   /**
1320    * @copydoc Dali::Actor::SetKeyboardFocusable()
1321    */
1322   void SetKeyboardFocusable( bool focusable )
1323   {
1324     mKeyboardFocusable = focusable;
1325   }
1326
1327   /**
1328    * @copydoc Dali::Actor::IsKeyboardFocusable()
1329    */
1330   bool IsKeyboardFocusable() const
1331   {
1332     return mKeyboardFocusable;
1333   }
1334
1335
1336   /**
1337    * Query whether the application or derived actor type requires intercept touch events.
1338    * @return True if intercept touch events are required.
1339    */
1340   bool GetInterceptTouchRequired() const
1341   {
1342     return !mInterceptTouchedSignal.Empty();
1343   }
1344
1345   /**
1346    * Query whether the application or derived actor type requires touch events.
1347    * @return True if touch events are required.
1348    */
1349   bool GetTouchRequired() const
1350   {
1351     return !mTouchedSignal.Empty();
1352   }
1353
1354   /**
1355    * Query whether the application or derived actor type requires hover events.
1356    * @return True if hover events are required.
1357    */
1358   bool GetHoverRequired() const
1359   {
1360     return !mHoveredSignal.Empty();
1361   }
1362
1363   /**
1364    * Query whether the application or derived actor type requires wheel events.
1365    * @return True if wheel events are required.
1366    */
1367   bool GetWheelEventRequired() const
1368   {
1369     return !mWheelEventSignal.Empty();
1370   }
1371
1372   /**
1373    * Query whether the actor is actually hittable.  This method checks whether the actor is
1374    * sensitive, has the visibility flag set to true and is not fully transparent.
1375    * @return true, if it can be hit, false otherwise.
1376    */
1377   bool IsHittable() const
1378   {
1379     return IsSensitive() && IsVisible() && ( GetCurrentWorldColor().a > FULLY_TRANSPARENT ) && IsNodeConnected();
1380   }
1381
1382   /**
1383    * Query whether the actor captures all touch after it starts even if touch leaves its boundary.
1384    * @return true, if it captures all touch after start
1385    */
1386   bool CapturesAllTouchAfterStart() const
1387   {
1388     return mCaptureAllTouchAfterStart;
1389   }
1390
1391   /**
1392    * Sets the touch area of an actor.
1393    * @param [in] area The new area.
1394    */
1395   void SetTouchArea(Vector2 area)
1396   {
1397     mTouchArea = area;
1398   }
1399
1400   /**
1401    * Retrieve the Actor's touch area.
1402    * @return The Actor's touch area.
1403    */
1404   const Vector2& GetTouchArea() const
1405   {
1406     return mTouchArea;
1407   }
1408
1409
1410   // Gestures
1411
1412   /**
1413    * Retrieve the gesture data associated with this actor. The first call to this method will
1414    * allocate space for the ActorGestureData so this should only be called if an actor really does
1415    * require gestures.
1416    * @return Reference to the ActorGestureData for this actor.
1417    * @note Once the gesture-data is created for an actor it is likely that gestures are required
1418    * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
1419    */
1420   ActorGestureData& GetGestureData();
1421
1422   /**
1423    * Queries whether the actor requires the gesture type.
1424    * @param[in] type The gesture type.
1425    * @return True if the gesture is required, false otherwise.
1426    */
1427   bool IsGestureRequired( GestureType::Value type ) const;
1428
1429   // Signals
1430
1431   /**
1432    * Used by the EventProcessor to emit intercept touch event signals.
1433    * @param[in] touch The touch data.
1434    * @return True if the event was intercepted.
1435    */
1436   bool EmitInterceptTouchEventSignal( const Dali::TouchEvent& touch );
1437
1438   /**
1439    * Used by the EventProcessor to emit touch event signals.
1440    * @param[in] touch The touch data.
1441    * @return True if the event was consumed.
1442    */
1443   bool EmitTouchEventSignal( const Dali::TouchEvent& touch );
1444
1445   /**
1446    * Used by the EventProcessor to emit hover event signals.
1447    * @param[in] event The hover event.
1448    * @return True if the event was consumed.
1449    */
1450   bool EmitHoverEventSignal( const Dali::HoverEvent& event );
1451
1452   /**
1453    * Used by the EventProcessor to emit wheel event signals.
1454    * @param[in] event The wheel event.
1455    * @return True if the event was consumed.
1456    */
1457   bool EmitWheelEventSignal( const Dali::WheelEvent& event );
1458
1459   /**
1460    * @brief Emits the visibility change signal for this actor and all its children.
1461    * @param[in] visible Whether the actor has become visible or not.
1462    * @param[in] type Whether the actor's visible property has changed or a parent's.
1463    */
1464   void EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityChange::Type type );
1465
1466   /**
1467    * @brief Emits the layout direction change signal for this actor and all its children.
1468    * @param[in] type Whether the actor's layout direction property has changed or a parent's.
1469    */
1470   void EmitLayoutDirectionChangedSignal( LayoutDirection::Type type );
1471
1472   /**
1473    * @brief Emits the ChildAdded signal for this actor
1474    * @param[in] child The child actor that has been added
1475    */
1476   void EmitChildAddedSignal( Actor& child );
1477
1478   /**
1479    * @brief Emits the ChildRemoved signal for this actor
1480    * @param[in] child The child actor that has been removed
1481    */
1482   void EmitChildRemovedSignal( Actor& child );
1483
1484   /**
1485    * @copydoc DevelActor::InterceptTouchedSignal()
1486    */
1487   Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
1488   {
1489     return mInterceptTouchedSignal;
1490   }
1491
1492   /**
1493    * @copydoc Dali::Actor::TouchedSignal()
1494    */
1495   Dali::Actor::TouchEventSignalType& TouchedSignal()
1496   {
1497     return mTouchedSignal;
1498   }
1499
1500   /**
1501    * @copydoc Dali::Actor::HoveredSignal()
1502    */
1503   Dali::Actor::HoverSignalType& HoveredSignal()
1504   {
1505     return mHoveredSignal;
1506   }
1507
1508   /**
1509    * @copydoc Dali::Actor::WheelEventSignal()
1510    */
1511   Dali::Actor::WheelEventSignalType& WheelEventSignal()
1512   {
1513     return mWheelEventSignal;
1514   }
1515
1516   /**
1517    * @copydoc Dali::Actor::OnSceneSignal()
1518    */
1519   Dali::Actor::OnSceneSignalType& OnSceneSignal()
1520   {
1521     return mOnSceneSignal;
1522   }
1523
1524   /**
1525    * @copydoc Dali::Actor::OffSceneSignal()
1526    */
1527   Dali::Actor::OffSceneSignalType& OffSceneSignal()
1528   {
1529     return mOffSceneSignal;
1530   }
1531
1532   /**
1533    * @copydoc Dali::Actor::OnRelayoutSignal()
1534    */
1535   Dali::Actor::OnRelayoutSignalType& OnRelayoutSignal()
1536   {
1537     return mOnRelayoutSignal;
1538   }
1539
1540   /**
1541    * @copydoc DevelActor::VisibilityChangedSignal
1542    */
1543   DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal()
1544   {
1545     return mVisibilityChangedSignal;
1546   }
1547
1548   /**
1549    * @copydoc LayoutDirectionChangedSignal
1550    */
1551   Dali::Actor::LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal()
1552   {
1553     return mLayoutDirectionChangedSignal;
1554   }
1555
1556   /**
1557    * @copydoc DevelActor::ChildAddedSignal
1558    */
1559   DevelActor::ChildChangedSignalType& ChildAddedSignal()
1560   {
1561     return mChildAddedSignal;
1562   }
1563
1564   /**
1565    * @copydoc DevelActor::ChildRemovedSignal
1566    */
1567   DevelActor::ChildChangedSignalType& ChildRemovedSignal()
1568   {
1569     return mChildRemovedSignal;
1570   }
1571
1572   /**
1573    * @copydoc DevelActor::ChildOrderChangedSignal
1574    */
1575   DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal()
1576   {
1577     return mChildOrderChangedSignal;
1578   }
1579
1580   /**
1581    * Connects a callback function with the object's signals.
1582    * @param[in] object The object providing the signal.
1583    * @param[in] tracker Used to disconnect the signal.
1584    * @param[in] signalName The signal to connect to.
1585    * @param[in] functor A newly allocated FunctorDelegate.
1586    * @return True if the signal was connected.
1587    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1588    */
1589   static bool DoConnectSignal( BaseObject* object,
1590                                ConnectionTrackerInterface* tracker,
1591                                const std::string& signalName,
1592                                FunctorDelegate* functor );
1593
1594   /**
1595    * Performs actions as requested using the action name.
1596    * @param[in] object The object on which to perform the action.
1597    * @param[in] actionName The action to perform.
1598    * @param[in] attributes The attributes with which to perfrom this action.
1599    * @return true if the action was done.
1600    */
1601   static bool DoAction( BaseObject* object,
1602                         const std::string& actionName,
1603                         const Property::Map& attributes );
1604
1605 public:
1606   // For Animation
1607
1608   /**
1609    * For use in derived classes.
1610    * This should only be called by Animation, when the actor is resized using Animation::Resize().
1611    */
1612   virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
1613   {
1614   }
1615
1616 protected:
1617
1618   enum DerivedType
1619   {
1620     BASIC, LAYER, ROOT_LAYER
1621   };
1622
1623   /**
1624    * Protected Constructor.  See Actor::New().
1625    * The second-phase construction Initialize() member should be called immediately after this.
1626    * @param[in] derivedType The derived type of actor (if any).
1627    * @param[in] reference to the node
1628    */
1629   Actor( DerivedType derivedType, const SceneGraph::Node& node );
1630
1631   /**
1632    * Second-phase constructor. Must be called immediately after creating a new Actor;
1633    */
1634   void Initialize( void );
1635
1636   /**
1637    * A reference counted object may only be deleted by calling Unreference()
1638    */
1639   ~Actor() override;
1640
1641   /**
1642    * Called on a child during Add() when the parent actor is connected to the Scene.
1643    * @param[in] parentDepth The depth of the parent in the hierarchy.
1644    */
1645   void ConnectToScene( uint32_t parentDepth );
1646
1647   /**
1648    * Helper for ConnectToScene, to recursively connect a tree of actors.
1649    * This is atomic i.e. not interrupted by user callbacks.
1650    * @param[in]  depth The depth in the hierarchy of the actor
1651    * @param[out] connectionList On return, the list of connected actors which require notification.
1652    */
1653   void RecursiveConnectToScene( ActorContainer& connectionList, uint32_t depth );
1654
1655   /**
1656    * Connect the Node associated with this Actor to the scene-graph.
1657    */
1658   void ConnectToSceneGraph();
1659
1660   /**
1661    * Helper for ConnectToScene, to notify a connected actor through the public API.
1662    */
1663   void NotifyStageConnection();
1664
1665   /**
1666    * Called on a child during Remove() when the actor was previously on the Stage.
1667    */
1668   void DisconnectFromStage();
1669
1670   /**
1671    * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1672    * This is atomic i.e. not interrupted by user callbacks.
1673    * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1674    */
1675   void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1676
1677   /**
1678    * Disconnect the Node associated with this Actor from the scene-graph.
1679    */
1680   void DisconnectFromSceneGraph();
1681
1682   /**
1683    * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1684    */
1685   void NotifyStageDisconnection();
1686
1687   /**
1688    * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph.
1689    * @return True if the Actor is OnScene & has a Node connected to the scene graph.
1690    */
1691   bool IsNodeConnected() const;
1692
1693 public:
1694   /**
1695    * Trigger a rebuild of the actor depth tree from this root
1696    * If a Layer3D is encountered, then this doesn't descend any further.
1697    * The mSortedDepth of each actor is set appropriately.
1698    */
1699   void RebuildDepthTree();
1700
1701 protected:
1702
1703   /**
1704    * Traverse the actor tree, inserting actors into the depth tree in sibling order.
1705    * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
1706    * @param[in,out] depthIndex The current depth index (traversal index)
1707    */
1708   void DepthTraverseActorTree( OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex );
1709
1710 public:
1711
1712   // Default property extensions from Object
1713
1714   /**
1715    * @copydoc Dali::Internal::Object::SetDefaultProperty()
1716    */
1717   void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) override;
1718
1719   /**
1720    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
1721    */
1722   void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ) override;
1723
1724   /**
1725    * @copydoc Dali::Internal::Object::GetDefaultProperty()
1726    */
1727   Property::Value GetDefaultProperty( Property::Index index ) const override;
1728
1729   /**
1730    * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
1731    */
1732   Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
1733
1734   /**
1735    * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
1736    */
1737   void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType ) override;
1738
1739   /**
1740    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
1741    */
1742   const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const override;
1743
1744   /**
1745    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
1746    */
1747   const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
1748
1749   /**
1750    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
1751    */
1752   int32_t GetPropertyComponentIndex( Property::Index index ) const override;
1753
1754   /**
1755    * @copydoc Dali::Internal::Object::IsAnimationPossible()
1756    */
1757   bool IsAnimationPossible() const override
1758   {
1759     return OnScene();
1760   }
1761
1762   /**
1763    * Retrieve the actor's node.
1764    * @return The node used by this actor
1765    */
1766   const SceneGraph::Node& GetNode() const
1767   {
1768     return *static_cast<const SceneGraph::Node*>( mUpdateObject );
1769   }
1770
1771   /**
1772    * @copydoc Dali::DevelActor::Raise()
1773    */
1774   void Raise();
1775
1776   /**
1777    * @copydoc Dali::DevelActor::Lower()
1778    */
1779   void Lower();
1780
1781   /**
1782    * @copydoc Dali::DevelActor::RaiseToTop()
1783    */
1784   void RaiseToTop();
1785
1786   /**
1787    * @copydoc Dali::DevelActor::LowerToBottom()
1788    */
1789   void LowerToBottom();
1790
1791   /**
1792    * @copydoc Dali::DevelActor::RaiseAbove()
1793    */
1794   void RaiseAbove( Internal::Actor& target );
1795
1796   /**
1797    * @copydoc Dali::DevelActor::LowerBelow()
1798    */
1799   void LowerBelow( Internal::Actor& target );
1800
1801 public:
1802
1803   /**
1804    * Sets the scene which this actor is added to.
1805    * @param[in] scene The scene
1806    */
1807   void SetScene( Scene& scene )
1808   {
1809     mScene = &scene;
1810   }
1811
1812   /**
1813    * Gets the scene which this actor is added to.
1814    * @return The scene
1815    */
1816   Scene& GetScene() const
1817   {
1818     return *mScene;
1819   }
1820
1821 private:
1822
1823   struct SendMessage
1824   {
1825     enum Type
1826     {
1827       FALSE = 0,
1828       TRUE  = 1,
1829     };
1830   };
1831
1832   struct AnimatedSizeFlag
1833   {
1834     enum Type
1835     {
1836       CLEAR  = 0,
1837       WIDTH  = 1,
1838       HEIGHT = 2,
1839       DEPTH  = 4
1840     };
1841   };
1842
1843   struct Relayouter;
1844
1845   // Remove default constructor and copy constructor
1846   Actor() = delete;
1847   Actor( const Actor& ) = delete;
1848   Actor& operator=( const Actor& rhs ) = delete;
1849
1850   /**
1851    * Set the actors parent.
1852    * @param[in] parent The new parent.
1853    */
1854   void SetParent( Actor* parent );
1855
1856   /**
1857    * For use in derived classes, called after Initialize()
1858    */
1859   virtual void OnInitialize()
1860   {
1861   }
1862
1863   /**
1864    * For use in internal derived classes.
1865    * This is called during ConnectToScene(), after the actor has finished adding its node to the scene-graph.
1866    * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1867    */
1868   virtual void OnSceneConnectionInternal()
1869   {
1870   }
1871
1872   /**
1873    * For use in internal derived classes.
1874    * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1875    * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1876    */
1877   virtual void OnSceneDisconnectionInternal()
1878   {
1879   }
1880
1881   /**
1882    * For use in external (CustomActor) derived classes.
1883    * This is called after the atomic ConnectToScene() traversal has been completed.
1884    */
1885   virtual void OnSceneConnectionExternal( int depth )
1886   {
1887   }
1888
1889   /**
1890    * For use in external (CustomActor) derived classes.
1891    * This is called after the atomic DisconnectFromStage() traversal has been completed.
1892    */
1893   virtual void OnSceneDisconnectionExternal()
1894   {
1895   }
1896
1897   /**
1898    * For use in derived classes; this is called after Add() has added a child.
1899    * @param[in] child The child that was added.
1900    */
1901   virtual void OnChildAdd( Actor& child )
1902   {
1903   }
1904
1905   /**
1906    * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ).
1907    * @param[in] child The child that was removed.
1908    */
1909   virtual void OnChildRemove( Actor& child )
1910   {
1911   }
1912
1913   /**
1914    * For use in derived classes.
1915    * This is called after SizeSet() has been called.
1916    */
1917   virtual void OnSizeSet( const Vector3& targetSize )
1918   {
1919   }
1920
1921   /**
1922    * @brief Retrieves the cached event side value of a default property.
1923    * @param[in]  index  The index of the property
1924    * @param[out] value  Is set with the cached value of the property if found.
1925    * @return True if value set, false otherwise.
1926    */
1927   bool GetCachedPropertyValue( Property::Index index, Property::Value& value ) const;
1928
1929   /**
1930    * @brief Retrieves the current value of a default property from the scene-graph.
1931    * @param[in]  index  The index of the property
1932    * @param[out] value  Is set with the current scene-graph value of the property
1933    * @return True if value set, false otherwise.
1934    */
1935   bool GetCurrentPropertyValue( Property::Index index, Property::Value& value  ) const;
1936
1937   /**
1938    * @brief Ensure the relayouter is allocated
1939    */
1940   Relayouter& EnsureRelayouter();
1941
1942   /**
1943    * @brief Apply the size set policy to the input size
1944    *
1945    * @param[in] size The size to apply the policy to
1946    * @return Return the adjusted size
1947    */
1948   Vector2 ApplySizeSetPolicy( const Vector2& size );
1949
1950   /**
1951    * Retrieve the parent object of an Actor.
1952    * @return The parent object, or NULL if the Actor does not have a parent.
1953    */
1954   Object* GetParentObject() const override
1955   {
1956     return mParent;
1957   }
1958
1959   /**
1960    * Set Sibling order
1961    * @param[in] order The sibling order this Actor should be. It will place
1962    * the actor at this index in it's parent's child array.
1963    */
1964   void SetSiblingOrder( uint32_t order);
1965
1966   /**
1967    * Get Sibling order
1968    * @return the order of this actor amongst it's siblings
1969    */
1970   uint32_t GetSiblingOrder() const;
1971
1972   /**
1973    * Emit ChildOrderChanged signal, and request that the scene
1974    * rebuilds the actor depth indices.
1975    */
1976   void EmitOrderChangedAndRebuild();
1977
1978   /**
1979    * @brief Get the current position of the actor in screen coordinates.
1980    *
1981    * @return Returns the screen position of actor
1982    */
1983   const Vector2 GetCurrentScreenPosition() const;
1984
1985   /**
1986    * Sets the visibility flag of an actor.
1987    * @param[in] visible The new visibility flag.
1988    * @param[in] sendMessage Whether to send a message to the update thread or not.
1989    */
1990   void SetVisibleInternal( bool visible, SendMessage::Type sendMessage );
1991
1992   /**
1993    * Set whether a child actor inherits it's parent's layout direction. Default is to inherit.
1994    * @param[in] inherit - true if the actor should inherit layout direction, false otherwise.
1995    */
1996   void SetInheritLayoutDirection( bool inherit );
1997
1998   /**
1999    * Returns whether the actor inherits it's parent's layout direction.
2000    * @return true if the actor inherits it's parent's layout direction, false otherwise.
2001    */
2002   bool IsLayoutDirectionInherited() const
2003   {
2004     return mInheritLayoutDirection;
2005   }
2006
2007   /**
2008    * @brief Propagates layout direction recursively.
2009    * @param[in] actor The actor for seting layout direction.
2010    * @param[in] direction New layout direction.
2011    */
2012   void InheritLayoutDirectionRecursively( ActorPtr actor, Dali::LayoutDirection::Type direction, bool set = false );
2013
2014   /**
2015    * @brief Sets the update size hint of an actor.
2016    * @param [in] updateSizeHint The update size hint.
2017    */
2018   void SetUpdateSizeHint( const Vector2& updateSizeHint );
2019
2020 protected:
2021
2022   Scene* mScene;                  ///< The scene the actor is added to
2023
2024   Actor* mParent;                 ///< Each actor (except the root) can have one parent
2025   ActorContainer* mChildren;      ///< Container of referenced actors, lazily initialized
2026   RendererContainer* mRenderers;   ///< Renderer container
2027
2028   Vector3* mParentOrigin;         ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
2029   Vector3* mAnchorPoint;          ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
2030
2031   Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
2032
2033   ActorGestureData* mGestureData;   ///< Optional Gesture data. Only created when actor requires gestures
2034
2035   // Signals
2036   Dali::Actor::TouchEventSignalType         mInterceptTouchedSignal;
2037   Dali::Actor::TouchEventSignalType        mTouchedSignal;
2038   Dali::Actor::HoverSignalType             mHoveredSignal;
2039   Dali::Actor::WheelEventSignalType        mWheelEventSignal;
2040   Dali::Actor::OnSceneSignalType           mOnSceneSignal;
2041   Dali::Actor::OffSceneSignalType          mOffSceneSignal;
2042   Dali::Actor::OnRelayoutSignalType        mOnRelayoutSignal;
2043   DevelActor::VisibilityChangedSignalType  mVisibilityChangedSignal;
2044   Dali::Actor::LayoutDirectionChangedSignalType  mLayoutDirectionChangedSignal;
2045   DevelActor::ChildChangedSignalType       mChildAddedSignal;
2046   DevelActor::ChildChangedSignalType       mChildRemovedSignal;
2047   DevelActor::ChildOrderChangedSignalType  mChildOrderChangedSignal;
2048
2049   Quaternion      mTargetOrientation; ///< Event-side storage for orientation
2050   Vector4         mTargetColor;       ///< Event-side storage for color
2051   Vector3         mTargetSize;        ///< Event-side storage for size (not a pointer as most actors will have a size)
2052   Vector3         mTargetPosition;    ///< Event-side storage for position (not a pointer as most actors will have a position)
2053   Vector3         mTargetScale;       ///< Event-side storage for scale
2054   Vector3         mAnimatedSize;      ///< Event-side storage for size animation
2055   Vector2         mTouchArea;         ///< touch area
2056
2057   std::string     mName;              ///< Name of the actor
2058   uint32_t        mSortedDepth;       ///< The sorted depth index. A combination of tree traversal and sibling order.
2059   int16_t         mDepth;             ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
2060   uint16_t        mUseAnimatedSize;   ///< Whether the size is animated.
2061
2062   const bool mIsRoot                               : 1; ///< Flag to identify the root actor
2063   const bool mIsLayer                              : 1; ///< Flag to identify that this is a layer
2064   bool mIsOnScene                                  : 1; ///< Flag to identify whether the actor is on-scene
2065   bool mSensitive                                  : 1; ///< Whether the actor emits touch event signals
2066   bool mLeaveRequired                              : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
2067   bool mKeyboardFocusable                          : 1; ///< Whether the actor should be focusable by keyboard navigation
2068   bool mOnSceneSignalled                           : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection
2069   bool mInsideOnSizeSet                            : 1; ///< Whether we are inside OnSizeSet
2070   bool mInheritPosition                            : 1; ///< Cached: Whether the parent's position should be inherited.
2071   bool mInheritOrientation                         : 1; ///< Cached: Whether the parent's orientation should be inherited.
2072   bool mInheritScale                               : 1; ///< Cached: Whether the parent's scale should be inherited.
2073   bool mPositionUsesAnchorPoint                    : 1; ///< Cached: Whether the position uses the anchor point or not.
2074   bool mVisible                                    : 1; ///< Cached: Whether the actor is visible or not.
2075   bool mInheritLayoutDirection                     : 1; ///< Whether the actor inherits the layout direction from parent.
2076   bool mCaptureAllTouchAfterStart                  : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area.
2077   LayoutDirection::Type mLayoutDirection           : 2; ///< Layout direction, Left to Right or Right to Left.
2078   DrawMode::Type mDrawMode                         : 3; ///< Cached: How the actor and its children should be drawn
2079   ColorMode mColorMode                             : 3; ///< Cached: Determines whether mWorldColor is inherited
2080   ClippingMode::Type mClippingMode                 : 3; ///< Cached: Determines which clipping mode (if any) to use.
2081   DevelBlendEquation::Type mBlendEquation          : 16;///< Cached: Determines which blend equation will be used to render renderers.
2082   bool mIsBlendEquationSet                         : 1; ///< Flag to identify whether the Blend equation is set
2083
2084 private:
2085
2086   static ActorContainer mNullChildren;  ///< Empty container (shared by all actors, returned by GetChildren() const)
2087
2088   struct PropertyHandler;
2089   struct SiblingHandler;
2090 };
2091
2092 } // namespace Internal
2093
2094 // Helpers for public-api forwarding methods
2095
2096 inline Internal::Actor& GetImplementation( Dali::Actor& actor )
2097 {
2098   DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2099
2100   BaseObject& handle = actor.GetBaseObject();
2101
2102   return static_cast< Internal::Actor& >( handle );
2103 }
2104
2105 inline const Internal::Actor& GetImplementation( const Dali::Actor& actor )
2106 {
2107   DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" );
2108
2109   const BaseObject& handle = actor.GetBaseObject();
2110
2111   return static_cast< const Internal::Actor& >( handle );
2112 }
2113
2114 } // namespace Dali
2115
2116 #endif // DALI_INTERNAL_ACTOR_H