idlehomescreen/xmluirendering/renderingplugins/xnanimationfactory/src/xnanimationadapter.cpp
changeset 5 c743ef5928ba
parent 4 4d54b72983ae
child 9 f966699dea19
equal deleted inserted replaced
4:4d54b72983ae 5:c743ef5928ba
    23 #include "xnproperty.h"
    23 #include "xnproperty.h"
    24 #include "xncontroladapter.h"
    24 #include "xncontroladapter.h"
    25 
    25 
    26 #include "xnanimationadapter.h"
    26 #include "xnanimationadapter.h"
    27 
    27 
    28 const TInt KPeriodicTimerInterval5Sec(100000); // 0.1 sec
       
    29 // ============================ MEMBER FUNCTIONS ===============================
    28 // ============================ MEMBER FUNCTIONS ===============================
    30 
    29 
    31 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    32 // CXnAnimationAdapter::NewL
    31 // CXnAnimationAdapter::NewL
    33 // Symbian static 1st phase constructor
    32 // Symbian static 1st phase constructor
    51 //
    50 //
    52 void CXnAnimationAdapter::ConstructL(CXnNodePluginIf& aNode)
    51 void CXnAnimationAdapter::ConstructL(CXnNodePluginIf& aNode)
    53     {
    52     {
    54     CXnControlAdapter::ConstructL( aNode );
    53     CXnControlAdapter::ConstructL( aNode );
    55     iSkinId = KAknsIIDNone;
    54     iSkinId = KAknsIIDNone;
    56     iAnimationSarted = EFalse;
       
    57     }
    55     }
    58     
    56     
    59 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    60 // CXnAnimationAdapter::CXnAnimationAdapter
    58 // CXnAnimationAdapter::CXnAnimationAdapter
    61 // C++ default constructor
    59 // C++ default constructor
    70 // C++ destructor
    68 // C++ destructor
    71 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    72 //
    70 //
    73 CXnAnimationAdapter::~CXnAnimationAdapter()
    71 CXnAnimationAdapter::~CXnAnimationAdapter()
    74     {
    72     {
    75     if (iPeriodicTimer)
    73     StopAnimation();
    76         {
       
    77         iPeriodicTimer->Cancel();
       
    78         delete iPeriodicTimer;
       
    79         iPeriodicTimer = NULL;
       
    80         }
       
    81     }
    74     }
    82 
    75 
    83 
    76 
    84 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    85 // CXnAnimationAdapter::Draw
    78 // CXnAnimationAdapter::Draw
   106            {
    99            {
   107            const TDesC8& display( aProperty->StringValue() );
   100            const TDesC8& display( aProperty->StringValue() );
   108  
   101  
   109            if( display == XnPropertyNames::style::common::display::KBlock )
   102            if( display == XnPropertyNames::style::common::display::KBlock )
   110                {
   103                {
   111                iDisplay = ETrue; 
       
   112                StartAnimation();
   104                StartAnimation();
   113                }    
   105                }    
   114            else
   106            else
   115                {
   107                {
   116                iDisplay = EFalse;
       
   117                StopAnimation();
   108                StopAnimation();
   118                }
   109                }
   119            }
   110            }
   120         }
   111         }
   121     }
   112     }
   124 // CXnNewstickerAdapter::MakeVisible()
   115 // CXnNewstickerAdapter::MakeVisible()
   125 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
   126 //
   117 //
   127 void CXnAnimationAdapter::MakeVisible( TBool aVisible )
   118 void CXnAnimationAdapter::MakeVisible( TBool aVisible )
   128     {
   119     {
   129     if( aVisible )
   120     TBool visible( IsVisible() ? ETrue : EFalse );
       
   121     if ( visible == aVisible ) { return; }
       
   122     
       
   123     CCoeControl::MakeVisible( aVisible );
       
   124     
       
   125     if ( aVisible )
   130         {
   126         {
   131         StartAnimation();
   127         StartAnimation();
   132         }
   128         }
   133     else
   129     else
   134         {
   130         {
   135         StopAnimation();
   131         StopAnimation();
   136         }
   132         }
   137     CCoeControl::MakeVisible( aVisible );
       
   138     }
   133     }
   139 
   134 
   140 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   141 // CXnAnimationAdapter::Update
   136 // CXnAnimationAdapter::Update
   142 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   143 //
   138 //
   144 void CXnAnimationAdapter::Update()
   139 void CXnAnimationAdapter::Update()
   145     {
   140     {
   146     if (iAnimationSarted )
   141     if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
   147         {
   142         {
   148         switch(iSkinId.iMinor )
   143         switch( iSkinId.iMinor )
   149             {
   144             {
   150             case EAknsMinorGenericQgnHomeRefreshing1:
   145             case EAknsMinorGenericQgnHomeRefreshing1:
   151                 {
   146                 {
   152                 iSkinId.Set(KAknsIIDQgnHomeRefreshing2);
   147                 iSkinId.Set(KAknsIIDQgnHomeRefreshing2);
   153                 }
   148                 }
   181 //
   176 //
   182 TInt CXnAnimationAdapter::TimerCallBack(TAny* aAny)
   177 TInt CXnAnimationAdapter::TimerCallBack(TAny* aAny)
   183     {
   178     {
   184     CXnAnimationAdapter* self = static_cast<CXnAnimationAdapter*> (aAny);
   179     CXnAnimationAdapter* self = static_cast<CXnAnimationAdapter*> (aAny);
   185 
   180 
   186     // Update widget every 5 seconds
   181     // Update widget
   187     self->Update();
   182     self->Update();
   188 
   183 
   189     return KErrNone; // Return value ignored by CPeriodic
   184     return KErrNone; // Return value ignored by CPeriodic
   190     }
   185     }
   191 
   186 
   193 // CXnAnimationAdapter::StartAnimation()
   188 // CXnAnimationAdapter::StartAnimation()
   194 // ----------------------------------------------------------------------------
   189 // ----------------------------------------------------------------------------
   195 //
   190 //
   196 void CXnAnimationAdapter::StartAnimation()
   191 void CXnAnimationAdapter::StartAnimation()
   197     {
   192     {
   198     if ( !iAnimationSarted && iDisplay )
   193     if ( !iPeriodicTimer && IsVisible() )
   199         {
   194         {
   200        TRAPD(err, iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle) );
   195        TRAPD(err, iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle) );
   201        if ( err == KErrNone )
   196        if ( err == KErrNone )
   202            {
   197            {
   203            iPeriodicTimer->Start( KPeriodicTimerInterval5Sec,
   198 		   const TInt KPeriodicTimerInterval = 100000; // 0.1 sec
   204                    KPeriodicTimerInterval5Sec, TCallBack( TimerCallBack, this ) );
   199            iPeriodicTimer->Start( KPeriodicTimerInterval,
       
   200                    KPeriodicTimerInterval, TCallBack( TimerCallBack, this ) );
   205            iSkinId = KAknsIIDQgnHomeRefreshing1;
   201            iSkinId = KAknsIIDQgnHomeRefreshing1;
   206            iAnimationSarted = ETrue;
       
   207            }
   202            }
   208         }
   203         }
   209     }
   204     }
   210 
   205 
   211 // ----------------------------------------------------------------------------
   206 // ----------------------------------------------------------------------------
   212 // CXnAnimationAdapter::StopAnimation()
   207 // CXnAnimationAdapter::StopAnimation()
   213 // ----------------------------------------------------------------------------
   208 // ----------------------------------------------------------------------------
   214 //
   209 //
   215 void CXnAnimationAdapter::StopAnimation()
   210 void CXnAnimationAdapter::StopAnimation()
   216     {
   211     {
   217     if ( iAnimationSarted )
   212     if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
   218         {
   213         {
   219         iPeriodicTimer->Cancel();
   214         iPeriodicTimer->Cancel();
   220         delete iPeriodicTimer;
   215         }
   221         iPeriodicTimer = NULL;
   216     delete iPeriodicTimer;
   222         iSkinId = KAknsIIDNone;
   217     iPeriodicTimer = NULL;
   223         iAnimationSarted = EFalse;
   218     iSkinId = KAknsIIDNone;
   224         }
       
   225     }
   219     }
   226 
   220 
   227 // End of File
   221 // End of File
   228 
   222