Move TouchPoint to Devel API
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture / pinch-gesture-recognizer.cpp
index 13e171e..a552ca7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -21,7 +21,7 @@
 // EXTERNAL INCLUDES
 #include <cmath>
 
-#include <dali/public-api/events/touch-point.h>
+#include <dali/devel-api/events/touch-point.h>
 #include <dali/public-api/math/vector2.h>
 
 #include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
@@ -90,6 +90,7 @@ void PinchGestureRecognizer::SetMinimumPinchDistance(float value)
 void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
 {
   int pointCount = event.GetPointCount();
+  GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
 
   switch (mState)
   {
@@ -117,7 +118,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
         const Integration::Point& currentPoint1 = event.points[0];
         const Integration::Point& currentPoint2 = event.points[1];
 
-        if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP)
+        if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED)
         {
           // One of our touch points has an Up event so change our state back to Clear.
           mState = Clear;
@@ -170,7 +171,15 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
 
     case Started:
     {
-      if (pointCount != 2)
+      if(event.points[0].GetState() == PointState::INTERRUPTED)
+      {
+        // System interruption occurred, pinch should be cancelled
+        mTouchEvents.clear();
+        SendPinch(Gesture::Cancelled, event);
+        mState = Clear;
+        mTouchEvents.clear();
+      }
+      else if (pointCount != 2)
       {
         // Send pinch finished event
         SendPinch(Gesture::Finished, event);