Add methods to set variables for Pinch and Rotation gesture processing 44/222944/3
authorJiyun Yang <ji.yang@samsung.com>
Tue, 21 Jan 2020 11:00:47 +0000 (20:00 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Tue, 4 Feb 2020 07:30:07 +0000 (16:30 +0900)
- Set the minimum touch events required before a pinch can be started
- Set the minimum touch events required after a pinch started
- Set the minimum touch events required before a rotation can be started
- Set the minimum touch events required after a rotation started

Change-Id: Ib9e268d2508e9b529bf219ac6662b9d82da52092
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
15 files changed:
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/utc-Dali-PinchGestureRecognizer.cpp
automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp [new file with mode: 0644]
dali/integration-api/input-options.cpp
dali/integration-api/input-options.h
dali/internal/event/events/gesture-event-processor.cpp
dali/internal/event/events/gesture-event-processor.h
dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp
dali/internal/event/events/pinch-gesture/pinch-gesture-processor.h
dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp
dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h
dali/internal/event/events/rotation-gesture/rotation-gesture-processor.cpp
dali/internal/event/events/rotation-gesture/rotation-gesture-processor.h
dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp
dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h

index c501853..169f2d1 100644 (file)
@@ -81,6 +81,7 @@ SET(TC_SOURCES
         utc-Dali-ResourceImage.cpp
         utc-Dali-RotationGesture.cpp
         utc-Dali-RotationGestureDetector.cpp
+        utc-Dali-RotationGestureRecognizer.cpp
         utc-Dali-Sampler.cpp
         utc-Dali-Scene.cpp
         utc-Dali-Scripting.cpp
index 3a20b67..08ae245 100644 (file)
@@ -650,3 +650,94 @@ int UtcDaliPinchGestureRecognizerLongDistance04(void)
 
   END_TEST;
 }
+
+int UtcDaliPinchGestureRecognizerMinimumTouchEvents(void)
+{
+  TestApplication application;
+
+  PinchGestureDetector detector = PinchGestureDetector::New();
+
+  Actor actor = Actor::New();
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( actor );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  detector.Attach( actor );
+
+  SignalData data;
+  GestureReceivedFunctor functor( data );
+  detector.DetectedSignal().Connect( &application, functor );
+
+  // Case 1
+  // 2 touch events make a gesture begin
+  Integration::SetPinchGestureMinimumTouchEvents( 2 );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.state, TEST_LOCATION );
+  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+  data.Reset();
+
+  // Case 2
+  // 4 touch events make a gesture begin
+  Integration::SetPinchGestureMinimumTouchEvents( 4 );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  // Check the gesture is not detected unlike previous case
+  DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPinchGestureRecognizerMinimumTouchEventsAfterStart(void)
+{
+  TestApplication application;
+
+  PinchGestureDetector detector = PinchGestureDetector::New();
+
+  Actor actor = Actor::New();
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( actor );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  detector.Attach( actor );
+
+  SignalData data;
+  GestureReceivedFunctor functor( data );
+  detector.DetectedSignal().Connect( &application, functor );
+
+  // Case 1
+  // > 2 touch events make a gesture begin
+  // > 4 touch events generate gestures after begin
+  Integration::SetPinchGestureMinimumTouchEvents(2);
+  Integration::SetPinchGestureMinimumTouchEventsAfterStart(6);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 180 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) );
+  // > Test : not enough touch events to make the gesture state "Continuing"
+  DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) );
+  // > Test : 6 touch events after start make the gesture state "Continuing"
+  DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
+
+  END_TEST;
+}
diff --git a/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-RotationGestureRecognizer.cpp
new file mode 100644 (file)
index 0000000..044fd47
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/input-options.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/devel-api/events/rotation-gesture.h>
+#include <dali/devel-api/events/rotation-gesture-detector.h>
+#include <dali-test-suite-utils.h>
+#include <test-touch-utils.h>
+
+using namespace Dali;
+
+void utc_dali_rotation_gesture_recognizer_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_rotation_gesture_recognizer_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace
+{
+
+struct SignalData
+{
+  SignalData()
+  : functorCalled(false),
+    voidFunctorCalled(false),
+    receivedGesture(Gesture::Started)
+  {}
+
+  void Reset()
+  {
+    functorCalled = false;
+    voidFunctorCalled = false;
+
+    receivedGesture.state = Gesture::Started;
+    receivedGesture.rotation = 0.0f;
+    receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
+    receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
+
+    rotatedActor.Reset();
+  }
+
+  bool functorCalled;
+  bool voidFunctorCalled;
+  RotationGesture receivedGesture;
+  Actor rotatedActor;
+};
+
+// Functor that sets the data when called
+struct GestureReceivedFunctor
+{
+  GestureReceivedFunctor(SignalData& data) : signalData(data) { }
+
+  void operator()(Actor actor, const RotationGesture& rotation)
+  {
+    signalData.functorCalled = true;
+    signalData.receivedGesture = rotation;
+    signalData.rotatedActor = actor;
+  }
+
+  void operator()()
+  {
+    signalData.voidFunctorCalled = true;
+  }
+
+  SignalData& signalData;
+};
+
+Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time )
+{
+  Integration::TouchEvent touchEvent;
+  Integration::Point point;
+  point.SetState( stateA );
+  point.SetScreenPosition( screenPositionA );
+  point.SetDeviceClass( Device::Class::TOUCH );
+  point.SetDeviceSubclass( Device::Subclass::NONE );
+  touchEvent.points.push_back( point );
+  point.SetScreenPosition( screenPositionB );
+  point.SetState( stateB);
+  touchEvent.points.push_back( point );
+  touchEvent.time = time;
+  return touchEvent;
+}
+
+
+} // anon namespace
+
+///////////////////////////////////////////////////////////////////////////////
+
+int UtcDaliRotationGestureRecognizerMinimumTouchEvents(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render();
+
+  SignalData data;
+  GestureReceivedFunctor functor( data );
+
+  RotationGestureDetector detector = RotationGestureDetector::New();
+  detector.Attach( actor );
+  detector.DetectedSignal().Connect( &application, functor );
+
+  // Case 1
+  // 2 touch events make a gesture begin
+  Integration::SetRotationGestureMinimumTouchEvents( 2 );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  DALI_TEST_EQUALS( Gesture::Started, data.receivedGesture.state, TEST_LOCATION );
+  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+  data.Reset();
+
+  // Case 2
+  // 4 touch events make a gesture begin
+  Integration::SetRotationGestureMinimumTouchEvents( 4 );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  // Check the gesture is not detected unlike previous case
+  DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRotationGestureRecognizerMinimumTouchEventsAfterStart(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render();
+
+  SignalData data;
+  GestureReceivedFunctor functor( data );
+
+  RotationGestureDetector detector = RotationGestureDetector::New();
+  detector.Attach( actor );
+  detector.DetectedSignal().Connect( &application, functor );
+
+  // Case 1
+  // > 2 touch events make a gesture begin
+  // > 4 touch events generate gestures after begin
+  Integration::SetRotationGestureMinimumTouchEvents(2);
+  Integration::SetRotationGestureMinimumTouchEventsAfterStart(6);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 90.0f, 90.0f ), 160 ) );
+
+  DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 170 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 180 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 190 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 200 ) );
+  // > Test : not enough touch events to make the gesture state "Continuing"
+  DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
+
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 210 ) );
+  application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 20.0f ), PointState::MOTION, Vector2( 20.0f, 90.0f ), 220 ) );
+  // > Test : 6 touch events after start make the gesture state "Continuing"
+  DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
+
+  END_TEST;
+}
index b432b9e..1a8bc5f 100644 (file)
@@ -120,6 +120,30 @@ void SetPinchGestureMinimumDistance( float value )
   eventProcessor.SetPinchGestureMinimumDistance( value );
 }
 
