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