|
1 /* |
|
2 * Copyright (c) 2002-2006 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: View switcher. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef _XNVIEWSWITCHER_H |
|
19 #define _XNVIEWSWITCHER_H |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 #include <akntouchgesturefw.h> |
|
24 |
|
25 // User includes |
|
26 #include "xnviewmanager.h" |
|
27 |
|
28 class CXnViewControlAdapter; |
|
29 |
|
30 using namespace AknTouchGestureFw; |
|
31 |
|
32 // Class declaration |
|
33 |
|
34 /** |
|
35 * This class handles view swithing when "finger follow" feature is used. |
|
36 * The windows of current, next and previous views are moved along with the finger. |
|
37 * Final view switch animation has been handled here as well. |
|
38 * |
|
39 * @ingroup group_xnlayoutengine |
|
40 * @lib xn3layoutengine.lib |
|
41 * @since S60 5.2 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CXnViewSwitcher ) : public CBase |
|
44 { |
|
45 |
|
46 /** |
|
47 * Important information of a view to be dragged. |
|
48 */ |
|
49 struct TViewInformation |
|
50 { |
|
51 CXnControlAdapter* iAdapter; |
|
52 CXnViewData* iViewData; |
|
53 TBool iReadyToDraw; |
|
54 TBool iBgDrawn; |
|
55 }; |
|
56 |
|
57 /** |
|
58 * States for the view swithcing using "finger follow". |
|
59 */ |
|
60 enum TViewSwitchState |
|
61 { |
|
62 KViewSwitchIdle, |
|
63 KViewSwitchBegin, |
|
64 KViewSwitchDragOngoing, |
|
65 KViewSwitchScroll |
|
66 }; |
|
67 |
|
68 public: |
|
69 // Constructors and destructor |
|
70 |
|
71 /** |
|
72 * 2 phase construction. |
|
73 */ |
|
74 static CXnViewSwitcher* NewL(); |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 ~CXnViewSwitcher(); |
|
80 |
|
81 /** |
|
82 * Is finger follow feature activated |
|
83 */ |
|
84 TBool FingerFollowSupported() const; |
|
85 |
|
86 /** |
|
87 * Try to handle and consume pointer event |
|
88 */ |
|
89 TBool ProcessPointerEventL( const TPointerEvent& aPointerEvent ); |
|
90 |
|
91 /** |
|
92 * Check if flick or some gesture occured during drag |
|
93 */ |
|
94 void TouchGesture( TAknTouchGestureFwType& aTouchGesture ); |
|
95 |
|
96 /** |
|
97 * Updates the client rect |
|
98 */ |
|
99 void SizeChanged( TRect aRect ); |
|
100 |
|
101 |
|
102 private: // constructors |
|
103 |
|
104 /** |
|
105 * C++ default constructor |
|
106 */ |
|
107 CXnViewSwitcher(); |
|
108 |
|
109 /** |
|
110 * 2nd phase constructor |
|
111 */ |
|
112 void ConstructL(); |
|
113 |
|
114 /** |
|
115 * View scroll timer callback |
|
116 */ |
|
117 static TInt TimerCallback( TAny *aPtr ); |
|
118 |
|
119 /** |
|
120 * Gets value of finger follow support from AI repository |
|
121 */ |
|
122 TBool IsFingerFollowSupportedL() const; |
|
123 |
|
124 /** |
|
125 * Adjusts current view position. Used in final animation. |
|
126 */ |
|
127 void Scroll(); |
|
128 |
|
129 /** |
|
130 * Moves windows according to the current view position. |
|
131 */ |
|
132 void DoScroll(); |
|
133 |
|
134 /** |
|
135 * Start view dragging by setting up view control adapters |
|
136 */ |
|
137 TBool SetupViewsL(); |
|
138 |
|
139 /** |
|
140 * Layouts and renders the given view out of sight. |
|
141 */ |
|
142 void PrepareViewL( CXnViewSwitcher::TViewInformation& aView ); |
|
143 |
|
144 /** |
|
145 * Removes focused node and sends the up event in order to prevent activate triggers and long tapping. |
|
146 */ |
|
147 void StartViewDraggingL(); |
|
148 |
|
149 /** |
|
150 * Stop view dragging and start view scroll |
|
151 */ |
|
152 void StartViewScrolling(); |
|
153 |
|
154 /** |
|
155 * View scrolling ended. |
|
156 */ |
|
157 void ViewSwitchEndedL(); |
|
158 |
|
159 /** |
|
160 * Get view data |
|
161 */ |
|
162 CXnViewData* ViewData( CXnViewData& aCurrentViewData, TInt aView ); |
|
163 |
|
164 /** |
|
165 * Clear view information of current, next and previous views. |
|
166 */ |
|
167 void ClearViews(); |
|
168 |
|
169 /** |
|
170 * Sets whether next, current or previous view is to be activeted. |
|
171 * Updated also background if needed. |
|
172 */ |
|
173 void UpdateViewToBeActivated( TInt aOffset ); |
|
174 |
|
175 /** |
|
176 * Changes background image and runs NGA effect. |
|
177 */ |
|
178 void ChangeBackground( CXnViewData& aCurrent, CXnViewData& aNext ); |
|
179 |
|
180 private: // data |
|
181 |
|
182 /** |
|
183 * AppUi |
|
184 */ |
|
185 CXnAppUiAdapter& iAppUi; |
|
186 |
|
187 /** |
|
188 * Client rect set by UI Engine |
|
189 */ |
|
190 TRect iRect; |
|
191 |
|
192 /** |
|
193 * Whether the feature is supported or not. ETrue when finger follow is supported |
|
194 */ |
|
195 TBool iFingerFollowSupported; |
|
196 |
|
197 /** |
|
198 * Timer for animating view switch. |
|
199 * Own. |
|
200 */ |
|
201 CPeriodic* iTimer; |
|
202 |
|
203 /** |
|
204 * Important information of the current view. |
|
205 */ |
|
206 TViewInformation iCurrentView; |
|
207 |
|
208 /** |
|
209 * Important information of the view coming from the right side. |
|
210 */ |
|
211 TViewInformation iNextView; |
|
212 |
|
213 /** |
|
214 * Important information of the view coming from the left side. |
|
215 */ |
|
216 TViewInformation iPreviousView; |
|
217 |
|
218 /** |
|
219 * Flick gesture type. |
|
220 */ |
|
221 //TAknTouchGestureFwType iTouchGesture; |
|
222 |
|
223 /** |
|
224 * The state of view switch. |
|
225 */ |
|
226 TViewSwitchState iViewSwitchState; |
|
227 |
|
228 /** |
|
229 * Scroll speed in pixels. |
|
230 */ |
|
231 TInt iScrollSpeed; |
|
232 |
|
233 /** |
|
234 * Total scroll distance from the beginning in mode KViewSwitchDragOngoing. |
|
235 * Remaining distance to be scrolled in mode KViewSwitchScroll. |
|
236 */ |
|
237 TInt iScrollDistance; |
|
238 |
|
239 /** |
|
240 * Measures the scroll distance in current direction. I.e. if direction changes, |
|
241 * this is set to 0. |
|
242 */ |
|
243 TInt iScrollDirectionDistance; |
|
244 |
|
245 /** |
|
246 * Position of the current view in the beginning. |
|
247 */ |
|
248 TPoint iViewStartPosition; |
|
249 |
|
250 /** |
|
251 * Position in the beginning. |
|
252 */ |
|
253 TPoint iStartPosition; |
|
254 |
|
255 /** |
|
256 * Current view position from the beginning. |
|
257 */ |
|
258 TPoint iViewPosition; |
|
259 |
|
260 /** |
|
261 * View to be activated. |
|
262 */ |
|
263 TInt iActivateView; |
|
264 |
|
265 /** |
|
266 * Tick amount to be used when calculating drag speed. |
|
267 */ |
|
268 TInt iTickAmount; |
|
269 |
|
270 /** |
|
271 * Scroll direction. |
|
272 */ |
|
273 TInt iDirection; |
|
274 |
|
275 }; |
|
276 |
|
277 #endif // _XNVIEWSWITCHER_H |
|
278 |
|
279 // End of File |