|
1 /* |
|
2 * Copyright (c) 2009 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: Class for tracing the direction in which pointer |
|
15 * is being dragged. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef C_AKNTOUCHGESTUREFWDRAGTRACER_H |
|
20 #define C_AKNTOUCHGESTUREFWDRAGTRACER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 namespace AknTouchGestureFw |
|
25 { |
|
26 |
|
27 /** |
|
28 * Traces the direction in which pointer is being dragged. |
|
29 */ |
|
30 NONSHARABLE_CLASS( CAknTouchGestureFwDragTracer ) : public CBase |
|
31 { |
|
32 public: |
|
33 |
|
34 /** |
|
35 * Values used to represent horizontal and vertical direction. |
|
36 */ |
|
37 enum TDirection |
|
38 { |
|
39 EDirectionNone, ///< No change in position. |
|
40 EDirectionForward, ///< Movement towards right or down. |
|
41 EDirectionBackward ///< Movement towards left or up. |
|
42 }; |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CAknTouchGestureFwDragTracer* NewL(); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 static CAknTouchGestureFwDragTracer* NewLC(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CAknTouchGestureFwDragTracer(); |
|
58 |
|
59 /** |
|
60 * Initializes tracer. |
|
61 * |
|
62 * @param aStartPosition Start coordinate. |
|
63 */ |
|
64 void Initialize( const TPoint& aStartPosition ); |
|
65 |
|
66 /** |
|
67 * Checks if dragging direction has changed with new position. |
|
68 * |
|
69 * @param aPosition New position. |
|
70 * @param aSensitivity Tells how many points can be dragged to reversed |
|
71 * direction before direction is changed. |
|
72 * |
|
73 * @return @c ETrue if direction has changed |
|
74 */ |
|
75 TBool IsDirectionChanged( const TPoint& aPosition, TInt aSensitivity ); |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * C++ constructor. |
|
81 */ |
|
82 CAknTouchGestureFwDragTracer(); |
|
83 |
|
84 /** |
|
85 * Checks if dragging direction has changed horizontally or vertically |
|
86 * with new position. Only horizontal or vertical direction can be checked |
|
87 * with single call. |
|
88 * |
|
89 * @param aCurrentCoordinate Current X- or Y-coordinate |
|
90 * @param aPrevCoordinate Previous X- or Y-coordinate |
|
91 * @param aDirection Current direction, will be updated within |
|
92 * this call. |
|
93 * @param aCounter Counter of coordinates that are dragged |
|
94 * to reversed direction, will be updated |
|
95 * within this call. |
|
96 * @param aSensitivity Tells how many points can be dragged to |
|
97 * reversed direction before direction is |
|
98 * changed. |
|
99 * |
|
100 * @return @c ETrue if direction has changed |
|
101 */ |
|
102 TBool IsDirectionChanged( TInt aCurrentCoordinate, |
|
103 TInt aPrevCoordinate, |
|
104 TDirection& aDirection, |
|
105 TInt& aCounter, |
|
106 TInt aSensitivity ); |
|
107 |
|
108 private: // data |
|
109 |
|
110 /** |
|
111 * Current horizontal direction |
|
112 */ |
|
113 TDirection iHorizDirection; |
|
114 |
|
115 /** |
|
116 * Current vertical direction |
|
117 */ |
|
118 TDirection iVertDirection; |
|
119 |
|
120 /** |
|
121 * Counter for points which are to reversed horizontal direction |
|
122 * compared to current direction. |
|
123 */ |
|
124 TInt iHorizCounter; |
|
125 |
|
126 /** |
|
127 * Counter for points which are to reversed vertical direction |
|
128 * compared to current direction. |
|
129 */ |
|
130 TInt iVertCounter; |
|
131 |
|
132 /** |
|
133 * Current position. |
|
134 */ |
|
135 TPoint iPosition; |
|
136 }; |
|
137 |
|
138 } // namespace AknTouchGestureFw |
|
139 |
|
140 #endif // C_AKNTOUCHGESTUREFWDRAGTRACER_H |