Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-processor.h
index 2469f33..85261e5 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_GESTURE_PROCESSOR_H__
-#define __DALI_INTERNAL_GESTURE_PROCESSOR_H__
+#ifndef DALI_INTERNAL_GESTURE_PROCESSOR_H
+#define DALI_INTERNAL_GESTURE_PROCESSOR_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/internal/event/common/object-impl.h>
 #include <dali/internal/event/events/gesture-detector-impl.h>
+#include <dali/internal/event/events/gesture-recognizer.h>
 #include <dali/internal/event/events/hit-test-algorithm-impl.h>
-#include <dali/internal/event/common/proxy-object.h>
 
 namespace Dali
 {
-
 class Actor;
 
 namespace Internal
 {
-
 /**
  * Base class for the different Gesture Processors.
  */
-class GestureProcessor : public ProxyObject::Observer
+class GestureProcessor : public Object::Observer
 {
-protected:
+public:
+  /**
+   * Process the touch event in the attached recognizer
+   * @param[in] scene Scene.
+   * @param[in] event Touch event to process
+   */
+  void ProcessTouch(Scene& scene, const Integration::TouchEvent& event);
 
+  /**
+   * Returns whether any GestureDetector requires a Core::Update
+   * @return true if update required
+   */
+  inline bool NeedsUpdate()
+  {
+    bool updateRequired = mNeedsUpdate;
+    mNeedsUpdate        = false;
+    return updateRequired;
+  }
+
+protected:
   // Construction & Destruction
 
   /**
    * Protected constructor.  Cannot create an instance of GestureProcessor
    */
-  GestureProcessor( Gesture::Type type );
+  GestureProcessor(GestureType::Value type);
 
   /**
    * Virtual protected destructor.
    */
-  virtual ~GestureProcessor();
+  ~GestureProcessor() override;
 
   // Methods to be used by deriving classes
 
@@ -61,7 +78,7 @@ protected:
    * @note Uses CheckGestureDetector() to check if a the current gesture matches the criteria the gesture detector requires.
    * @pre gestureDetectors should be empty.
    */
-  void GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors );
+  void GetGesturedActor(Actor*& actor, GestureDetectorContainer& gestureDetectors);
 
   /**
    * Calls the emission method in the deriving class for matching gesture-detectors with the hit-actor (or one of its parents).
@@ -72,22 +89,22 @@ protected:
    *       and EmitGestureSignal() to emit the signal.
    * @pre Hit Testing should already be done.
    */
-  void ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults );
+  void ProcessAndEmit(HitTestAlgorithm::Results& hitTestResults);
 
   /**
    * Hit test the screen coordinates, and place the results in hitTestResults.
-   * @param[in] stage Stage.
+   * @param[in] scene Scene.
    * @param[in] screenCoordinates The screen coordinates to test.
    * @param[out] hitTestResults Structure to write results into.
    * @return false if the system overlay was hit or no actor was hit.
    */
-  virtual bool HitTest(Stage& stage, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults);
+  virtual bool HitTest(Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults);
 
   /**
    * Sets the mCurrentGesturedActor and connects to the required signals.
    * @actor  actor  The actor so set.
    */
-  void SetActor( Actor* actor );
+  void SetActor(Actor* actor);
 
   /**
    * Resets the set actor and disconnects any connected signals.
@@ -102,7 +119,6 @@ protected:
   Actor* GetCurrentGesturedActor();
 
 private:
-
   // For derived classes to override
 
   /**
@@ -119,7 +135,7 @@ private:
    *
    * @return true, if the detector meets the parameters, false otherwise.
    */
-  virtual bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) = 0;
+  virtual bool CheckGestureDetector(GestureDetector* detector, Actor* actor) = 0;
 
   /**
    * Called by the ProcessAndEmit() method when the gesture meets all applicable criteria and
@@ -130,46 +146,51 @@ private:
    * @param[in]  gestureDetectors  The detectors that should emit the signal.
    * @param[in]  actorCoordinates  The local actor coordinates where the gesture took place.
    */
-  virtual void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
+  virtual void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) = 0;
 
   // Undefined
 
-  GestureProcessor( const GestureProcessor& );
-  GestureProcessor& operator=( const GestureProcessor& );
+  GestureProcessor(const GestureProcessor&);
+  GestureProcessor& operator=(const GestureProcessor&);
 
   // SceneObject overrides
 
   /**
    * This will never get called as we do not observe objects that have not been added to the scene.
-   * @param[in] proxy The proxy object.
-   * @see ProxyObject::Observer::SceneObjectAdded()
+   * @param[in] object The object object.
+   * @see Object::Observer::SceneObjectAdded()
    */
-  virtual void SceneObjectAdded(ProxyObject& proxy) { }
+  void SceneObjectAdded(Object& object) override
+  {
+  }
 
   /**
    * This will be called when the actor is removed from the stage, we should clear and stop
    * observing it.
-   * @param[in] proxy The proxy object.
-   * @see ProxyObject::Observer::SceneObjectRemoved()
+   * @param[in] object The object object.
+   * @see Object::Observer::SceneObjectRemoved()
    */
-  virtual void SceneObjectRemoved(ProxyObject& proxy);
+  void SceneObjectRemoved(Object& object) override;
 
   /**
    * This will be called when the actor is destroyed. We should clear the actor.
    * No need to stop observing as the object is being destroyed anyway.
-   * @see ProxyObject::Observer::ProxyDestroyed()
+   * @see Object::Observer::ObjectDestroyed()
    */
-  virtual void ProxyDestroyed(ProxyObject& proxy);
+  void ObjectDestroyed(Object& object) override;
 
-private: // Data
+protected:                                 //Data
+  GestureRecognizerPtr mGestureRecognizer; ///< The gesture recognizer
+  bool                 mNeedsUpdate;       ///< Indicates if any GestureDetector requires a Core::Update
 
-  Gesture::Type mType;                 ///< Type of GestureProcessor
-  Actor* mCurrentGesturedActor;        ///< The current actor that has been gestured.
-  bool   mGesturedActorDisconnected:1; ///< Indicates whether the gestured actor has been disconnected from the scene
+private:                                             // Data
+  GestureType::Value mType;                          ///< Type of GestureProcessor
+  Actor*             mCurrentGesturedActor;          ///< The current actor that has been gestured.
+  bool               mGesturedActorDisconnected : 1; ///< Indicates whether the gestured actor has been disconnected from the scene
 };
 
 } // namespace Internal
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_GESTURE_PROCESSOR_H__
+#endif // DALI_INTERNAL_GESTURE_PROCESSOR_H