1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <Browser_platform_variant.hrh> |
|
21 #include "config.h" |
|
22 #include "../../bidi.h" |
|
23 #include <coemain.h> |
|
24 #include "WebGestureInterface.h" |
|
25 #include "WebView.h" |
|
26 #include "WebPointerEventHandler.h" |
|
27 |
|
28 const TInt TOUCH_AREA_TIMEOUT = 200; |
|
29 const TInt TOUCH_TIME_AREA_TIMEOUT = 0; |
|
30 const TInt HOLD_AREA_TIMEOUT = 2000; |
|
31 const TInt DOUBLE_TAP_TIMEOUT = 400; |
|
32 const TInt SUPPRESS_TIMEOUT = 0; |
|
33 const TInt MOVE_SUPPRESS_TIMEOUT = 0; |
|
34 |
|
35 const TInt TOUCH_TIME_AREA_WIDTH = 4; |
|
36 const TInt TOUCH_AREA_WIDTH = 4; |
|
37 const TInt HOLD_AREA_WIDTH = 4; |
|
38 |
|
39 const TInt PAN_SPEED_LOW = 0; |
|
40 const TInt PAN_SPEED_HIGH = 400; |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CgesturetestAppView::NewL() |
|
46 // Two-phased constructor. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 WebGestureInterface* WebGestureInterface::NewL(WebView* view) |
|
50 { |
|
51 WebGestureInterface* self = WebGestureInterface::NewLC(view); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CgesturetestAppView::NewLC() |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 WebGestureInterface* WebGestureInterface::NewLC(WebView* view) |
|
62 { |
|
63 WebGestureInterface* self = new (ELeave) WebGestureInterface(view); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // WebGestureInterface::WebGestureInterface |
|
71 // C++ default constructor |
|
72 // |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 WebGestureInterface::WebGestureInterface(WebView* view) |
|
76 : m_webview(view) |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // WebGestureInterface::~WebGestureInterface |
|
82 // ----------------------------------------------------------------------------- |
|
83 WebGestureInterface::~WebGestureInterface() |
|
84 { |
|
85 iGestureContext->Deactivate(); |
|
86 iGestureContext->RemoveListener(this); |
|
87 delete iGestureEngine; |
|
88 } |
|
89 // ----------------------------------------------------------------------------- |
|
90 // WebGestureInterface::ConstructL |
|
91 // Symbian 2nd phase constructor can leave. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void WebGestureInterface::ConstructL() |
|
95 { |
|
96 iGestureEngine = CStmGestureEngine::NewL(); |
|
97 iGestureContext = iGestureEngine->CreateContextL(TInt(this)); |
|
98 iGestureContext->SetContext(m_webview); |
|
99 iGestureContext->AddListenerL(this); |
|
100 |
|
101 CStmGestureParameters& gestureParams = iGestureContext->Config(); |
|
102 //Enable the Gestures needed |
|
103 gestureParams.SetEnabled(stmGesture::EGestureUidTouch, ETrue); |
|
104 gestureParams.SetEnabled(stmGesture::EGestureUidTap, ETrue); |
|
105 gestureParams.SetEnabled(stmGesture::EGestureUidRelease, ETrue); |
|
106 gestureParams.SetEnabled(stmGesture::EGestureUidPan, ETrue); |
|
107 gestureParams.SetEnabled(stmGesture::EGestureUidFlick, ETrue); |
|
108 gestureParams.SetEnabled(stmGesture::EGestureUidLongPress, ETrue); |
|
109 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
|
110 gestureParams.SetEnabled(stmGesture::EGestureUidPinch, ETrue); |
|
111 #else |
|
112 gestureParams.SetEnabled(stmGesture::EGestureUidPinch, EFalse); |
|
113 #endif |
|
114 |
|
115 //Set other parameters |
|
116 |
|
117 TStmGestureArea& touchTimeArea = *gestureParams.Area(stmGesture::ETouchTimeArea); |
|
118 TStmGestureArea& touchArea = *gestureParams.Area(stmGesture::ETouchArea); |
|
119 TStmGestureArea& holdArea = *gestureParams.Area(stmGesture::EHoldArea); |
|
120 |
|
121 touchTimeArea.iShape = TStmGestureArea::ERectangle; |
|
122 touchTimeArea.iTimeout = TOUCH_TIME_AREA_TIMEOUT; |
|
123 touchTimeArea.iSize.iWidth = TOUCH_TIME_AREA_WIDTH; |
|
124 |
|
125 touchArea.iShape = TStmGestureArea::ERectangle; |
|
126 touchArea.iTimeout = TOUCH_AREA_TIMEOUT; |
|
127 touchArea.iSize.iWidth = TOUCH_AREA_WIDTH; |
|
128 |
|
129 holdArea.iShape = TStmGestureArea::ERectangle; |
|
130 holdArea.iTimeout = HOLD_AREA_TIMEOUT; |
|
131 holdArea.iSize.iWidth = HOLD_AREA_WIDTH; |
|
132 |
|
133 gestureParams[stmGesture::EDoubleTapTimeout ] = DOUBLE_TAP_TIMEOUT; |
|
134 gestureParams[stmGesture::ESuppressTimeout ] = SUPPRESS_TIMEOUT; |
|
135 gestureParams[stmGesture::EMoveSuppressTimeout] = MOVE_SUPPRESS_TIMEOUT; |
|
136 gestureParams[stmGesture::EPanSpeedLow ] = PAN_SPEED_LOW; |
|
137 gestureParams[stmGesture::EPanSpeedHigh ] = PAN_SPEED_HIGH; |
|
138 |
|
139 gestureParams[stmGesture::EEnableFiltering ] = ETrue; |
|
140 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
|
141 gestureParams[stmGesture::ECapacitiveUpUsed ] = ETrue; |
|
142 gestureParams[stmGesture::EAdjustYPos ] = ETrue; |
|
143 #else |
|
144 gestureParams[stmGesture::ECapacitiveUpUsed ] = EFalse; |
|
145 gestureParams[stmGesture::EAdjustYPos ] = EFalse; |
|
146 #endif |
|
147 iGestureContext->ActivateL(); |
|
148 |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // HandlePointerEventL |
|
153 // ----------------------------------------------------------------------------- |
|
154 void WebGestureInterface::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
155 { |
|
156 iGestureEngine->HandlePointerEventL(aPointerEvent, m_webview); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // HandleGestureEventL |
|
161 // ----------------------------------------------------------------------------- |
|
162 void WebGestureInterface::HandleGestureEventL(const TStmGestureEvent& aGesture) |
|
163 { |
|
164 m_webview->pointerEventHandler()->HandleGestureEventL(aGesture); |
|
165 } |
|
166 |
|
167 |
|