emailuis/uicomponents/src/fsfadeeffect.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Fade effect implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //////SYSTEM INCLUDES
       
    21 
       
    22 //////TOOLKIT INCLUDES
       
    23 // <cmail> SF
       
    24 #include "emailtrace.h"
       
    25 #include <alf/alfvisual.h>
       
    26 #include <alf/alftimedvalue.h>
       
    27 #include <alf/alflayout.h>
       
    28 #include <alf/alfenv.h>
       
    29 #include <alf/alfcommand.h>
       
    30 #include <alf/alfcontrol.h>
       
    31 #include <alf/alfevent.h>
       
    32 // </cmail>
       
    33 
       
    34 //////PROJECT INCLUDES
       
    35 //<cmail> removed __FS_ALFRED_SUPPORT flag
       
    36 //#include <fsconfig.h>
       
    37 //</cmail> removed __FS_ALFRED_SUPPORT flag
       
    38 #include "fsfadeeffect.h"
       
    39 //<cmail>
       
    40 #include "fsfadeeffectobserver.h"
       
    41 //</cmail>
       
    42 
       
    43 
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Two-phased constructor.
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CFsFadeEffect* CFsFadeEffect::NewL(CAlfControl* aControl,CAlfVisual* aRoot, TInt aTime)
       
    52     {
       
    53     FUNC_LOG;
       
    54     CFsFadeEffect* self = new (ELeave) CFsFadeEffect(aControl, aRoot, aTime);
       
    55     return self;
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Two-phased constructor.
       
    61 // ---------------------------------------------------------------------------
       
    62 //    
       
    63 CFsFadeEffect* CFsFadeEffect::NewL(
       
    64     CAlfControl* aControl,
       
    65     MFsFadeEffectObserver* aObserver, 
       
    66     CAlfVisual* aRoot, 
       
    67     TInt aTime)
       
    68     {
       
    69     FUNC_LOG;
       
    70     CFsFadeEffect* self = new (ELeave) CFsFadeEffect(aControl, aObserver, aRoot, aTime);    
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Constructor.
       
    77 // ---------------------------------------------------------------------------
       
    78 //    
       
    79 CFsFadeEffect::CFsFadeEffect(CAlfControl* aControl,CAlfVisual* aRoot, TInt aTime)
       
    80     : iControl( aControl ), 
       
    81       iRoot(aRoot), 
       
    82       iTime(aTime)
       
    83     {
       
    84     FUNC_LOG;
       
    85     //No implementation nedeed
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // Constructor.
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 CFsFadeEffect::CFsFadeEffect(
       
    93     CAlfControl* aControl,
       
    94     MFsFadeEffectObserver* aObserver, 
       
    95     CAlfVisual* aRoot, TInt aTime)
       
    96     : iControl( aControl ),
       
    97       iRoot(aRoot),
       
    98       iObserver(aObserver), 
       
    99       iTime(aTime)
       
   100     {
       
   101     FUNC_LOG;
       
   102     //No implementation nedeed
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Launches fade in effect.
       
   107 // ---------------------------------------------------------------------------
       
   108 //    
       
   109 void CFsFadeEffect::FadeIn()
       
   110     {
       
   111     FUNC_LOG;
       
   112     TAlfTimedValue opacity;
       
   113     opacity.SetValueNow( 0 );
       
   114     iRoot->SetOpacity( opacity );
       
   115     
       
   116     opacity.SetTarget( 1.0f, iTime );    
       
   117     iRoot->SetOpacity(opacity); 
       
   118     
       
   119     if (iObserver)
       
   120         {
       
   121         iObserver->FadeEffectEvent(MFsFadeEffectObserver::EFadingIn);
       
   122         }
       
   123     //cancel pending events
       
   124     if ( iControl )
       
   125         {
       
   126         iControl->Env().CancelCustomCommands(this);
       
   127 
       
   128         //send a command to inform about an end of fade out effect
       
   129         TInt error = iControl->Env().Send(TAlfCustomEventCommand(ECustomEventFadeInFinished, this), iTime);
       
   130         if (error != KErrNone)
       
   131             {
       
   132             
       
   133             }
       
   134         }
       
   135     }
       
   136     
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // Launches fade out effect.
       
   140 // ---------------------------------------------------------------------------
       
   141 //        
       
   142 void CFsFadeEffect::FadeOut()
       
   143     {
       
   144     FUNC_LOG;
       
   145     TAlfTimedValue opacity;
       
   146     opacity.SetTarget( 0.0f, iTime ); 
       
   147     iRoot->SetOpacity(opacity);
       
   148     
       
   149     if (iObserver)
       
   150         {
       
   151         iObserver->FadeEffectEvent(MFsFadeEffectObserver::EFadingOut);
       
   152         }
       
   153     
       
   154     //cancel pending events
       
   155     if ( iControl )
       
   156         {
       
   157         iControl->Env().CancelCustomCommands(this);
       
   158 
       
   159         //send a command to inform about an end of fade out effect
       
   160         TInt error = iControl->Env().Send(TAlfCustomEventCommand(ECustomEventFadeOutFinished, this), iTime);
       
   161         if (error != KErrNone)
       
   162             {
       
   163             
       
   164             }
       
   165         }
       
   166     }
       
   167 
       
   168     
       
   169 // ---------------------------------------------------------------------------
       
   170 // Sets speed of fade in/out effect.
       
   171 // ---------------------------------------------------------------------------
       
   172 //        
       
   173 void CFsFadeEffect::SetTime( const TInt aTime)
       
   174     {
       
   175     FUNC_LOG;
       
   176     iTime = aTime;
       
   177     }
       
   178     
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // Returns speed of fade in/out effect.
       
   182 // ---------------------------------------------------------------------------
       
   183 //    
       
   184 TInt CFsFadeEffect::Time() const
       
   185     {
       
   186     FUNC_LOG;
       
   187     return iTime;    
       
   188     }
       
   189 
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // From MAlfEventHandler
       
   193 // Called when an input event is being offered to this object.
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 TBool CFsFadeEffect::OfferEventL(const TAlfEvent& aEvent)
       
   197     {
       
   198     FUNC_LOG;
       
   199     TBool result(EFalse);
       
   200     if( aEvent.IsCustomEvent() )
       
   201         {
       
   202         if ( aEvent.CustomParameter() == ECustomEventFadeInFinished )
       
   203             {
       
   204             result = ETrue;
       
   205             //inform observer
       
   206             if ( iObserver )
       
   207                 {
       
   208                 iObserver->FadeEffectEvent(MFsFadeEffectObserver::EFadeInFinished);
       
   209                 }
       
   210             }
       
   211         else if ( aEvent.CustomParameter() == ECustomEventFadeOutFinished )
       
   212             {
       
   213             result = ETrue;
       
   214             //inform observer
       
   215             if ( iObserver )
       
   216                 {
       
   217                 iObserver->FadeEffectEvent(MFsFadeEffectObserver::EFadeOutFinished);
       
   218                 }
       
   219             }
       
   220         }
       
   221     else
       
   222         {
       
   223         result = EFalse;
       
   224         }
       
   225     
       
   226     return result;
       
   227     }
       
   228 
       
   229 
       
   230 //End Of File
       
   231