idlehomescreen/xmluirendering/uiengine/src/xneffectmanager.cpp
branchRCL_3
changeset 12 9674c1a575e9
parent 11 ff572dfe6d86
child 23 7be2816dbabd
equal deleted inserted replaced
11:ff572dfe6d86 12:9674c1a575e9
    14 * Description:  Effect manager.
    14 * Description:  Effect manager.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // System includes
       
    20 #include <eikapp.h>
       
    21 #include <aknappui.h>
       
    22 #include <gfxtranseffect/gfxtranseffect.h>  
       
    23 #include <akntranseffect.h>                 
       
    24 
       
    25 // User includes
    20 #include "xneffectmanager.h"
    26 #include "xneffectmanager.h"
    21 #include "xnplugindata.h"
    27 #include "xnplugindata.h"
    22 #include "xnviewdata.h"
    28 #include "xnviewdata.h"
    23 #include "xnnode.h"
    29 #include "xnnode.h"
    24 #include "xndomnode.h"
    30 #include "xndomnode.h"
    25 #include "xncontroladapter.h"
    31 #include "xncontroladapter.h"
    26 
    32 
    27 // SYSTEM INCLUDE FILES
    33 // Constants
    28 #include <eikapp.h>
       
    29 #include <aknappui.h>
       
    30 #include <gfxtranseffect/gfxtranseffect.h>  // For transition effects
       
    31 #include <akntranseffect.h>                 // For transition effects
       
    32 
       
    33 // CONSTANTS
       
    34 const TInt KWaitForLayout = 1;
    34 const TInt KWaitForLayout = 1;
    35 const TInt KEffectStarted = 2;
    35 const TInt KEffectStarted = 2;
    36 
    36 
    37 // ============================ MEMBER FUNCTIONS ===============================
    37 // ============================ MEMBER FUNCTIONS ===============================
    38 
    38 
    39 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    40 // C++ default constructor.
    40 // CXnEffectManager::CXnEffectManager
       
    41 //
    41 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    42 //
    43 //
    43 CXnEffectManager::CXnEffectManager()
    44 CXnEffectManager::CXnEffectManager()
    44     {
    45     {
    45     }
    46     }
    46 
    47 
    47 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    48 // Symbian 2nd phase constructor.
    49 // CXnEffectManager::ConstructL
       
    50 //
    49 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    50 //
    52 //
    51 void CXnEffectManager::ConstructL()
    53 void CXnEffectManager::ConstructL()
    52     {
    54     {
    53     }
    55     }
    54 
    56 
    55 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    56 // Two-phased constructor.
    58 // CXnEffectManager::NewL
       
    59 //
    57 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    58 //
    61 //
    59 CXnEffectManager* CXnEffectManager::NewL()
    62 CXnEffectManager* CXnEffectManager::NewL()
    60     {
    63     {
    61     CXnEffectManager* self = new (ELeave) CXnEffectManager();
    64     CXnEffectManager* self = new ( ELeave ) CXnEffectManager();
    62     CleanupStack::PushL( self );
    65     CleanupStack::PushL( self );
    63     self->ConstructL();
    66     self->ConstructL();
    64     CleanupStack::Pop( self );
    67     CleanupStack::Pop( self );
    65     return self;
    68     return self;
    66     }
    69     }
    67 
    70 
    68 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    69 // Destructor.
    72 // CXnEffectManager::~CXnEffectManager
       
    73 //
    70 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    71 //
    75 //
    72 CXnEffectManager::~CXnEffectManager()
    76 CXnEffectManager::~CXnEffectManager()
    73     {
    77     {
    74     GfxTransEffect::AbortFullScreen();
    78     GfxTransEffect::AbortFullScreen();
    75     iEffects.ResetAndDestroy();
    79     iEffects.ResetAndDestroy();
    76     }
    80     }
    77 
    81 
    78 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    79 // CXnEffectManager::BeginFullscreenEffectL
    83 // CXnEffectManager::BeginFullscreenEffectL
       
    84 //
    80 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    81 //
    86 //
    82 void CXnEffectManager::BeginFullscreenEffectL( TInt aId, CXnViewData& aView )
    87 void CXnEffectManager::BeginFullscreenEffectL( TInt aId, CXnViewData& aView )
    83     {
    88     {
    84     // Only one fullscreen effect at time
    89     // Only one fullscreen effect at time
   104         }
   109         }
   105     }
   110     }
   106 
   111 
   107 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   108 // CXnEffectManager::UiRendered
   113 // CXnEffectManager::UiRendered
       
   114 //
   109 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   110 //
   116 //
   111 void CXnEffectManager::UiRendered()
   117 void CXnEffectManager::UiRendered()
   112     {
   118     {
   113     for ( TInt i = 0; i < iEffects.Count(); )
   119     for ( TInt i = 0; i < iEffects.Count(); )
   114         {
   120         {
   115         TXnEffect* effect = iEffects[i];
   121         TXnEffect* effect( iEffects[i] );
   116         if ( effect &&
   122         
   117              effect->iState == KEffectStarted )
   123         if ( effect && effect->iState == KEffectStarted )            
   118             {
   124             {
   119             GfxTransEffect::EndFullScreen();
   125             GfxTransEffect::EndFullScreen();
   120             RemoveEffect( effect );
   126             RemoveEffect( effect );
   121             }
   127             }
   122         else
   128         else
   126         }
   132         }
   127     }
   133     }
   128 
   134 
   129 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   130 // CXnEffectManager::UiLayouted
   136 // CXnEffectManager::UiLayouted
       
   137 //
   131 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   132 //
   139 //
   133 void CXnEffectManager::UiLayouted()
   140 void CXnEffectManager::UiLayouted()
   134     {
   141     {
   135     for ( TInt i = 0; i < iEffects.Count(); )
   142     for ( TInt i = 0; i < iEffects.Count(); )
   136         {
   143         {
   137         TBool effectStarted = ETrue;
   144         TBool effectStarted( ETrue );
   138         TXnEffect* effect = iEffects[i];
   145         
       
   146         TXnEffect* effect( iEffects[i] );
       
   147         
   139         if ( effect && effect->iNode &&
   148         if ( effect && effect->iNode &&
   140              effect->iState == KWaitForLayout &&
   149              effect->iState == KWaitForLayout &&
   141              effect->iNode->IsLaidOut() )
   150              effect->iNode->IsLaidOut() )
   142             {
   151             {
   143             effectStarted = DoBeginFullscreenEffect( *effect );
   152             effectStarted = DoBeginFullscreenEffect( *effect );
   155         }
   164         }
   156     }
   165     }
   157 
   166 
   158 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   159 // CXnEffectManager::DoBeginFullscreenEffect
   168 // CXnEffectManager::DoBeginFullscreenEffect
       
   169 //
   160 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   161 //
   171 //
   162 TBool CXnEffectManager::DoBeginFullscreenEffect( TXnEffect& aEffect )
   172 TBool CXnEffectManager::DoBeginFullscreenEffect( TXnEffect& aEffect )
   163     {
   173     {
   164     CCoeEnv* coe( CCoeEnv::Static() );
   174     CCoeEnv* env( CCoeEnv::Static() );
   165            
   175            
   166     if ( coe->WsSession().GetFocusWindowGroup() != 
   176     RWsSession& session( env->WsSession() );
   167          coe->RootWin().Identifier() )
   177     
       
   178     if ( session.GetFocusWindowGroup() != env->RootWin().Identifier() )          
   168         {
   179         {
   169         // Window group is not focused
   180         // Window group is not focused
   170         return EFalse;
   181         return EFalse;
   171         }
   182         }
   172 
   183 
   173     const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel );
   184     const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel );
   174     const TUid targetAppUid( iAvkonAppUi->Application()->AppDllUid() );
   185     const TUid targetAppUid( iAvkonAppUi->Application()->AppDllUid() );
   175 
   186     
       
   187     // Must give some time before starting effect, because otherwise
       
   188     // fullscreen effect may contain unwanted parts (dialog, note, etc.)
       
   189     // which was shown when fullscreen effect is about to be started
       
   190     session.Finish();
       
   191     User::After( 1000 );
       
   192         
   176     // Set effect begin point
   193     // Set effect begin point
   177     GfxTransEffect::BeginFullScreen( aEffect.iId , iAvkonAppUi->ClientRect(),
   194     GfxTransEffect::BeginFullScreen( aEffect.iId , iAvkonAppUi->ClientRect(),
   178         AknTransEffect::EParameterType, AknTransEffect::GfxTransParam(
   195         AknTransEffect::EParameterType, AknTransEffect::GfxTransParam(
   179         targetAppUid, flags ) );
   196         targetAppUid, flags ) );
   180     
   197     
   181     aEffect.iState = KEffectStarted;
   198     aEffect.iState = KEffectStarted;
       
   199     
   182     return ETrue;
   200     return ETrue;
   183     }
   201     }
   184 
   202 
   185 // -----------------------------------------------------------------------------
   203 // -----------------------------------------------------------------------------
   186 // CXnEffectManager::RemoveEffect
   204 // CXnEffectManager::RemoveEffect
       
   205 //
   187 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   188 //
   207 //
   189 void CXnEffectManager::RemoveEffect( TXnEffect* aEffect )
   208 void CXnEffectManager::RemoveEffect( TXnEffect* aEffect )
   190     {
   209     {
   191     TInt index = iEffects.Find( aEffect );
   210     TInt index( iEffects.Find( aEffect ) );
       
   211     
   192     if ( index != KErrNotFound )
   212     if ( index != KErrNotFound )
   193         {
   213         {
   194         TXnEffect* temp = iEffects[index];
   214         TXnEffect* temp( iEffects[index] ); 
   195         iEffects.Remove( index );
       
   196         delete temp;
   215         delete temp;
       
   216         temp = NULL;
       
   217         
       
   218         iEffects.Remove( index );        
   197         }
   219         }
   198     }
   220     }
   199 
   221 
   200 //  End of File
   222 //  End of File