|
1 /* |
|
2 * Copyright (c) 2008 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: Effect manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <eikapp.h> |
|
21 #include <aknappui.h> |
|
22 #include <gfxtranseffect/gfxtranseffect.h> |
|
23 #include <akntranseffect.h> |
|
24 #include <alf/alfcompositionutility.h> |
|
25 #include <layoutmetadata.cdl.h> |
|
26 |
|
27 // User includes |
|
28 #include "xnappuiadapter.h" |
|
29 #include "xnbackgroundmanager.h" |
|
30 #include "xneffectmanager.h" |
|
31 #include "xnplugindata.h" |
|
32 #include "xnviewdata.h" |
|
33 #include "xnviewadapter.h" |
|
34 #include "xnnode.h" |
|
35 #include "xndomnode.h" |
|
36 #include "xncontroladapter.h" |
|
37 |
|
38 // Constants |
|
39 const TInt KWaitForLayout( 1 ); |
|
40 const TInt KEffectStarted( 2 ); |
|
41 |
|
42 const TInt KControlEffectWaitInterval( 100000 ); // 100ms |
|
43 const TInt KFullScreenEffectWaitInterval( 300000 ); // 300ms |
|
44 const TInt KWaitInterval( 25000 ); // 25ms |
|
45 const TInt KInterval( 500000 ); |
|
46 |
|
47 #define IS_VALID( e ) \ |
|
48 ( e == KGfxContextActivateNextView || \ |
|
49 e == KGfxContextActivatePrevView ) |
|
50 |
|
51 // ============================ LOCAL FUNCTIONS ================================ |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CXnEffectManager::CXnEffectManager |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CXnEffectManager::CXnEffectManager( CXnAppUiAdapter& aAppUiAdapter ) |
|
60 : CTimer( CActive::EPriorityIdle ), iAppUiAdapter( aAppUiAdapter ), |
|
61 iGroupId( -1 ) |
|
62 { |
|
63 CActiveScheduler::Add( this ); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CXnEffectManager::ConstructL |
|
68 // |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CXnEffectManager::ConstructL() |
|
72 { |
|
73 CTimer::ConstructL(); |
|
74 |
|
75 OrientationChanged(); |
|
76 |
|
77 iObserver = CAlfEffectObserver::NewL(); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CXnEffectManager::NewL |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CXnEffectManager* CXnEffectManager::NewL( CXnAppUiAdapter& aAppUiAdapter ) |
|
86 { |
|
87 CXnEffectManager* self = new ( ELeave ) CXnEffectManager( aAppUiAdapter ); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CXnEffectManager::~CXnEffectManager |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CXnEffectManager::~CXnEffectManager() |
|
100 { |
|
101 Cancel(); |
|
102 |
|
103 delete iObserver; |
|
104 |
|
105 iControls.Reset(); |
|
106 |
|
107 iEffects.Reset(); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CXnEffectManager::RunL |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CXnEffectManager::RunL() |
|
116 { |
|
117 // No implementation required |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CXnEffectManager::BeginFullscreenEffectL |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CXnEffectManager::BeginFullscreenEffectL( TInt aId, CXnViewData& aView ) |
|
126 { |
|
127 TXnEffect effect; |
|
128 |
|
129 effect.iId = aId; |
|
130 effect.iNode = aView.ViewNode(); |
|
131 |
|
132 if ( !aView.ViewNode()->IsLaidOut() ) |
|
133 { |
|
134 effect.iState = KWaitForLayout; |
|
135 |
|
136 iEffects.AppendL( effect ); |
|
137 } |
|
138 else |
|
139 { |
|
140 if ( DoBeginFullscreenEffect( effect ) ) |
|
141 { |
|
142 iEffects.AppendL( effect ); |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CXnEffectManager::BeginFullscreenEffectL |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CXnEffectManager::BeginFullscreenEffectL( TInt aId ) |
|
153 { |
|
154 TXnEffect effect; |
|
155 |
|
156 effect.iId = aId; |
|
157 effect.iExplicitEnd = ETrue; |
|
158 |
|
159 if ( DoBeginFullscreenEffect( effect ) ) |
|
160 { |
|
161 iEffects.AppendL( effect ); |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CXnEffectManager::EndFullscreenEffect |
|
167 // |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CXnEffectManager::EndFullscreenEffect( TInt aId ) |
|
171 { |
|
172 for ( TInt i = 0; i < iEffects.Count(); i++ ) |
|
173 { |
|
174 TXnEffect& effect( iEffects[i] ); |
|
175 |
|
176 if ( effect.iId == aId && |
|
177 effect.iExplicitEnd && |
|
178 effect.iState == KEffectStarted ) |
|
179 { |
|
180 GfxTransEffect::EndFullScreen(); |
|
181 |
|
182 iEffects.Remove( i ); |
|
183 break; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CXnEffectManager::UiRendered |
|
190 // |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void CXnEffectManager::UiRendered() |
|
194 { |
|
195 for ( TInt i = 0; i < iEffects.Count(); ) |
|
196 { |
|
197 TXnEffect& effect( iEffects[i] ); |
|
198 |
|
199 if ( effect.iState == KEffectStarted && !effect.iExplicitEnd ) |
|
200 { |
|
201 GfxTransEffect::EndFullScreen(); |
|
202 |
|
203 iEffects.Remove( i ); |
|
204 } |
|
205 else |
|
206 { |
|
207 i++; |
|
208 } |
|
209 } |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CXnEffectManager::UiLayouted |
|
214 // |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CXnEffectManager::UiLayouted() |
|
218 { |
|
219 for ( TInt i = 0; i < iEffects.Count(); ) |
|
220 { |
|
221 TBool started( ETrue ); |
|
222 |
|
223 TXnEffect& effect( iEffects[i] ); |
|
224 |
|
225 if ( effect.iNode && effect.iState == KWaitForLayout && |
|
226 effect.iNode->IsLaidOut() ) |
|
227 { |
|
228 started = DoBeginFullscreenEffect( effect ); |
|
229 } |
|
230 |
|
231 if ( !started ) |
|
232 { |
|
233 iEffects.Remove( i ); |
|
234 } |
|
235 else |
|
236 { |
|
237 i++; |
|
238 } |
|
239 } |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CXnEffectManager::DoBeginFullscreenEffect |
|
244 // |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 TBool CXnEffectManager::DoBeginFullscreenEffect( TXnEffect& aEffect ) |
|
248 { |
|
249 if ( !iAppUiAdapter.IsForeground() ) |
|
250 { |
|
251 // Not in foreground |
|
252 return EFalse; |
|
253 } |
|
254 |
|
255 if ( !WaitActiveEffect( KFullScreenEffectWaitInterval ) ) |
|
256 { |
|
257 return EFalse; |
|
258 } |
|
259 |
|
260 const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel ); |
|
261 const TUid targetAppUid( iAppUiAdapter.Application()->AppDllUid() ); |
|
262 |
|
263 // Set effect begin point |
|
264 GfxTransEffect::BeginFullScreen( aEffect.iId , iAppUiAdapter.ClientRect(), |
|
265 AknTransEffect::EParameterType, AknTransEffect::GfxTransParam( |
|
266 targetAppUid, flags ) ); |
|
267 |
|
268 aEffect.iState = KEffectStarted; |
|
269 |
|
270 return ETrue; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CXnEffectManager::WaitActiveEffect |
|
275 // |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 TBool CXnEffectManager::WaitActiveEffect( TInt aInterval ) |
|
279 { |
|
280 TBool retval( EFalse ); |
|
281 |
|
282 TInt loop( aInterval / KWaitInterval ); |
|
283 |
|
284 while ( loop >= 0 ) |
|
285 { |
|
286 TInt count( iObserver->ActiveEffectsCount() ); |
|
287 |
|
288 if ( count == 0 ) |
|
289 { |
|
290 retval = ETrue; |
|
291 break; |
|
292 } |
|
293 |
|
294 User::After( KWaitInterval ); |
|
295 loop--; |
|
296 } |
|
297 |
|
298 return retval; |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CXnEffectManager::BeginActivateViewEffect |
|
303 // |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 TBool CXnEffectManager::BeginActivateViewEffect( const CXnViewData& aThis, |
|
307 const CXnViewData& aOther, TUid aEffect ) |
|
308 { |
|
309 CleanupControlEffect(); |
|
310 |
|
311 if ( !IS_VALID( aEffect ) ) |
|
312 { |
|
313 // Not a valid view switch effect uid |
|
314 return EFalse; |
|
315 } |
|
316 |
|
317 CXnControlAdapter* thisView( aThis.ViewNode()->Control() ); |
|
318 CXnControlAdapter* otherView( aOther.ViewNode()->Control() ); |
|
319 |
|
320 if ( thisView == otherView ) |
|
321 { |
|
322 // Same controls |
|
323 return EFalse; |
|
324 } |
|
325 |
|
326 if ( IsActive() ) |
|
327 { |
|
328 Cancel(); |
|
329 After( KInterval ); |
|
330 |
|
331 return EFalse; |
|
332 } |
|
333 |
|
334 if ( !WaitActiveEffect( KControlEffectWaitInterval ) ) |
|
335 { |
|
336 After( KInterval ); |
|
337 |
|
338 return EFalse; |
|
339 } |
|
340 |
|
341 iControls.Append( thisView ); |
|
342 iControls.Append( otherView ); |
|
343 |
|
344 GfxTransEffect::Register( thisView, aEffect ); |
|
345 GfxTransEffect::Register( otherView, aEffect ); |
|
346 |
|
347 iGroupId = GfxTransEffect::BeginGroup(); |
|
348 |
|
349 CFbsBitmap* currentBg( aThis.WallpaperImage() ); |
|
350 CFbsBitmap* nextBg( aOther.WallpaperImage() ); |
|
351 |
|
352 if ( currentBg || nextBg ) |
|
353 { |
|
354 CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() ); |
|
355 |
|
356 iControls.Append( bg ); |
|
357 |
|
358 if ( !currentBg && nextBg ) |
|
359 { |
|
360 GfxTransEffect::Begin( bg, KGfxControlActionBgAnimToImgAppear ); |
|
361 } |
|
362 else |
|
363 { |
|
364 GfxTransEffect::Begin( bg, KGfxControlActionBgImgToImgAppear ); |
|
365 } |
|
366 |
|
367 iBgEffect = ETrue; |
|
368 } |
|
369 |
|
370 // because of changes in nga end has to call here. Effects below are |
|
371 // grouped and those will be triggered when calling GfxTransEffect::EndGroup |
|
372 if ( iLandscape ) |
|
373 { |
|
374 GfxTransEffect::Begin( thisView, KGfxControlActionDisappearLsc ); |
|
375 GfxTransEffect::Begin( otherView, KGfxControlActionAppearLsc ); |
|
376 |
|
377 GfxTransEffect::SetDemarcation( otherView, otherView->Position() ); |
|
378 GfxTransEffect::End( otherView ); |
|
379 |
|
380 GfxTransEffect::SetDemarcation( thisView, thisView->Position() ); |
|
381 GfxTransEffect::End( thisView ); |
|
382 } |
|
383 else |
|
384 { |
|
385 GfxTransEffect::Begin( thisView, KGfxControlActionDisappearPrt ); |
|
386 GfxTransEffect::Begin( otherView, KGfxControlActionAppearPrt ); |
|
387 |
|
388 GfxTransEffect::SetDemarcation( otherView, otherView->Position() ); |
|
389 GfxTransEffect::End( otherView ); |
|
390 |
|
391 GfxTransEffect::SetDemarcation( thisView, thisView->Position() ); |
|
392 GfxTransEffect::End( thisView ); |
|
393 } |
|
394 |
|
395 return ETrue; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CXnEffectManager::EndActivateViewEffect |
|
400 // |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 void CXnEffectManager::EndActivateViewEffect( const CXnViewData& aThis, |
|
404 const CXnViewData& aOther, TUid aEffect ) |
|
405 { |
|
406 if ( !IS_VALID( aEffect ) || iGroupId == -1 ) |
|
407 { |
|
408 // Not a valid view switch effect uid or group effect is not started |
|
409 return; |
|
410 } |
|
411 |
|
412 CXnControlAdapter* thisView( aThis.ViewNode()->Control() ); |
|
413 CXnControlAdapter* otherView( aOther.ViewNode()->Control() ); |
|
414 |
|
415 if ( iBgEffect ) |
|
416 { |
|
417 CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() ); |
|
418 |
|
419 GfxTransEffect::SetDemarcation( bg, bg->Position() ); |
|
420 GfxTransEffect::End( bg ); |
|
421 } |
|
422 |
|
423 GfxTransEffect::EndGroup( iGroupId ); |
|
424 |
|
425 GfxTransEffect::Deregister( otherView ); |
|
426 GfxTransEffect::Deregister( thisView ); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CXnEffectManager::BgAppearEffect |
|
431 // |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 void CXnEffectManager::BgAppearEffect( CCoeControl* aBg, TBool aWaitActiveEffect ) |
|
435 { |
|
436 if ( aWaitActiveEffect ) |
|
437 { |
|
438 WaitActiveEffect( KFullScreenEffectWaitInterval ); |
|
439 } |
|
440 |
|
441 GfxTransEffect::Begin( aBg, KGfxControlActionBgImgToImgAppear ); |
|
442 |
|
443 GfxTransEffect::SetDemarcation( aBg, aBg->Position() ); |
|
444 GfxTransEffect::End( aBg ); |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CXnEffectManager::Cleanup |
|
449 // |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 void CXnEffectManager::CleanupControlEffect() |
|
453 { |
|
454 iBgEffect = EFalse; |
|
455 iGroupId = -1; |
|
456 |
|
457 iControls.Reset(); |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CXnEffectManager::ControlEffectActive |
|
462 // |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 TBool CXnEffectManager::ControlEffectActive( const CCoeControl* aControl ) const |
|
466 { |
|
467 TInt index( iControls.Find( aControl ) ); |
|
468 |
|
469 return index != KErrNotFound; |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CXnEffectManager::OrientationChanged |
|
474 // |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 void CXnEffectManager::OrientationChanged() |
|
478 { |
|
479 iLandscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
480 } |
|
481 |
|
482 // End of File |