/*
- * Copyright (c) 2019 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.
// EXTERNAL INCLUDES
#include <cmath>
-#include <dali/public-api/events/touch-point.h>
+#include <dali/devel-api/events/touch-point.h>
#include <dali/public-api/math/vector2.h>
#include <dali/internal/event/common/thread-local-storage.h>
} // unnamed namespace
LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime )
-: GestureRecognizer( screenSize, Gesture::LongPress ),
+: GestureRecognizer( screenSize, Dali::Gesture::LongPress ),
mObserver( observer ),
mState( Clear ),
mMinimumTouchesRequired( request.minTouches ),
{
unsigned int pointCount( event.GetPointCount() );
Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
+ GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
switch (mState)
{
// A long press gesture may be possible, tell Core about this and change state to Touched.
mState = Touched;
- EmitGesture( Gesture::Possible );
+ EmitGesture( Dali::Gesture::Possible );
}
break;
if (pointCount > mMaximumTouchesRequired)
{
// A long press did not occur, tell Core that it was cancelled and change state to Failed.
- EmitGesture( Gesture::Cancelled );
+ EmitGesture( Dali::Gesture::Cancelled );
mTouchPositions.clear();
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
case PointState::INTERRUPTED:
{
// System has interrupted us, long press is not possible, inform Core
- EmitGesture( Gesture::Cancelled );
+ EmitGesture( Dali::Gesture::Cancelled );
mTouchPositions.clear();
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
if (distanceSquared > ( MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED ) )
{
// We have moved more than the allowable motion for a long press gesture. Inform Core and change state to Failed.
- EmitGesture( Gesture::Cancelled );
+ EmitGesture( Dali::Gesture::Cancelled );
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
mState = Failed;
if(mState == Finished)
{
// When the last touch point is lifted, we should inform the Core that the Long press has finished.
- EmitGesture(Gesture::Finished);
+ EmitGesture(Dali::Gesture::Finished);
}
mTouchPositions.clear();
mState = Clear; // Reset state to clear when last touch point is lifted.
bool LongPressGestureRecognizer::TimerCallback()
{
- EmitGesture(Gesture::Started);
+ EmitGesture(Dali::Gesture::Started);
mState = Finished;
unsigned int touchPoints ( static_cast<unsigned int>( mTouchPositions.size() ) );
// We should tell Core about the Possible and Cancelled states regardless of whether we have satisfied long press requirements.
- if ( (state == Gesture::Possible) ||
- (state == Gesture::Cancelled) ||
+ if ( (state == Dali::Gesture::Possible) ||
+ (state == Dali::Gesture::Cancelled) ||
(touchPoints >= mMinimumTouchesRequired) )
{
LongPressGestureEvent longPress( state );
longPress.point /= static_cast<float>( touchPoints );
longPress.time = mTouchTime;
- if ( state != Gesture::Possible )
+ if ( state != Dali::Gesture::Possible )
{
longPress.time += mMinimumHoldingTime;
}