|
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 to store physics related data in forms. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_CAKNFORMPHYSICS_H |
|
22 #define C_CAKNFORMPHYSICS_H |
|
23 |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <aknphysicsobserveriface.h> |
|
27 |
|
28 |
|
29 class CAknPhysics; |
|
30 class CEikDialogPage; |
|
31 class CAknRecordingGc; |
|
32 |
|
33 /** |
|
34 * ?one_line_short_description |
|
35 * ?more_complete_description |
|
36 * |
|
37 * @code |
|
38 * ?good_class_usage_example(s) |
|
39 * @endcode |
|
40 * |
|
41 * @lib ?library |
|
42 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
43 */ |
|
44 NONSHARABLE_CLASS( CAknFormPhysics ) : public CBase, public MAknPhysicsObserver |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 static CAknFormPhysics* NewL( CEikDialogPage& aParent, CAknRecordingGc& aRecordingGc ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 virtual ~CAknFormPhysics(); |
|
57 |
|
58 /** |
|
59 * Initializes physics engine. |
|
60 * |
|
61 * @since S60 v5.0 |
|
62 * @param aWorldSize Collected size of all form items. |
|
63 * @param aViewSize View's size i.e. size of form's rect. |
|
64 * @param aViewCenter View center's initial position. |
|
65 */ |
|
66 void InitPhysicsL( const TSize& aWorldSize, const TSize& aViewSize, const TPoint& aViewCenter ); |
|
67 |
|
68 /** |
|
69 * Stops the physics engine. |
|
70 * |
|
71 * @since S60 v5.0 |
|
72 */ |
|
73 void Stop(); |
|
74 |
|
75 /** |
|
76 * Starts the physics engine. |
|
77 * |
|
78 * @since S60 v5.0 |
|
79 * @param aLength Length of the flick on display (in pixels). |
|
80 * @param aStartTime Flick's start time. |
|
81 * @return ETrue if flicking was started. |
|
82 */ |
|
83 TBool StartFlick( const TPoint& aLength, const TTime& aStartTime ); |
|
84 |
|
85 /** |
|
86 * Returns highlight timeout. Tapped item should be activated only after a small delay. |
|
87 * |
|
88 * @since S60 v5.0 |
|
89 * @return Highlight delay. |
|
90 */ |
|
91 TInt HighlightDelay() const; |
|
92 |
|
93 |
|
94 /** |
|
95 * Return drag event's treshold. |
|
96 * |
|
97 * @since S60 v5.0 |
|
98 * @return Drag treshold in pixels. |
|
99 */ |
|
100 TInt DragThreshold() const; |
|
101 |
|
102 |
|
103 /** |
|
104 * Returns current view size. |
|
105 * |
|
106 * @since S60 v5.0 |
|
107 * @return View size. |
|
108 */ |
|
109 TSize ViewSize() const; |
|
110 |
|
111 /** |
|
112 * Registers panning position to physics. |
|
113 * |
|
114 * @since S60 v5.0 |
|
115 * @aPosition Position delta. |
|
116 */ |
|
117 void SetPanningPosition( const TPoint& aDelta ); |
|
118 |
|
119 public: // From base class MAknPhysicsObserver. |
|
120 |
|
121 /** |
|
122 * Called when view position changes. |
|
123 * |
|
124 * @param aNewPosition The new position of the view. |
|
125 * @param aDrawNow @c ETrue if the screen is to be redrawn, |
|
126 * otherwise @c EFalse. |
|
127 * @param aFlags Additional flags, not used currently. |
|
128 */ |
|
129 virtual void ViewPositionChanged( const TPoint& aNewPosition, |
|
130 TBool aDrawNow = ETrue, |
|
131 TUint aFlags = 0 ); |
|
132 |
|
133 /** |
|
134 * Physics emulation has stopped moving the view. |
|
135 * |
|
136 * @since S60 v5.0 |
|
137 */ |
|
138 virtual void PhysicEmulationEnded(); |
|
139 |
|
140 /** |
|
141 * Returns the observer's view position. |
|
142 * |
|
143 * @since S60 v5.0 |
|
144 * |
|
145 * @return Physics observer's view position. |
|
146 */ |
|
147 virtual TPoint ViewPosition() const; |
|
148 |
|
149 public: // New methods |
|
150 |
|
151 /** |
|
152 * Checks whether the physics engine can be stopped. |
|
153 * |
|
154 * @since S60 v5.0 |
|
155 * @return ETrue if the physics engine can be stopped. |
|
156 */ |
|
157 TBool CanBeStopped() const; |
|
158 |
|
159 /** |
|
160 * Returns CAknPhysics action code i.e. which action CAknPhysics |
|
161 * is currently performing. |
|
162 * |
|
163 * @since S60 v5.2 |
|
164 * @return TAknPhysicsAction type action code. |
|
165 */ |
|
166 TInt OngoingPhysicsAction() const; |
|
167 |
|
168 /** |
|
169 * Returns view's top y coordinate. |
|
170 * |
|
171 * @since S60 v5.0 |
|
172 * @return View's top y coordinate in pixels, relative to 0. |
|
173 */ |
|
174 TInt ViewTopY() const; |
|
175 |
|
176 /** |
|
177 * Returns distance from view's top to its center. In other words, |
|
178 * ViewPosition() == ViewTopY() + ViewDistance(). |
|
179 * |
|
180 * @since S60 v5.0 |
|
181 * @return Distance from view's top y to its center. |
|
182 */ |
|
183 TInt ViewCenterDistance() const; |
|
184 |
|
185 /** |
|
186 * Sets view center position. |
|
187 * |
|
188 * @since S60 v5.0 |
|
189 */ |
|
190 void SetViewCenter( const TPoint& aPosition ); |
|
191 |
|
192 /** |
|
193 * Return view center position. |
|
194 * |
|
195 * @since S60 v5.0 |
|
196 * @return View center. |
|
197 */ |
|
198 TPoint ViewCenter() const; |
|
199 |
|
200 private: |
|
201 |
|
202 /** |
|
203 * Constructor. |
|
204 */ |
|
205 CAknFormPhysics( CEikDialogPage& aParent, CAknRecordingGc& aRecordingGc ); |
|
206 |
|
207 /** |
|
208 * Second stage constructor. |
|
209 */ |
|
210 void ConstructL(); |
|
211 |
|
212 /** |
|
213 * Checks whether panning and flicking are allowed with current world and |
|
214 * view sizes. |
|
215 * |
|
216 * @since S60 v5.0 |
|
217 * @return ETrue if allowed. |
|
218 */ |
|
219 TBool PhysicsAllowed() const; |
|
220 |
|
221 private: // data |
|
222 /** |
|
223 * Center of the "view" (the visible window to the whole form i.e. form's |
|
224 * virtual rect). |
|
225 */ |
|
226 TPoint iViewCenter; |
|
227 |
|
228 /** |
|
229 * Interface to the physics engine. |
|
230 * Own. |
|
231 */ |
|
232 CAknPhysics* iPhysics; |
|
233 |
|
234 /** |
|
235 * Dialog page whose scrolling is controlled by this class. |
|
236 */ |
|
237 CEikDialogPage& iParent; |
|
238 |
|
239 /** |
|
240 * Graphics context used to cache drawing commands. |
|
241 */ |
|
242 CAknRecordingGc& iRecordingGc; |
|
243 |
|
244 /** |
|
245 * Size of the "world". |
|
246 */ |
|
247 TSize iWorldSize; |
|
248 |
|
249 /** |
|
250 * View size. |
|
251 */ |
|
252 TSize iViewSize; |
|
253 |
|
254 /** |
|
255 * Benchmark timestamp. |
|
256 */ |
|
257 TTime iStartTime; |
|
258 |
|
259 /** |
|
260 * Benchmark frame counter. |
|
261 */ |
|
262 TInt iFrameCount; |
|
263 }; |
|
264 |
|
265 #endif // C_CAKNFORMPHYSICS_H |