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