|
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: Algorithm to recognise gesture from a stream of points |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _XNGESTURERECOGNISER_H_ |
|
20 #define _XNGESTURERECOGNISER_H_ |
|
21 |
|
22 // System includes |
|
23 #include <e32std.h> |
|
24 |
|
25 |
|
26 /** |
|
27 * XnGestureHelper namespace |
|
28 * Used for the whole gesture family - Gesture recognizer, gesture helper, |
|
29 * Point array |
|
30 */ |
|
31 namespace XnGestureHelper |
|
32 { |
|
33 |
|
34 // Forward declarations |
|
35 class TXnPointArray; |
|
36 |
|
37 /** |
|
38 * flag that indicates gesture code is a holding code |
|
39 * clients should use MGestureEvent::IsHolding |
|
40 */ |
|
41 const TInt EFlagHold = 0x10000000; |
|
42 |
|
43 /** |
|
44 * Gesture codes and states |
|
45 */ |
|
46 enum TXnGestureCode |
|
47 { |
|
48 // states |
|
49 /** gesture just started (user pressed stylus down)*/ |
|
50 EGestureStart = 0x00000001, |
|
51 /** user moved stylus (may be holding or not holding) */ |
|
52 EGestureDrag = 0x00000002, |
|
53 /** user lifted stylus while user was holding */ |
|
54 EGestureReleased = 0x00000003, |
|
55 |
|
56 // gestures |
|
57 /** gesture was not recognised */ |
|
58 EGestureUnknown = 0x00000005, |
|
59 /** these codes are sent when user lifts stylus |
|
60 * (if holding not started) |
|
61 */ |
|
62 EGestureTap = 0x00000006, |
|
63 /** first tap emits EGestureTap */ |
|
64 EGestureDoubleTap = 0x00000007, |
|
65 /** swipe left */ |
|
66 EGestureSwipeLeft = 0x00000008, |
|
67 /** swipe right */ |
|
68 EGestureSwipeRight = 0x00000009, |
|
69 /** swipe up */ |
|
70 EGestureSwipeUp = 0x0000000A, |
|
71 /** swipe down */ |
|
72 EGestureSwipeDown = 0x0000000B, |
|
73 /** |
|
74 * these codes are sent when user initiates holding by keeping stylus |
|
75 * in same place for a longer duration |
|
76 */ |
|
77 EGestureHoldLeft = EGestureSwipeLeft | EFlagHold, |
|
78 EGestureHoldRight = EGestureSwipeRight | EFlagHold, |
|
79 EGestureHoldUp = EGestureSwipeUp | EFlagHold, |
|
80 EGestureHoldDown = EGestureSwipeDown | EFlagHold |
|
81 }; |
|
82 |
|
83 //Class declaration |
|
84 |
|
85 /** |
|
86 * Set of algorithms to recognise gesture from a stream of points |
|
87 * Note: Not a static class or a function pointer, just to make it |
|
88 * sligthly easier to replace it with a heavier implementation |
|
89 * |
|
90 * @ingroup group_xnlayoutengine |
|
91 */ |
|
92 NONSHARABLE_CLASS( TXnGestureRecogniser ) |
|
93 { |
|
94 public: |
|
95 |
|
96 /** |
|
97 * Translates points into a gesture code |
|
98 * @param aPoints Points that form the gestures. Client is not |
|
99 * required to pass in repeated points (sequential |
|
100 * points that are almost in the same place) |
|
101 * @param aIsHolding ETrue if gesture was ended at pointer being held |
|
102 * down at same position |
|
103 * EFalse if gesture ended at pointer being released |
|
104 * @return recognised gesture id or EUnknownGesture |
|
105 */ |
|
106 TXnGestureCode GestureCode( const TXnPointArray& aPoints ) const; |
|
107 }; |
|
108 } // namespace XnGestureHelper |
|
109 |
|
110 #endif // _XNGESTURERECOGNISER_H_ |