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