1 #ifndef __DALI_INTERNAL_ACTOR_H__
2 #define __DALI_INTERNAL_ACTOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/common/map-wrapper.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/object/ref-object.h>
28 #include <dali/public-api/actors/actor.h>
29 #include <dali/public-api/common/dali-common.h>
30 #include <dali/public-api/events/gesture.h>
31 #include <dali/public-api/math/viewport.h>
32 #include <dali/internal/event/common/proxy-object.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>
38 #ifdef DYNAMICS_SUPPORT
39 #include <dali/internal/event/dynamics/dynamics-declarations.h>
47 struct MouseWheelEvent;
53 class ActorGestureData;
56 typedef IntrusivePtr<ShaderEffect> ShaderEffectPtr;
59 typedef IntrusivePtr<Actor> ActorPtr;
60 typedef Dali::ActorContainer ActorContainer; // Store handles to return via public-api
61 typedef ActorContainer::iterator ActorIter;
62 typedef ActorContainer::const_iterator ActorConstIter;
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.
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.
74 class Actor : public ProxyObject
80 * @return A smart-pointer to the newly allocated Actor.
82 static ActorPtr New();
85 * Retrieve the name of the actor.
88 const std::string& GetName() const;
91 * Set the name of the actor.
92 * @param[in] name The new name.
94 void SetName(const std::string& name);
97 * @copydoc Dali::Actor::GetId
99 unsigned int GetId() const;
104 * Attach an object to an actor.
105 * @pre The actor does not already have an attachment.
106 * @param[in] attachment The object to attach.
108 void Attach(ActorAttachment& attachment);
111 * Retreive the object attached to an actor.
112 * @return The attachment.
114 ActorAttachmentPtr GetAttachment();
119 * Query whether an actor is the root actor, which is owned by the Stage.
120 * @return True if the actor is a root actor.
128 * Query whether the actor is connected to the Stage.
130 bool OnStage() const;
133 * Query whether the actor is a RenderableActor derived type.
134 * @return True if the actor is renderable.
136 bool IsRenderable() const
138 // inlined as this is called a lot in hit testing
139 return mIsRenderable;
143 * Query whether the actor is of class Dali::Layer
144 * @return True if the actor is a layer.
148 // inlined as this is called a lot in hit testing
153 * Gets the layer in which the actor is present
154 * @return The layer, which will be uninitialized if the actor is off-stage.
156 Dali::Layer GetLayer();
159 * Adds a child Actor to this Actor.
160 * @pre The child actor is not the same as the parent actor.
161 * @pre The child actor does not already have a parent.
162 * @param [in] child The child.
163 * @post The child will be referenced by its parent.
165 void Add(Actor& child);
168 * Removes a child Actor from this Actor.
169 * @param [in] child The child.
170 * @post The child will be unreferenced.
172 void Remove(Actor& child);
175 * @copydoc Dali::Actor::Unparent
180 * Retrieve the number of children held by the actor.
181 * @return The number of children
183 unsigned int GetChildCount() const;
186 * @copydoc Dali::Actor::GetChildAt
188 Dali::Actor GetChildAt(unsigned int index) const;
191 * Retrieve the Actor's children.
192 * @return A copy of the container of children.
194 ActorContainer GetChildren();
197 * Retrieve the Actor's children.
198 * @return A const reference to the container of children.
200 const ActorContainer& GetChildren() const;
203 * Retrieve a reference to Actor's children.
204 * @note Not for public use.
205 * @return A reference to the container of children.
207 ActorContainer& GetChildrenInternal()
213 * @copydoc Dali::Actor::FindChildByName
215 ActorPtr FindChildByName(const std::string& actorName);
218 * @copydoc Dali::Actor::FindChildByAlias
220 Dali::Actor FindChildByAlias(const std::string& actorAlias);
223 * @copydoc Dali::Actor::FindChildById
225 ActorPtr FindChildById(const unsigned int id);
228 * Retrieve the parent of an Actor.
229 * @return The parent actor, or NULL if the Actor does not have a parent.
231 Actor* GetParent() const
237 * Sets the size of an actor.
238 * ActorAttachments attached to the actor, can be scaled to fit within this area.
239 * This does not interfere with the actors scale factor.
240 * @param [in] width The new width.
241 * @param [in] height The new height.
243 void SetSize(float width, float height);
246 * Sets the size of an actor.
247 * ActorAttachments attached to the actor, can be scaled to fit within this area.
248 * This does not interfere with the actors scale factor.
249 * @param [in] width The size of the actor along the x-axis.
250 * @param [in] height The size of the actor along the y-axis.
251 * @param [in] depth The size of the actor along the z-axis.
253 void SetSize(float width, float height, float depth);
256 * Sets the size of an actor.
257 * ActorAttachments attached to the actor, can be scaled to fit within this area.
258 * This does not interfere with the actors scale factor.
259 * @param [in] size The new size.
261 void SetSize(const Vector2& size);
264 * Sets the size of an actor.
265 * ActorAttachments attached to the actor, can be scaled to fit within this area.
266 * This does not interfere with the actors scale factor.
267 * @param [in] size The new size.
269 void SetSize(const Vector3& size);
272 * Set the width component of the Actor's size.
273 * @param [in] width The new width component.
275 void SetWidth( float width );
278 * Set the height component of the Actor's size.
279 * @param [in] height The new height component.
281 void SetHeight( float height );
284 * Set the depth component of the Actor's size.
285 * @param [in] depth The new depth component.
287 void SetDepth( float depth );
290 * Retrieve the Actor's size.
291 * @return The Actor's size.
293 const Vector3& GetCurrentSize() const;
296 * Set the origin of an actor, within its parent's area.
297 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
298 * and (1.0, 1.0, 0.5) is the bottom-right corner.
299 * The default parent-origin is top-left (0.0, 0.0, 0.5).
300 * An actor position is the distance between this origin, and the actors anchor-point.
301 * @param [in] origin The new parent-origin.
303 void SetParentOrigin(const Vector3& origin);
306 * Set the x component of the parent-origin
307 * @param [in] x The new x value.
309 void SetParentOriginX( float x );
312 * Set the y component of the parent-origin
313 * @param [in] y The new y value.
315 void SetParentOriginY( float y );
318 * Set the z component of the parent-origin
319 * @param [in] z The new z value.
321 void SetParentOriginZ( float z );
324 * Retrieve the parent-origin of an actor.
325 * @return The parent-origin.
327 const Vector3& GetCurrentParentOrigin() const;
330 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
331 * (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.
332 * The default anchor point is top-left (0.0, 0.0, 0.5).
333 * An actor position is the distance between its parent-origin, and this anchor-point.
334 * An actor's rotation is centered around its anchor-point.
335 * @param [in] anchorPoint The new anchor-point.
337 void SetAnchorPoint(const Vector3& anchorPoint);
340 * Set the x component of the anchor-point.
341 * @param [in] x The new x value.
343 void SetAnchorPointX( float x );
346 * Set the y component of the anchor-point.
347 * @param [in] y The new y value.
349 void SetAnchorPointY( float y );
352 * Set the z component of the anchor-point.
353 * @param [in] z The new z value.
355 void SetAnchorPointZ( float z );
358 * Retrieve the anchor-point of an actor.
359 * @return The anchor-point.
361 const Vector3& GetCurrentAnchorPoint() const;
364 * Sets the position of the Actor.
365 * The coordinates are relative to the Actor's parent.
366 * The Actor's z position will be set to 0.0f.
367 * @param [in] x The new x position
368 * @param [in] y The new y position
370 void SetPosition(float x, float y);
373 * Sets the position of the Actor.
374 * The coordinates are relative to the Actor's parent.
375 * @param [in] x The new x position
376 * @param [in] y The new y position
377 * @param [in] z The new z position
379 void SetPosition(float x, float y, float z);
382 * Sets the position of the Actor.
383 * The coordinates are relative to the Actor's parent.
384 * @param [in] position The new position.
386 void SetPosition(const Vector3& position);
389 * Set the position of an actor along the X-axis.
390 * @param [in] x The new x position
395 * Set the position of an actor along the Y-axis.
396 * @param [in] y The new y position.
401 * Set the position of an actor along the Z-axis.
402 * @param [in] z The new z position
407 * Move an actor relative to its existing position.
408 * @param[in] distance The actor will move by this distance.
410 void MoveBy(const Vector3& distance);
413 * Retrieve the position of the Actor.
414 * The coordinates are relative to the Actor's parent.
415 * @return the Actor's position.
417 const Vector3& GetCurrentPosition() const;
420 * @copydoc Dali::Actor::GetCurrentWorldPosition()
422 const Vector3& GetCurrentWorldPosition() const;
425 * @copydoc Dali::Actor::SetPositionInheritanceMode()
427 void SetPositionInheritanceMode( PositionInheritanceMode mode );
430 * @copydoc Dali::Actor::GetPositionInheritanceMode()
432 PositionInheritanceMode GetPositionInheritanceMode() const;
435 * Sets the rotation of the Actor.
436 * @param [in] angleRadians The new rotation angle in radians.
437 * @param [in] axis The new axis of rotation.
439 void SetRotation(const Radian& angleRadians, const Vector3& axis);
442 * Sets the rotation of the Actor.
443 * @param [in] rotation The new rotation.
445 void SetRotation(const Quaternion& rotation);
448 * Rotate an actor around its existing rotation axis.
449 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
450 * @param[in] axis The axis of the rotation to combine with the existing rotation.
452 void RotateBy(const Radian& angleRadians, const Vector3& axis);
455 * Apply a relative rotation to an actor.
456 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
458 void RotateBy(const Quaternion& relativeRotation);
461 * Retreive the Actor's rotation.
462 * @return the rotation.
464 const Quaternion& GetCurrentRotation() const;
467 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
468 * Switching this off means that using SetRotation() sets the actor's world orientation.
469 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
471 void SetInheritRotation(bool inherit);
474 * Returns whether the actor inherit's it's parent's orientation.
475 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
477 bool IsRotationInherited() const;
480 * @copydoc Dali::Actor::GetCurrentWorldRotation()
482 const Quaternion& GetCurrentWorldRotation() const;
485 * Sets a scale factor applied to an actor.
486 * @param [in] scale The scale factor applied on all axes.
488 void SetScale(float scale);
491 * Sets a scale factor applied to an actor.
492 * @param [in] scaleX The scale factor applied along the x-axis.
493 * @param [in] scaleY The scale factor applied along the y-axis.
494 * @param [in] scaleZ The scale factor applied along the z-axis.
496 void SetScale(float scaleX, float scaleY, float scaleZ);
499 * Sets a scale factor applied to an actor.
500 * @param [in] scale A vector representing the scale factor for each axis.
502 void SetScale(const Vector3& scale);
505 * Set the x component of the scale factor.
506 * @param [in] x The new x value.
508 void SetScaleX( float x );
511 * Set the y component of the scale factor.
512 * @param [in] y The new y value.
514 void SetScaleY( float y );
517 * Set the z component of the scale factor.
518 * @param [in] z The new z value.
520 void SetScaleZ( float z );
523 * Apply a relative scale to an actor.
524 * @param[in] relativeScale The scale to combine with the actors existing scale.
526 void ScaleBy(const Vector3& relativeScale);
529 * Retrieve the scale factor applied to an actor.
530 * @return A vector representing the scale factor for each axis.
532 const Vector3& GetCurrentScale() const;
535 * @copydoc Dali::Actor::GetCurrentWorldScale()
537 const Vector3& GetCurrentWorldScale() const;
540 * @copydoc Dali::Actor::SetInheritScale()
542 void SetInheritScale( bool inherit );
545 * @copydoc Dali::Actor::IsScaleInherited()
547 bool IsScaleInherited() const;
550 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
552 Matrix GetCurrentWorldMatrix() const;
557 * Sets the visibility flag of an actor.
558 * @param [in] visible The new visibility flag.
560 void SetVisible(bool visible);
563 * Retrieve the visibility flag of an actor.
564 * @return The visibility flag.
566 bool IsVisible() const;
569 * Sets the opacity of an actor.
570 * @param [in] opacity The new opacity.
572 void SetOpacity(float opacity);
575 * Apply a relative opacity change to an actor.
576 * @param[in] relativeOpacity The opacity to combine with the actors existing opacity.
578 void OpacityBy(float relativeOpacity);
581 * Retrieve the actor's opacity.
582 * @return The actor's opacity.
584 float GetCurrentOpacity() const;
587 * Sets whether an actor should emit touch signals; see SignalTouch().
588 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
589 * the touch event signal will be emitted.
591 * If the application wishes to temporarily disable the touch event signal emission, then they can do so by calling:
593 * actor.SetSensitive(false);
596 * Then, to re-enable the touch event signal emission, the application should call:
598 * actor.SetSensitive(true);
601 * @see SignalTouch().
602 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch event signal either.
603 * @param[in] sensitive true to enable emission of the touch event signals, false otherwise.
605 void SetSensitive(bool sensitive)
607 mSensitive = sensitive;
611 * Query whether an actor emits touch event signals.
612 * @see SetSensitive(bool)
613 * @return true, if emission of touch event signals is enabled, false otherwise.
615 bool IsSensitive() const
620 // Shader effects, these are virtual so that RenderableActor can override the behaviour.
621 // Default actor behaviour is to do nothing, but the API is kept in Actor for convenience.
624 * @todo remove when API is cleaned up
625 * Sets the shader effect for the Actor.
626 * Shader effects provide special effects like rippling and bending.
627 * Setting a shader effect removes any shader effect previously set by SetShaderEffect.
628 * @param [in] effect The shader effect.
630 virtual void SetShaderEffect(ShaderEffect& effect);
633 * @todo remove when API is cleaned up
634 * Retrieve the shader effect for the Actor.
635 * @return The shader effect
637 virtual ShaderEffectPtr GetShaderEffect() const;
640 * @todo remove when API is cleaned up
641 * Removes the current shader effect.
643 virtual void RemoveShaderEffect();
646 * @copydoc Dali::Actor::SetDrawMode
648 void SetDrawMode( DrawMode::Type drawMode );
651 * @copydoc Dali::Actor::GetDrawMode
653 DrawMode::Type GetDrawMode() const;
656 * @copydoc Dali::Actor::SetOverlay
658 void SetOverlay(bool enable);
661 * @copydoc Dali::Actor::IsOverlay
663 bool IsOverlay() const;
666 * Sets whether an actor transmits geometry scaling to it's children.
667 * The default value is for it not to transmit scaling.
668 * @param[in] transmitGeometryScaling True to transmit scaling.
670 void SetTransmitGeometryScaling(bool transmitGeometryScaling);
673 * Get the TransmitGeometryScaling property for this actor.
674 * @return True if geometry scaling is applied to the inherited scale.
676 bool GetTransmitGeometryScaling() const;
679 * Sets the initial volume of the actor. Used for scaling the
680 * actor appropriately as the actor is sized when transmitGeometryScaling
683 * @param[in] volume the volume of the model and it's children
685 void SetInitialVolume(const Vector3& volume);
688 * Sets the actor's color. The final color of actor depends on its color mode.
689 * This final color is applied to the drawable elements of an actor.
690 * @param [in] color The new color.
692 void SetColor(const Vector4& color);
695 * Set the red component of the color.
696 * @param [in] red The new red component.
698 void SetColorRed( float red );
701 * Set the green component of the color.
702 * @param [in] green The new green component.
704 void SetColorGreen( float green );
707 * Set the blue component of the scale factor.
708 * @param [in] blue The new blue value.
710 void SetColorBlue( float blue );
713 * Apply a relative color change to an actor.
714 * @param[in] relativeColor The color to combine with the actors existing color.
716 void ColorBy(const Vector4& relativeColor);
719 * Retrieve the actor's color.
722 const Vector4& GetCurrentColor() const;
725 * Sets the actor's color mode.
726 * Color mode specifies whether Actor uses its own color or inherits its parent color
727 * @param [in] colorMode to use.
729 void SetColorMode(ColorMode colorMode);
732 * Returns the actor's color mode.
733 * @return currently used colorMode.
735 ColorMode GetColorMode() const;
738 * @copydoc Dali::Actor::GetCurrentWorldColor()
740 const Vector4& GetCurrentWorldColor() const;
742 #ifdef DYNAMICS_SUPPORT
746 /// @copydoc Dali::Actor::DisableDynamics
747 void DisableDynamics();
749 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
750 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
752 /// @copydoc Dali::Actor::GetDynamicsBody
753 DynamicsBodyPtr GetDynamicsBody() const;
755 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
756 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
758 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
759 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
761 /// @copydoc Dali::Actor::GetNumberOfJoints
762 const int GetNumberOfJoints() const;
764 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
765 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
767 /// @copydoc Dali::Actor::GetDynamicsJoint
768 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
770 /// @copydoc Dali::Actor::RemoveDynamicsJoint
771 void RemoveDynamicsJoint( DynamicsJointPtr joint );
774 * Hold a reference to a DynamicsJoint
775 * @param[in] joint The joint
777 void ReferenceJoint( DynamicsJointPtr joint );
780 * Release a reference to a DynamicsJoint
781 * @param[in] joint The joint
783 void ReleaseJoint( DynamicsJointPtr joint );
786 * Set this actor to be the root actor in the dynamics simulation
787 * All children of the actor are added/removed from the simulation.
788 * @param[in] flag When true sets this actor to be the simulation world root actor and
789 * if OnStage() all dynamics enabled child actors are added to the simulation,
790 * when false stops this actor being the simulation root and if OnStage() all
791 * dynamics enabled child actors are removed from the simulation.
793 void SetDynamicsRoot(bool flag);
797 * Check if this actor is the root actor in the dynamics simulation
798 * @return true if this is the dynamics root actor.
800 bool IsDynamicsRoot() const;
803 * Add actor to the dynamics simulation
804 * Invoked when the actor is staged, or it's parent becomes the simulation root
806 void ConnectDynamics();
809 * Remove actor from the dynamics simulation
810 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
812 void DisconnectDynamics();
815 * An actor in a DynamicsJoint relationship has been staged
816 * @param[in] actor The actor passed into AddDynamicsJoint()
818 void AttachedActorOnStage( Dali::Actor actor );
821 * An actor in a DynamicsJoint relationship has been unstaged
822 * @param[in] actor The actor passed into AddDynamicsJoint()
824 void AttachedActorOffStage( Dali::Actor actor );
826 #endif // DYNAMICS_SUPPORT
830 * Converts screen coordinates into the actor's coordinate system.
831 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
832 * @param[out] localX On return, the X-coordinate relative to the actor.
833 * @param[out] localY On return, the Y-coordinate relative to the actor.
834 * @param[in] screenX The screen X-coordinate.
835 * @param[in] screenY The screen Y-coordinate.
836 * @return True if the conversion succeeded.
838 bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
841 * Converts screen coordinates into the actor's coordinate system.
842 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
843 * @param[in] renderTask The render-task used to display the actor.
844 * @param[out] localX On return, the X-coordinate relative to the actor.
845 * @param[out] localY On return, the Y-coordinate relative to the actor.
846 * @param[in] screenX The screen X-coordinate.
847 * @param[in] screenY The screen Y-coordinate.
848 * @return True if the conversion succeeded.
850 bool ScreenToLocal(RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const;
853 * Converts from the actor's coordinate system to screen coordinates.
854 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
855 * @param[in] viewMatrix The view-matrix
856 * @param[in] projectionMatrix The projection-matrix
857 * @param[in] viewport The view-port
858 * @param[out] localX On return, the X-coordinate relative to the actor.
859 * @param[out] localY On return, the Y-coordinate relative to the actor.
860 * @param[in] screenX The screen X-coordinate.
861 * @param[in] screenY The screen Y-coordinate.
862 * @return True if the conversion succeeded.
864 bool ScreenToLocal( const Matrix& viewMatrix,
865 const Matrix& projectionMatrix,
866 const Viewport& viewport,
870 float screenY ) const;
873 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
874 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
875 * @param[in] rayOrigin The ray origin in the world's reference system.
876 * @param[in] rayDir The ray director vector in the world's reference system.
877 * @return True if the ray intersects the actor's bounding sphere.
879 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
882 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
883 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
884 * @param[in] rayOrigin The ray origin in the world's reference system.
885 * @param[in] rayDir The ray director vector in the world's reference system.
886 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
887 * @param[out] distance The distance from the hit point to the camera.
888 * @return True if the ray intersects the actor's geometry.
890 bool RayActorTest( const Vector4& rayOrigin, const Vector4& rayDir, Vector4& hitPointLocal, float& distance ) const;
893 * Sets whether the actor should receive a notification when touch motion events leave
894 * the boundary of the actor.
896 * @note By default, this is set to false as most actors do not require this.
897 * @note Need to connect to the SignalTouch to actually receive this event.
899 * @param[in] required Should be set to true if a Leave event is required
901 void SetLeaveRequired(bool required);
904 * This returns whether the actor requires touch events whenever touch motion events leave
905 * the boundary of the actor.
906 * @return true if a Leave event is required, false otherwise.
908 bool GetLeaveRequired() const;
911 * @copydoc Dali::Actor::SetKeyboardFocusable()
913 void SetKeyboardFocusable( bool focusable );
916 * @copydoc Dali::Actor::IsKeyboardFocusable()
918 bool IsKeyboardFocusable() const;
921 * Query whether the application or derived actor type requires touch events.
922 * @return True if touch events are required.
924 bool GetTouchRequired() const;
927 * Query whether the application or derived actor type requires mouse wheel events.
928 * @return True if mouse wheel events are required.
930 bool GetMouseWheelEventRequired() const;
933 * Query whether the actor is actually hittable. This method checks whether the actor is
934 * sensitive, has the visibility flag set to true and is not fully transparent.
935 * @return true, if it can be hit, false otherwise.
937 bool IsHittable() const;
942 * Retrieve the gesture data associated with this actor. The first call to this method will
943 * allocate space for the ActorGestureData so this should only be called if an actor really does
945 * @return Reference to the ActorGestureData for this actor.
946 * @note Once the gesture-data is created for an actor it is likely that gestures are required
947 * throughout the actor's lifetime so it will only be deleted when the actor is destroyed.
949 ActorGestureData& GetGestureData();
952 * Queries whether the actor requires the gesture type.
953 * @param[in] type The gesture type.
955 bool IsGestureRequred( Gesture::Type type ) const;
960 * Used by the EventProcessor to emit touch event signals.
961 * @param[in] event The touch event.
962 * @return True if the event was consumed.
964 bool EmitTouchEventSignal(const TouchEvent& event);
967 * Used by the EventProcessor to emit mouse wheel event signals.
968 * @param[in] event The mouse wheel event.
969 * @return True if the event was consumed.
971 bool EmitMouseWheelEventSignal(const MouseWheelEvent& event);
974 * @copydoc Dali::Actor::TouchedSignal()
976 Dali::Actor::TouchSignalV2& TouchedSignal();
979 * @copydoc Dali::Actor::MouseWheelEventSignal()
981 Dali::Actor::MouseWheelEventSignalV2& MouseWheelEventSignal();
984 * @copydoc Dali::Actor::SetSizeSignal()
986 Dali::Actor::SetSizeSignalV2& SetSizeSignal();
989 * @copydoc Dali::Actor::OnStageSignal()
991 Dali::Actor::OnStageSignalV2& OnStageSignal();
994 * @copydoc Dali::Actor::OffStageSignal()
996 Dali::Actor::OffStageSignalV2& OffStageSignal();
999 * Connects a callback function with the object's signals.
1000 * @param[in] object The object providing the signal.
1001 * @param[in] tracker Used to disconnect the signal.
1002 * @param[in] signalName The signal to connect to.
1003 * @param[in] functor A newly allocated FunctorDelegate.
1004 * @return True if the signal was connected.
1005 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
1007 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
1010 * Performs actions as requested using the action name.
1011 * @param[in] object The object on which to perform the action.
1012 * @param[in] actionName The action to perform.
1013 * @param[in] attributes The attributes with which to perfrom this action.
1014 * @return true if the action was done.
1016 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
1018 public: // For Animation
1021 * For use in derived classes.
1022 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1024 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) {}
1037 * Protected Constructor. See Actor::New().
1038 * The second-phase construction Initialize() member should be called immediately after this.
1039 * @param[in] derivedType The derived type of actor (if any).
1041 Actor( DerivedType derivedType );
1044 * Second-phase constructor. Must be called immediately after creating a new Actor;
1046 void Initialize(void);
1049 * A reference counted object may only be deleted by calling Unreference()
1054 * Called on a child during Add() when the parent actor is connected to the Stage.
1055 * @param[in] stage The stage.
1057 void ConnectToStage(Stage& stage);
1060 * Helper for ConnectToStage, to recursively connect a tree of actors.
1061 * This is atomic i.e. not interrupted by user callbacks.
1062 * @param[in] stage The stage.
1063 * @param[out] connectionList On return, the list of connected actors which require notification.
1065 void RecursiveConnectToStage( Stage& stage, ActorContainer& connectionList );
1068 * Connect the Node associated with this Actor to the scene-graph.
1070 void ConnectToSceneGraph();
1073 * Helper for ConnectToStage, to notify a connected actor through the public API.
1075 void NotifyStageConnection();
1078 * Called on a child during Remove() when the actor was previously on the Stage.
1080 void DisconnectFromStage();
1083 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1084 * This is atomic i.e. not interrupted by user callbacks.
1085 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1087 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1090 * Disconnect the Node associated with this Actor from the scene-graph.
1092 void DisconnectFromSceneGraph();
1095 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1097 void NotifyStageDisconnection();
1100 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1101 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1103 bool IsNodeConnected() const;
1105 public: // Default property extensions from ProxyObject
1108 * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
1110 virtual bool IsSceneObjectRemovable() const;
1113 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
1115 virtual unsigned int GetDefaultPropertyCount() const;
1118 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
1120 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1123 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
1125 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
1128 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
1130 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
1133 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
1135 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
1138 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
1140 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
1143 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
1145 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1148 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
1150 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
1153 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
1155 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
1158 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
1160 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
1163 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
1165 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1168 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
1170 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
1173 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
1175 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1178 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
1180 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1183 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
1185 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1188 * @copydoc Dali::Internal::ProxyObject::GetPropertyComponentIndex()
1190 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1198 Actor(const Actor&);
1201 Actor& operator=(const Actor& rhs);
1204 * Set the actors parent.
1205 * @param[in] parent The new parent.
1207 void SetParent(Actor* parent);
1210 * Helper to create a Node for this Actor.
1211 * To be overriden in derived classes.
1212 * @return A newly allocated node.
1214 virtual SceneGraph::Node* CreateNode() const;
1217 * For use in derived classes, called after Initialize()
1219 virtual void OnInitialize() {}
1222 * For use in internal derived classes.
1223 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1224 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1226 virtual void OnStageConnectionInternal() {}
1229 * For use in internal derived classes.
1230 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1231 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1233 virtual void OnStageDisconnectionInternal() {}
1236 * For use in external (CustomActor) derived classes.
1237 * This is called after the atomic ConnectToStage() traversal has been completed.
1239 virtual void OnStageConnectionExternal() {}
1242 * For use in external (CustomActor) derived classes.
1243 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1245 virtual void OnStageDisconnectionExternal() {}
1248 * For use in derived classes; this is called after Add() has added a child.
1249 * @param[in] child The child that was added.
1251 virtual void OnChildAdd( Actor& child ) {}
1254 * For use in derived classes; this is called after Remove() has removed a child.
1255 * @param[in] child The child that was removed.
1257 virtual void OnChildRemove( Actor& child ) {}
1260 * For use in derived classes.
1261 * This is called after SizeSet() has been called.
1263 virtual void OnSizeSet(const Vector3& targetSize) {}
1266 * For use in derived classes.
1267 * This is called after a non animatable custom property is set.
1268 * @param [in] index The index of the property.
1269 * @param [in] propertyValue The value of the property.
1271 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {}
1274 * For use in derived classes.
1275 * This is only called if mTouchRequired is true, and the touch-signal was not consumed.
1276 * @param[in] event The touch event.
1277 * @return True if the event should be consumed.
1279 virtual bool OnTouchEvent(const TouchEvent& event) { return false; }
1282 * For use in derived classes.
1283 * This is only called if the mouse wheel signal was not consumed.
1284 * @param[in] event The mouse event.
1285 * @return True if the event should be consumed.
1287 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { return false; }
1290 * For use in derived class
1291 * If an alias for a child exists, return the child otherwise return an empty handle.
1292 * For example 'previous' could return the last selected child.
1293 * @pre The Actor has been initialized.
1294 * @param[in] actorAlias the name of the actor to find
1295 * @return A handle to the actor if found, or an empty handle if not.
1297 virtual Dali::Actor GetChildByAlias(const std::string& actorAlias) { return Dali::Actor(); }
1300 * Support function for FindChildByAlias
1301 * @pre The Actor has been initialized.
1302 * @param[in] actorAlias the name of the aliased actor to find
1303 * @return A handle to the actor if found, or an empty handle if not.
1305 Dali::Actor DoGetChildByAlias(const std::string& actorAlias);
1309 StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
1310 Actor* mParent; ///< Each actor (except the root) can have one parent
1311 ActorContainer* mChildren; ///< Container of referenced actors
1312 const SceneGraph::Node* mNode; ///< Not owned
1313 Vector3* mParentOrigin; // NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1314 Vector3* mAnchorPoint; // NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1316 #ifdef DYNAMICS_SUPPORT
1317 DynamicsData* mDynamicsData; ///< optional physics data
1320 ActorGestureData* mGestureData; /// Optional Gesture data. Only created when actor requires gestures
1322 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1325 Dali::Actor::TouchSignalV2 mTouchedSignalV2;
1326 Dali::Actor::MouseWheelEventSignalV2 mMouseWheelEventSignalV2;
1327 Dali::Actor::SetSizeSignalV2 mSetSizeSignalV2;
1328 Dali::Actor::OnStageSignalV2 mOnStageSignalV2;
1329 Dali::Actor::OffStageSignalV2 mOffStageSignalV2;
1331 std::string mName; ///< Name of the actor
1332 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1334 const bool mIsRoot : 1; ///< Flag to identify the root actor
1335 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1336 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1337 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1338 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1339 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1340 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1341 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1342 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1343 bool mDerivedRequiresMouseWheelEvent : 1; ///< Whether the derived actor type requires mouse wheel event signals
1344 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1345 bool mInheritRotation : 1; ///< Cached: Whether the parent's rotation should be inherited.
1346 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1347 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1348 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1349 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1351 // Default properties
1352 typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
1356 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1357 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1359 // Default properties
1360 static DefaultPropertyLookup* mDefaultPropertyLookup;
1365 * @brief Structure for setting up default properties and their details.
1367 struct PropertyDetails
1369 std::string name; ///< The name of the property.
1370 Property::Type type; ///< The property type.
1371 bool writable:1; ///< Whether the property is writable
1372 bool animatable:1; ///< Whether the property is animatable.
1373 bool constraintInput:1; ///< Whether the property can be used as an input to a constraint.
1376 } // namespace Internal
1378 // Helpers for public-api forwarding methods
1380 inline Internal::Actor& GetImplementation(Dali::Actor& actor)
1382 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
1384 BaseObject& handle = actor.GetBaseObject();
1386 return static_cast<Internal::Actor&>(handle);
1389 inline const Internal::Actor& GetImplementation(const Dali::Actor& actor)
1391 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
1393 const BaseObject& handle = actor.GetBaseObject();
1395 return static_cast<const Internal::Actor&>(handle);
1400 #endif // __DALI_INTERNAL_ACTOR_H__