[Tizen] Pan now possible without a touch down
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pan-gesture / pan-gesture-processor.cpp
index 05589ef..51bef8d 100644 (file)
@@ -167,7 +167,6 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent
         SetActor( &GetImplementation( hitTestResults.actor ) );
         mPossiblePanPosition = panEvent.currentPosition;
       }
-
       break;
     }
 
@@ -176,29 +175,33 @@ void PanGestureProcessor::Process( Scene& scene, const PanGestureEvent& panEvent
       // Requires a core update
       mNeedsUpdate = true;
 
-      if ( GetCurrentGesturedActor() )
-      {
-        // The pan gesture should only be sent to the gesture detector which first received it so that
-        // it can be told when the gesture ends as well.
-
-        HitTestAlgorithm::Results hitTestResults;
-        HitTest( scene, mPossiblePanPosition, hitTestResults ); // Hit test original possible position...
+      // The pan gesture should only be sent to the gesture detector which first received it so that
+      // it can be told when the gesture ends as well.
 
-        if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
-        {
-          // Record the current render-task for Screen->Actor coordinate conversions
-          mCurrentRenderTask = hitTestResults.renderTask;
+      HitTestAlgorithm::Results hitTestResults;
+      HitTest( scene, panEvent.previousPosition, hitTestResults ); // Hit Test previous position
 
-          // Set mCurrentPanEvent to use inside overridden methods called in ProcessAndEmit()
-          mCurrentPanEvent = &panEvent;
-          ProcessAndEmit( hitTestResults );
-          mCurrentPanEvent = nullptr;
-        }
-        else
+      if ( hitTestResults.actor )
+      {
+        // If the current hit actor is different from the one we touched down on then set accordingly & update initial pan position
+        if( &GetImplementation( hitTestResults.actor ) != GetCurrentGesturedActor() )
         {
-          ResetActor();
-          mCurrentPanEmitters.clear();
+          mPossiblePanPosition = panEvent.previousPosition;
+          SetActor( &GetImplementation( hitTestResults.actor ) );
         }
+
+        // Record the current render-task for Screen->Actor coordinate conversions
+        mCurrentRenderTask = hitTestResults.renderTask;
+
+        // Set mCurrentPanEvent to use inside overridden methods called in ProcessAndEmit()
+        mCurrentPanEvent = &panEvent;
+        ProcessAndEmit( hitTestResults );
+        mCurrentPanEvent = nullptr;
+      }
+      else
+      {
+        ResetActor();
+        mCurrentPanEmitters.clear();
       }
       break;
     }