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