Moved Gesture::State and -::Type to gesture-enumerations.h.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-processor.cpp
index a196d1a..dab221d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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,6 +22,7 @@
 #include <dali/integration-api/debug.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/actors/layer-impl.h>
+#include <dali/internal/event/common/scene-impl.h>
 #include <dali/internal/event/events/hit-test-algorithm-impl.h>
 #include <dali/internal/event/events/actor-gesture-data.h>
 #include <dali/internal/event/render-tasks/render-task-impl.h>
@@ -40,15 +41,15 @@ namespace
  */
 struct GestureHitTestCheck : public HitTestAlgorithm::HitTestInterface
 {
-  GestureHitTestCheck( Gesture::Type type )
+  GestureHitTestCheck( GestureType::Value type )
   : mType( type )
   {
   }
 
   virtual bool IsActorHittable( Actor* actor )
   {
-    return actor->IsGestureRequred( mType ) && // Does the Application or derived actor type require the gesture?
-           actor->IsHittable();                // Is actor sensitive, visible and on the scene?
+    return actor->IsGestureRequired( mType ) && // Does the Application or derived actor type require the gesture?
+           actor->IsHittable();                 // Is actor sensitive, visible and on the scene?
   }
 
   virtual bool DescendActorHierarchy( Actor* actor )
@@ -62,15 +63,17 @@ struct GestureHitTestCheck : public HitTestAlgorithm::HitTestInterface
     return layer->IsTouchConsumed();
   }
 
-  Gesture::Type mType;
+  GestureType::Value mType;
 };
 
 } // unnamed namespace
 
 
-GestureProcessor::GestureProcessor( Gesture::Type type )
-: mType( type ),
-  mCurrentGesturedActor( NULL ),
+GestureProcessor::GestureProcessor( GestureType::Value type )
+: mGestureRecognizer(),
+  mNeedsUpdate( false ),
+  mType( type ),
+  mCurrentGesturedActor( nullptr ),
   mGesturedActorDisconnected( false )
 {
 }
@@ -80,12 +83,20 @@ GestureProcessor::~GestureProcessor()
   ResetActor();
 }
 
+void GestureProcessor::ProcessTouch( Scene& scene, const Integration::TouchEvent& event )
+{
+  if( mGestureRecognizer )
+  {
+    mGestureRecognizer->SendEvent(scene, event);
+  }
+}
+
 void GestureProcessor::GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors )
 {
   while ( actor )
   {
     // We may be checking a parent so ensure the parent requires this gesture (and do not unintentionally create the gesture data for the parent)
-    if ( actor->IsGestureRequred( mType ) )
+    if ( actor->IsGestureRequired( mType ) )
     {
       // Retrieve the actor's detectors and check if they satisfy current gesture
       const GestureDetectorContainer& connectedDetectors( actor->GetGestureData().GetGestureDetectorContainer( mType ) );
@@ -147,12 +158,12 @@ void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults
               // Ensure tap is within the actor's area
               if ( actor->RaySphereTest( hitTestResults.rayOrigin, hitTestResults.rayDirection ) ) // Quick check
               {
-                Vector4 hitPointLocal;
+                Vector2 hitPointLocal;
                 float distance( 0.0f );
                 if( actor->RayActorTest( hitTestResults.rayOrigin, hitTestResults.rayDirection, hitPointLocal, distance ) )
                 {
                   // One of the parents was the gestured actor so we can emit the signal for that actor.
-                  EmitGestureSignal( actor, gestureDetectors, Vector2( hitPointLocal.x, hitPointLocal.y ) );
+                  EmitGestureSignal( actor, gestureDetectors, hitPointLocal );
                   break; // We have found AND emitted a signal on the gestured actor, break out.
                 }
               }
@@ -170,13 +181,10 @@ void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults
   }
 }
 
-bool GestureProcessor::HitTest(
-  Stage&                     stage,
-  Vector2                    screenCoordinates,
-  HitTestAlgorithm::Results& hitTestResults)
+bool GestureProcessor::HitTest( Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults )
 {
   GestureHitTestCheck hitCheck( mType );
-  HitTestAlgorithm::HitTest( stage, screenCoordinates, hitTestResults, hitCheck );
+  HitTestAlgorithm::HitTest( scene.GetSize(), scene.GetRenderTaskList(), scene.GetLayerList(), screenCoordinates, hitTestResults, hitCheck );
   return hitTestResults.renderTask && hitTestResults.actor;
 }
 
@@ -197,14 +205,14 @@ void GestureProcessor::ResetActor()
   if ( mCurrentGesturedActor )
   {
     mCurrentGesturedActor->RemoveObserver( *this );
-    mCurrentGesturedActor = NULL;
+    mCurrentGesturedActor = nullptr;
     mGesturedActorDisconnected = false;
   }
 }
 
 Actor* GestureProcessor::GetCurrentGesturedActor()
 {
-  return mGesturedActorDisconnected ? NULL : mCurrentGesturedActor;
+  return mGesturedActorDisconnected ? nullptr : mCurrentGesturedActor;
 }
 
 void GestureProcessor::SceneObjectRemoved(Object& object)
@@ -227,7 +235,7 @@ void GestureProcessor::ObjectDestroyed(Object& object)
     // Inform deriving classes.
     OnGesturedActorStageDisconnection();
 
-    mCurrentGesturedActor = NULL;
+    mCurrentGesturedActor = nullptr;
   }
 }