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