+void SetPinchGestureMinimumTouchEvents( uint32_t value )
+{
+  GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+  eventProcessor.SetPinchGestureMinimumTouchEvents( value );
+}
+
+void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value )
+{
+  GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+  eventProcessor.SetPinchGestureMinimumTouchEventsAfterStart( value );
+}
+
+void SetRotationGestureMinimumTouchEvents( uint32_t value )
+{
+  GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+  eventProcessor.SetRotationGestureMinimumTouchEvents( value );
+}
+
+void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value )
+{
+  GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+  eventProcessor.SetRotationGestureMinimumTouchEventsAfterStart( value );
+}
+
 void SetLongPressMinimumHoldingTime( unsigned int value )
 {
   GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
index f4df355..c64ee4b 100644 (file)
@@ -22,6 +22,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/type-info.h>
 
 namespace Dali
 {
@@ -165,6 +166,34 @@ DALI_CORE_API void SetPanGestureMinimumPanEvents( int value );
 DALI_CORE_API void SetPinchGestureMinimumDistance( float value );
 
 /**
+ * @brief Sets the minimum touch events required before a pinch can be started
+ *
+ * @param[in] value The number of touch events
+ */
+DALI_CORE_API void SetPinchGestureMinimumTouchEvents( uint32_t value );
+
+/**
+ * @brief Sets the minimum touch events required after a pinch started
+ *
+ * @param[in] value The number of touch events
+ */
+DALI_CORE_API void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value );
+
+/**
+ * @brief Sets the minimum touch events required before a rotation can be started
+ *
+ * @param[in] value The number of touch events
+ */
+DALI_CORE_API void SetRotationGestureMinimumTouchEvents( uint32_t value );
+
+/**
+ * @brief Sets the minimum touch events required after a rotation started
+ *
+ * @param[in] value The number of touch events
+ */
+DALI_CORE_API void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value );
+
+/**
  * @brief Sets the minimum holding time required to be recognized as a long press gesture
  *
  * @param[in] value The time value in milliseconds
index 04863ff..63617b6 100644 (file)
@@ -321,6 +321,26 @@ void GestureEventProcessor::SetPinchGestureMinimumDistance( float value)
   mPinchGestureProcessor.SetMinimumPinchDistance( value );
 }
 
+void GestureEventProcessor::SetPinchGestureMinimumTouchEvents( uint32_t value )
+{
+  mPinchGestureProcessor.SetMinimumTouchEvents( value );
+}
+
+void GestureEventProcessor::SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value )
+{
+  mPinchGestureProcessor.SetMinimumTouchEventsAfterStart( value );
+}
+
+void GestureEventProcessor::SetRotationGestureMinimumTouchEvents( uint32_t value )
+{
+  mRotationGestureProcessor.SetMinimumTouchEvents( value );
+}
+
+void GestureEventProcessor::SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value )
+{
+  mRotationGestureProcessor.SetMinimumTouchEventsAfterStart( value );
+}
+
 void GestureEventProcessor::SetLongPressMinimumHoldingTime( uint32_t value )
 {
   mLongPressGestureProcessor.SetMinimumHoldingTime( value );
index 9ae5d6f..58083f3 100644 (file)
@@ -253,6 +253,34 @@ public: // Called by Core
   void SetPinchGestureMinimumDistance( float value);
 
   /**
+   * @brief Sets the minimum touch events required before a pinch can be started
+   *
+   * @param[in] value The number of touch events
+   */
+  void SetPinchGestureMinimumTouchEvents( uint32_t value );
+
+  /**
+   * @brief Sets the minimum touch events required after a pinch started
+   *
+   * @param[in] value The number of touch events
+   */
+  void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value );
+
+  /**
+   * @brief Sets the minimum touch events required before a rotation can be started
+   *
+   * @param[in] value The number of touch events
+   */
+  void SetRotationGestureMinimumTouchEvents( uint32_t value );
+
+  /**
+   * @brief Sets the minimum touch events required after a rotation started
+   *
+   * @param[in] value The number of touch events
+   */
+  void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value );
+
+  /**
    * @brief Sets the minimum holding time required to be recognized as a long press gesture
    *
    * @param[in] value The time value in milliseconds
index c373fae..6d2f6a1 100644 (file)
@@ -40,6 +40,8 @@ namespace Internal
 
 namespace
 {
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4u;
 
 /**
  * Creates a PinchGesture and asks the specified detector to emit its detected signal.
@@ -106,7 +108,9 @@ PinchGestureProcessor::PinchGestureProcessor()
   mPinchGestureDetectors(),
   mCurrentPinchEmitters(),
   mCurrentPinchEvent(NULL),
-  mMinimumPinchDistance(-1.0f)
+  mMinimumPinchDistance(-1.0f),
+  mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
+  mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
 {
 }
 
@@ -128,6 +132,40 @@ void PinchGestureProcessor::SetMinimumPinchDistance( float value )
   }
 }
 
+void PinchGestureProcessor::SetMinimumTouchEvents( uint32_t value )
+{
+  if( value > 1u && mMinimumTouchEvents != value )
+  {
+    mMinimumTouchEvents = value;
+
+    if( mGestureRecognizer )
+    {
+      PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>( mGestureRecognizer.Get() );
+      if( pinchRecognizer )
+      {
+        pinchRecognizer->SetMinimumTouchEvents( value );
+      }
+    }
+  }
+}
+
+void PinchGestureProcessor::SetMinimumTouchEventsAfterStart( uint32_t value )
+{
+  if( value > 1u && mMinimumTouchEventsAfterStart != value )
+  {
+    mMinimumTouchEventsAfterStart = value;
+
+    if( mGestureRecognizer )
+    {
+      PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>( mGestureRecognizer.Get() );
+      if( pinchRecognizer )
+      {
+        pinchRecognizer->SetMinimumTouchEventsAfterStart( value );
+      }
+    }
+  }
+}
+
 void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinchEvent )
 {
   switch ( pinchEvent.state )
@@ -222,7 +260,7 @@ void PinchGestureProcessor::AddGestureDetector( PinchGestureDetector* gestureDet
   if (createRecognizer)
   {
     Size size = scene.GetSize();
-    mGestureRecognizer = new PinchGestureRecognizer( *this, Vector2(size.width, size.height), scene.GetDpi(), mMinimumPinchDistance );
+    mGestureRecognizer = new PinchGestureRecognizer( *this, Vector2(size.width, size.height), scene.GetDpi(), mMinimumPinchDistance, mMinimumTouchEventsAfterStart, mMinimumTouchEventsAfterStart );
   }
 }
 
index 839175c..7f37f4a 100644 (file)
@@ -67,6 +67,18 @@ public: // To be called by GestureEventProcessor
   void SetMinimumPinchDistance( float value );
 
   /**
+   * Sets the minimum touch events required before a pinch can be started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEvents( uint32_t value );
+
+  /**
+   * Sets the minimum touch events required after a pinch started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEventsAfterStart( uint32_t value );
+
+  /**
    * This method is called whenever a pinch gesture event occurs.
    * @param[in] scene The scene the pinch gesture event occurs in.
    * @param[in] pinchEvent The event that has occurred.
@@ -129,6 +141,8 @@ private:
   const PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
 
   float mMinimumPinchDistance;
+  uint32_t mMinimumTouchEvents;
+  uint32_t mMinimumTouchEventsAfterStart;
 };
 
 } // namespace Internal
index 23b24d8..13e171e 100644 (file)
@@ -39,9 +39,6 @@ namespace Internal
 
 namespace
 {
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
-
 const float MINIMUM_DISTANCE_IN_MILLIINCH = 45.0f; // This value is used for measuring minimum pinch distance in pixel.
 const float MINIMUM_DISTANCE_IN_PIXEL = 10.0f; // This value is for devices that do not provide a valid dpi value. (assumes 220dpi)
 
@@ -68,13 +65,15 @@ inline float GetDefaultMinimumPinchDistance( const Vector2& dpi )
 
 } // unnamed namespace
 
-PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance )
+PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart )
 : GestureRecognizer( screenSize, Gesture::Pinch ),
   mObserver( observer ),
   mState( Clear ),
   mTouchEvents(),
   mDefaultMinimumDistanceDelta( GetDefaultMinimumPinchDistance( screenDpi ) ),
-  mStartingDistance( 0.0f )
+  mStartingDistance( 0.0f ),
+  mMinimumTouchEvents( minimumTouchEvents ),
+  mMinimumTouchEventsAfterStart( minimumTouchEventsAfterStart )
 {
   SetMinimumPinchDistance( minimumPinchDistance );
 }
@@ -129,7 +128,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
           mTouchEvents.push_back(event);
 
           // We can only determine a pinch after a certain number of touch points have been collected.
-          if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED)
+          if( mTouchEvents.size() >= mMinimumTouchEvents )
           {
             const Integration::Point& firstPoint1 = mTouchEvents[0].points[0];
             const Integration::Point& firstPoint2 = mTouchEvents[0].points[1];
@@ -142,7 +141,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
             if (fabsf(distanceChanged) > mMinimumDistanceDelta)
             {
               // Remove the first few events from the vector otherwise values are exaggerated
-              mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START);
+              mTouchEvents.erase( mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents );
 
               if ( !mTouchEvents.empty() )
               {
@@ -197,7 +196,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
         {
           mTouchEvents.push_back(event);
 
-          if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
+          if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
           {
             // Send pinch continuing
             SendPinch(Gesture::Continuing, event);
@@ -267,6 +266,16 @@ void PinchGestureRecognizer::SendPinch(Gesture::State state, const Integration::
   }
 }
 
+void PinchGestureRecognizer::SetMinimumTouchEvents( uint32_t value )
+{
+  mMinimumTouchEvents = value;
+}
+
+void PinchGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value )
+{
+  mMinimumTouchEventsAfterStart = value;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index 509b6ef..7bc429d 100644 (file)
@@ -50,8 +50,10 @@ public:
    * @param[in] screenSize The size of the screen.
    * @param[in] screenDpi The dpi value of the screen
    * @param[in] minimumPinchDistance in pixels
+   * @param[in] minimumTouchEvents The number of touch events required
+   * @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
    */
