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