1 /* |
|
2 * Copyright (c) 2007 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 "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: Gesture helper interface |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef _GESTUREHELPER_H_ |
|
19 #define _GESTUREHELPER_H_ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <gestureobserver.h> |
|
23 |
|
24 class CAlfEnv; |
|
25 class CAlfDisplay; |
|
26 class TAlfEvent; |
|
27 struct TPointerEvent; |
|
28 |
|
29 namespace GestureHelper |
|
30 { |
|
31 |
|
32 class CGestureHelperImpl; |
|
33 |
|
34 /** |
|
35 * Gesture helper provides functionality to convert a stream of pointer events |
|
36 * into a logical gesture, and to assist clients in calculation of gesture |
|
37 * speed and distance. |
|
38 * |
|
39 * Interfaces |
|
40 * - CGestureHelper is a parser of pointer events. Recognises gestures from |
|
41 * a sequence of pointer events, and converts them to gesture commands. |
|
42 * For documentation of callbacks, see @ref MGestureObserver. |
|
43 * - MGestureObserver allows clients to get notified of gestures |
|
44 * - MGestureEvent represents the gesture (event) |
|
45 */ |
|
46 NONSHARABLE_CLASS( CGestureHelper ) : public CBase |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * The helper is expected to be a member variable, hence NewLC is not provided |
|
51 */ |
|
52 IMPORT_C static CGestureHelper* NewL( MGestureObserver& aObserver ); |
|
53 |
|
54 /** Destructor */ |
|
55 IMPORT_C ~CGestureHelper(); |
|
56 |
|
57 /** |
|
58 * Specify whether the helper will send hold events. By default, holding is enabled. |
|
59 * "Hold" means user has held stylus/finger on the same position for a longer duration. |
|
60 * |
|
61 * Clients that require holding to be treated with no special meaning should disable |
|
62 * holding to simplify their event handling. |
|
63 * For example, assume the client uses swipe left/right to control navigation, and |
|
64 * holding is enabled. If user holds, the client gets hold left/right |
|
65 * event, and no swipe event. If user now drags left or right while still pressing |
|
66 * stylus down, the client will not get a swipe event (since it already received a hold |
|
67 * event). Upon release event, the client no reliable way of knowing whether the |
|
68 * user swiped left/right or cancelled the swipe. This problem is removed if the |
|
69 * client simply disables holding. In the above scenario while holding disabled, |
|
70 * the client would get only swipe events (and released event). |
|
71 * (Swipe can be cancelled by dragging towards, but not beyond, the starting position.) |
|
72 */ |
|
73 IMPORT_C void SetHoldingEnabled( TBool aEnabled ); |
|
74 |
|
75 /** |
|
76 * @return whether sending hold events is currently enabled |
|
77 * ("Hold" means user has held stylus/finger on the same position for a longer duration.) |
|
78 */ |
|
79 IMPORT_C TBool IsHoldingEnabled() const; |
|
80 |
|
81 /** |
|
82 * Enables/disables double tap support. Double tap is disabled by default. |
|
83 * When double tap is disabled, gesture helper emits tap events immediately when |
|
84 * user lifts stylus/finger. |
|
85 * When double tap is enabled, tap events are emitted after the double tap timeout passes. |
|
86 * The timeout is the maximum time within which the second tap will be treated |
|
87 * as a double tap. That is, there is a delay (sluggishness) before client receives |
|
88 * the tap event when double tap is enabled. |
|
89 * tap + timeout => tap event emitted after timeout |
|
90 * tap + tap before timeout => double tap event emitted immediately after the second tap |
|
91 * tap + swipe => tap + swipe events |
|
92 * (tap + timeout + tap + timeout => two tap events) |
|
93 */ |
|
94 IMPORT_C void SetDoubleTapEnabled( TBool aEnabled ); |
|
95 |
|
96 /** |
|
97 * @return whether double tap is currently enabled. See SetDoubleTapEnabled |
|
98 */ |
|
99 IMPORT_C TBool IsDoubleTapEnabled() const; |
|
100 |
|
101 /** |
|
102 * Initialise pointer capture for Alfred |
|
103 * This means that helper will receive drag events and pointer events that |
|
104 * go outside the original visual area |
|
105 */ |
|
106 IMPORT_C void InitAlfredPointerCaptureL( CAlfEnv& aEnv, CAlfDisplay& aDisplay, |
|
107 TInt aFreeControlGroupId ); |
|
108 |
|
109 /** |
|
110 * Give a pointer event to the helper, to form a part of a gesture |
|
111 * For AVKON-based client, this interface is the only option. |
|
112 * Alfred-based client should use OfferEventL, as it allows gesture events to |
|
113 * provider the visual on which the pointer event started. |
|
114 * @param aEvent pointer event |
|
115 * @return whether event was consumed or not |
|
116 * EFalse the event is not a pointer events and if pointer up/drag |
|
117 * event received without pointer down event |
|
118 * ETrue in all the other cases of pointer event |
|
119 */ |
|
120 IMPORT_C TBool HandlePointerEventL( const TPointerEvent& aEvent ); |
|
121 |
|
122 /** |
|
123 * Offer an Alf event. See HandlePointerEventL. |
|
124 * @return whether event was consumed or not |
|
125 * EFalse the event is not a pointer events and if pointer up/drag |
|
126 * event received without pointer down event |
|
127 * ETrue in all the other cases of pointer event |
|
128 */ |
|
129 IMPORT_C TBool OfferEventL( const TAlfEvent& aEvent ); |
|
130 |
|
131 /** |
|
132 * Cancel ongoing recognision. Purges all pointer events given earlier, and |
|
133 * starts afresh. It is not necessary to call Cancel before deleting the object. |
|
134 */ |
|
135 IMPORT_C void Cancel(); |
|
136 |
|
137 /** |
|
138 * Adds a new observer to gesture helper events. Replaces any earlier observer. |
|
139 * This is to allow sharing of gesture helper between different controls. |
|
140 * The control which is currently shown (control that is on top of the roster) |
|
141 * will add as an observer and the earlier control which is now not in focus will |
|
142 * automatically be removed as an observer. |
|
143 * |
|
144 * This API should be used only when the gesture helper is shared between more |
|
145 * than one control. Gesture helper can be shared only among the controls within the same roster. |
|
146 * Only required for alf based applications, not required for CCoeControl. |
|
147 * |
|
148 */ |
|
149 IMPORT_C void AddObserver(MGestureObserver* aObserver); |
|
150 |
|
151 private: |
|
152 /// interface implementation |
|
153 CGestureHelperImpl* iImpl; |
|
154 }; |
|
155 |
|
156 } // namespace GestureHelper |
|
157 |
|
158 #endif // _GESTUREHELPER_H_ |
|