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
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;
+}
--- /dev/null
+/*
+ * 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;
+}
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();
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/type-info.h>
namespace Dali
{
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
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 );
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
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.
mPinchGestureDetectors(),
mCurrentPinchEmitters(),
mCurrentPinchEvent(NULL),
- mMinimumPinchDistance(-1.0f)
+ mMinimumPinchDistance(-1.0f),
+ mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
+ mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
{
}
}
}
+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 )
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 );
}
}
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.
const PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
float mMinimumPinchDistance;
+ uint32_t mMinimumTouchEvents;
+ uint32_t mMinimumTouchEventsAfterStart;
};
} // 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)
} // 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 );
}
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];
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() )
{
{
mTouchEvents.push_back(event);
- if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
+ if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
{
// Send pinch continuing
SendPinch(Gesture::Continuing, event);
}
}
+void PinchGestureRecognizer::SetMinimumTouchEvents( uint32_t value )
+{
+ mMinimumTouchEvents = value;
+}
+
+void PinchGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value )
+{
+ mMinimumTouchEventsAfterStart = value;
+}
+
} // namespace Internal
} // namespace Dali
* @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.
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);
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
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.
: GestureProcessor( DevelGesture::Rotation ),
mRotationGestureDetectors(),
mCurrentRotationEmitters(),
- mCurrentRotationEvent( nullptr )
+ mCurrentRotationEvent( nullptr ),
+ mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
+ mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
{
}
if (createRecognizer)
{
- mGestureRecognizer = new RotationGestureRecognizer( *this );
+ mGestureRecognizer = new RotationGestureRecognizer( *this, mMinimumTouchEvents, mMinimumTouchEventsAfterStart );
}
}
}
}
+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();
*/
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
RenderTaskPtr mCurrentRenderTask;
const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
+
+ uint32_t mMinimumTouchEvents;
+ uint32_t mMinimumTouchEventsAfterStart;
};
} // 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 )
{
} // 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 )
{
}
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() )
{
{
mTouchEvents.push_back( event );
- if( mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
+ if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
{
// Send rotation continuing
SendRotation( Gesture::Continuing, 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 );
/**
* 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.
*/
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:
/**
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