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