1 #ifndef __DALI_INTERNAL_ACTOR_H__
2 #define __DALI_INTERNAL_ACTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
24 #include <dali/public-api/common/map-wrapper.h>
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/public-api/object/ref-object.h>
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/math/viewport.h>
30 #include <dali/internal/event/common/proxy-object.h>
31 #include <dali/internal/event/common/stage-def.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/update/nodes/node-declarations.h>
36 #ifdef DYNAMICS_SUPPORT
37 #include <dali/internal/event/dynamics/dynamics-declarations.h>
45 struct MouseWheelEvent;
55 typedef IntrusivePtr<Actor> ActorPtr;
56 typedef IntrusivePtr<ShaderEffect> ShaderEffectPtr;
57 typedef Dali::ActorContainer ActorContainer; // Store handles to return via public-api
58 typedef ActorContainer::iterator ActorIter;
59 typedef ActorContainer::const_iterator ActorConstIter;
62 * Actor is the primary object which Dali applications interact with.
63 * UI controls can be built by combining multiple actors.
64 * Multi-Touch events are received through signals emitted by the actor tree.
66 * An Actor is a proxy for a Node in the scene graph.
67 * When an Actor is added to the Stage, it creates a node and attaches it to the scene graph.
68 * The scene-graph can be updated in a separate thread, so the attachment is done using an asynchronous message.
69 * When a tree of Actors is detached from the Stage, a message is sent to destroy the associated nodes.
71 class Actor : public ProxyObject
77 * @return A smart-pointer to the newly allocated Actor.
79 static ActorPtr New();
82 * Retrieve the name of the actor.
85 const std::string& GetName() const;
88 * Set the name of the actor.
89 * @param[in] name The new name.
91 void SetName(const std::string& name);
94 * @copydoc Dali::Actor::GetId
96 unsigned int GetId() const;
101 * Attach an object to an actor.
102 * @pre The actor does not already have an attachment.
103 * @param[in] attachment The object to attach.
105 void Attach(ActorAttachment& attachment);
108 * Retreive the object attached to an actor.
109 * @return The attachment.
111 ActorAttachmentPtr GetAttachment();
116 * Query whether an actor is the root actor, which is owned by the Stage.
117 * @return True if the actor is a root actor.
125 * Query whether the actor is connected to the Stage.
127 bool OnStage() const;
130 * Query whether the actor is a RenderableActor derived type.
131 * @return True if the actor is renderable.
133 bool IsRenderable() const
135 // inlined as this is called a lot in hit testing
136 return mIsRenderable;
140 * Query whether the actor is of class Dali::Layer
141 * @return True if the actor is a layer.
145 // inlined as this is called a lot in hit testing
150 * Gets the layer in which the actor is present
151 * @return The layer, which will be uninitialized if the actor is off-stage.
153 Dali::Layer GetLayer();
156 * Adds a child Actor to this Actor.
157 * @pre The child actor is not the same as the parent actor.
158 * @pre The child actor does not already have a parent.
159 * @param [in] child The child.
160 * @post The child will be referenced by its parent.
162 void Add(Actor& child);
165 * Removes a child Actor from this Actor.
166 * @param [in] child The child.
167 * @post The child will be unreferenced.
169 void Remove(Actor& child);
172 * @copydoc Dali::Actor::Unparent
177 * Retrieve the number of children held by the actor.
178 * @return The number of children
180 unsigned int GetChildCount() const;
183 * @copydoc Dali::Actor::GetChildAt
185 Dali::Actor GetChildAt(unsigned int index) const;
188 * Retrieve the Actor's children.
189 * @return A copy of the container of children.
191 ActorContainer GetChildren();
194 * Retrieve the Actor's children.
195 * @return A const reference to the container of children.
197 const ActorContainer& GetChildren() const;
200 * Retrieve a reference to Actor's children.
201 * @note Not for public use.
202 * @return A reference to the container of children.
204 ActorContainer& GetChildrenInternal()
210 * @copydoc Dali::Actor::FindChildByName
212 ActorPtr FindChildByName(const std::string& actorName);
215 * @copydoc Dali::Actor::FindChildByAlias
217 Dali::Actor FindChildByAlias(const std::string& actorAlias);
220 * @copydoc Dali::Actor::FindChildById
222 ActorPtr FindChildById(const unsigned int id);
225 * Retrieve the parent of an Actor.
226 * @return The parent actor, or NULL if the Actor does not have a parent.
228 Actor* GetParent() const
234 * Sets the size of an actor.
235 * ActorAttachments attached to the actor, can be scaled to fit within this area.
236 * This does not interfere with the actors scale factor.
237 * @param [in] width The new width.
238 * @param [in] height The new height.
240 void SetSize(float width, float height);
243 * Sets the size of an actor.
244 * ActorAttachments attached to the actor, can be scaled to fit within this area.
245 * This does not interfere with the actors scale factor.
246 * @param [in] width The size of the actor along the x-axis.
247 * @param [in] height The size of the actor along the y-axis.
248 * @param [in] depth The size of the actor along the z-axis.
250 void SetSize(float width, float height, float depth);
253 * Sets the size of an actor.
254 * ActorAttachments attached to the actor, can be scaled to fit within this area.
255 * This does not interfere with the actors scale factor.
256 * @param [in] size The new size.
258 void SetSize(const Vector2& size);
261 * Sets the size of an actor.
262 * ActorAttachments attached to the actor, can be scaled to fit within this area.
263 * This does not interfere with the actors scale factor.
264 * @param [in] size The new size.
266 void SetSize(const Vector3& size);
269 * Set the width component of the Actor's size.
270 * @param [in] width The new width component.
272 void SetWidth( float width );
275 * Set the height component of the Actor's size.
276 * @param [in] height The new height component.
278 void SetHeight( float height );
281 * Set the depth component of the Actor's size.
282 * @param [in] depth The new depth component.
284 void SetDepth( float depth );
287 * Retrieve the Actor's size.
288 * @return The Actor's size.
290 const Vector3& GetCurrentSize() const;
293 * Set the origin of an actor, within its parent's area.
294 * This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
295 * and (1.0, 1.0, 0.5) is the bottom-right corner.
296 * The default parent-origin is top-left (0.0, 0.0, 0.5).
297 * An actor position is the distance between this origin, and the actors anchor-point.
298 * @param [in] origin The new parent-origin.
300 void SetParentOrigin(const Vector3& origin);
303 * Set the x component of the parent-origin
304 * @param [in] x The new x value.
306 void SetParentOriginX( float x );
309 * Set the y component of the parent-origin
310 * @param [in] y The new y value.
312 void SetParentOriginY( float y );
315 * Set the z component of the parent-origin
316 * @param [in] z The new z value.
318 void SetParentOriginZ( float z );
321 * Retrieve the parent-origin of an actor.
322 * @return The parent-origin.
324 const Vector3& GetCurrentParentOrigin() const;
327 * Set the anchor-point of an actor. This is expressed in 2D unit coordinates, such that
328 * (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.
329 * The default anchor point is top-left (0.0, 0.0, 0.5).
330 * An actor position is the distance between its parent-origin, and this anchor-point.
331 * An actor's rotation is centered around its anchor-point.
332 * @param [in] anchorPoint The new anchor-point.
334 void SetAnchorPoint(const Vector3& anchorPoint);
337 * Set the x component of the anchor-point.
338 * @param [in] x The new x value.
340 void SetAnchorPointX( float x );
343 * Set the y component of the anchor-point.
344 * @param [in] y The new y value.
346 void SetAnchorPointY( float y );
349 * Set the z component of the anchor-point.
350 * @param [in] z The new z value.
352 void SetAnchorPointZ( float z );
355 * Retrieve the anchor-point of an actor.
356 * @return The anchor-point.
358 const Vector3& GetCurrentAnchorPoint() const;
361 * Sets the position of the Actor.
362 * The coordinates are relative to the Actor's parent.
363 * The Actor's z position will be set to 0.0f.
364 * @param [in] x The new x position
365 * @param [in] y The new y position
367 void SetPosition(float x, float y);
370 * Sets the position of the Actor.
371 * The coordinates are relative to the Actor's parent.
372 * @param [in] x The new x position
373 * @param [in] y The new y position
374 * @param [in] z The new z position
376 void SetPosition(float x, float y, float z);
379 * Sets the position of the Actor.
380 * The coordinates are relative to the Actor's parent.
381 * @param [in] position The new position.
383 void SetPosition(const Vector3& position);
386 * Set the position of an actor along the X-axis.
387 * @param [in] x The new x position
392 * Set the position of an actor along the Y-axis.
393 * @param [in] y The new y position.
398 * Set the position of an actor along the Z-axis.
399 * @param [in] z The new z position
404 * Move an actor relative to its existing position.
405 * @param[in] distance The actor will move by this distance.
407 void MoveBy(const Vector3& distance);
410 * Retrieve the position of the Actor.
411 * The coordinates are relative to the Actor's parent.
412 * @return the Actor's position.
414 const Vector3& GetCurrentPosition() const;
417 * @copydoc Dali::Actor::GetCurrentWorldPosition()
419 const Vector3& GetCurrentWorldPosition() const;
422 * @copydoc Dali::Actor::SetPositionInheritanceMode()
424 void SetPositionInheritanceMode( PositionInheritanceMode mode );
427 * @copydoc Dali::Actor::GetPositionInheritanceMode()
429 PositionInheritanceMode GetPositionInheritanceMode() const;
432 * Sets the rotation of the Actor.
433 * @param [in] angleRadians The new rotation angle in radians.
434 * @param [in] axis The new axis of rotation.
436 void SetRotation(const Radian& angleRadians, const Vector3& axis);
439 * Sets the rotation of the Actor.
440 * @param [in] rotation The new rotation.
442 void SetRotation(const Quaternion& rotation);
445 * Rotate an actor around its existing rotation axis.
446 * @param[in] angleRadians The angle to the rotation to combine with the existing rotation.
447 * @param[in] axis The axis of the rotation to combine with the existing rotation.
449 void RotateBy(const Radian& angleRadians, const Vector3& axis);
452 * Apply a relative rotation to an actor.
453 * @param[in] relativeRotation The rotation to combine with the actors existing rotation.
455 void RotateBy(const Quaternion& relativeRotation);
458 * Retreive the Actor's rotation.
459 * @return the rotation.
461 const Quaternion& GetCurrentRotation() const;
464 * Set whether a child actor inherits it's parent's orientation. Default is to inherit.
465 * Switching this off means that using SetRotation() sets the actor's world orientation.
466 * @param[in] inherit - true if the actor should inherit orientation, false otherwise.
468 void SetInheritRotation(bool inherit);
471 * Returns whether the actor inherit's it's parent's orientation.
472 * @return true if the actor inherit's it's parent orientation, false if it uses world orientation.
474 bool IsRotationInherited() const;
477 * @copydoc Dali::Actor::GetCurrentWorldRotation()
479 const Quaternion& GetCurrentWorldRotation() const;
482 * Sets a scale factor applied to an actor.
483 * @param [in] scale The scale factor applied on all axes.
485 void SetScale(float scale);
488 * Sets a scale factor applied to an actor.
489 * @param [in] scaleX The scale factor applied along the x-axis.
490 * @param [in] scaleY The scale factor applied along the y-axis.
491 * @param [in] scaleZ The scale factor applied along the z-axis.
493 void SetScale(float scaleX, float scaleY, float scaleZ);
496 * Sets a scale factor applied to an actor.
497 * @param [in] scale A vector representing the scale factor for each axis.
499 void SetScale(const Vector3& scale);
502 * Set the x component of the scale factor.
503 * @param [in] x The new x value.
505 void SetScaleX( float x );
508 * Set the y component of the scale factor.
509 * @param [in] y The new y value.
511 void SetScaleY( float y );
514 * Set the z component of the scale factor.
515 * @param [in] z The new z value.
517 void SetScaleZ( float z );
520 * Apply a relative scale to an actor.
521 * @param[in] relativeScale The scale to combine with the actors existing scale.
523 void ScaleBy(const Vector3& relativeScale);
526 * Retrieve the scale factor applied to an actor.
527 * @return A vector representing the scale factor for each axis.
529 const Vector3& GetCurrentScale() const;
532 * @copydoc Dali::Actor::GetCurrentWorldScale()
534 const Vector3& GetCurrentWorldScale() const;
537 * @copydoc Dali::Actor::SetInheritScale()
539 void SetInheritScale( bool inherit );
542 * @copydoc Dali::Actor::IsScaleInherited()
544 bool IsScaleInherited() const;
547 * @copydoc Dali::Actor::GetCurrentWorldMatrix()
549 Matrix GetCurrentWorldMatrix() const;
554 * Sets the visibility flag of an actor.
555 * @param [in] visible The new visibility flag.
557 void SetVisible(bool visible);
560 * Retrieve the visibility flag of an actor.
561 * @return The visibility flag.
563 bool IsVisible() const;
566 * Sets the opacity of an actor.
567 * @param [in] opacity The new opacity.
569 void SetOpacity(float opacity);
572 * Apply a relative opacity change to an actor.
573 * @param[in] relativeOpacity The opacity to combine with the actors existing opacity.
575 void OpacityBy(float relativeOpacity);
578 * Retrieve the actor's opacity.
579 * @return The actor's opacity.
581 float GetCurrentOpacity() const;
584 * Sets whether an actor should emit touch signals; see SignalTouch().
585 * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
586 * the touch event signal will be emitted.
588 * If the application wishes to temporarily disable the touch event signal emission, then they can do so by calling:
590 * actor.SetSensitive(false);
593 * Then, to re-enable the touch event signal emission, the application should call:
595 * actor.SetSensitive(true);
598 * @see SignalTouch().
599 * @note If an actor's sensitivity is set to false, then it's children will not emit a touch event signal either.
600 * @param[in] sensitive true to enable emission of the touch event signals, false otherwise.
602 void SetSensitive(bool sensitive)
604 mSensitive = sensitive;
608 * Query whether an actor emits touch event signals.
609 * @see SetSensitive(bool)
610 * @return true, if emission of touch event signals is enabled, false otherwise.
612 bool IsSensitive() const
618 * Set whether the actor inherits a shader effect from its parent.
619 * The inherited effect can be overridden using SetShaderEffect()
620 * @param [in] inherit True if the parent effect is inherited.
622 void SetInheritShaderEffect(bool inherit);
625 * Query whether the actor inherits a shader effect from its parent.
626 * @return True if the parent effect is inherited.
628 bool GetInheritShaderEffect() const;
631 * Sets the shader effect for the Actor.
632 * Shader effects provide special effects like rippling and bending.
633 * Setting a shader effect removes any shader effect previously set by SetShaderEffect.
634 * @param [in] effect The shader effect.
636 void SetShaderEffect(ShaderEffect& effect);
639 * Retrieve the shader effect for the Actor.
640 * @return The shader effect
642 ShaderEffectPtr GetShaderEffect() const;
645 * Removes the current shader effect.
647 void RemoveShaderEffect();
650 * @copydoc Dali::Actor::SetDrawMode
652 void SetDrawMode( DrawMode::Type drawMode );
655 * @copydoc Dali::Actor::GetDrawMode
657 DrawMode::Type GetDrawMode() const;
660 * @copydoc Dali::Actor::SetOverlay
662 void SetOverlay(bool enable);
665 * @copydoc Dali::Actor::IsOverlay
667 bool IsOverlay() const;
670 * Sets whether an actor transmits geometry scaling to it's children.
671 * The default value is for it not to transmit scaling.
672 * @param[in] transmitGeometryScaling True to transmit scaling.
674 void SetTransmitGeometryScaling(bool transmitGeometryScaling);
677 * Get the TransmitGeometryScaling property for this actor.
678 * @return True if geometry scaling is applied to the inherited scale.
680 bool GetTransmitGeometryScaling() const;
683 * Sets the initial volume of the actor. Used for scaling the
684 * actor appropriately as the actor is sized when transmitGeometryScaling
687 * @param[in] volume the volume of the model and it's children
689 void SetInitialVolume(const Vector3& volume);
692 * Sets the actor's color. The final color of actor depends on its color mode.
693 * This final color is applied to the drawable elements of an actor.
694 * @param [in] color The new color.
696 void SetColor(const Vector4& color);
699 * Set the red component of the color.
700 * @param [in] red The new red component.
702 void SetColorRed( float red );
705 * Set the green component of the color.
706 * @param [in] green The new green component.
708 void SetColorGreen( float green );
711 * Set the blue component of the scale factor.
712 * @param [in] blue The new blue value.
714 void SetColorBlue( float blue );
717 * Apply a relative color change to an actor.
718 * @param[in] relativeColor The color to combine with the actors existing color.
720 void ColorBy(const Vector4& relativeColor);
723 * Retrieve the actor's color.
726 const Vector4& GetCurrentColor() const;
729 * Sets the actor's color mode.
730 * Color mode specifies whether Actor uses its own color or inherits its parent color
731 * @param [in] colorMode to use.
733 void SetColorMode(ColorMode colorMode);
736 * Returns the actor's color mode.
737 * @return currently used colorMode.
739 ColorMode GetColorMode() const;
742 * @copydoc Dali::Actor::GetCurrentWorldColor()
744 const Vector4& GetCurrentWorldColor() const;
746 #ifdef DYNAMICS_SUPPORT
750 /// @copydoc Dali::Actor::DisableDynamics
751 void DisableDynamics();
753 /// @copydoc Dali::Actor::EnableDynamics(Dali::DynamicsBodyConfig)
754 DynamicsBodyPtr EnableDynamics(DynamicsBodyConfigPtr bodyConfig);
756 /// @copydoc Dali::Actor::GetDynamicsBody
757 DynamicsBodyPtr GetDynamicsBody() const;
759 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&)
760 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offset );
762 /// @copydoc Dali::Actor::AddDynamicsJoint(Dali::Actor,const Vector3&,const Vector3&)
763 DynamicsJointPtr AddDynamicsJoint( ActorPtr attachedActor, const Vector3& offsetA, const Vector3& offsetB );
765 /// @copydoc Dali::Actor::GetNumberOfJoints
766 const int GetNumberOfJoints() const;
768 /// @copydoc Dali::Actor::GetDynamicsJointByIndex
769 DynamicsJointPtr GetDynamicsJointByIndex( const int index ) const;
771 /// @copydoc Dali::Actor::GetDynamicsJoint
772 DynamicsJointPtr GetDynamicsJoint( ActorPtr attachedActor ) const;
774 /// @copydoc Dali::Actor::RemoveDynamicsJoint
775 void RemoveDynamicsJoint( DynamicsJointPtr joint );
778 * Hold a reference to a DynamicsJoint
779 * @param[in] joint The joint
781 void ReferenceJoint( DynamicsJointPtr joint );
784 * Release a reference to a DynamicsJoint
785 * @param[in] joint The joint
787 void ReleaseJoint( DynamicsJointPtr joint );
790 * Set this actor to be the root actor in the dynamics simulation
791 * All children of the actor are added/removed from the simulation.
792 * @param[in] flag When true sets this actor to be the simulation world root actor and
793 * if OnStage() all dynamics enabled child actors are added to the simulation,
794 * when false stops this actor being the simulation root and if OnStage() all
795 * dynamics enabled child actors are removed from the simulation.
797 void SetDynamicsRoot(bool flag);
801 * Check if this actor is the root actor in the dynamics simulation
802 * @return true if this is the dynamics root actor.
804 bool IsDynamicsRoot() const;
807 * Add actor to the dynamics simulation
808 * Invoked when the actor is staged, or it's parent becomes the simulation root
810 void ConnectDynamics();
813 * Remove actor from the dynamics simulation
814 * Invoked when the actor is unstaged, or it's parent stops being the the simulation root
816 void DisconnectDynamics();
819 * An actor in a DynamicsJoint relationship has been staged
820 * @param[in] actor The actor passed into AddDynamicsJoint()
822 void AttachedActorOnStage( Dali::Actor actor );
825 * An actor in a DynamicsJoint relationship has been unstaged
826 * @param[in] actor The actor passed into AddDynamicsJoint()
828 void AttachedActorOffStage( Dali::Actor actor );
830 #endif // DYNAMICS_SUPPORT
834 * Converts screen coordinates into the actor's coordinate system.
835 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
836 * @param[out] localX On return, the X-coordinate relative to the actor.
837 * @param[out] localY On return, the Y-coordinate relative to the actor.
838 * @param[in] screenX The screen X-coordinate.
839 * @param[in] screenY The screen Y-coordinate.
840 * @return True if the conversion succeeded.
842 bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
845 * Converts screen coordinates into the actor's coordinate system.
846 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
847 * @param[in] renderTask The render-task used to display the actor.
848 * @param[out] localX On return, the X-coordinate relative to the actor.
849 * @param[out] localY On return, the Y-coordinate relative to the actor.
850 * @param[in] screenX The screen X-coordinate.
851 * @param[in] screenY The screen Y-coordinate.
852 * @return True if the conversion succeeded.
854 bool ScreenToLocal(RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const;
857 * Converts from the actor's coordinate system to screen coordinates.
858 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
859 * @param[in] viewMatrix The view-matrix
860 * @param[in] projectionMatrix The projection-matrix
861 * @param[in] viewport The view-port
862 * @param[out] localX On return, the X-coordinate relative to the actor.
863 * @param[out] localY On return, the Y-coordinate relative to the actor.
864 * @param[in] screenX The screen X-coordinate.
865 * @param[in] screenY The screen Y-coordinate.
866 * @return True if the conversion succeeded.
868 bool ScreenToLocal( const Matrix& viewMatrix,
869 const Matrix& projectionMatrix,
870 const Viewport& viewport,
874 float screenY ) const;
877 * Performs a ray-sphere test with the given pick-ray and the actor's bounding sphere.
878 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
879 * @param[in] rayOrigin The ray origin in the world's reference system.
880 * @param[in] rayDir The ray director vector in the world's reference system.
881 * @return True if the ray intersects the actor's bounding sphere.
883 bool RaySphereTest( const Vector4& rayOrigin, const Vector4& rayDir ) const;
886 * Performs a ray-actor test with the given pick-ray and the actor's geometry.
887 * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
888 * @param[in] rayOrigin The ray origin in the world's reference system.
889 * @param[in] rayDir The ray director vector in the world's reference system.
890 * @param[out] hitPointLocal The hit point in the Actor's local reference system.
891 * @param[out] distance The distance from the hit point to the camera.
892 * @return True if the ray intersects the actor's geometry.
894 bool RayActorTest( const Vector4& rayOrigin, const Vector4& rayDir, Vector4& hitPointLocal, float& distance ) const;
897 * Sets whether the actor should receive a notification when touch motion events leave
898 * the boundary of the actor.
900 * @note By default, this is set to false as most actors do not require this.
901 * @note Need to connect to the SignalTouch to actually receive this event.
903 * @param[in] required Should be set to true if a Leave event is required
905 void SetLeaveRequired(bool required);
908 * This returns whether the actor requires touch events whenever touch motion events leave
909 * the boundary of the actor.
910 * @return true if a Leave event is required, false otherwise.
912 bool GetLeaveRequired() const;
915 * @copydoc Dali::Actor::SetKeyboardFocusable()
917 void SetKeyboardFocusable( bool focusable );
920 * @copydoc Dali::Actor::IsKeyboardFocusable()
922 bool IsKeyboardFocusable() const;
925 * Query whether the application or derived actor type requires touch events.
926 * @return True if touch events are required.
928 bool GetTouchRequired() const;
931 * Query whether the application or derived actor type requires mouse wheel events.
932 * @return True if mouse wheel events are required.
934 bool GetMouseWheelEventRequired() const;
937 * Query whether the actor is actually hittable. This method checks whether the actor is
938 * sensitive, has the visibility flag set to true and is not fully transparent.
939 * @return true, if it can be hit, false otherwise.
941 bool IsHittable() const;
947 * Used by the EventProcessor to emit touch event signals.
948 * @param[in] event The touch event.
949 * @return True if the event was consumed.
951 bool EmitTouchEventSignal(const TouchEvent& event);
954 * Used by the EventProcessor to emit mouse wheel event signals.
955 * @param[in] event The mouse wheel event.
956 * @return True if the event was consumed.
958 bool EmitMouseWheelEventSignal(const MouseWheelEvent& event);
961 * @copydoc Dali::Actor::TouchedSignal()
963 Dali::Actor::TouchSignalV2& TouchedSignal();
966 * @copydoc Dali::Actor::MouseWheelEventSignal()
968 Dali::Actor::MouseWheelEventSignalV2& MouseWheelEventSignal();
971 * @copydoc Dali::Actor::SetSizeSignal()
973 Dali::Actor::SetSizeSignalV2& SetSizeSignal();
976 * @copydoc Dali::Actor::OnStageSignal()
978 Dali::Actor::OnStageSignalV2& OnStageSignal();
981 * @copydoc Dali::Actor::OffStageSignal()
983 Dali::Actor::OffStageSignalV2& OffStageSignal();
986 * Connects a callback function with the object's signals.
987 * @param[in] object The object providing the signal.
988 * @param[in] tracker Used to disconnect the signal.
989 * @param[in] signalName The signal to connect to.
990 * @param[in] functor A newly allocated FunctorDelegate.
991 * @return True if the signal was connected.
992 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
994 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
997 * Performs actions as requested using the action name.
998 * @param[in] object The object on which to perform the action.
999 * @param[in] actionName The action to perform.
1000 * @param[in] attributes The attributes with which to perfrom this action.
1001 * @return true if the action was done.
1003 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
1005 public: // For Animation
1008 * For use in derived classes.
1009 * This should only be called by Animation, when the actor is resized using Animation::Resize().
1011 virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) {}
1024 * Protected Constructor. See Actor::New().
1025 * The second-phase construction Initialize() member should be called immediately after this.
1026 * @param[in] derivedType The derived type of actor (if any).
1028 Actor( DerivedType derivedType );
1031 * Second-phase constructor. Must be called immediately after creating a new Actor;
1033 void Initialize(void);
1036 * A reference counted object may only be deleted by calling Unreference()
1041 * Called on a child during Add() when the parent actor is connected to the Stage.
1042 * @param[in] stage The stage.
1044 void ConnectToStage(Stage& stage);
1047 * Helper for ConnectToStage, to recursively connect a tree of actors.
1048 * This is atomic i.e. not interrupted by user callbacks.
1049 * @param[in] stage The stage.
1050 * @param[out] connectionList On return, the list of connected actors which require notification.
1052 void RecursiveConnectToStage( Stage& stage, ActorContainer& connectionList );
1055 * Connect the Node associated with this Actor to the scene-graph.
1057 void ConnectToSceneGraph();
1060 * Helper for ConnectToStage, to notify a connected actor through the public API.
1062 void NotifyStageConnection();
1065 * Called on a child during Remove() when the actor was previously on the Stage.
1067 void DisconnectFromStage();
1070 * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
1071 * This is atomic i.e. not interrupted by user callbacks.
1072 * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
1074 void RecursiveDisconnectFromStage( ActorContainer& disconnectionList );
1077 * Disconnect the Node associated with this Actor from the scene-graph.
1079 void DisconnectFromSceneGraph();
1082 * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
1084 void NotifyStageDisconnection();
1087 * When the Actor is OnStage, checks whether the corresponding Node is connected to the scene graph.
1088 * @return True if the Actor is OnStage & has a Node connected to the scene graph.
1090 bool IsNodeConnected() const;
1092 public: // Default property extensions from ProxyObject
1095 * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
1097 virtual bool IsSceneObjectRemovable() const;
1100 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
1102 virtual unsigned int GetDefaultPropertyCount() const;
1105 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
1107 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
1110 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
1112 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
1115 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
1117 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
1120 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
1122 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
1125 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
1127 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
1130 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
1132 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
1135 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
1137 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
1140 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
1142 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
1145 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
1147 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
1150 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
1152 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
1155 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
1157 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
1160 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
1162 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
1165 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
1167 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
1170 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
1172 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
1175 * @copydoc Dali::Internal::ProxyObject::GetPropertyComponentIndex()
1177 virtual int GetPropertyComponentIndex( Property::Index index ) const;
1185 Actor(const Actor&);
1188 Actor& operator=(const Actor& rhs);
1191 * Set the actors parent.
1192 * @param[in] parent The new parent.
1194 void SetParent(Actor* parent);
1197 * Helper to create a Node for this Actor.
1198 * To be overriden in derived classes.
1199 * @return A newly allocated node.
1201 virtual SceneGraph::Node* CreateNode() const;
1204 * For use in derived classes, called after Initialize()
1206 virtual void OnInitialize() {}
1209 * For use in internal derived classes.
1210 * This is called during ConnectToStage(), after the actor has finished adding its node to the scene-graph.
1211 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1213 virtual void OnStageConnectionInternal() {}
1216 * For use in internal derived classes.
1217 * This is called during DisconnectFromStage(), before the actor removes its node from the scene-graph.
1218 * The derived class must not modify the actor hierachy (Add/Remove children) during this callback.
1220 virtual void OnStageDisconnectionInternal() {}
1223 * For use in external (CustomActor) derived classes.
1224 * This is called after the atomic ConnectToStage() traversal has been completed.
1226 virtual void OnStageConnectionExternal() {}
1229 * For use in external (CustomActor) derived classes.
1230 * This is called after the atomic DisconnectFromStage() traversal has been completed.
1232 virtual void OnStageDisconnectionExternal() {}
1235 * For use in derived classes; this is called after Add() has added a child.
1236 * @param[in] child The child that was added.
1238 virtual void OnChildAdd( Actor& child ) {}
1241 * For use in derived classes; this is called after Remove() has removed a child.
1242 * @param[in] child The child that was removed.
1244 virtual void OnChildRemove( Actor& child ) {}
1247 * For use in derived classes.
1248 * This is called after SizeSet() has been called.
1250 virtual void OnSizeSet(const Vector3& targetSize) {}
1253 * For use in derived classes.
1254 * This is called after a non animatable custom property is set.
1255 * @param [in] index The index of the property.
1256 * @param [in] propertyValue The value of the property.
1258 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {}
1261 * For use in derived classes.
1262 * This is only called if mTouchRequired is true, and the touch-signal was not consumed.
1263 * @param[in] event The touch event.
1264 * @return True if the event should be consumed.
1266 virtual bool OnTouchEvent(const TouchEvent& event) { return false; }
1269 * For use in derived classes.
1270 * This is only called if the mouse wheel signal was not consumed.
1271 * @param[in] event The mouse event.
1272 * @return True if the event should be consumed.
1274 virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) { return false; }
1277 * For use in derived class
1278 * If an alias for a child exists, return the child otherwise return an empty handle.
1279 * For example 'previous' could return the last selected child.
1280 * @pre The Actor has been initialized.
1281 * @param[in] actorAlias the name of the actor to find
1282 * @return A handle to the actor if found, or an empty handle if not.
1284 virtual Dali::Actor GetChildByAlias(const std::string& actorAlias) { return Dali::Actor(); }
1287 * Support function for FindChildByAlias
1288 * @pre The Actor has been initialized.
1289 * @param[in] actorAlias the name of the aliased actor to find
1290 * @return A handle to the actor if found, or an empty handle if not.
1292 Dali::Actor DoGetChildByAlias(const std::string& actorAlias);
1296 StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
1297 Actor* mParent; ///< Each actor (except the root) can have one parent
1298 ActorContainer* mChildren; ///< Container of referenced actors
1299 const SceneGraph::Node* mNode; ///< Not owned
1300 Vector3* mParentOrigin; // NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
1301 Vector3* mAnchorPoint; // NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
1303 #ifdef DYNAMICS_SUPPORT
1304 DynamicsData* mDynamicsData; ///< optional physics data
1307 ActorAttachmentPtr mAttachment; ///< Optional referenced attachment
1308 ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect
1311 Dali::Actor::TouchSignalV2 mTouchedSignalV2;
1312 Dali::Actor::MouseWheelEventSignalV2 mMouseWheelEventSignalV2;
1313 Dali::Actor::SetSizeSignalV2 mSetSizeSignalV2;
1314 Dali::Actor::OnStageSignalV2 mOnStageSignalV2;
1315 Dali::Actor::OffStageSignalV2 mOffStageSignalV2;
1317 std::string mName; ///< Name of the actor
1318 unsigned int mId; ///< A unique ID to identify the actor starting from 1, and 0 is reserved
1320 const bool mIsRoot : 1; ///< Flag to identify the root actor
1321 const bool mIsRenderable : 1; ///< Flag to identify that this is a renderable actor
1322 const bool mIsLayer : 1; ///< Flag to identify that this is a layer
1323 bool mIsOnStage : 1; ///< Flag to identify whether the actor is on-stage
1324 bool mIsDynamicsRoot : 1; ///< Flag to identify if this is the dynamics world root
1325 bool mSensitive : 1; ///< Whether the actor emits touch event signals
1326 bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
1327 bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation
1328 bool mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
1329 bool mDerivedRequiresMouseWheelEvent : 1; ///< Whether the derived actor type requires mouse wheel event signals
1330 bool mOnStageSignalled : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
1331 bool mInheritRotation : 1; ///< Cached: Whether the parent's rotation should be inherited.
1332 bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited.
1333 DrawMode::Type mDrawMode : 2; ///< Cached: How the actor and its children should be drawn
1334 PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
1335 ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited
1337 // Default properties
1338 typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
1342 static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
1343 static unsigned int mActorCounter; ///< A counter to track the actor instance creation
1345 // Default properties
1346 static DefaultPropertyLookup* mDefaultPropertyLookup;
1351 * @brief Structure for setting up default properties and their details.
1353 struct PropertyDetails
1355 std::string name; ///< The name of the property.
1356 Property::Type type; ///< The property type.
1357 bool writable:1; ///< Whether the property is writable
1358 bool animatable:1; ///< Whether the property is animatable.
1359 bool constraintInput:1; ///< Whether the property can be used as an input to a constraint.
1362 } // namespace Internal
1364 // Helpers for public-api forwarding methods
1366 inline Internal::Actor& GetImplementation(Dali::Actor& actor)
1368 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
1370 BaseObject& handle = actor.GetBaseObject();
1372 return static_cast<Internal::Actor&>(handle);
1375 inline const Internal::Actor& GetImplementation(const Dali::Actor& actor)
1377 DALI_ASSERT_ALWAYS(actor && "Actor handle is empty");
1379 const BaseObject& handle = actor.GetBaseObject();
1381 return static_cast<const Internal::Actor&>(handle);
1386 #endif // __DALI_INTERNAL_ACTOR_H__