Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-detector-impl.h
index 3fc429c..dd312e6 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_GESTURE_DETECTOR_H__
+#ifndef DALI_INTERNAL_GESTURE_DETECTOR_H
+#define DALI_INTERNAL_GESTURE_DETECTOR_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/internal/event/actors/actor-impl.h>
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/gesture-detector.h>
 #include <dali/public-api/events/gesture.h>
 #include <dali/public-api/signals/slot-delegate.h>
-#include <dali/public-api/events/gesture-detector.h>
-#include <dali/internal/event/actors/actor-impl.h>
 
 namespace Dali
 {
-
 namespace Integration
 {
 struct GestureEvent;
@@ -36,21 +35,20 @@ struct GestureEvent;
 
 namespace Internal
 {
-
 class GestureDetector;
 class GestureEventProcessor;
 
-typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
-typedef std::vector<GestureDetector*> GestureDetectorContainer;
-typedef std::vector<Actor*> GestureDetectorActorContainer;
+using GestureDetectorPtr            = IntrusivePtr<GestureDetector>;
+using GestureDetectorContainer      = std::vector<GestureDetector*>;
+using GestureDetectorActorContainer = std::vector<Actor*>;
 
 /**
  * This is a type trait that should be used by deriving gesture detectors for their container type.
  */
-template< typename Detector >
+template<typename Detector>
 struct DerivedGestureDetectorContainer
 {
-  typedef std::vector<Detector*> type;
+  using type = std::vector<Detector*>;
 };
 
 /**
@@ -59,7 +57,6 @@ struct DerivedGestureDetectorContainer
 class GestureDetector : public Object, public Object::Observer
 {
 public:
-
   /**
    * @copydoc Dali::GestureDetector::Attach()
    */
@@ -76,9 +73,14 @@ public:
   void DetachAll();
 
   /**
-   * @copydoc Dali::GestureDetector::GetAttachedActors() const
+   * @copydoc Dali::GestureDetector::GetAttachedActorCount() const
+   */
+  size_t GetAttachedActorCount() const;
+
+  /**
+   * @copydoc Dali::GestureDetector::GetAttachedActor() const
    */
-  std::vector<Dali::Actor> GetAttachedActors() const;
+  Dali::Actor GetAttachedActor(size_t index) const;
 
   /**
    * Returns a const reference to the container of attached actor pointers.
@@ -93,52 +95,54 @@ public:
    * Retrieves the type of GestureDetector
    * @return The GestureDetector Type
    */
-  Gesture::Type GetType() const
+  GestureType::Value GetType() const
   {
     return mType;
   }
 
   /**
-   * Checks if the specified actor is still attached.
+   * Checks if the specified actor is still attached or pending attachment.
    * @param[in]  actor  The actor to check.
-   * @return true, if the actor is attached, false otherwise.
+   * @return true, if the actor is attached or pending, false otherwise.
    */
   bool IsAttached(Actor& actor) const;
 
 protected: // Creation & Destruction
-
   /**
    * Construct a new GestureDetector.
+   * @param type the type of gesture
+   * @param pointer to the scene object, nullptr if none
+   * by default GestureDetectors don't have our own scene object
    */
-  GestureDetector(Gesture::Type mType);
+  GestureDetector(GestureType::Value type, const SceneGraph::PropertyOwner* sceneObject = nullptr);
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual ~GestureDetector();
+  ~GestureDetector() override;
 
 private:
-
-  // Undefined
-  GestureDetector(const GestureDetector&);
-
   // Undefined
-  GestureDetector& operator=(const GestureDetector& rhs);
+  GestureDetector()                       = delete;
+  GestureDetector(const GestureDetector&) = delete;
+  GestureDetector& operator=(const GestureDetector& rhs) = delete;
 
   /**
    * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
    */
-  virtual void SceneObjectAdded(Object& object) {}
+  void SceneObjectAdded(Object& object) override;
 
   /**
    * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
    */
-  virtual void SceneObjectRemoved(Object& object) {}
+  void SceneObjectRemoved(Object& object) override
+  {
+  }
 
   /**
    * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed()
    */
-  virtual void ObjectDestroyed(Object& object);
+  void ObjectDestroyed(Object& object) override;
 
   /**
    * For use in derived classes, called after an actor is attached.
@@ -160,77 +164,10 @@ private:
    */
   virtual void OnActorDestroyed(Object& object) = 0;
 
-private: // Default property extensions from Object
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
-   */
-  virtual unsigned int GetDefaultPropertyCount() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
-   */
-  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
-   */
-  virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
-   */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
-   */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
-   */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
-   */
-  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
-   */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::SetDefaultProperty()
-   */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultProperty()
-   */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObject()
-   */
-  virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
-   */
-  virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
-   */
-  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
 protected:
-
-  Gesture::Type                 mType;                  ///< The gesture detector will detect this type of gesture.
+  GestureType::Value            mType;                  ///< The gesture detector will detect this type of gesture.
   GestureDetectorActorContainer mAttachedActors;        ///< Object::Observer is used to provide weak-pointer behaviour
+  GestureDetectorActorContainer mPendingAttachActors;   ///< Object::Observer is used to provide weak-pointer behaviour
   GestureEventProcessor&        mGestureEventProcessor; ///< A reference to the gesture event processor.
 };
 
@@ -240,7 +177,7 @@ protected:
 
 inline Internal::GestureDetector& GetImplementation(Dali::GestureDetector& detector)
 {
-  DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
+  DALI_ASSERT_ALWAYS(detector && "GestureDetector handle is empty");
 
   BaseObject& handle = detector.GetBaseObject();
 
@@ -249,7 +186,7 @@ inline Internal::GestureDetector& GetImplementation(Dali::GestureDetector& detec
 
 inline const Internal::GestureDetector& GetImplementation(const Dali::GestureDetector& detector)
 {
-  DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
+  DALI_ASSERT_ALWAYS(detector && "GestureDetector handle is empty");
 
   const BaseObject& handle = detector.GetBaseObject();
 
@@ -258,4 +195,4 @@ inline const Internal::GestureDetector& GetImplementation(const Dali::GestureDet
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_GESTURE_DETECTOR_H__
+#endif // DALI_INTERNAL_GESTURE_DETECTOR_H