This is the time from touch down to touch up to recognize a tap gesture.
If set to 300ms, a touch up after a touch down must occur within 300ms to be recognized as a tap gesture.
Change-Id: I1b7be723938a32f4009232553671bda17503c782
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
END_TEST;
}
+
+int UtcDaliTapGestureSetRecognizerTime(void)
+{
+ TestApplication application;
+
+ TapGestureDetector detector = TapGestureDetector::New();
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ detector.Attach(actor);
+
+ try
+ {
+ Integration::SetTapRecognizerTime(0);
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+
+ // Reduce the recognizer time. 500 -> 100
+ Integration::SetTapRecognizerTime(100);
+
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+ detector.DetectedSignal().Connect(&application, functor);
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150));
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 200));
+
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ data.Reset();
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 300));
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 450));
+
+ application.SendNotification();
+
+ // The tap fails because the recognizer time has been exceeded
+ DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+
+ // reset recognizer time
+ Integration::SetTapRecognizerTime(500);
+
+ END_TEST;
+}
eventProcessor.SetTapMaximumAllowedTime(time);
}
+void SetTapRecognizerTime(uint32_t time)
+{
+ GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+ eventProcessor.SetTapRecognizerTime(time);
+}
+
} // namespace Integration
} // namespace Dali
#define DALI_INTEGRATION_INPUT_OPTIONS_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
/**
* @brief Sets the maximum allowed time required to be recognized as a multi tap gesture (millisecond)
*
+ * Recognizes how many tap gestures occurred within the maximum allowed time interval.
+ * If there are two tap gestures within this time, it is a double tap gesture.
+ *
+ * @note If it's a double tap, it's like this:
+ * |<--- maximumAllowedTime --->|
+ * |(touch down <--recognizerTime--> touch up) <-- maximumAllowedTime --> (touch down <--recognizerTime--> touch up)|
+ *
+ * @see SetTapRecognizerTime()
+ *
* @param[in] time The time value in milliseconds
*/
DALI_CORE_API void SetTapMaximumAllowedTime(uint32_t time);
+/**
+ * @brief Sets the recognizer time required to be recognized as a tap gesture (millisecond)
+ *
+ * This time is from touch down to touch up to recognize the tap gesture.
+ *
+ * @note The tab is like below:
+ * touch down <--recognizerTime--> touch up
+ * If the time between touch down and touch up is longer than recognizer time, it is not recognized as a tap gesture.
+ *
+ * @see SetTapMaximumAllowedTime()
+ *
+ * @param[in] time The time value in milliseconds
+ */
+DALI_CORE_API void SetTapRecognizerTime(uint32_t time);
+
} // namespace Integration
} // namespace Dali
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
mTapGestureProcessor.SetMaximumAllowedTime(time);
}
+void GestureEventProcessor::SetTapRecognizerTime(uint32_t time)
+{
+ mTapGestureProcessor.SetRecognizerTime(time);
+}
+
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
*/
void SetTapMaximumAllowedTime(uint32_t time);
+ /**
+ * @brief Sets the recognizer time required to be recognized as a tap gesture (millisecond)
+ *
+ * This time is from touch down to touch up to recognize the tap gesture.
+ *
+ * @param[in] time The time value in milliseconds
+ */
+ void SetTapRecognizerTime(uint32_t time);
+
public: // needed for PanGesture
/**
* @return the pan gesture processor
{
DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
constexpr uint32_t DEFAULT_MAXIMUM_ALLOWED_TIME = 500u;
+constexpr uint32_t DEFAULT_RECOGNIZER_TIME = 500u;
/**
* Creates a TapGesture and asks the specified detector to emit its detected signal.
mMaxTouchesRequired(1),
mCurrentTapEvent(nullptr),
mPossibleProcessed(false),
- mMaximumAllowedTime(DEFAULT_MAXIMUM_ALLOWED_TIME)
+ mMaximumAllowedTime(DEFAULT_MAXIMUM_ALLOWED_TIME),
+ mRecognizerTime(DEFAULT_RECOGNIZER_TIME)
{
}
request.maxTouches = mMaxTouchesRequired;
Size size = scene.GetSize();
- mGestureRecognizer = new TapGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const TapGestureRequest&>(request), mMaximumAllowedTime);
+ mGestureRecognizer = new TapGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const TapGestureRequest&>(request), mMaximumAllowedTime, mRecognizerTime);
}
else
{
}
}
+void TapGestureProcessor::SetRecognizerTime(uint32_t time)
+{
+ if(time == 0u)
+ {
+ DALI_LOG_WARNING("RecognizerTime must be greater than zero.");
+ return;
+ }
+ if(mRecognizerTime != time)
+ {
+ mRecognizerTime = time;
+
+ if(mGestureRecognizer)
+ {
+ TapGestureRecognizer* tapRecognizer = dynamic_cast<TapGestureRecognizer*>(mGestureRecognizer.Get());
+ if(tapRecognizer)
+ {
+ tapRecognizer->SetRecognizerTime(time);
+ }
+ }
+ }
+}
+
void TapGestureProcessor::UpdateDetection()
{
DALI_ASSERT_DEBUG(!mTapGestureDetectors.empty());
#define DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
*/
void SetMaximumAllowedTime(uint32_t time);
+ /**
+ * @brief This method sets the recognizer time required to be recognized as a tap gesture (millisecond)
+ *
+ * This time is from touch down to touch up to recognize the tap gesture.
+ *
+ * @param[in] time The time value in milliseconds
+ */
+ void SetRecognizerTime(uint32_t time);
+
private:
// Undefined
TapGestureProcessor(const TapGestureProcessor&);
bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
+ uint32_t mRecognizerTime; ///< The recognizer time required to be recognized as a tap gesture (millisecond)
};
} // namespace Internal
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
constexpr float MAXIMUM_MOTION_ALLOWED = 20.0f;
} // unnamed namespace
-TapGestureRecognizer::TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request, uint32_t maximumAllowedTime)
+TapGestureRecognizer::TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request, uint32_t maximumAllowedTime, uint32_t recognizerTime)
: GestureRecognizer(screenSize, GestureType::TAP),
mObserver(observer),
mState(CLEAR),
mTouchTime(0u),
mLastTapTime(0u),
mLastTouchTime(0u),
- mMaximumAllowedTime(maximumAllowedTime)
+ mMaximumAllowedTime(maximumAllowedTime),
+ mRecognizerTime(recognizerTime)
{
}
if(pointState == PointState::UP)
{
- if(deltaBetweenTouchDownTouchUp < mMaximumAllowedTime)
+ if(deltaBetweenTouchDownTouchUp < mRecognizerTime)
{
mLastTapTime = event.time;
EmitSingleTap(event.time, point);
{
uint32_t deltaBetweenLastTouchDownTouchUp = event.time - mLastTouchTime;
// Clear if the time between touch down and touch up is long.
- if(deltaBetweenLastTouchDownTouchUp > mMaximumAllowedTime)
+ if(deltaBetweenLastTouchDownTouchUp > mRecognizerTime)
{
mState = CLEAR;
}
mMaximumAllowedTime = time;
}
+void TapGestureRecognizer::SetRecognizerTime(uint32_t time)
+{
+ mRecognizerTime = time;
+}
+
void TapGestureRecognizer::EmitGesture(GestureState state, uint32_t time)
{
if((state == GestureState::CANCELLED) ||
#define DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
* @param[in] screenSize The size of the screen.
* @param[in] request The tap gesture request.
* @param[in] maximumAllowedTime The maximum allowed time required in milliseconds.
+ * @param[in] recognizerTime This recognizer time required in milliseconds.
*/
- TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request, uint32_t maximumAllowedTime);
+ TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request, uint32_t maximumAllowedTime, uint32_t recognizerTime);
/**
* Virtual destructor.
*/
void SetMaximumAllowedTime(uint32_t time);
+ /**
+ * @brief This method sets the recognizer time required to be recognized as a tap gesture (millisecond)
+ *
+ * @param[in] time The time value in milliseconds
+ */
+ void SetRecognizerTime(uint32_t time);
+
private:
/**
* Checks if registered taps are within required bounds and emits tap gesture if they are.
uint32_t mLastTouchTime; ///< The last touch down time.
uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
+ uint32_t mRecognizerTime; ///< The recognizer time required to be recognized as a tap gesture (millisecond)
};
} // namespace Internal