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