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