#include <dali/public-api/math/vector2.h>
-// INTERNAL INCLUDES
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/platform-abstraction.h>
+
+// INTERNAL INCLUDES
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/events/gesture-requests.h>
namespace Dali
// TODO: Set these according to DPI
const float MAXIMUM_MOTION_ALLOWED = 20.0f;
const unsigned long MAXIMUM_TIME_ALLOWED = 500u;
-const uint32_t WAIT_TIME = 330u;
} // unnamed namespace
TapGestureRecognizer::TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request)
mTouchPosition(),
mTouchTime(0u),
mLastTapTime(0u),
- mEventTime(0u),
- mGestureSourceType(GestureSourceType::INVALID),
- mTimerId(0)
+ mGestureSourceType(GestureSourceType::INVALID)
{
}
-TapGestureRecognizer::~TapGestureRecognizer()
-{
- if(mTimerId != 0 && ThreadLocalStorage::Created())
- {
- Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
- platformAbstraction.CancelTimer(mTimerId);
- }
-}
+TapGestureRecognizer::~TapGestureRecognizer() = default;
void TapGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
if(event.GetPointCount() == 1)
{
- const Integration::Point& point = event.points[0];
- PointState::Type pointState = point.GetState();
- Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
+ const Integration::Point& point = event.points[0];
+ PointState::Type pointState = point.GetState();
MouseButton::Type mouseButton = point.GetMouseButton();
switch(mouseButton)
{
if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
- if(mMaximumTapsRequired > mMinimumTapsRequired)
- {
- mEventTime = event.time;
- mTimerId = platformAbstraction.StartTimer(WAIT_TIME, MakeCallback(this, &TapGestureRecognizer::TimerCallback));
- }
-
mLastTapTime = mTouchTime;
EmitSingleTap(event.time, point);
mState = REGISTERED;
else if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
++mTapsRegistered;
- if(mMaximumTapsRequired > mMinimumTapsRequired)
- {
- mEventTime = event.time;
- mTimerId = platformAbstraction.StartTimer(WAIT_TIME, MakeCallback(this, &TapGestureRecognizer::TimerCallback));
- }
- else
- {
- EmitGesture(GestureState::STARTED, event.time);
- }
+ EmitGesture(GestureState::STARTED, event.time);
}
else // Delta between touch down and touch up too long to be considered a TAP event
{
{
EmitPossibleState(event);
}
-
- if(mTimerId != 0)
- {
- platformAbstraction.CancelTimer(mTimerId);
- mTimerId = 0;
- }
}
break;
}
}
}
-bool TapGestureRecognizer::TimerCallback()
-{
- EmitGesture(GestureState::STARTED, mEventTime);
-
- mTimerId = 0;
- return false;
-}
-
void TapGestureRecognizer::SetupForTouchDown(const Integration::TouchEvent& event, const Integration::Point& point)
{
mTouchPosition = point.GetScreenPosition();
Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
std::abs(mTouchPosition.y - screen.y));
- mTapsRegistered = 1u;
if(distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
distanceDelta.y > MAXIMUM_MOTION_ALLOWED)
{
event.state = GestureState::CANCELLED;
- if(mTimerId != 0)
- {
- Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
- platformAbstraction.CancelTimer(mTimerId);
- mTimerId = 0;
- }
- }
- if(mTimerId == 0)
- {
- EmitTap(time, event);
}
+ mTapsRegistered = 1u;
+ EmitTap(time, event);
}
void TapGestureRecognizer::EmitTap(uint32_t time, TapGestureEvent& event)