|
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: Touch gesture framework pointer state. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_AKNTOUCHGESTUREFWPOINTERSTATE_H |
|
19 #define C_AKNTOUCHGESTUREFWPOINTERSTATE_H |
|
20 |
|
21 #include "akntouchgesturefwutils.h" |
|
22 |
|
23 namespace AknTouchGestureFw { |
|
24 |
|
25 /** |
|
26 * Maximum amount of simultaneous pointers supported by the |
|
27 * touch gesture framework. |
|
28 */ |
|
29 const TInt KMaxPointerCount( 2 ); |
|
30 |
|
31 /** |
|
32 * Represents a single pointer data |
|
33 */ |
|
34 struct TPointerData |
|
35 { |
|
36 TPoint iPosition; |
|
37 TPoint iStartPosition; |
|
38 TBool iIsPressedDown; |
|
39 TBool iTargetedToControl; |
|
40 }; |
|
41 |
|
42 /** |
|
43 * Touch gesture framework pointer state. |
|
44 * |
|
45 * @lib akntouchgesturefw |
|
46 * @since S60 v5.2 |
|
47 */ |
|
48 NONSHARABLE_CLASS( CAknTouchGestureFwPointerState ) : public CBase |
|
49 { |
|
50 |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 static CAknTouchGestureFwPointerState* NewL(); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 */ |
|
61 static CAknTouchGestureFwPointerState* NewLC(); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 */ |
|
66 virtual ~CAknTouchGestureFwPointerState(); |
|
67 |
|
68 /** |
|
69 * Resets pointer state. |
|
70 */ |
|
71 void Reset(); |
|
72 |
|
73 /** |
|
74 * Updates pointer-related data. |
|
75 * |
|
76 * @param aPointerData Pointer event related data. |
|
77 */ |
|
78 TBool Update( const TPointerEventData& aPointerData ); |
|
79 |
|
80 /** |
|
81 * Provides the position of first pointer. |
|
82 * |
|
83 * @return First pointer position. |
|
84 */ |
|
85 TPoint* FirstPointerPosition(); |
|
86 |
|
87 /** |
|
88 * Provides the position of second pointer. |
|
89 * |
|
90 * @return Second pointer position. |
|
91 */ |
|
92 TPoint* SecondPointerPosition(); |
|
93 |
|
94 /** |
|
95 * Returns @c ETrue if two pointers are down. |
|
96 * |
|
97 * @return @c ETrue if two pointer are down. |
|
98 */ |
|
99 TBool IsDoubleTouch() const; |
|
100 |
|
101 /** |
|
102 * Returns @c ETrue if single pointer is down. |
|
103 * |
|
104 * @return @c ETrue if single pointer is down. |
|
105 */ |
|
106 TBool IsSingleTouch() const; |
|
107 |
|
108 /** |
|
109 * Returns @c ETrue if no pointers are down. |
|
110 * |
|
111 * @return @c ETrue if no pointers are down. |
|
112 */ |
|
113 TBool IsNoTouch() const; |
|
114 |
|
115 /** |
|
116 * Returns @c ETrue if event was invalid because of two successive |
|
117 * down events. |
|
118 * |
|
119 * @return @c ETrue if two successive down events were received. |
|
120 */ |
|
121 TBool SuccessiveDownEventsReceived(); |
|
122 |
|
123 private: |
|
124 |
|
125 /** |
|
126 * C++ constructor. |
|
127 */ |
|
128 CAknTouchGestureFwPointerState(); |
|
129 |
|
130 /** |
|
131 * Updates order of pointers. In practice updates variables |
|
132 * @c iFirstPointerNumber an @c iSecondPointerNumber. |
|
133 * |
|
134 * @c iFirstPointerNumber contains always the number (=id) of pointer |
|
135 * that was pressed down first and/or released last. |
|
136 * |
|
137 * @c iSecondPointerNumber contains always the number (=id) of pointer |
|
138 * that was pressed down when first pointer was already down and/or |
|
139 * released first when another pointer was still down. |
|
140 * |
|
141 * @param aPointerType Pointer state |
|
142 * @param aPointerNumber Number (=id) of the pointer |
|
143 */ |
|
144 void UpdatePointerOrder( TPointerEvent::TType aPointerType, |
|
145 TInt aPointerNumber ); |
|
146 |
|
147 /** |
|
148 * Returns @c ETrue if pointer event is valid (for example up received |
|
149 * after down). |
|
150 * |
|
151 * @param aPointerType New pointer state. |
|
152 * @param aPointerNumber Pointer number. |
|
153 * |
|
154 * @return @c ETrue if valid & can be accepted, @c EFalse otherwise. |
|
155 */ |
|
156 TBool IsValidEvent( TPointerEvent::TType aPointerType, |
|
157 TInt aPointerNumber ); |
|
158 |
|
159 /** |
|
160 * Returns @c ETrue if pointers are down outside control area. |
|
161 * |
|
162 * @return @c ETrue if pointers are down outside control area. |
|
163 */ |
|
164 TBool PointersDownOutsideControlArea() const; |
|
165 |
|
166 private: // data |
|
167 |
|
168 /** |
|
169 * Pointer number (=id) of pointer that was pressed down first. |
|
170 */ |
|
171 TInt iFirstPointerNumber; |
|
172 |
|
173 /** |
|
174 * Pointer number (=id) of pointer that was pressed down next. |
|
175 */ |
|
176 TInt iSecondPointerNumber; |
|
177 |
|
178 /** |
|
179 * Data for each pointer. |
|
180 */ |
|
181 TPointerData iPointerData[ KMaxPointerCount ]; |
|
182 |
|
183 /** |
|
184 * Tells number of pointers pressed down. |
|
185 */ |
|
186 TInt iPointerCount; |
|
187 |
|
188 /** |
|
189 * @c ETrue if event was invalid because of two successive down events. |
|
190 * Used only for testing. |
|
191 */ |
|
192 TBool iSuccessiveDownEvents; |
|
193 }; |
|
194 |
|
195 } // namespace AknTouchGestureFw |
|
196 |
|
197 #endif // C_AKNTOUCHGESTUREFWPOINTERSTATE_H |