Fix an issue where TapGesture Events are not being received.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture / tap-gesture-impl.h
index cdbef66..58c62f4 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_TAP_GESTURE_H
 
 /*
- * Copyright (c) 2020 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/events/gesture-impl.h>
+#include <dali/public-api/events/tap-gesture.h>
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/object/base-object.h>
-#include <dali/public-api/events/tap-gesture.h>
-#include <dali/internal/event/events/gesture-impl.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 class TapGesture;
-typedef IntrusivePtr< TapGesture > TapGesturePtr;
+using TapGesturePtr = IntrusivePtr<TapGesture>;
 
 /**
  * @copydoc Dali::TapGesture
@@ -39,25 +37,24 @@ typedef IntrusivePtr< TapGesture > TapGesturePtr;
 class TapGesture final : public Gesture
 {
 public:
-
   /**
    * @brief Default constructor
    */
-  TapGesture( Gesture::State state )
-  : Gesture(Dali::Gesture::Tap, state)
+  TapGesture(GestureState state)
+  : Gesture(GestureType::TAP, state)
   {
   }
 
-  TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor
-  TapGesture(TapGesture&&) = delete; ///< Deleted move constructor
+  TapGesture(const TapGesture&) = delete;            ///< Deleted copy constructor
+  TapGesture(TapGesture&&)      = delete;            ///< Deleted move constructor
   TapGesture& operator=(const TapGesture&) = delete; ///< Deleted copy assignment operator
-  TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator
+  TapGesture& operator=(TapGesture&&) = delete;      ///< Deleted move assignment operator
 
   /**
    * @brief The number of taps in this tap gesture.
    * @param[in] numberOfTaps The number of taps to set.
    */
-  inline void SetNumberOfTaps( uint32_t numberOfTaps )
+  inline void SetNumberOfTaps(uint32_t numberOfTaps)
   {
     mNumberOfTaps = numberOfTaps;
   }
@@ -74,7 +71,7 @@ public:
    * @brief The number of touch points in this tap gesture, i.e. the number of fingers the user had on the screen to generate the tap gesture.
    * @param[in] numberOfTouches The number of touch points in this tap gesture to set.
    */
-  inline void SetNumberOfTouches( uint32_t numberOfTouches )
+  inline void SetNumberOfTouches(uint32_t numberOfTouches)
   {
     mNumberOfTouches = numberOfTouches;
   }
@@ -91,7 +88,7 @@ public:
    * @brief This is the point, in screen coordinates, where the tap occurred.
    * @param[in] screenPoint The point in screen coordinates to set.
    */
-  inline void SetScreenPoint( const Vector2& screenPoint )
+  inline void SetScreenPoint(const Vector2& screenPoint)
   {
     mScreenPoint = screenPoint;
   }
@@ -108,7 +105,7 @@ public:
    * @brief This is the point, in local actor coordinates, where the tap occurred.
    * @param[in] localPoint The point in local actor coordinates to set.
    */
-  inline void SetLocalPoint( const Vector2& localPoint )
+  inline void SetLocalPoint(const Vector2& localPoint)
   {
     mLocalPoint = localPoint;
   }
@@ -121,42 +118,59 @@ public:
     return mLocalPoint;
   }
 
-private:
+  /**
+   * @brief This is the value of which input was tapped.
+   * @param[in] source This is the value of which input was tapped to set.
+   */
+  inline void SetGestureSourceType(const GestureSourceType sourceType)
+  {
+    mGestureSourceType = sourceType;
+  }
 
   /**
+   * @copydoc Dali::TapGesture::GetSourceType()
+   */
+  inline const GestureSourceType& GetSourceType() const
+  {
+    return mGestureSourceType;
+  }
+
+private:
+  /**
    * @brief Virtual destructor
    *
    * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual ~TapGesture() = default;
+  ~TapGesture() override = default;
 
 private:
-  Vector2 mScreenPoint;
-  Vector2 mLocalPoint;
-  uint32_t mNumberOfTaps{1u};
-  uint32_t mNumberOfTouches{1u};
+  Vector2           mScreenPoint;
+  Vector2           mLocalPoint;
+  uint32_t          mNumberOfTaps{1u};
+  uint32_t          mNumberOfTouches{1u};
+  GestureSourceType mGestureSourceType{GestureSourceType::INVALID};
 };
 
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
 
-inline Internal::TapGesture& GetImplementation( Dali::TapGesture& tapGesture )
+inline Internal::TapGesture& GetImplementation(Dali::TapGesture& tapGesture)
 {
-  DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
+  DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
 
   BaseObject& object = tapGesture.GetBaseObject();
 
-  return static_cast< Internal::TapGesture& >( object );
+  return static_cast<Internal::TapGesture&>(object);
 }
 
-inline const Internal::TapGesture& GetImplementation( const Dali::TapGesture& tapGesture )
+inline const Internal::TapGesture& GetImplementation(const Dali::TapGesture& tapGesture)
 {
-  DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
+  DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
 
   const BaseObject& object = tapGesture.GetBaseObject();
 
-  return static_cast< const Internal::TapGesture& >( object );
+  return static_cast<const Internal::TapGesture&>(object);
 }
 
 } // namespace Dali