|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "GfxTransImpl.h" |
|
17 #include "GfxTransUtils.h" |
|
18 #include "TransitionControl.h" |
|
19 #include "RegisteredControl.h" |
|
20 #include "GfxTransEffectPanic.h" |
|
21 #include <coecntrl.h> |
|
22 |
|
23 // |
|
24 // |
|
25 |
|
26 const TUid CGfxTransEffect::KTransEffectUid = {0x102822A6}; |
|
27 |
|
28 // |
|
29 // Construction/Destruction |
|
30 // |
|
31 |
|
32 CGfxTransEffect::CGfxTransEffect() : |
|
33 CCoeStatic(KTransEffectUid,-1,CCoeStatic::EApp), |
|
34 iEnabled(ETrue) |
|
35 { |
|
36 iCreateHandle = 0; |
|
37 } |
|
38 |
|
39 CGfxTransEffect::~CGfxTransEffect() |
|
40 { |
|
41 delete iPolicyHandler; |
|
42 |
|
43 iInTransition.ResetAndDestroy(); |
|
44 iInTransition.Close(); |
|
45 |
|
46 iRegistered.ResetAndDestroy(); |
|
47 iRegistered.Close(); |
|
48 |
|
49 iActiveStack.ResetAndDestroy(); |
|
50 iActiveStack.Close(); |
|
51 |
|
52 MGfxTransAdapter::Destroy(iAdapter); |
|
53 } |
|
54 |
|
55 TInt CGfxTransEffect::Construct() |
|
56 { |
|
57 TRAPD(err,iAdapter = MGfxTransAdapter::CreateL(this)); |
|
58 if(err != KErrNone) |
|
59 { |
|
60 return err; |
|
61 } |
|
62 iPolicyHandler = new CPolicyHandler(); |
|
63 if(!iPolicyHandler) |
|
64 { |
|
65 return KErrNoMemory; |
|
66 } |
|
67 // Get policies from engine |
|
68 TInt count; |
|
69 TControlPolicy *policies = iAdapter->GetTransitionPolicies(count); |
|
70 if(count > 0 && policies != NULL) |
|
71 { |
|
72 // the policyhandler handles the memory cleanup |
|
73 iPolicyHandler->SetTransitionPolicies(policies, count); |
|
74 } |
|
75 return KErrNone; |
|
76 } |
|
77 |
|
78 CGfxTransEffect* CGfxTransEffect::Static(const CCoeControl * aControl) |
|
79 { |
|
80 CGfxTransEffect *singleton = StaticNoCreate(aControl); |
|
81 if(!singleton) |
|
82 { |
|
83 singleton = new CGfxTransEffect; |
|
84 if(NULL == singleton) |
|
85 { |
|
86 return NULL; |
|
87 } |
|
88 if(KErrNone != singleton->Construct()) |
|
89 { |
|
90 delete singleton; |
|
91 singleton=NULL; |
|
92 return NULL; |
|
93 } |
|
94 __ASSERT_ALWAYS(aControl->ControlEnv()->FindStatic(KTransEffectUid) == singleton,Panic(EGfxTransEffectFindStatic)); |
|
95 } |
|
96 __ASSERT_ALWAYS(singleton,Panic(EGfxTransEffectNotSingleton)); |
|
97 return singleton; |
|
98 } |
|
99 |
|
100 CGfxTransEffect* CGfxTransEffect::StaticNoCreate(const CCoeControl * aControl) |
|
101 { |
|
102 __ASSERT_DEBUG(aControl,Panic(KErrArgument)); |
|
103 if (!aControl->ControlEnv()) |
|
104 { |
|
105 return NULL; |
|
106 } |
|
107 return reinterpret_cast<CGfxTransEffect*>(aControl->ControlEnv()->FindStatic(KTransEffectUid)); |
|
108 } |
|
109 CGfxTransEffect* CGfxTransEffect::Static() |
|
110 { |
|
111 if (!CCoeEnv::Static()) |
|
112 { |
|
113 return NULL; |
|
114 } |
|
115 CGfxTransEffect *singleton = reinterpret_cast<CGfxTransEffect*>(CCoeEnv::Static(KTransEffectUid)); |
|
116 if(!singleton) |
|
117 { |
|
118 singleton = new CGfxTransEffect; |
|
119 if(NULL == singleton) |
|
120 { |
|
121 return NULL; |
|
122 } |
|
123 if(KErrNone != singleton->Construct()) |
|
124 { |
|
125 delete singleton; |
|
126 singleton=NULL; |
|
127 return NULL; |
|
128 } |
|
129 __ASSERT_ALWAYS(CCoeEnv::Static(KTransEffectUid) == singleton,Panic(EGfxTransEffectNotSingleton)); |
|
130 } |
|
131 __ASSERT_ALWAYS(singleton,Panic(EGfxTransEffectNotSingleton)); |
|
132 return singleton; |
|
133 } |
|
134 |
|
135 CGfxTransEffect* CGfxTransEffect::StaticNoCreate() |
|
136 { |
|
137 if (!CCoeEnv::Static()) |
|
138 { |
|
139 return NULL; |
|
140 } |
|
141 return reinterpret_cast<CGfxTransEffect*>(CCoeEnv::Static(KTransEffectUid)); |
|
142 } |
|
143 |
|
144 // |
|
145 // API implementation |
|
146 // |
|
147 //--------------------------------- |
|
148 // registration |
|
149 //--------------------------------- |
|
150 void CGfxTransEffect::Register(const CCoeControl * aKey,const TVwsViewId &aView,TUid aType) |
|
151 { |
|
152 const TInt idx = FindRegistration(aKey); |
|
153 if(IsValidIndex(idx)) // previously registered! update. |
|
154 { |
|
155 iRegistered[idx]->SetUid(aType); |
|
156 iRegistered[idx]->SetViewId(aView); |
|
157 iRegistered[idx]->SetType(CRegisteredControl::EView); |
|
158 iRegistered[idx]->SetRegistered(ETrue); |
|
159 } |
|
160 else |
|
161 { |
|
162 if(CRegisteredControl* regctrl = new CRegisteredControl(aKey,aView,aType)) |
|
163 { |
|
164 if(KErrNone != iRegistered.Append(regctrl)) |
|
165 { |
|
166 //Failed to add, probably due to memory constraints. Fail silently without registering. |
|
167 delete regctrl; |
|
168 } |
|
169 } |
|
170 } |
|
171 } |
|
172 void CGfxTransEffect::Register(const CCoeControl * aKey,TUid aType,TBool aNLayered) |
|
173 { |
|
174 const TInt idx = FindRegistration(aKey); |
|
175 if(IsValidIndex(idx)) // previously registered! update. |
|
176 { |
|
177 iRegistered[idx]->SetUid(aType); |
|
178 iRegistered[idx]->SetNLayered(aNLayered); |
|
179 iRegistered[idx]->SetType(CRegisteredControl::ECoeControl); |
|
180 iRegistered[idx]->SetRegistered(ETrue); |
|
181 } |
|
182 else |
|
183 { |
|
184 if(CRegisteredControl* regctrl = new CRegisteredControl(aKey,aType,aNLayered)) |
|
185 { |
|
186 if(KErrNone != iRegistered.Append(regctrl)) |
|
187 { |
|
188 //Failed to add, probably due to memory constraints. Fail silently without registering. |
|
189 delete regctrl; |
|
190 } |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 TBool CGfxTransEffect::IsRegistered(const CCoeControl * aKey) |
|
196 { |
|
197 const TInt idx = FindRegistration(aKey); |
|
198 return (IsValidIndex(idx) && iRegistered[idx]->Registered()); |
|
199 } |
|
200 |
|
201 void CGfxTransEffect::Deregister(const CCoeControl * aKey) |
|
202 { |
|
203 const TInt idx = FindRegistration(aKey); |
|
204 if(IsValidIndex(idx)) |
|
205 { |
|
206 CRegisteredControl* regctrl = iRegistered[idx]; |
|
207 TInt activeidx = iActiveStack.Find(regctrl); |
|
208 if(IsValidIndex(activeidx)) |
|
209 { |
|
210 //deregisters between begin and end aborts transition. |
|
211 Abort(aKey); |
|
212 } |
|
213 if(regctrl->InTransitionCount() > 0) |
|
214 { |
|
215 //If in transition, set registered flag to EFalse |
|
216 regctrl->SetRegistered(EFalse); |
|
217 //and reset all transition data (such as remotegc) |
|
218 regctrl->ResetTransitions(); |
|
219 //and draw now |
|
220 regctrl->Control()->DrawNow(); |
|
221 } |
|
222 else |
|
223 { |
|
224 //no ongoing transitions - so remove |
|
225 iRegistered.Remove(idx); |
|
226 #ifdef _DEBUG |
|
227 iRegistered.Compress(); //for __UHEAP_MARK tests. |
|
228 #endif |
|
229 delete regctrl; |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 //--------------------------------- |
|
235 // Begin/End |
|
236 //--------------------------------- |
|
237 void CGfxTransEffect::Begin(const CCoeControl * aKey,TUint aAction) |
|
238 { |
|
239 const TInt regidx = FindRegistration(aKey); |
|
240 if(!IsValidIndex(regidx) || !(iRegistered[regidx]->Registered())) |
|
241 { |
|
242 return; //Unregistered controls are silently ignored. |
|
243 } |
|
244 CRegisteredControl* regctrl = iRegistered[regidx]; |
|
245 |
|
246 //get policy |
|
247 TPolicy policy; |
|
248 if(!IsEnabled() || !iAdapter->IsActive()) |
|
249 { |
|
250 policy = ENotSupported; |
|
251 } |
|
252 else |
|
253 { |
|
254 policy = iPolicyHandler->GetPolicy(regctrl->Uid(), aAction); |
|
255 } |
|
256 |
|
257 //reset active and ongoing transitions for this registered control |
|
258 if(policy == ESupported) |
|
259 { |
|
260 regctrl->ResetTransitions(); |
|
261 } |
|
262 |
|
263 //Create a new transition control |
|
264 CTransitionControl *transctrl; |
|
265 if(NULL == (transctrl = CTransitionControl::New(regctrl, this, aAction, policy, CreateTransitionHandle()))) |
|
266 { |
|
267 return; |
|
268 } |
|
269 |
|
270 //add transition to the registered control |
|
271 if(KErrNone != regctrl->AddTransition(transctrl)) |
|
272 { |
|
273 delete transctrl; |
|
274 return; |
|
275 } |
|
276 |
|
277 //add to stack |
|
278 if(KErrNone != iActiveStack.Push(transctrl)) |
|
279 { |
|
280 delete transctrl; |
|
281 return; |
|
282 } |
|
283 |
|
284 |
|
285 // if supported: Capture Begin state |
|
286 iAdapter->HandleClientState(MGfxTransAdapter::EPreBeginCapture, aKey, transctrl->Handle()); |
|
287 |
|
288 transctrl->CaptureBegin(); |
|
289 |
|
290 iAdapter->HandleClientState(MGfxTransAdapter::EPostBeginCapture, aKey, transctrl->Handle()); |
|
291 } |
|
292 |
|
293 void CGfxTransEffect::BeginLC(const CCoeControl * aKey,TUint aAction) |
|
294 { |
|
295 const TInt regidx = FindRegistration(aKey); |
|
296 if(!IsValidIndex(regidx) || !(iRegistered[regidx]->Registered())) |
|
297 { |
|
298 return; //Unregistered controls are silently ignored. |
|
299 } |
|
300 CRegisteredControl* regctrl = iRegistered[regidx]; |
|
301 |
|
302 TPolicy policy; |
|
303 if(!IsEnabled() || !iAdapter->IsActive()) |
|
304 { |
|
305 policy = ENotSupported; |
|
306 } |
|
307 else |
|
308 { |
|
309 policy = iPolicyHandler->GetPolicy(regctrl->Uid(), aAction); |
|
310 } |
|
311 |
|
312 //reset active and ongoing transitions for this registered control |
|
313 if(policy == ESupported) |
|
314 { |
|
315 regctrl->ResetTransitions(); |
|
316 } |
|
317 |
|
318 //Create a new transition control |
|
319 CTransitionControl *transctrl = NULL; |
|
320 if(NULL == (transctrl = CTransitionControl::New(regctrl, this, aAction, policy, CreateTransitionHandle()))) |
|
321 { |
|
322 return; |
|
323 } |
|
324 |
|
325 //add transition to the registered control |
|
326 if(KErrNone != regctrl->AddTransition(transctrl)) |
|
327 { |
|
328 delete transctrl; |
|
329 return; |
|
330 } |
|
331 |
|
332 //add to stack |
|
333 if(KErrNone != iActiveStack.PushLC(transctrl)) |
|
334 { |
|
335 delete transctrl; |
|
336 return; |
|
337 } |
|
338 |
|
339 iAdapter->HandleClientState(MGfxTransAdapter::EPreBeginCapture, aKey, transctrl->Handle()); |
|
340 |
|
341 //capture begin |
|
342 transctrl->CaptureBegin(); |
|
343 |
|
344 iAdapter->HandleClientState(MGfxTransAdapter::EPostBeginCapture, aKey, transctrl->Handle()); |
|
345 } |
|
346 |
|
347 void CGfxTransEffect::End(const CCoeControl * aKey) |
|
348 { |
|
349 CTransitionControl* transctrl = NULL; |
|
350 |
|
351 TInt idx = iActiveStack.Find(aKey); |
|
352 |
|
353 //Fallback if the control isn't in the iActiveStack |
|
354 if(!IsValidIndex(idx)) |
|
355 { |
|
356 Fallback(aKey); |
|
357 return; |
|
358 } |
|
359 |
|
360 iActiveStack.ClearAbove(idx); |
|
361 |
|
362 transctrl = iActiveStack.Top(); |
|
363 if(!transctrl) |
|
364 { |
|
365 Fallback(aKey); |
|
366 return; |
|
367 } |
|
368 |
|
369 iAdapter->HandleClientState(MGfxTransAdapter::EPreEndCapture, transctrl->RegControl()->Control(), transctrl->Handle()); |
|
370 |
|
371 //capture end |
|
372 transctrl->CaptureEnd(); |
|
373 |
|
374 iAdapter->HandleClientState(MGfxTransAdapter::EPostEndCapture, transctrl->RegControl()->Control(), transctrl->Handle()); |
|
375 |
|
376 //pop control from stack |
|
377 iActiveStack.Pop(); |
|
378 |
|
379 |
|
380 if(!transctrl->Failed()) |
|
381 { |
|
382 // start the transition |
|
383 if( (transctrl->Policy() == ESupported)) |
|
384 { |
|
385 //add control to InTranstionList |
|
386 if(KErrNone != iInTransition.Append(transctrl)) |
|
387 { |
|
388 delete transctrl; |
|
389 Fallback(aKey); |
|
390 return; |
|
391 } |
|
392 iAdapter->StartTransition(transctrl->Handle()); |
|
393 if((0 < iInTransition.Count()) && (transctrl == iInTransition[iInTransition.Count() - 1])) |
|
394 { |
|
395 transctrl->SetListenForUpdates(ETrue); |
|
396 } |
|
397 } |
|
398 // if not supported: draw the updated parts of the control |
|
399 else |
|
400 { |
|
401 RRegion region; |
|
402 if(KErrNone != transctrl->GetUpdatedRegion(region)) |
|
403 { |
|
404 delete transctrl; |
|
405 Fallback(aKey); |
|
406 return; |
|
407 } |
|
408 TInt count = region.Count(); |
|
409 for(TInt i = 0; i < count; i++) |
|
410 { |
|
411 aKey->DrawNow(region[i]); |
|
412 } |
|
413 region.Close(); |
|
414 delete transctrl; |
|
415 } |
|
416 } |
|
417 else |
|
418 { |
|
419 delete transctrl; |
|
420 Fallback(aKey); |
|
421 return; |
|
422 } |
|
423 } |
|
424 |
|
425 //--------------------------------- |
|
426 // NotifyExternalState |
|
427 //--------------------------------- |
|
428 |
|
429 void CGfxTransEffect::NotifyExternalState(TInt aState, const TDesC8* aArg) |
|
430 { |
|
431 iAdapter->NotifyExternalState(aState,aArg); |
|
432 } |
|
433 |
|
434 //--------------------------------- |
|
435 // Abort |
|
436 //--------------------------------- |
|
437 |
|
438 void CGfxTransEffect::Abort(const CCoeControl * aKey) |
|
439 { |
|
440 //abort current begin-end pair |
|
441 CTransitionControl *current = iActiveStack.Top(); |
|
442 if(current && current->RegControl()->Control() == aKey) |
|
443 { |
|
444 iActiveStack.Pop(); |
|
445 iAdapter->HandleClientState(MGfxTransAdapter::EAbort, aKey, current->Handle()); |
|
446 delete current; |
|
447 } |
|
448 } |
|
449 |
|
450 // global abort |
|
451 void CGfxTransEffect::Abort() |
|
452 { |
|
453 CTransitionControl *current = iActiveStack.Top(); |
|
454 |
|
455 // inform the engine |
|
456 if(current) |
|
457 { |
|
458 iAdapter->HandleClientState(MGfxTransAdapter::EGlobalAbort, current->RegControl()->Control(), 0); |
|
459 } |
|
460 |
|
461 // delete all transitions in active stack |
|
462 while(current) |
|
463 { |
|
464 iActiveStack.Pop(); |
|
465 iAdapter->HandleClientState(MGfxTransAdapter::EAbort, current->RegControl()->Control(), current->Handle()); |
|
466 delete current; |
|
467 current = iActiveStack.Top(); |
|
468 } |
|
469 |
|
470 // abort all transitions in InTransition list |
|
471 TInt const count = iInTransition.Count(); |
|
472 for(TInt i = 0; i < count; i++) |
|
473 { |
|
474 iAdapter->HandleClientState(MGfxTransAdapter::EAbort, iInTransition[i]->RegControl()->Control(), iInTransition[i]->Handle()); |
|
475 //no removal, wait for TransitionFinished from the server |
|
476 } |
|
477 } |
|
478 |
|
479 //--------------------------------- |
|
480 // Hints |
|
481 //--------------------------------- |
|
482 void CGfxTransEffect::SetHints(const CCoeControl * aControl,TUint aFlags) |
|
483 { |
|
484 //first check the active stack for registered controls |
|
485 TInt idx = iActiveStack.Find(aControl); |
|
486 if(IsValidIndex(idx)) |
|
487 { |
|
488 iActiveStack[idx]->SetHints(aControl, aFlags); |
|
489 return; |
|
490 } |
|
491 // if not a registered control is active stack |
|
492 // check if it is a registered control |
|
493 idx = FindRegistration(aControl); |
|
494 if(IsValidIndex(idx)) |
|
495 { |
|
496 iRegistered[idx]->SetFlags(aFlags); |
|
497 } |
|
498 // Also test if aControl is a layer in a transition |
|
499 idx = iActiveStack.Find(aControl->Parent()); |
|
500 if(IsValidIndex(idx)) |
|
501 { |
|
502 iActiveStack[idx]->SetHints(aControl, aFlags); |
|
503 return; |
|
504 } |
|
505 } |
|
506 |
|
507 TUint CGfxTransEffect::GetHints(const CCoeControl * aControl) |
|
508 { |
|
509 // first check if it is a registered control |
|
510 TInt idx = FindRegistration(aControl); |
|
511 if(IsValidIndex(idx)) |
|
512 { |
|
513 return iRegistered[idx]->Flags(); |
|
514 } |
|
515 // check if it is a subcontrol in an active transition |
|
516 idx = iActiveStack.Find(aControl->Parent()); |
|
517 if(IsValidIndex(idx)) |
|
518 { |
|
519 return iActiveStack[idx]->GetHints(aControl); |
|
520 } |
|
521 return GfxTransEffect::ENone; |
|
522 } |
|
523 |
|
524 void CGfxTransEffect::SetHints(const CCoeControl * aControl,TUid aLayerType) |
|
525 { |
|
526 TInt idx = iActiveStack.Find(aControl); |
|
527 if(!IsValidIndex(idx)) |
|
528 { |
|
529 idx = iActiveStack.Find(aControl->Parent()); |
|
530 if(!IsValidIndex(idx)) |
|
531 { |
|
532 return; |
|
533 } |
|
534 } |
|
535 iActiveStack[idx]->SetHints(aControl, aLayerType); |
|
536 } |
|
537 |
|
538 void CGfxTransEffect::Invalidate(const CCoeControl * aControl) |
|
539 { |
|
540 TInt idx = iActiveStack.Find(aControl); |
|
541 if(!IsValidIndex(idx)) |
|
542 { |
|
543 idx = iActiveStack.Find(aControl->Parent()); |
|
544 if(!IsValidIndex(idx)) |
|
545 { |
|
546 return; |
|
547 } |
|
548 } |
|
549 iActiveStack[idx]->Invalidate(aControl); |
|
550 } |
|
551 |
|
552 //--------------------------------- |
|
553 // Demarcation |
|
554 //--------------------------------- |
|
555 void CGfxTransEffect::SetDemarcation(const CCoeControl * aControl,TPoint const &aDemarcation) |
|
556 { |
|
557 TInt idx = iActiveStack.Find(aControl); |
|
558 if(!IsValidIndex(idx)) |
|
559 { |
|
560 idx = iActiveStack.Find(aControl->Parent()); |
|
561 if(!IsValidIndex(idx)) |
|
562 { |
|
563 return; |
|
564 } |
|
565 } |
|
566 iActiveStack[idx]->DoSetDemarcation(aControl, TRect(aDemarcation, TSize(0,0))); |
|
567 } |
|
568 |
|
569 void CGfxTransEffect::SetDemarcation(TVwsViewId const &aView,TPoint const &aDemarcation) |
|
570 { |
|
571 TInt idx = iActiveStack.FindView(aView); |
|
572 if(!IsValidIndex(idx)) |
|
573 { |
|
574 return; |
|
575 } |
|
576 iActiveStack[idx]->DoSetDemarcation(iActiveStack[idx]->RegControl()->Control(), |
|
577 TRect(aDemarcation, TSize(0,0))); |
|
578 } |
|
579 |
|
580 void CGfxTransEffect::SetDemarcation(const CCoeControl * aControl,TRect const &aDemarcation) |
|
581 { |
|
582 TInt idx = iActiveStack.Find(aControl); |
|
583 if(!IsValidIndex(idx)) |
|
584 { |
|
585 idx = iActiveStack.Find(aControl->Parent()); |
|
586 if(!IsValidIndex(idx)) |
|
587 { |
|
588 return; |
|
589 } |
|
590 } |
|
591 iActiveStack[idx]->DoSetDemarcation(aControl, aDemarcation); |
|
592 } |
|
593 |
|
594 void CGfxTransEffect::SetDemarcation(TVwsViewId const &aView,TRect const &aDemarcation) |
|
595 { |
|
596 TInt idx = iActiveStack.FindView(aView); |
|
597 if(!IsValidIndex(idx)) |
|
598 { |
|
599 return; |
|
600 } |
|
601 iActiveStack[idx]->DoSetDemarcation(iActiveStack[idx]->RegControl()->Control(), aDemarcation); |
|
602 } |
|
603 |
|
604 void CGfxTransEffect::SetDemarcation(const CCoeControl * aControl,const CCoeControl * aSrc,TRect const &aDemarcation) |
|
605 { |
|
606 TInt idx = iActiveStack.Find(aControl); |
|
607 if(!IsValidIndex(idx)) |
|
608 { |
|
609 idx = iActiveStack.Find(aControl->Parent()); |
|
610 if(!IsValidIndex(idx)) |
|
611 { |
|
612 return; |
|
613 } |
|
614 } |
|
615 iActiveStack[idx]->DoSetDemarcation(aControl, aSrc, aDemarcation); |
|
616 } |
|
617 |
|
618 void CGfxTransEffect::SetDemarcation(TVwsViewId const &aView,const CCoeControl * aSrc,TRect const &aDemarcation) |
|
619 { |
|
620 TInt idx = iActiveStack.FindView(aView); |
|
621 if(!IsValidIndex(idx)) |
|
622 { |
|
623 return; |
|
624 } |
|
625 iActiveStack[idx]->DoSetDemarcation(iActiveStack[idx]->RegControl()->Control(), |
|
626 aSrc, aDemarcation); |
|
627 } |
|
628 |
|
629 //--------------------------------- |
|
630 // Adapter state |
|
631 //--------------------------------- |
|
632 void CGfxTransEffect::Enable() |
|
633 { |
|
634 iAdapter->IsActive(); |
|
635 iEnabled = ETrue; //enable regardless if engine IsActive or not. |
|
636 } |
|
637 |
|
638 void CGfxTransEffect::Disable() |
|
639 { |
|
640 Abort(); |
|
641 iEnabled = EFalse; |
|
642 } |
|
643 |
|
644 //--------------------------------- |
|
645 // API additions |
|
646 //--------------------------------- |
|
647 void CGfxTransEffect::SetEndDemarcation(const CCoeControl* aControl, const TRect& aDemarcation) |
|
648 { |
|
649 TInt idx = iActiveStack.Find(aControl); |
|
650 if(!IsValidIndex(idx)) |
|
651 { |
|
652 idx = iActiveStack.Find(aControl->Parent()); |
|
653 if(!IsValidIndex(idx)) |
|
654 { |
|
655 return; |
|
656 } |
|
657 } |
|
658 iActiveStack[idx]->DoSetEndDemarcation(aControl, aDemarcation); |
|
659 } |
|
660 |
|
661 void CGfxTransEffect::SetBeginDemarcation(const CCoeControl* aControl, const TRect& aDemarcation) |
|
662 { |
|
663 TInt idx = iActiveStack.Find(aControl); |
|
664 if(!IsValidIndex(idx)) |
|
665 { |
|
666 idx = iActiveStack.Find(aControl->Parent()); |
|
667 if(!IsValidIndex(idx)) |
|
668 { |
|
669 return; |
|
670 } |
|
671 } |
|
672 iActiveStack[idx]->DoSetBeginDemarcation(aControl, aDemarcation); |
|
673 } |
|
674 |
|
675 TInt CGfxTransEffect::BeginGroup() |
|
676 { |
|
677 TInt groupId = CreateTransitionHandle(); |
|
678 iAdapter->HandleClientState(MGfxTransAdapter::EBeginGroup, NULL, groupId); |
|
679 return groupId; |
|
680 } |
|
681 |
|
682 void CGfxTransEffect::EndGroup(TInt aGroupId) |
|
683 { |
|
684 iAdapter->HandleClientState(MGfxTransAdapter::EEndGroup, NULL, aGroupId); |
|
685 } |
|
686 |
|
687 void CGfxTransEffect::SetTransitionData(TUint aType, const TDesC8& aData) |
|
688 { |
|
689 CTransitionControl *aTransControl = iActiveStack.Top(); |
|
690 if(aTransControl) |
|
691 { |
|
692 aTransControl->SetTransitionData(aType, aData); |
|
693 } |
|
694 } |
|
695 |
|
696 void CGfxTransEffect::SetTransitionObserver(MGfxTransEffectObserver *aObserver) |
|
697 { |
|
698 iObserver = aObserver; |
|
699 } |
|
700 |
|
701 //--------------------------------- |
|
702 // Draw item controls |
|
703 //--------------------------------- |
|
704 void CGfxTransEffect::RegisterDrawItemControl(const CCoeControl *aControl, TUid aType) |
|
705 { |
|
706 const TInt idx = FindRegistration(aControl); |
|
707 if(IsValidIndex(idx)) // previously registered! update. |
|
708 { |
|
709 iRegistered[idx]->SetUid(aType); |
|
710 iRegistered[idx]->SetType(CRegisteredControl::EDrawItemControl); |
|
711 } |
|
712 else |
|
713 { |
|
714 if(CRegisteredControl* regctrl = new CRegisteredControl(aControl,aType)) |
|
715 { |
|
716 if(KErrNone != iRegistered.Append(regctrl)) |
|
717 { |
|
718 //Failed to add, probably due to memory constraints. Fail silently without registring. |
|
719 delete regctrl; |
|
720 } |
|
721 } |
|
722 } |
|
723 } |
|
724 |
|
725 void CGfxTransEffect::BeginDrawItem(const CCoeControl */*aControl*/, TUint /*aId*/, TUid /*aType*/,TRect &/*aDrawRect*/, const TRect */*aFromRect*/, const TRect */*aToRect*/) |
|
726 { |
|
727 // Will be implemented later |
|
728 } |
|
729 |
|
730 void CGfxTransEffect::EndDrawItem(const CCoeControl */*aControl*/) |
|
731 { |
|
732 // Will be implemented later |
|
733 } |
|
734 //--------------------------------- |
|
735 // Full screen effects |
|
736 //--------------------------------- |
|
737 void CGfxTransEffect::BeginFullScreen(TUint aAction, const TRect &aEffectArea) |
|
738 { |
|
739 iAdapter->BeginFullScreen(aAction, aEffectArea); |
|
740 } |
|
741 |
|
742 void CGfxTransEffect::BeginFullScreen(TUint aAction, const TRect &aEffectArea, TUint aType, const TDesC8& aParams) |
|
743 { |
|
744 iAdapter->BeginFullScreen(aAction, aEffectArea, aType, aParams); |
|
745 } |
|
746 |
|
747 void CGfxTransEffect::EndFullScreen() |
|
748 { |
|
749 iAdapter->EndFullScreen(); |
|
750 } |
|
751 |
|
752 void CGfxTransEffect::AbortFullScreen() |
|
753 { |
|
754 iAdapter->AbortFullScreen(); |
|
755 } |
|
756 |
|
757 |
|
758 |
|
759 // |
|
760 // Internal functions |
|
761 // |
|
762 //--------------------------------- |
|
763 // Registration handling |
|
764 //--------------------------------- |
|
765 TInt CGfxTransEffect::FindRegistration(const CCoeControl * aControl) const |
|
766 { |
|
767 const TInt count = iRegistered.Count(); |
|
768 for(TInt i=0; i<count; i++) |
|
769 { |
|
770 if(aControl == iRegistered[i]->Control()) |
|
771 { |
|
772 return i; |
|
773 } |
|
774 } |
|
775 return KErrNotFound; |
|
776 } |
|
777 |
|
778 TInt CGfxTransEffect::FindRegistration(TVwsViewId const &aViewId) const |
|
779 { |
|
780 const TInt count = iRegistered.Count(); |
|
781 for(TInt i=0; i<count; i++) |
|
782 { |
|
783 if(aViewId == iRegistered[i]->ViewId()) |
|
784 { |
|
785 return i; |
|
786 } |
|
787 } |
|
788 return KErrNotFound; |
|
789 } |
|
790 |
|
791 //--------------------------------- |
|
792 // Fallback |
|
793 //--------------------------------- |
|
794 void CGfxTransEffect::Fallback(const CCoeControl * aKey) |
|
795 { |
|
796 iAdapter->HandleClientState(MGfxTransAdapter::EFallback, aKey, 0); |
|
797 aKey->DrawNow(); |
|
798 } |
|
799 |
|
800 //--------------------------------- |
|
801 // Transition Handle |
|
802 //--------------------------------- |
|
803 TInt CGfxTransEffect::CreateTransitionHandle() |
|
804 { |
|
805 if(iCreateHandle == 0) |
|
806 iCreateHandle = 1; |
|
807 iCreateHandle++; |
|
808 return iCreateHandle; |
|
809 } |
|
810 |
|
811 //--------------------------------- |
|
812 // MGfxTransDataProvider |
|
813 //--------------------------------- |
|
814 void CGfxTransEffect::TransitionPolicyUpdate(TControlPolicy* aPolicy) |
|
815 { |
|
816 iPolicyHandler->UpdatePolicy(aPolicy->iId, aPolicy->iAction, aPolicy->iPolicy); |
|
817 delete aPolicy; |
|
818 } |
|
819 |
|
820 void CGfxTransEffect::TransitionFinished(TInt aHandle) |
|
821 { |
|
822 TInt idx = iInTransition.Find(aHandle); |
|
823 if(IsValidIndex(idx)) |
|
824 { |
|
825 //remove from intransition list |
|
826 CTransitionControl *transcontrol = iInTransition[idx]; |
|
827 iInTransition.Remove(idx); |
|
828 CRegisteredControl *regcontrol = transcontrol->RegControl(); |
|
829 // save callback data |
|
830 TUint action = transcontrol->Action(); |
|
831 const CCoeControl *control = regcontrol->Control(); |
|
832 // delete data and reset remotegc |
|
833 delete transcontrol; |
|
834 if(regcontrol->InTransitionCount() == 0) |
|
835 { |
|
836 if(!(regcontrol->Registered())) |
|
837 { |
|
838 TInt regidx = iRegistered.Find(regcontrol); |
|
839 if(IsValidIndex(regidx)) |
|
840 { |
|
841 iRegistered.Remove(regidx); |
|
842 } |
|
843 delete regcontrol; |
|
844 } |
|
845 else |
|
846 { |
|
847 control->DrawNow(); |
|
848 } |
|
849 } |
|
850 if(iObserver) |
|
851 { |
|
852 iObserver->TransitionFinished(control, action); |
|
853 } |
|
854 } |
|
855 } |
|
856 |
|
857 TInt CGfxTransEffect::GetTransitionData(TInt aHandle, const CTransitionData*& aTransData) |
|
858 { |
|
859 //try to find in active stack |
|
860 TInt idx = iActiveStack.Find(aHandle); |
|
861 if(IsValidIndex(idx)) |
|
862 { |
|
863 iActiveStack[idx]->GetTransitionData(aTransData); |
|
864 return KErrNone; |
|
865 } |
|
866 //try to find in InTransition stack |
|
867 idx = iInTransition.Find(aHandle); |
|
868 if(IsValidIndex(idx)) |
|
869 { |
|
870 iInTransition[idx]->GetTransitionData(aTransData); |
|
871 return KErrNone; |
|
872 } |
|
873 // not found |
|
874 return KErrNotFound; |
|
875 } |
|
876 |
|
877 void CGfxTransEffect::ClearAllPolicies() |
|
878 { |
|
879 iPolicyHandler->SetTransitionPolicies(NULL, 0); |
|
880 } |
|
881 |
|
882 //--------------------------------- |
|
883 // MTransitionControlObserver |
|
884 //--------------------------------- |
|
885 void CGfxTransEffect::ParticipantUpdated(CTransitionControl *aTransControl, CTransitionParticipant *aParticipant, |
|
886 RWsGraphicMsgBuf* aCommandBuffer, const TRect& aDrawRect, const TRect& aBoundingRect) |
|
887 { |
|
888 |
|
889 iAdapter->HandleParticpantUpdate(aTransControl->Handle(), aParticipant->Data(), aCommandBuffer, aDrawRect, aBoundingRect); |
|
890 } |
|
891 |