(Gestures) Each actor is now aware of what gestures it requires which is used when...
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.h
index 2b5557a..239b162 100644 (file)
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/events/gesture.h>
 #include <dali/public-api/math/viewport.h>
 #include <dali/internal/event/common/proxy-object.h>
 #include <dali/internal/event/common/stage-def.h>
 #include <dali/internal/event/actors/actor-declarations.h>
 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
 #include <dali/internal/update/nodes/node-declarations.h>
 
+#ifdef DYNAMICS_SUPPORT
+#include <dali/internal/event/dynamics/dynamics-declarations.h>
+#endif
+
 namespace Dali
 {
 
@@ -45,9 +49,11 @@ namespace Internal
 {
 
 class Actor;
+class GestureDetector;
 class RenderTask;
 class ShaderEffect;
 struct DynamicsData;
+struct GestureData;
 
 typedef IntrusivePtr<Actor>                   ActorPtr;
 typedef IntrusivePtr<ShaderEffect>            ShaderEffectPtr;
@@ -740,6 +746,8 @@ public:
    */
   const Vector4& GetCurrentWorldColor() const;
 
+#ifdef DYNAMICS_SUPPORT
+
   // Dynamics
 
   /// @copydoc Dali::Actor::DisableDynamics
@@ -821,6 +829,9 @@ private:
    * @param[in] actor The actor passed into AddDynamicsJoint()
    */
   void AttachedActorOffStage( Dali::Actor actor );
+
+#endif // DYNAMICS_SUPPORT
+
 public:
   /**
    * Converts screen coordinates into the actor's coordinate system.
@@ -932,6 +943,30 @@ public:
    */
   bool IsHittable() const;
 
+  // Gestures
+
+  /**
+   * Adds a gesture detector to the actor so that the actor is aware that it requires this type of
+   * gesture.
+   * @param[in] detector The detector being added.
+   * @note A raw pointer to the detector is stored, so the detector MUST remove itself when it is
+   * destroyed using RemoveGestureDetector()
+   */
+  void AddGestureDetector( GestureDetector& detector );
+
+  /**
+   * Removes a previously added gesture detector from the actor. If no more gesture detectors of
+   * this type are registered with this actor then the actor will no longer be hit-tested for that
+   * gesture.
+   * @param[in] detector The detector to remove.
+   */
+  void RemoveGestureDetector( GestureDetector& detector );
+
+  /**
+   * Queries whether the actor requires the gesture type.
+   * @param[in] type The gesture type.
+   */
+  bool IsGestureRequred( Gesture::Type type ) const;
 
   // Signals
 
@@ -1094,6 +1129,11 @@ public: // Default property extensions from ProxyObject
   virtual unsigned int GetDefaultPropertyCount() const;
 
   /**
+   * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
+   */
+  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
+
+  /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
    */
   virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
@@ -1114,6 +1154,11 @@ public: // Default property extensions from ProxyObject
   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
 
   /**
+   * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+   */
+  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+  /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
    */
   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
@@ -1275,64 +1320,72 @@ private:
 
 protected:
 
-  std::string mName;
-
-  static unsigned int mActorCounter;  ///< A counter to track the actor instance creation
-  unsigned int mId;  ///< A unique ID to identify the actor starting from 1, and 0 is reserved
-
-  StagePtr mStage; ///< Used to send messages to Node; valid until Core destruction
-
-  const bool mIsRoot                   : 1;   ///< Flag to identify the root actor
-  const bool mIsRenderable             : 1;   ///< Flag to identify that this is a renderable actor
-  const bool mIsLayer                  : 1;   ///< Flag to identify that this is a layer
-  bool mIsOnStage                      : 1;   ///< Flag to identify whether the actor is on-stage
-  bool mIsDynamicsRoot                 : 1;   ///< Flag to identify if this is the dynamics world root
-  bool mSensitive                      : 1;   ///< Whether the actor emits touch event signals
-  bool mLeaveRequired                  : 1;   ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
-  bool mKeyboardFocusable              : 1;   ///< Whether the actor should be focusable by keyboard navigation
-  bool mDerivedRequiresTouch           : 1;   ///< Whether the derived actor type requires touch event signals
-  bool mDerivedRequiresMouseWheelEvent : 1;   ///< Whether the derived actor type requires mouse wheel event signals
-  bool mOnStageSignalled               : 1;   ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
+  StagePtr                mStage;        ///< Used to send messages to Node; valid until Core destruction
+  Actor*                  mParent;       ///< Each actor (except the root) can have one parent
+  ActorContainer*         mChildren;     ///< Container of referenced actors
+  const SceneGraph::Node* mNode;         ///< Not owned
+  Vector3*                mParentOrigin; // NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
+  Vector3*                mAnchorPoint;  // NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
 
-  bool mInheritRotation:1; ///< Cached: Whether the parent's rotation should be inherited.
-  bool mInheritScale:1; ///< Cached: Whether the parent's scale should be inherited.
-  DrawMode::Type mDrawMode:2; ///< Cached: How the actor and its children should be drawn
-  PositionInheritanceMode mPositionInheritanceMode:2; ///< Cached: Determines how position is inherited
-  ColorMode mColorMode:2; ///< Cached: Determines whether mWorldColor is inherited
+#ifdef DYNAMICS_SUPPORT
+  DynamicsData*           mDynamicsData; ///< optional physics data
+#endif
 
-  Actor* mParent; ///< Each actor (except the root) can have one parent
+  GestureData*            mGestureData; /// Optional Gesture data. Only created when actor requires gestures
 
-  ActorContainer*              mChildren;     ///< Container of referenced actors
-  static ActorContainer        mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
-  ActorAttachmentPtr           mAttachment;   ///< Optional referenced attachment
-
-  const SceneGraph::Node* mNode; ///< Not owned
-
-  // ParentOrigin & AnchorPoint are non-animatable
-  Vector3* mParentOrigin; // NULL means ParentOrigin::DEFAULT
-  Vector3* mAnchorPoint; // NULL means AnchorPoint::DEFAULT
-
-  ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect
-
-  // Dynamics
-  DynamicsData* mDynamicsData;
+  ActorAttachmentPtr      mAttachment;   ///< Optional referenced attachment
+  ShaderEffectPtr         mShaderEffect; ///< Optional referenced shader effect
 
   // Signals
-  Dali::Actor::TouchSignalV2              mTouchedSignalV2;
-  Dali::Actor::MouseWheelEventSignalV2    mMouseWheelEventSignalV2;
-  Dali::Actor::SetSizeSignalV2            mSetSizeSignalV2;
-  Dali::Actor::OnStageSignalV2            mOnStageSignalV2;
-  Dali::Actor::OffStageSignalV2           mOffStageSignalV2;
+  Dali::Actor::TouchSignalV2             mTouchedSignalV2;
+  Dali::Actor::MouseWheelEventSignalV2   mMouseWheelEventSignalV2;
+  Dali::Actor::SetSizeSignalV2           mSetSizeSignalV2;
+  Dali::Actor::OnStageSignalV2           mOnStageSignalV2;
+  Dali::Actor::OffStageSignalV2          mOffStageSignalV2;
+
+  std::string     mName;      ///< Name of the actor
+  unsigned int    mId;        ///< A unique ID to identify the actor starting from 1, and 0 is reserved
+
+  const bool mIsRoot                               : 1; ///< Flag to identify the root actor
+  const bool mIsRenderable                         : 1; ///< Flag to identify that this is a renderable actor
+  const bool mIsLayer                              : 1; ///< Flag to identify that this is a layer
+  bool mIsOnStage                                  : 1; ///< Flag to identify whether the actor is on-stage
+  bool mIsDynamicsRoot                             : 1; ///< Flag to identify if this is the dynamics world root
+  bool mSensitive                                  : 1; ///< Whether the actor emits touch event signals
+  bool mLeaveRequired                              : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
+  bool mKeyboardFocusable                          : 1; ///< Whether the actor should be focusable by keyboard navigation
+  bool mDerivedRequiresTouch                       : 1; ///< Whether the derived actor type requires touch event signals
+  bool mDerivedRequiresMouseWheelEvent             : 1; ///< Whether the derived actor type requires mouse wheel event signals
+  bool mOnStageSignalled                           : 1; ///< Set to true before OnStageConnection signal is emitted, and false before OnStageDisconnection
+  bool mInheritRotation                            : 1; ///< Cached: Whether the parent's rotation should be inherited.
+  bool mInheritScale                               : 1; ///< Cached: Whether the parent's scale should be inherited.
+  DrawMode::Type mDrawMode                         : 2; ///< Cached: How the actor and its children should be drawn
+  PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited
+  ColorMode mColorMode                             : 2; ///< Cached: Determines whether mWorldColor is inherited
 
   // Default properties
-
   typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
 
 private:
 
-  // Default properties
+  static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const)
+  static unsigned int   mActorCounter; ///< A counter to track the actor instance creation
 
+  // Default properties
   static DefaultPropertyLookup* mDefaultPropertyLookup;
+
+};
+
+/**
+ * @brief Structure for setting up default properties and their details.
+ */
+struct PropertyDetails
+{
+  std::string name;         ///< The name of the property.
+  Property::Type type;      ///< The property type.
+  bool writable:1;          ///< Whether the property is writable
+  bool animatable:1;        ///< Whether the property is animatable.
+  bool constraintInput:1;   ///< Whether the property can be used as an input to a constraint.
 };
 
 } // namespace Internal