change drag&drop StartedSignal emit 23/194623/4
authorjunqing.ma <junqing.ma@samsung.com>
Thu, 6 Dec 2018 10:22:03 +0000 (18:22 +0800)
committerjunqing.ma <junqing.ma@samsung.com>
Thu, 6 Dec 2018 11:58:54 +0000 (19:58 +0800)
Change-Id: I104449ac80fe7b1b5d4a2d51087ea7d9024f80c3

automated-tests/src/dali-toolkit/utc-Dali-DragAndDropDetector.cpp
dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp

index 8e574b4..3fbbfcd 100755 (executable)
@@ -305,12 +305,12 @@ int UtcDaliDragAndDropDetectorStartSignal(void)
   DragSignalFunctor functor(data);
   detector.StartedSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.StartedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control, data.control, TEST_LOCATION);
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control, data.control, TEST_LOCATION);
-  DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(12.0f, 12.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION);
   data.Reset();
 
   END_TEST;
   data.Reset();
 
   END_TEST;
@@ -345,11 +345,10 @@ int UtcDaliDragAndDropDetectorEnteredSignal(void)
   DragSignalFunctor functor(data);
   detector.EnteredSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.EnteredSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
+  Vector2 screenCoordinates(10.0f, 110.0f);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
@@ -390,11 +389,10 @@ int UtcDaliDragAndDropDetectorMovedSignal(void)
   DragSignalFunctor functor(data);
   detector.MovedSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.MovedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
+  Vector2 screenCoordinates(10.0f, 110.0f);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
@@ -442,11 +440,10 @@ int UtcDaliDragAndDropDetectorExitedSignal(void)
   DragSignalFunctor functor(data);
   detector.ExitedSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.ExitedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
+  Vector2 screenCoordinates(10.0f, 110.0f);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 20.0f;
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 20.0f;
@@ -489,11 +486,10 @@ int UtcDaliDragAndDropDetectorDroppedSignal(void)
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
+  Vector2 screenCoordinates(10.0f, 110.0f);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
@@ -585,11 +581,10 @@ int UtcDaliDragAndDropDetectorGetContent(void)
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
+  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
 
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
+  Vector2 screenCoordinates(10.0f, 110.0f);
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
index c26e4ae..dcb52fa 100755 (executable)
@@ -126,26 +126,6 @@ void DragAndDropDetector::OnPan(Dali::Actor actor, const PanGesture& gesture)
   if(gesture.state == Gesture::Started)
   {
     mDragLocalPosition = gesture.position;
   if(gesture.state == Gesture::Started)
   {
     mDragLocalPosition = gesture.position;
-  }
-  if(gesture.state == Gesture::Continuing)
-  {
-      Vector2 screenPosition = gesture.screenPosition;
-      control.GetParent().ScreenToLocal(mLocalPosition.x, mLocalPosition.y, screenPosition.x, screenPosition.y);
-      mShadowControl.SetPosition(mLocalPosition.x - mDragLocalPosition.x, mLocalPosition.y - mDragLocalPosition.y);
-  }
-  if(gesture.state == Gesture::Finished)
-  {
-    mDragControl.GetParent().Remove(mShadowControl);
-    EmitEndedSignal(control);
-  }
-}
-
-bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data)
-{
-  Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
-  PointState::Type type = data.GetState(0);
-  if(type == PointState::DOWN)
-  {
     mPointDown = true;
     mDragControl = control;
     mFirstEnter.clear();
     mPointDown = true;
     mDragControl = control;
     mFirstEnter.clear();
@@ -164,9 +144,26 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data)
     mShadowControl.SetParentOrigin(control.GetCurrentParentOrigin());
     mShadowControl.SetAnchorPoint(control.GetCurrentAnchorPoint());
     control.GetParent().Add(mShadowControl);
     mShadowControl.SetParentOrigin(control.GetCurrentParentOrigin());
     mShadowControl.SetAnchorPoint(control.GetCurrentAnchorPoint());
     control.GetParent().Add(mShadowControl);
-    SetPosition(data.GetScreenPosition(0));
+    SetPosition(gesture.screenPosition);
     EmitStartedSignal(control);
   }
     EmitStartedSignal(control);
   }
+  if(gesture.state == Gesture::Continuing)
+  {
+      Vector2 screenPosition = gesture.screenPosition;
+      control.GetParent().ScreenToLocal(mLocalPosition.x, mLocalPosition.y, screenPosition.x, screenPosition.y);
+      mShadowControl.SetPosition(mLocalPosition.x - mDragLocalPosition.x, mLocalPosition.y - mDragLocalPosition.y);
+  }
+  if(gesture.state == Gesture::Finished)
+  {
+    mDragControl.GetParent().Remove(mShadowControl);
+    EmitEndedSignal(control);
+  }
+}
+
+bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data)
+{
+  Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
+  PointState::Type type = data.GetState(0);
 
   if(type == PointState::MOTION)
   {
 
   if(type == PointState::MOTION)
   {