Move TouchPoint to Devel API
[platform/core/uifw/dali-core.git] / dali / internal / event / events / rotation-gesture / rotation-gesture-recognizer.cpp
index b0a99a8..c4911aa 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.
@@ -22,9 +22,8 @@
 #include <cmath>
 
 // INTERNAL INCLUDES
-#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/devel-api/events/gesture-devel.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
 #include <dali/internal/event/common/scene-impl.h>
@@ -56,7 +55,7 @@ inline Vector2 GetCenterPoint( const Integration::Point& point1, const Integrati
 } // unnamed namespace
 
 RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart )
-: GestureRecognizer( DevelGesture::Rotation ),
+: GestureRecognizer( Gesture::Rotation ),
   mObserver( observer ),
   mState( Clear ),
   mTouchEvents(),
@@ -69,6 +68,7 @@ RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer, uint32
 void RotationGestureRecognizer::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 )
   {
@@ -96,7 +96,7 @@ void RotationGestureRecognizer::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;
@@ -138,7 +138,15 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
 
     case Started:
     {
-      if( pointCount != 2 )
+      if(event.points[0].GetState() == PointState::INTERRUPTED)
+      {
+        // System interruption occurred, rotation should be cancelled
+        mTouchEvents.clear();
+        SendRotation(Gesture::Cancelled, event);
+        mState = Clear;
+        mTouchEvents.clear();
+      }
+      else if( pointCount != 2 )
       {
         // Send rotation finished event
         SendRotation( Gesture::Finished, event );