1/* 2 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies) 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 * THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#ifndef GestureRecognizer_h 28#define GestureRecognizer_h 29 30#if ENABLE(TOUCH_EVENTS) 31#include "EflTypedefs.h" 32#include <WebCore/IntPoint.h> 33#include <WebKit/WKEventEfl.h> 34 35class EwkView; 36 37namespace WebKit { 38 39class GestureHandler; 40 41class GestureRecognizer { 42public: 43 explicit GestureRecognizer(EwkView*); 44 ~GestureRecognizer(); 45 46 void processTouchEvent(WKTouchEventRef); 47 void reset(); 48 49private: 50 static Eina_Bool doubleTapTimerCallback(void*); 51 static Eina_Bool tapAndHoldTimerCallback(void*); 52 53 bool exceedsPanThreshold(const WebCore::IntPoint& first, const WebCore::IntPoint& last) const; 54 bool exceedsDoubleTapThreshold(const WebCore::IntPoint& first, const WebCore::IntPoint& last) const; 55 56 // State functions. 57 void noGesture(WKTouchEventRef); 58 void singleTapGesture(WKTouchEventRef); 59 void doubleTapGesture(WKTouchEventRef); 60 void panGesture(WKTouchEventRef); 61 void pinchGesture(WKTouchEventRef); 62 63 void stopTapTimers(); 64 65 static const double s_doubleTapTimeoutInSeconds; 66 static const double s_tapAndHoldTimeoutInSeconds; 67 static const int s_squaredDoubleTapThreshold; 68 static const int s_squaredPanThreshold; 69 70 typedef void (GestureRecognizer::*RecognizerFunction)(WKTouchEventRef); 71 RecognizerFunction m_recognizerFunction; 72 73 std::unique_ptr<WebKit::GestureHandler> m_gestureHandler; 74 Ecore_Timer* m_tapAndHoldTimer; 75 Ecore_Timer* m_doubleTapTimer; 76 WebCore::IntPoint m_firstPressedPoint; 77}; 78 79} // namespace WebKit 80 81#endif // ENABLE(TOUCH_EVENTS) 82 83#endif // GestureRecognizer_h 84