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