24 #include <AknUtils.h> |
24 #include <AknUtils.h> |
25 #include <apgwgnam.h> |
25 #include <apgwgnam.h> |
26 #include <bautils.h> |
26 #include <bautils.h> |
27 #include <barsread.h> |
27 #include <barsread.h> |
28 #include <gulicon.h> |
28 #include <gulicon.h> |
29 #include <gfxtranseffect/gfxtranseffect.h> |
|
30 #include <akntransitionutils.h> |
|
31 #include <avkon.hrh> |
29 #include <avkon.hrh> |
32 #include "akndiscreetpopupcontrol.h" |
30 #include "akndiscreetpopupcontrol.h" |
33 #include "akndiscreetpopupdrawer.h" |
31 #include "akndiscreetpopupdrawer.h" |
34 #include "akntrace.h" |
|
35 |
32 |
36 _LIT( KDiscreetPopupWindowGroupName, "Discreet pop-up" ); |
33 _LIT( KDiscreetPopupWindowGroupName, "Discreet pop-up" ); |
37 |
34 |
|
35 const TInt KOpacityChangeSpeed( 18 ); |
|
36 const TInt KAlphaMax( 255 ); |
|
37 const TInt KAlphaMin( 0 ); |
38 const TInt KShortTimeout( 1500000 ); |
38 const TInt KShortTimeout( 1500000 ); |
39 const TInt KLongTimeout( 3000000 ); |
39 const TInt KLongTimeout( 3000000 ); |
|
40 const TInt KShowDelay( 300000 ); |
|
41 const TInt KShowInterval( 50000 ); |
|
42 const TInt KHideDelay( 50000 ); |
|
43 const TInt KHideInterval( 50000 ); |
40 const TInt KGlobalShowOrdinalPriority( ECoeWinPriorityAlwaysAtFront * 4 ); |
44 const TInt KGlobalShowOrdinalPriority( ECoeWinPriorityAlwaysAtFront * 4 ); |
41 const TInt KLocalShowOrdinalPriority( ECoeWinPriorityNormal + 1 ); |
45 const TInt KLocalShowOrdinalPriority( ECoeWinPriorityNormal + 1 ); |
42 const TInt KLocalHideOrdinalPosition( -10 ); |
46 const TInt KLocalHideOrdinalPosition( -10 ); |
|
47 const TInt KOpacityDismissFactor( 3 ); |
|
48 const TInt KMaxFadeTime( 1000000 ); |
43 |
49 |
44 /** |
50 /** |
45 * Internal discreet popup control flags. |
51 * Internal discreet popup control flags. |
46 */ |
52 */ |
47 enum TAknDiscreetPopupControlFlags |
53 enum TAknDiscreetPopupControlFlags |
48 { |
54 { |
49 EPressedDown, // Pointer down is received in popup area |
55 EPressedDown, // Pointer down is received in popup area |
50 EDismissed, // Popup is dismissed (pointer up is received in popup area) |
56 EDismissed, // Popup is dismissed (pointer up is received in popup area) |
51 EGlobal, // Popup is global |
57 EGlobal, // Popup is global |
52 EDragged, // Pointer is dragged while popup open |
58 EFading, // Popup is closing (fading) |
53 EStartTimerAgain // Start timer again when timer is out and keep pressing |
59 EDragged // Pointer is dragged while popup open |
54 }; |
60 }; |
55 |
61 |
56 |
62 |
57 // ======== MEMBER FUNCTIONS ======== |
63 // ======== MEMBER FUNCTIONS ======== |
58 |
64 |
104 const TDesC& aResourceFile, |
108 const TDesC& aResourceFile, |
105 const TInt& aCommand, |
109 const TInt& aCommand, |
106 const TInt& aPopupId, |
110 const TInt& aPopupId, |
107 MEikCommandObserver* aCommandObserver ) |
111 MEikCommandObserver* aCommandObserver ) |
108 { |
112 { |
109 _AKNTRACE_FUNC_ENTER; |
|
110 CAknDiscreetPopupControl* self = |
113 CAknDiscreetPopupControl* self = |
111 CAknDiscreetPopupControl::NewLC( aGlobal, |
114 CAknDiscreetPopupControl::NewLC( aGlobal, |
112 aCommand, |
115 aCommand, |
113 aPopupId, |
116 aPopupId, |
114 aCommandObserver ); |
117 aCommandObserver ); |
115 |
118 |
116 self->ConstructFromResourceL( aResourceId, aResourceFile ); |
119 self->ConstructFromResourceL( aResourceId, aResourceFile ); |
117 CleanupStack::Pop( self ); |
120 CleanupStack::Pop( self ); |
118 _AKNTRACE_FUNC_EXIT; |
|
119 return self; |
121 return self; |
120 } |
122 } |
121 |
123 |
122 |
124 |
123 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
259 // CAknDiscreetPopupControl::MakeVisible |
253 // CAknDiscreetPopupControl::MakeVisible |
260 // --------------------------------------------------------------------------- |
254 // --------------------------------------------------------------------------- |
261 // |
255 // |
262 void CAknDiscreetPopupControl::MakeVisible( TBool aVisible ) |
256 void CAknDiscreetPopupControl::MakeVisible( TBool aVisible ) |
263 { |
257 { |
|
258 if ( iTimer ) |
|
259 { |
|
260 iTimer->Cancel(); |
|
261 } |
|
262 |
264 CCoeControl::MakeVisible( aVisible ); |
263 CCoeControl::MakeVisible( aVisible ); |
265 |
264 |
266 if( iInternalFlags.IsSet( EGlobal ) ) |
265 if( iInternalFlags.IsSet( EGlobal ) ) |
267 { |
266 { |
268 iWindowGroup.SetOrdinalPosition( 0, KGlobalShowOrdinalPriority ); |
267 iWindowGroup.SetOrdinalPosition( 0, KGlobalShowOrdinalPriority ); |
269 } |
268 } |
270 else |
269 else |
271 { |
270 { |
272 Window().SetOrdinalPosition( 0, KLocalShowOrdinalPriority ); |
271 Window().SetOrdinalPosition( 0, KLocalShowOrdinalPriority ); |
273 } |
272 } |
274 |
273 |
|
274 if ( aVisible && iTimer ) |
|
275 { |
|
276 iAlpha = 0; |
|
277 iInternalFlags.Clear( EFading ); |
|
278 iInternalFlags.Clear( EDismissed ); |
|
279 |
|
280 iTimer->Start( KShowDelay, |
|
281 KShowInterval, |
|
282 TCallBack( TimeOut, this ) ); |
|
283 |
|
284 iFadeTime.HomeTime(); |
|
285 TTimeIntervalMicroSeconds32 timeout( KShowDelay ); |
|
286 iFadeTime += timeout; |
|
287 } |
275 UpdateNonFadingStatus(); |
288 UpdateNonFadingStatus(); |
276 } |
289 } |
277 |
290 |
278 |
291 |
279 // --------------------------------------------------------------------------- |
292 // --------------------------------------------------------------------------- |
410 // CAknDiscreetPopupControl::DoTimeOut |
432 // CAknDiscreetPopupControl::DoTimeOut |
411 // --------------------------------------------------------------------------- |
433 // --------------------------------------------------------------------------- |
412 // |
434 // |
413 void CAknDiscreetPopupControl::DoTimeOut() |
435 void CAknDiscreetPopupControl::DoTimeOut() |
414 { |
436 { |
415 _AKNTRACE_FUNC_ENTER; |
437 if ( iInternalFlags.IsSet( EFading ) && iAlpha <= KAlphaMin ) |
416 if ( !iInternalFlags.IsSet( EPressedDown ) || |
438 { |
417 iInternalFlags.IsSet( EStartTimerAgain ) ) |
439 // popup has faded completely, exit |
418 { |
|
419 TRAP_IGNORE( RequestExitL() ); |
440 TRAP_IGNORE( RequestExitL() ); |
420 } |
441 } |
421 else |
442 else |
422 { |
443 { |
423 iTimer->Cancel(); |
444 TInt opacityChange = |
424 // if time is out and keep pressing, start short timer again. |
445 iInternalFlags.IsSet( EFading ) ? -KOpacityChangeSpeed : KOpacityChangeSpeed; |
425 iInternalFlags.Set( EStartTimerAgain ); |
446 |
426 iTimer->Start( KShortTimeout, |
447 if ( iInternalFlags.IsSet( EPressedDown ) |
427 0, |
448 && iInternalFlags.IsSet( EFading ) ) |
428 TCallBack( TimeOut, this ) ); |
449 { |
429 } |
450 iAlpha = KAlphaMax; |
430 _AKNTRACE_FUNC_EXIT; |
451 opacityChange = 0; |
|
452 } |
|
453 |
|
454 if ( iInternalFlags.IsSet( EDismissed ) ) |
|
455 { |
|
456 opacityChange *= KOpacityDismissFactor; |
|
457 } |
|
458 iAlpha += opacityChange; |
|
459 |
|
460 TTime now; |
|
461 now.HomeTime(); |
|
462 TInt fadeTime( now.MicroSecondsFrom( iFadeTime ).Int64() ); |
|
463 |
|
464 if ( fadeTime > KMaxFadeTime ) |
|
465 { |
|
466 if ( !iInternalFlags.IsSet( EFading ) ) |
|
467 { |
|
468 // fade in animation is taking too long, |
|
469 // make popup fully visible |
|
470 iAlpha = KAlphaMax; |
|
471 } |
|
472 else |
|
473 { |
|
474 // fade out animation is taking too long, |
|
475 // make popup invisible |
|
476 iAlpha = KAlphaMin; |
|
477 } |
|
478 } |
|
479 |
|
480 if ( iAlpha >= KAlphaMax ) |
|
481 { |
|
482 // popup is completely visible. set the EFading flag and set timeout |
|
483 iAlpha = KAlphaMax; |
|
484 iInternalFlags.Set( EFading ); |
|
485 iTimer->Cancel(); |
|
486 //fade out after timeout |
|
487 TTimeIntervalMicroSeconds32 timeout( KShortTimeout ); |
|
488 if ( iFlags & KAknDiscreetPopupDurationLong ) |
|
489 { |
|
490 timeout = KLongTimeout; |
|
491 } |
|
492 iTimer->Start( timeout, |
|
493 KHideInterval, |
|
494 TCallBack( TimeOut, this ) ); |
|
495 |
|
496 iFadeTime.HomeTime(); |
|
497 iFadeTime += timeout; |
|
498 } |
|
499 else if ( iAlpha < KAlphaMin ) |
|
500 { |
|
501 iAlpha = KAlphaMin; |
|
502 } |
|
503 |
|
504 DrawNow(); |
|
505 } |
431 } |
506 } |
432 |
507 |
433 |
508 |
434 // --------------------------------------------------------------------------- |
509 // --------------------------------------------------------------------------- |
435 // CAknDiscreetPopupControl::RequestExitL |
510 // CAknDiscreetPopupControl::RequestExitL |
436 // Popup exit when popup is completely invisible. |
511 // Popup exit when popup is completely invisible. |
437 // --------------------------------------------------------------------------- |
512 // --------------------------------------------------------------------------- |
438 // |
513 // |
439 void CAknDiscreetPopupControl::RequestExitL() |
514 void CAknDiscreetPopupControl::RequestExitL() |
440 { |
515 { |
441 _AKNTRACE_FUNC_ENTER; |
|
442 if( iCommandObserver && !iInternalFlags.IsSet( EGlobal ) ) |
516 if( iCommandObserver && !iInternalFlags.IsSet( EGlobal ) ) |
443 { |
517 { |
444 iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose ); |
518 iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose ); |
445 } |
519 } |
446 HidePopup(); |
520 HidePopup(); |
447 ReportEventL( MCoeControlObserver::EEventRequestExit ); |
521 ReportEventL( MCoeControlObserver::EEventRequestExit ); |
448 iInternalFlags.Clear( EStartTimerAgain ); |
|
449 iInternalFlags.Clear( EPressedDown ); |
522 iInternalFlags.Clear( EPressedDown ); |
450 _AKNTRACE_FUNC_EXIT; |
|
451 } |
523 } |
452 |
524 |
453 |
525 |
454 // --------------------------------------------------------------------------- |
526 // --------------------------------------------------------------------------- |
455 // CAknDiscreetPopupControl::NotifyObserverL |
527 // CAknDiscreetPopupControl::NotifyObserverL |
456 // --------------------------------------------------------------------------- |
528 // --------------------------------------------------------------------------- |
457 // |
529 // |
458 void CAknDiscreetPopupControl::NotifyObserverL() |
530 void CAknDiscreetPopupControl::NotifyObserverL() |
459 { |
531 { |
460 _AKNTRACE_FUNC_ENTER; |
|
461 if ( iCommand != 0 && iCommandObserver ) |
532 if ( iCommand != 0 && iCommandObserver ) |
462 { |
533 { |
463 _AKNTRACE( "CAknDiscreetPopupControl::NotifyObserverL(), tap event will be disposed." ); |
|
464 // Play feedback if there is command associated with the popup |
534 // Play feedback if there is command associated with the popup |
465 if ( iFeedBack ) |
535 ImmediateFeedback( ETouchFeedbackSensitive ); |
466 { |
|
467 iFeedBack->InstantFeedback( this, |
|
468 ETouchFeedbackSensitive, |
|
469 ETouchFeedbackVibra, |
|
470 TPointerEvent() |
|
471 ); |
|
472 } |
|
473 iCommandObserver->ProcessCommandL( iCommand ); |
536 iCommandObserver->ProcessCommandL( iCommand ); |
474 } |
537 } |
475 _AKNTRACE_FUNC_EXIT; |
|
476 } |
538 } |
477 |
539 |
478 |
540 |
479 // ----------------------------------------------------------------------------- |
541 // ----------------------------------------------------------------------------- |
480 // CAknDiscreetPopupControl::ImmediateFeedback |
542 // CAknDiscreetPopupControl::ImmediateFeedback |
560 // CAknDiscreetPopupControl::ShowPopupL |
622 // CAknDiscreetPopupControl::ShowPopupL |
561 // --------------------------------------------------------------------------- |
623 // --------------------------------------------------------------------------- |
562 // |
624 // |
563 void CAknDiscreetPopupControl::ShowPopupL() |
625 void CAknDiscreetPopupControl::ShowPopupL() |
564 { |
626 { |
565 _AKNTRACE_FUNC_ENTER; |
|
566 AppUi()->AddToStackL( |
627 AppUi()->AddToStackL( |
567 this, |
628 this, |
568 ECoeStackPriorityDefault, |
629 ECoeStackPriorityDefault, |
569 ECoeStackFlagRefusesAllKeys | |
630 ECoeStackFlagRefusesAllKeys | |
570 ECoeStackFlagRefusesFocus ); |
631 ECoeStackFlagRefusesFocus ); |
571 |
632 |
572 User::ResetInactivityTime(); |
633 User::ResetInactivityTime(); |
573 |
634 |
574 PlayTone(); |
635 PlayTone(); |
575 |
636 MakeVisible( ETrue ); |
576 if ( GfxTransEffect::IsRegistered( this ) ) |
|
577 { |
|
578 iInternalFlags.Clear( EDismissed ); |
|
579 GfxTransEffect::Begin( this, KGfxControlAppearAction ); |
|
580 MakeVisible( ETrue ); |
|
581 GfxTransEffect::SetDemarcation( this, iPosition ); |
|
582 GfxTransEffect::End( this ); |
|
583 } |
|
584 else |
|
585 { |
|
586 MakeVisible( ETrue ); |
|
587 } |
|
588 |
|
589 TTimeIntervalMicroSeconds32 timeout( KShortTimeout ); |
|
590 |
|
591 if ( iFlags & KAknDiscreetPopupDurationLong ) |
|
592 { |
|
593 timeout = KLongTimeout; |
|
594 } |
|
595 |
|
596 iTimer->Start( timeout, |
|
597 0, |
|
598 TCallBack( TimeOut, this ) ); |
|
599 |
|
600 _AKNTRACE_FUNC_EXIT; |
|
601 } |
637 } |
602 |
638 |
603 |
639 |
604 // --------------------------------------------------------------------------- |
640 // --------------------------------------------------------------------------- |
605 // CAknDiscreetPopupControl::HidePopup |
641 // CAknDiscreetPopupControl::HidePopup |
606 // --------------------------------------------------------------------------- |
642 // --------------------------------------------------------------------------- |
607 // |
643 // |
608 void CAknDiscreetPopupControl::HidePopup() |
644 void CAknDiscreetPopupControl::HidePopup() |
609 { |
645 { |
610 if ( GfxTransEffect::IsRegistered( this ) ) |
646 MakeVisible( EFalse ); |
611 { |
|
612 GfxTransEffect::Begin( this, KGfxControlDisappearAction ); |
|
613 MakeVisible( EFalse ); |
|
614 GfxTransEffect::End( this ); |
|
615 } |
|
616 else |
|
617 { |
|
618 MakeVisible( EFalse ); |
|
619 } |
|
620 |
|
621 AppUi()->RemoveFromStack( this ); |
647 AppUi()->RemoveFromStack( this ); |
622 } |
648 } |
623 |
649 |
624 |
650 |
625 // --------------------------------------------------------------------------- |
651 // --------------------------------------------------------------------------- |
768 // |
811 // |
769 void CAknDiscreetPopupControl::HandlePointerEventL( |
812 void CAknDiscreetPopupControl::HandlePointerEventL( |
770 const TPointerEvent& aPointerEvent ) |
813 const TPointerEvent& aPointerEvent ) |
771 { |
814 { |
772 TBool eventInRect( Rect().Contains( aPointerEvent.iPosition ) ); |
815 TBool eventInRect( Rect().Contains( aPointerEvent.iPosition ) ); |
773 |
816 |
774 // Pointer down - set pressed-down state (popup completely visible while |
817 // Pointer down - set pressed-down state (popup completely visible while |
775 // pressed-down) |
818 // pressed-down) |
776 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
819 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
777 && eventInRect |
820 && eventInRect |
778 && iInternalFlags.IsClear( EDismissed ) ) |
821 && iInternalFlags.IsClear( EDismissed ) ) |
779 { |
822 { |
780 _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Down" ); |
|
781 SetPressedDownState( ETrue ); |
823 SetPressedDownState( ETrue ); |
782 ImmediateFeedback( ETouchFeedbackSensitive ); |
824 // Play feedback only when popup is completely visible (or fading away) |
|
825 if ( iInternalFlags.IsSet( EFading ) ) |
|
826 { |
|
827 ImmediateFeedback( ETouchFeedbackSensitive ); |
|
828 } |
783 } |
829 } |
784 |
830 |
785 // Pointer drag - reset pressed-down state if pointer out of popup area |
831 // Pointer drag - reset pressed-down state if pointer out of popup area |
786 else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
832 else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
787 { |
833 { |
788 _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EDrag" ); |
|
789 iInternalFlags.Set( EDragged ); |
834 iInternalFlags.Set( EDragged ); |
790 if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) ) |
835 if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) ) |
791 { |
836 { |
792 iInternalFlags.Clear( EPressedDown ); |
837 iInternalFlags.Clear( EPressedDown ); |
793 } |
838 } |