|
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: AknPhysics flick tracker |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_AKNPHYSICSFLICKTRACKER_H |
|
19 #define C_AKNPHYSICSFLICKTRACKER_H |
|
20 |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 class CAknPhysicsParameterProvider; |
|
25 |
|
26 /** |
|
27 * Tracker data class |
|
28 * |
|
29 */ |
|
30 NONSHARABLE_CLASS( TAknPhysicsTrackerData ) |
|
31 { |
|
32 |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Flick tracker data coordinate attribute. |
|
37 */ |
|
38 TInt iCoordinate; |
|
39 |
|
40 /** |
|
41 * Flick tracker data time attribute. |
|
42 */ |
|
43 TTime iTime; |
|
44 |
|
45 }; |
|
46 |
|
47 /** |
|
48 * AknPhysics flick tracker |
|
49 * |
|
50 */ |
|
51 NONSHARABLE_CLASS( CAknPhysicsFlickTracker ) : public CBase |
|
52 { |
|
53 |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 */ |
|
59 static CAknPhysicsFlickTracker* NewL( |
|
60 CAknPhysicsParameterProvider* aProvider ); |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 */ |
|
65 static CAknPhysicsFlickTracker* NewLC( |
|
66 CAknPhysicsParameterProvider* aProvider ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 virtual ~CAknPhysicsFlickTracker(); |
|
72 |
|
73 /** |
|
74 * Initializes tracker. |
|
75 * |
|
76 * @param aCoordinate Start coordinate. |
|
77 */ |
|
78 void InitTracker( const TInt& aCoordinate ); |
|
79 |
|
80 /** |
|
81 * Checks if dragging parameters has changed |
|
82 * with new coordinate. |
|
83 * |
|
84 * @param aCoordinate New coordinate. |
|
85 */ |
|
86 void DragChanged( const TInt& aCoordinate ); |
|
87 |
|
88 /** |
|
89 * Returns flick start coordinate. |
|
90 * |
|
91 * @return Flick start coordinate. |
|
92 */ |
|
93 TInt FlickStartCoordinate() const; |
|
94 |
|
95 /** |
|
96 * Returns flick move time. |
|
97 * |
|
98 * @return Flick move time. |
|
99 */ |
|
100 TInt FlickMoveTime() const; |
|
101 |
|
102 private: |
|
103 |
|
104 /** |
|
105 * C++ constructor. |
|
106 */ |
|
107 CAknPhysicsFlickTracker( CAknPhysicsParameterProvider* aProvider ); |
|
108 |
|
109 /** |
|
110 * Symbian second-phase constructor. |
|
111 */ |
|
112 void ConstructL(); |
|
113 |
|
114 /** |
|
115 * Checks if dragging speed has changed. |
|
116 * |
|
117 * @param aCoordinate New drag coordinate. |
|
118 */ |
|
119 void SpeedChanged( const TInt& aCoordinate ); |
|
120 |
|
121 /** |
|
122 * Returns the drag threshold. |
|
123 * |
|
124 * @return Drag threshold. |
|
125 */ |
|
126 TInt Threshold(); |
|
127 |
|
128 /** |
|
129 * Calculates current dragging speed from new drag coordinate. |
|
130 * |
|
131 * @return Dragging speed. |
|
132 */ |
|
133 TInt DragSpeed( const TInt& aNewCoordinate ); |
|
134 |
|
135 /** |
|
136 * Inits tracker data item. |
|
137 * |
|
138 * @param aData Tracker data item. |
|
139 * @param aCoordinate Initial coordinate. |
|
140 */ |
|
141 void InitFlickData( TAknPhysicsTrackerData& aData, |
|
142 const TInt& aCoordinate ); |
|
143 |
|
144 /** |
|
145 * Returns "normal" flick move time. |
|
146 * |
|
147 * @return Flick move time. |
|
148 */ |
|
149 TInt NormalFlickMoveTime() const; |
|
150 |
|
151 private: // data |
|
152 |
|
153 /** |
|
154 * Direction enum. |
|
155 */ |
|
156 enum TDirection |
|
157 { |
|
158 EDirectionNone = 1, |
|
159 EDirectionForward, |
|
160 EDirectionBackward |
|
161 }; |
|
162 |
|
163 /** |
|
164 * Current direction |
|
165 */ |
|
166 TDirection iDirection; |
|
167 |
|
168 /** |
|
169 * Current coordinate. |
|
170 */ |
|
171 TInt iCoordinate; |
|
172 |
|
173 /** |
|
174 * Current direction change data. |
|
175 */ |
|
176 TAknPhysicsTrackerData iDirectionData; |
|
177 |
|
178 /** |
|
179 * "Normal" flick start data (not affected by speed-ups). |
|
180 */ |
|
181 TAknPhysicsTrackerData iNormalStartData; |
|
182 |
|
183 /** |
|
184 * Current speed up data. |
|
185 */ |
|
186 TAknPhysicsTrackerData iSpeedUpData; |
|
187 |
|
188 /** |
|
189 * Speed-up start data. |
|
190 */ |
|
191 TAknPhysicsTrackerData iSpeedUpStartData; |
|
192 |
|
193 /** |
|
194 * ETrue if last direction change is registered. |
|
195 */ |
|
196 TBool iChangeRegistered; |
|
197 |
|
198 /** |
|
199 * ETrue if last speed up is registered. |
|
200 */ |
|
201 TBool iSpeedUpRegistered; |
|
202 |
|
203 /** |
|
204 * Last drag time. |
|
205 */ |
|
206 TTime iLastDragTime; |
|
207 |
|
208 /** |
|
209 * Last drag speed. |
|
210 */ |
|
211 TInt iLastDragSpeed; |
|
212 |
|
213 /** |
|
214 * Count of ignored events since last speed-up. |
|
215 */ |
|
216 TInt iIgnoredEvents; |
|
217 |
|
218 /** |
|
219 * Physics parameter provider. |
|
220 * Not own. |
|
221 */ |
|
222 CAknPhysicsParameterProvider* iProvider; |
|
223 |
|
224 }; |
|
225 |
|
226 #endif // C_AKNPHYSICSFLICKTRACKER_H |