2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef GestureRecognizer_h
27 #define GestureRecognizer_h
29 #include "PageClientImpl.h"
32 #include <Elementary.h>
34 #include <wtf/PassOwnPtr.h>
42 class GestureRecognizer {
44 static PassOwnPtr<GestureRecognizer> create(Evas_Object* ewkView)
46 return adoptPtr(new GestureRecognizer(ewkView));
51 explicit GestureRecognizer(Evas_Object*);
52 void initializeCallbacks();
54 void setTapScheduled(bool);
56 void startTap(Elm_Gesture_Taps_Info*);
57 void endTap(Elm_Gesture_Taps_Info*);
58 void abortTap(Elm_Gesture_Taps_Info*);
59 void processTap(int x, int y, unsigned int timestamp);
60 void processScheduledTap(int x, int y, unsigned int timestamp);
61 void startLongTap(Elm_Gesture_Taps_Info*);
62 void moveLongTap(Elm_Gesture_Taps_Info*);
63 void endLongTap(Elm_Gesture_Taps_Info*);
64 void endDoubleTap(Elm_Gesture_Taps_Info*);
66 void startMomentum(Elm_Gesture_Momentum_Info*);
67 void moveMomentum(Elm_Gesture_Momentum_Info*);
68 void endMomentum(Elm_Gesture_Momentum_Info*);
69 void startZoom(Elm_Gesture_Zoom_Info*);
70 void moveZoom(Elm_Gesture_Zoom_Info*);
71 void endZoom(Elm_Gesture_Zoom_Info*);
73 void startGesture(Ewk_Gesture_Type, const WebCore::IntPoint& position, const WebCore::IntPoint& velocity, double scale, int count);
74 void endGesture(Ewk_Gesture_Type, const WebCore::IntPoint& position, const WebCore::IntPoint& velocity, double scale, int count);
75 void moveGesture(Ewk_Gesture_Type, const WebCore::IntPoint& position, const WebCore::IntPoint& velocity, double scale, int count);
77 static Evas_Event_Flags onTapStart(void* data, void* eventInfo);
78 static Evas_Event_Flags onTapAbort(void* data, void* eventInfo);
79 static Evas_Event_Flags onTapEnd(void* data, void* eventInfo);
80 static Evas_Event_Flags onLongTapStart(void* data, void* eventInfo);
81 static Evas_Event_Flags onLongTapMove(void* data, void* eventInfo);
82 static Evas_Event_Flags onLongTapEnd(void* data, void* eventInfo);
83 static Evas_Event_Flags onDoubleTapEnd(void* data, void* eventInfo);
84 static Evas_Event_Flags onMomentumStart(void* data, void* eventInfo);
85 static Evas_Event_Flags onMomentumMove(void* data, void* eventInfo);
86 static Evas_Event_Flags onMomentumEnd(void* data, void* eventInfo);
87 static Evas_Event_Flags onMomentumAbort(void* data, void* eventInfo);
88 static Evas_Event_Flags onZoomStart(void* data, void* eventInfo);
89 static Evas_Event_Flags onZoomMove(void* data, void* eventInfo);
90 static Evas_Event_Flags onZoomEnd(void* data, void* eventInfo);
92 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
94 #if ENABLE(TIZEN_DESKTOP_BROWSING)
95 static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
96 static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
100 static const int s_defaultFramerate = 60;
101 static const double s_thumbscrollMomentumThreshold;
102 static const int s_tapThreshold = 500;
105 Evas_Object* m_viewWidget;
106 Evas_Object* m_gestureObject;
108 WebCore::IntPoint m_pressedPoint;
109 WebCore::IntPoint m_currentPoint;
110 bool m_isTapScheduled;
111 bool m_isLongTapProcessed;
112 unsigned m_longTapCount;
115 } // namespace WebKit
117 #endif // GestureRecognizer_h