-  PinchGestureRecognizer(Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance);
+  PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
 
   /**
    * Virtual destructor.
@@ -63,6 +65,18 @@ public:
   void SetMinimumPinchDistance(float value);
 
   /**
+   * Sets the minimum touch events required before a pinch can be started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEvents( uint32_t value );
+
+  /**
+   * Sets the minimum touch events required after a pinch started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEventsAfterStart( uint32_t value );
+
+  /**
    * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
    */
   virtual void SendEvent(const Integration::TouchEvent& event);
@@ -104,6 +118,10 @@ private:
   float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
 
   float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
+
+  uint32_t mMinimumTouchEvents; ///< The minimum touch events required before a pinch can be started.
+
+  uint32_t mMinimumTouchEventsAfterStart; ///< The minimum touch events required after a pinch started.
 };
 
 } // namespace Internal
index f65642e..474f0e7 100644 (file)
@@ -41,6 +41,8 @@ namespace Internal
 
 namespace
 {
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4u;
 
 /**
  * Creates a RotationGesture and asks the specified detector to emit its detected signal.
@@ -103,7 +105,9 @@ RotationGestureProcessor::RotationGestureProcessor()
 : GestureProcessor( DevelGesture::Rotation ),
   mRotationGestureDetectors(),
   mCurrentRotationEmitters(),
-  mCurrentRotationEvent( nullptr )
+  mCurrentRotationEvent( nullptr ),
+  mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
+  mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
 {
 }
 
@@ -196,7 +200,7 @@ void RotationGestureProcessor::AddGestureDetector( RotationGestureDetector* gest
 
   if (createRecognizer)
   {
-    mGestureRecognizer = new RotationGestureRecognizer( *this );
+    mGestureRecognizer = new RotationGestureRecognizer( *this, mMinimumTouchEvents, mMinimumTouchEventsAfterStart );
   }
 }
 
@@ -228,6 +232,40 @@ void RotationGestureProcessor::RemoveGestureDetector( RotationGestureDetector* g
   }
 }
 
+void RotationGestureProcessor::SetMinimumTouchEvents( uint32_t value )
+{
+  if( value > 1u && mMinimumTouchEvents != value )
+  {
+    mMinimumTouchEvents = value;
+
+    if( mGestureRecognizer )
+    {
+      RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>( mGestureRecognizer.Get() );
+      if( rotationRecognizer )
+      {
+        rotationRecognizer->SetMinimumTouchEvents( value );
+      }
+    }
+  }
+}
+
+void RotationGestureProcessor::SetMinimumTouchEventsAfterStart( uint32_t value )
+{
+  if( value > 1u && mMinimumTouchEventsAfterStart != value )
+  {
+    mMinimumTouchEventsAfterStart = value;
+
+    if( mGestureRecognizer )
+    {
+      RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>( mGestureRecognizer.Get() );
+      if( rotationRecognizer )
+      {
+        rotationRecognizer->SetMinimumTouchEventsAfterStart( value );
+      }
+    }
+  }
+}
+
 void RotationGestureProcessor::OnGesturedActorStageDisconnection()
 {
   mCurrentRotationEmitters.clear();
index 72484c0..3021fe4 100644 (file)
@@ -87,6 +87,18 @@ public: // To be called by GestureEventProcessor
    */
   void RemoveGestureDetector( RotationGestureDetector* gestureDetector );
 
+  /**
+   * Sets the minimum touch events required before a rotation can be started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEvents( uint32_t value );
+
+  /**
+   * Sets the minimum touch events required after a rotation started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEventsAfterStart( uint32_t value );
+
 private:
 
   // GestureProcessor overrides
@@ -113,6 +125,9 @@ private:
   RenderTaskPtr mCurrentRenderTask;
 
   const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
+
+  uint32_t mMinimumTouchEvents;
+  uint32_t mMinimumTouchEventsAfterStart;
 };
 
 } // namespace Internal
index 308fc46..b0a99a8 100644 (file)
@@ -40,8 +40,6 @@ namespace Internal
 
 namespace
 {
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
 
 inline float GetAngle( const Integration::Point& point1, const Integration::Point& point2 )
 {
@@ -57,12 +55,14 @@ inline Vector2 GetCenterPoint( const Integration::Point& point1, const Integrati
 
 } // unnamed namespace
 
-RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer )
+RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart )
 : GestureRecognizer( DevelGesture::Rotation ),
   mObserver( observer ),
   mState( Clear ),
   mTouchEvents(),
-  mStartingAngle( 0.0f )
+  mStartingAngle( 0.0f ),
+  mMinimumTouchEvents( minimumTouchEvents ),
+  mMinimumTouchEventsAfterStart( minimumTouchEventsAfterStart )
 {
 }
 
@@ -107,10 +107,10 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
           mTouchEvents.push_back( event );
 
           // We can only determine a rotation after a certain number of touch points have been collected.
-          if( mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED )
+          if( mTouchEvents.size() >= mMinimumTouchEvents )
           {
             // Remove the first few events from the vector otherwise values are exaggerated
-            mTouchEvents.erase( mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START );
+            mTouchEvents.erase( mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents );
 
             if( !mTouchEvents.empty() )
             {
@@ -165,7 +165,7 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
         {
           mTouchEvents.push_back( event );
 
-          if( mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
+          if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
           {
             // Send rotation continuing
             SendRotation( Gesture::Continuing, event );
@@ -179,6 +179,16 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
   }
 }
 
+void RotationGestureRecognizer::SetMinimumTouchEvents( uint32_t value )
+{
+  mMinimumTouchEvents = value;
+}
+
+void RotationGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value )
+{
+  mMinimumTouchEventsAfterStart = value;
+}
+
 void RotationGestureRecognizer::SendRotation( Gesture::State state, const Integration::TouchEvent& currentEvent )
 {
   RotationGestureEvent gesture( state );
index 2413356..0890f2c 100644 (file)
@@ -48,8 +48,10 @@ public:
   /**
    * Constructor
    * @param[in] observer   The observer to send gesture too when it's detected
+   * @param[in] minimumTouchEvents The number of touch events required
+   * @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
    */
-  RotationGestureRecognizer( Observer& observer );
+  RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
 
   /**
    * Virtual destructor.
@@ -68,6 +70,18 @@ public:
    */
   virtual void Update( const GestureRequest& request ) { /* Nothing to do */ }
 
+  /**
+   * Sets the minimum touch events required before a rotation can be started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEvents( uint32_t value );
+
+  /**
+   * Sets the minimum touch events required after a rotation started
+   * @param[in] value The number of touch events
+   */
+  void SetMinimumTouchEventsAfterStart( uint32_t value );
+
 private:
 
   /**
@@ -96,6 +110,10 @@ private:
   std::vector< Integration::TouchEvent > mTouchEvents; ///< The touch events since initial touch down.
 
   float mStartingAngle; ///< The angle between the two touch points when the rotation is first detected.
+
+  uint32_t mMinimumTouchEvents; ///< The minimum touch events required before a rotation can be started.
+
+  uint32_t mMinimumTouchEventsAfterStart; ///< The minimum touch events required after a rotation started.
 };
 
 } // namespace Internal