menufw/menufwui/mmwidgets/src/mmdraweranimator.cpp
branchRCL_3
changeset 19 79311d856354
parent 1 5315654608de
child 26 1b758917cafc
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  
    14  * Description:
    15 *  Version     : %version: MM_41 % << Don't touch! Updated by Synergy at check-out.
    15  *  Version     : %version: MM_41 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16  *
    17 */
    17  */
    18 
    18 
    19 #include <AknUtils.h>
    19 #include <AknUtils.h>
    20 
    20 
    21 #include "mmdraweranimator.h"
    21 #include "mmdraweranimator.h"
    22 #include "mmlistboxitemdrawer.h"
    22 #include "mmlistboxitemdrawer.h"
    23 #include "mmfloatingitem.h"
    23 #include "mmfloatingitem.h"
    24 #include "mmwidgetcontainer.h"
    24 #include "mmwidgetcontainer.h"
    25 
    25 
    26 
    26 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
    27 //
    28 //
    28 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    29 //
    30 // 
    30 CMmDrawerAnimator::CMmDrawerAnimator( CMmListBoxItemDrawer& aDrawer ) :
    31 CMmDrawerAnimator::CMmDrawerAnimator(CMmListBoxItemDrawer& aDrawer) :
    31     CActive( AknLayoutUtils::PenEnabled()
    32     CActive( AknLayoutUtils::PenEnabled() ?
    32         ? EPriorityAbsoluteVeryLow
    33     		EPriorityRealTime : 
    33         : EPriorityAbsoluteRealTime8 ), iDrawer( aDrawer ),
    34 			EPriorityAbsoluteRealTime8 ), iDrawer(aDrawer), 
       
    35     iLastNotedHighlight( KErrNotFound ), iLastNotedTopItem( KErrNotFound ),
    34     iLastNotedHighlight( KErrNotFound ), iLastNotedTopItem( KErrNotFound ),
    36     iLastNotedVerticalOffset( 0 ),
    35     iLastNotedVerticalOffset( 0 ),
    37     iUsualAnimationFramesCount( AknLayoutUtils::PenEnabled() ?
    36     iUsualAnimationFramesCount( AknLayoutUtils::PenEnabled()
    38     		MmEffects::KUsualAnimationFramesCount : 
    37                     ? MmEffects::KUsualAnimationFramesCount
    39 			MmEffects::KUsualAnimationFramesCountNonTouch )
    38                     : MmEffects::KUsualAnimationFramesCountNonTouch ),
    40     {
    39     iPreparedForGarbage( EFalse )
    41     }
    40     {
    42 
    41     }
    43 // -----------------------------------------------------------------------------
    42 
    44 //
    43 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    44 //
    46 // 
    45 // -----------------------------------------------------------------------------
    47 CMmDrawerAnimator* CMmDrawerAnimator::NewLC(CMmListBoxItemDrawer& aDrawer)
    46 //
    48     {
    47 CMmDrawerAnimator* CMmDrawerAnimator::NewLC( CMmListBoxItemDrawer& aDrawer )
    49     CMmDrawerAnimator* self = new ( ELeave ) CMmDrawerAnimator(aDrawer);
    48     {
    50     CleanupStack::PushL(self);
    49     CMmDrawerAnimator* self = new ( ELeave ) CMmDrawerAnimator( aDrawer );
       
    50     CleanupStack::PushL( self );
    51     self->ConstructL();
    51     self->ConstructL();
    52     return self;
    52     return self;
    53     }
    53     }
    54 
    54 
    55 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    56 //
    56 //
    57 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    58 // 
    58 //
    59 CMmDrawerAnimator* CMmDrawerAnimator::NewL(CMmListBoxItemDrawer& aDrawer)
    59 CMmDrawerAnimator* CMmDrawerAnimator::NewL( CMmListBoxItemDrawer& aDrawer )
    60     {
    60     {
    61     CMmDrawerAnimator* self = CMmDrawerAnimator::NewLC(aDrawer);
    61     CMmDrawerAnimator* self = CMmDrawerAnimator::NewLC( aDrawer );
    62     CleanupStack::Pop( self );
    62     CleanupStack::Pop( self );
    63     return self;
    63     return self;
    64     }
    64     }
    65 
    65 
    66 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    67 //
    67 //
    68 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    69 // 
    69 //
    70 void CMmDrawerAnimator::ConstructL()
    70 void CMmDrawerAnimator::ConstructL()
    71     {
    71     {
    72     User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
    72     User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
    73     CActiveScheduler::Add( this); // Add to scheduler
    73     CActiveScheduler::Add( this ); // Add to scheduler
    74     iPreparedForGarbage = EFalse;
    74     }
    75     }
    75 
    76 
    76 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    77 //
    78 //
    78 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    79 //
    80 // 
       
    81 CMmDrawerAnimator::~CMmDrawerAnimator()
    80 CMmDrawerAnimator::~CMmDrawerAnimator()
    82     {
    81     {
    83     Cancel(); // Cancel any request, if outstanding
    82     Cancel(); // Cancel any request, if outstanding
    84     iTimer.Close(); // Destroy the RTimer object
    83     iTimer.Close(); // Destroy the RTimer object
    85     // Delete instance variables if any
    84     // Delete instance variables if any
    86     }
    85     }
    87 
    86 
    88 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    89 //
    88 //
    90 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    91 // 
    90 //
    92 void CMmDrawerAnimator::DoCancel()
    91 void CMmDrawerAnimator::DoCancel()
    93     {
    92     {
    94     iTimer.Cancel();
    93     iTimer.Cancel();
    95     }
    94     if( iDrawer.GetFloatingItemCount() == 0 )
    96 
    95         {
    97 // -----------------------------------------------------------------------------
    96         TRAP_IGNORE(TriggerMoveItemL());
    98 //
    97         }
    99 // -----------------------------------------------------------------------------
    98     }
   100 // 
    99 
   101 TBool CMmDrawerAnimator::CancelNextRedrawL()
   100 // -----------------------------------------------------------------------------
   102 	{
   101 //
   103 	RunL();
   102 // -----------------------------------------------------------------------------
   104     TTime currentTime;
   103 //
   105     currentTime.HomeTime();
       
   106     return (currentTime.MicroSecondsFrom(iLastRedrawTime) 
       
   107     		<= MmEffects::KAnimationFrameDelay);
       
   108 	}
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 // -----------------------------------------------------------------------------
       
   112 // 
       
   113 void CMmDrawerAnimator::RunL()
   104 void CMmDrawerAnimator::RunL()
   114     {      
   105     {
   115 	if ( iPreparedForGarbage )
   106     if( iPreparedForGarbage )
   116 		{
   107         {
   117 		return;
   108         return;
   118 		}
   109         }
   119 	
   110 
   120     TTime currentTime;
   111     if( iDrawer.GetFloatingItemCount() > 0 )
   121     currentTime.HomeTime();
   112         {
   122 	
   113         TRect refreshRect;
   123    if (currentTime.MicroSecondsFrom(iLastRedrawTime) 
   114         for( int i = 0; i < iDrawer.GetFloatingItemCount(); i++ )
   124     		>= MmEffects::KAnimationFrameDelay && iDrawer.GetFloatingItemCount() > 0)
   115             {
   125     	{
   116             TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex( i );
   126     	Cancel();
   117             TSize itemSize = iDrawer.GetItemSize(current.GetDrawnItemIndex(), EFalse);
   127     	
   118 
   128     	TRect refreshRect;
   119             TRect beforeRect( current.GetItemPosition(), itemSize );
   129     	for(int i=0; i< iDrawer.GetFloatingItemCount(); i++)
   120             current.MakeStep();
   130 			{
   121             TRect afterRect( current.GetItemPosition(), itemSize );
   131 			TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex(i);
   122 
   132 			TSize itemSize = iDrawer.GetItemSize(current.GetDrawnItemIndex(), EFalse);
   123             if( current.GetFloatingItemType() == EDrag )
   133 
   124                 {
   134 			TRect beforeRect(current.GetItemPosition(), itemSize);
   125                 TInt dragTrail = iDrawer.GetFloatingItemIndex( EPostDragRefreshItem );
   135 			current.MakeStep();
   126                 if( dragTrail != KErrNotFound )
   136 			TRect afterRect(current.GetItemPosition(), itemSize);
   127                     {
   137 			
   128                     refreshRect = ( refreshRect == TRect() ) ? beforeRect : refreshRect;
   138 			if (current.GetFloatingItemType() == EDrag )
   129                     refreshRect.BoundingRect( afterRect );
   139 				{
   130                     static_cast<CMmWidgetContainer*> ( iDrawer.Widget()->Parent() )->
   140 				TInt dragTrail = iDrawer.GetFloatingItemIndex( EPostDragRefreshItem );
   131                             SetAllowMove( EFalse );
   141 				if (dragTrail != KErrNotFound)
   132                     }
   142 					{
   133                 }
   143 					refreshRect = (refreshRect == TRect(0,0,0,0)) ? beforeRect : refreshRect;
   134             else
   144 					refreshRect.BoundingRect( afterRect );
   135                 {
   145 					}
   136                 refreshRect = (refreshRect == TRect() ) ? beforeRect : refreshRect;
   146 				}
   137                 refreshRect.BoundingRect( beforeRect );
   147 			else
   138                 refreshRect.BoundingRect( afterRect );
   148 				{
   139                 }
   149 				refreshRect = (refreshRect == TRect(0,0,0,0)) ? beforeRect : refreshRect;
   140             }
   150 				refreshRect.BoundingRect( beforeRect );
   141         const TInt highlightedItemIndex = iDrawer.Widget()->View()->CurrentItemIndex();
   151 				refreshRect.BoundingRect( afterRect );
   142         if( iLastNotedHighlight != highlightedItemIndex )
   152 				}
   143             {
   153 			}
       
   154     	const TInt highlightedItemIndex = iDrawer.Widget()->View()->CurrentItemIndex();
       
   155     	if ( iLastNotedHighlight != highlightedItemIndex )
       
   156     	    {
       
   157             TRect highlightedItemRect(
   144             TRect highlightedItemRect(
   158                     iDrawer.Widget()->View()->ItemPos( highlightedItemIndex ),
   145                     iDrawer.Widget()->View()->ItemPos( highlightedItemIndex ),
   159                     iDrawer.Widget()->View()->ItemSize( highlightedItemIndex ) ); 
   146                     iDrawer.Widget()->View()->ItemSize( highlightedItemIndex ) );
   160             refreshRect.BoundingRect( highlightedItemRect );
   147             refreshRect.BoundingRect( highlightedItemRect );
   161             iLastNotedHighlight = highlightedItemIndex;
   148             iLastNotedHighlight = highlightedItemIndex;
   162     	    }
   149             }
   163 
   150 
   164     	
   151 
   165     	TInt currentVerticalOffset = static_cast<CMmWidgetContainer*>(
   152       TInt currentVerticalOffset = static_cast<CMmWidgetContainer*>(
   166     	        iDrawer.Widget()->Parent() )->VerticalItemOffset();
   153               iDrawer.Widget()->Parent() )->VerticalItemOffset();
   167 
   154 
   168     	if (iLastNotedTopItem != iDrawer.Widget()->TopItemIndex() ||
   155         if( iLastNotedTopItem != iDrawer.Widget()->TopItemIndex()
   169     	        iLastNotedVerticalOffset != currentVerticalOffset )
   156                 || iLastNotedVerticalOffset != currentVerticalOffset )
   170     		{
   157             {
   171     		iDrawer.Widget()->DrawNow();
   158             iDrawer.Widget()->DrawNow();
   172         	iLastNotedTopItem = iDrawer.Widget()->TopItemIndex();
   159             iLastNotedTopItem = iDrawer.Widget()->TopItemIndex();
   173         	iLastNotedVerticalOffset = currentVerticalOffset;
   160             iLastNotedVerticalOffset = currentVerticalOffset;
   174     		}
   161             }
   175     	else
   162         else
   176     		{
   163             {
   177 			if ( refreshRect != TRect(0,0,0,0))
   164             if( refreshRect != TRect() )
   178 				{
   165                 {
   179 				TRect prev(iPreviousRefreshRect);
   166                 TRect prev( iPreviousRefreshRect );
   180 				iPreviousRefreshRect = refreshRect;
   167                 iPreviousRefreshRect = refreshRect;
   181 				refreshRect.BoundingRect(prev);
   168                 refreshRect.BoundingRect( prev );
   182 				
   169 
   183 	            // expand rect if non-touch
   170                 // expand rect if non-touch
   184 	            refreshRect = TRect( AdjustRefreshRectToNonTouch( refreshRect ) );
   171                 refreshRect = TRect( AdjustRefreshRectToNonTouch( refreshRect ) );
   185 	            
   172 
   186 	            // never draw on the outside of widget's view rectangle
   173                 // never draw on the outside of widget's view rectangle
   187 	            refreshRect.Intersection( iDrawer.Widget()->View()->ViewRect() );
   174                 refreshRect.Intersection( iDrawer.Widget()->View()->ViewRect() );
   188 	            
   175 
   189 				iDrawer.Widget()->View()->Draw( &refreshRect );
   176                 iDrawer.Widget()->View()->Draw( &refreshRect );
   190 				}
   177                 }
   191     		}
   178             }
   192 
   179 
   193     	
   180         iLastRedrawTime.HomeTime();
   194 		iLastRedrawTime.HomeTime();
   181 
   195     	
   182         }
   196     	}
   183 
   197     
   184     if( iDrawer.GetFloatingItemCount() > 0 )
   198 		if (iDrawer.GetFloatingItemCount() > 0)
   185         {
   199 			{
   186         Trigger();
   200 			Trigger();
   187         }
   201 			}
   188     else
   202 		else
   189         {
   203 			{
   190         TriggerMoveItemL();
   204 			Cancel();
   191         Cancel();
   205 			
   192 
   206 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   193 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   207 			if ( iTransTfx && iTransTfxInternal->EffectsDisabled() )
   194         if( iTransTfx && iTransTfxInternal->EffectsDisabled() )
   208 				{
   195             {
   209 				iTransTfx->EnableEffects( ETrue );
   196             iTransTfx->EnableEffects( ETrue );
   210 	
   197 
   211 				if ( iTransTfx )
   198             if( iTransTfx )
   212 					{
   199                 {
   213 					iTransTfxInternal->Remove( MAknListBoxTfxInternal::EListEverything );
   200                 iTransTfxInternal->Remove( MAknListBoxTfxInternal::EListEverything );
   214 					iDrawer.Widget()->DrawNow();
   201                 iDrawer.Widget()->DrawNow();
   215 					iTransTfxInternal->Draw( iDrawer.Widget()->Rect() );
   202                 iTransTfxInternal->Draw( iDrawer.Widget()->Rect() );
   216 					}
   203                 }
   217 				}
   204             }
   218 #endif
   205 #endif
   219 			}
   206         }
   220     }
   207     }
   221 
   208 
   222 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   223 //
   210 //
   224 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   225 // 
   212 //
   226 TRect CMmDrawerAnimator::AdjustRefreshRectToNonTouch( const TRect& aRefreshRect )
   213 TRect CMmDrawerAnimator::AdjustRefreshRectToNonTouch( const TRect& aRefreshRect )
   227     {
   214     {
   228     TRect rect( aRefreshRect );
   215     TRect rect( aRefreshRect );
   229     if( !AknLayoutUtils::PenEnabled() )
   216     if( !AknLayoutUtils::PenEnabled() )
   230         {
   217         {
   231         TRect indicatorRect( iDrawer.GetIndicatorRect() );
   218         TRect indicatorRect( iDrawer.GetIndicatorRect() );
   232         TSize itemSize( iDrawer.GetItemSize(
   219         TSize itemSize( iDrawer.GetItemSize(
   233                 iDrawer.Widget()->CurrentItemIndex(), ETrue ) );
   220                 iDrawer.Widget()->CurrentItemIndex(), ETrue ) );
   234         
   221 
   235         TInt horizontalMargin( ( indicatorRect.Width() - itemSize.iWidth ) / 2 );
   222         TInt horizontalMargin( ( indicatorRect.Width() - itemSize.iWidth ) / 2 );
   236         TInt verticalMargin( ( indicatorRect.Height() - itemSize.iHeight ) / 2 );
   223         TInt verticalMargin( ( indicatorRect.Height() - itemSize.iHeight ) / 2 );
   237         rect.iBr.iX += horizontalMargin;
   224         rect.Grow(horizontalMargin, verticalMargin);
   238         rect.iBr.iY += verticalMargin;
       
   239         rect.iTl.iX -= horizontalMargin;
       
   240         rect.iTl.iY -= verticalMargin;
       
   241         }
   225         }
   242     return rect;
   226     return rect;
   243     }
   227     }
   244 
   228 
   245 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   246 //
   230 //
   247 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   248 // 
   232 //
   249 TInt CMmDrawerAnimator::Trigger()
   233 TInt CMmDrawerAnimator::Trigger()
   250     {
   234     {
   251 	if ( iPreparedForGarbage )
   235     if( iPreparedForGarbage )
   252 		{
   236         {
   253 		return KErrCancel;
   237         return KErrCancel;
   254 		}
   238         }
   255 	
   239 
   256     if (!IsActive() && iDrawer.GetFloatingItemCount() > 0 )
   240     if( !IsActive() && iDrawer.GetFloatingItemCount() > 0 )
   257         {
   241         {
   258 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   242 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   259 		iTransTfx = CAknListLoader::TfxApi( iDrawer.Gc() );
   243         iTransTfx = CAknListLoader::TfxApi( iDrawer.Gc() );
   260 		iTransTfxInternal = CAknListLoader::TfxApiInternal( 
   244         iTransTfxInternal = CAknListLoader::TfxApiInternal( iDrawer.Gc() );
   261 				iDrawer.Gc() );
   245 
   262 	
   246         if( iTransTfx && !iTransTfxInternal->EffectsDisabled() )
   263 		if ( iTransTfx && !iTransTfxInternal->EffectsDisabled() )
   247             {
   264 			{
   248             iTransTfx->EnableEffects( EFalse );
   265 			iTransTfx->EnableEffects( EFalse );
   249 
   266 			
   250             if( iTransTfxInternal )
   267 			if ( iTransTfxInternal )
   251                 {
   268 				{
   252         iTransTfxInternal->Remove( MAknListBoxTfxInternal::EListEverything );
   269 				iTransTfxInternal->Remove( MAknListBoxTfxInternal::EListEverything );
   253                 iTransTfxInternal->Draw( iDrawer.Widget()->Rect() );
   270 				iTransTfxInternal->Draw( iDrawer.Widget()->Rect() );
   254                 }
   271 				}
   255             }
   272 			}
       
   273 #endif
   256 #endif
   274     
   257 
   275         iTimer.After(iStatus, TTimeIntervalMicroSeconds32( 
   258         iTimer.After( iStatus, TTimeIntervalMicroSeconds32(
   276         		MmEffects::KAnimationFrameDelay ) ); 
   259                 MmEffects::KAnimationFrameDelay ) );
   277         SetActive();
   260         SetActive();
   278         }
   261         }
   279     return KErrNone;
   262     return KErrNone;
   280     }
   263     }
   281 
   264 
   282 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   283 //
   266 //
   284 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   285 // 
   268 //
   286 TInt CMmDrawerAnimator::RunError(TInt aError)
   269 TInt CMmDrawerAnimator::RunError( TInt aError )
   287     {
   270     {
   288     return aError;
   271     return aError;
   289     }
   272     }
   290 
   273 
   291 // -----------------------------------------------------------------------------
   274 // -----------------------------------------------------------------------------
   292 //
   275 //
   293 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   294 // 
   277 //
   295 void CMmDrawerAnimator::AnimateDragItemTransitionL( )
   278 void CMmDrawerAnimator::AnimateDragItemTransitionL()
   296     {     
   279     {
   297     if (KErrNotFound != iDrawer.GetFloatingItemIndex(EDrag))
   280     if( KErrNotFound != iDrawer.GetFloatingItemIndex( EDrag ) )
   298         {
   281         {
   299         TMmFloatingItem floatingItem(
   282         TMmFloatingItem floatingItem(
   300                 iDrawer.GetFloatingItemL(EDrag).GetDrawnItemIndex(), 
   283                 iDrawer.GetFloatingItemL( EDrag ).GetDrawnItemIndex(),
   301                 iDrawer.GetFloatingItemL(EDrag).GetItemPosition(), 
   284                 iDrawer.GetFloatingItemL( EDrag ).GetItemPosition(),
   302                 EDragTransition, iUsualAnimationFramesCount,
   285                 EDragTransition, iUsualAnimationFramesCount,
   303                 iDrawer.Widget()->View());
   286                 iDrawer.Widget()->View() );
   304         TPoint pointEnd = iDrawer.Widget()->View()->ItemPos( floatingItem.GetDrawnItemIndex() );
   287         TPoint pointEnd = iDrawer.Widget()->View()->ItemPos( floatingItem.GetDrawnItemIndex() );
   305         floatingItem.SetPositionStep( pointEnd - floatingItem.GetItemPosition() );
   288         floatingItem.SetPositionStep( pointEnd - floatingItem.GetItemPosition() );
   306         iDrawer.AddFloatingItemL( floatingItem, 0 );
   289         iDrawer.AddFloatingItemL( floatingItem, 0 );
   307         iDrawer.RemoveFloatingItem( iDrawer.GetFloatingItemIndex(EDrag) );
   290         iDrawer.RemoveFloatingItem( iDrawer.GetFloatingItemIndex( EDrag ) );
   308         }
   291         }
   309     }
   292     }
   310   
   293 
   311 // -----------------------------------------------------------------------------
   294 // -----------------------------------------------------------------------------
   312 //
   295 //
   313 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   314 //
   297 //
   315 TBool CMmDrawerAnimator::IsReadyForNewAnimation()
   298 TBool CMmDrawerAnimator::IsReadyForNewAnimation()
   316     {
   299     {
   317 	if ( iPreparedForGarbage )
   300     if( iPreparedForGarbage )
   318 		{
   301         {
   319 		return EFalse;
   302         return EFalse;
   320 		}
   303         }
   321 	
   304 
   322     for(int i=0; i< iDrawer.GetFloatingItemCount(); i++)
   305     for( int i = 0; i < iDrawer.GetFloatingItemCount(); i++ )
   323         {
   306         {
   324         TMmFloatingItemType type 
   307         TMmFloatingItemType type =
   325 			= iDrawer.GetFloatingItemAtIndex(i).GetFloatingItemType();
   308                 iDrawer.GetFloatingItemAtIndex( i ).GetFloatingItemType();
   326         if ( type != EDrag && type != EZoomTransition )
   309         if( type != EDrag && type != EZoomTransition )
   327             {
   310             {
   328             return EFalse;
   311             return EFalse;
   329             }
   312             }
   330         }
   313         }
   331     return ETrue;
   314     return ETrue;
   335 //
   318 //
   336 // -----------------------------------------------------------------------------
   319 // -----------------------------------------------------------------------------
   337 //
   320 //
   338 void CMmDrawerAnimator::CancelAnimationsL()
   321 void CMmDrawerAnimator::CancelAnimationsL()
   339     {
   322     {
   340     for(int i=0; i< iDrawer.GetFloatingItemCount(); i++)
   323     for( int i = 0; i < iDrawer.GetFloatingItemCount(); i++ )
   341         {
   324         {
   342         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex(i);
   325         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex( i );
   343         if (current.GetFloatingItemType() != EDrag)
   326         if( current.GetFloatingItemType() != EDrag )
   344             {
   327             {
   345             current.InvalidateFloatingItem();
   328             current.InvalidateFloatingItem();
   346             }
   329             }
   347         }
   330         }
   348     }
   331     }
   349 
   332 
   350  // -----------------------------------------------------------------------------
   333 // -----------------------------------------------------------------------------
   351  //
   334 //
   352  // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   353  // 
   336 //
   354 void CMmDrawerAnimator::AnimateItemSwapL( TInt aItemFrom, TInt aItemTo )
   337 void CMmDrawerAnimator::AnimateItemSwapL( TInt aItemFrom, TInt aItemTo )
   355     {
   338     {
   356     TMmFloatingItem floatingItem( aItemTo, 
   339     TMmFloatingItem floatingItem( aItemTo,
   357             iDrawer.Widget()->View()->ItemPos( aItemFrom ), 
   340             iDrawer.Widget()->View()->ItemPos( aItemFrom ),
   358             ESwapTransition, iUsualAnimationFramesCount,
   341             ESwapTransition, iUsualAnimationFramesCount,
   359             iDrawer.Widget()->View() );
   342             iDrawer.Widget()->View() );
   360       
   343 
   361     for(int i=0; i< iDrawer.GetFloatingItemCount(); i++)
   344     for( int i = 0; i < iDrawer.GetFloatingItemCount(); i++ )
   362         {
   345         {
   363         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex(i);
   346         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex( i );
   364 
   347 
   365         if (current.GetFloatingItemType() == EZoomTransition 
   348         if( current.GetFloatingItemType() == EZoomTransition
   366                 && current.GetDrawnItemIndex() == aItemFrom )
   349                 && current.GetDrawnItemIndex() == aItemFrom )
   367             {
   350             {
   368             current.InvalidateFloatingItem();
   351             current.InvalidateFloatingItem();
   369             floatingItem.SetSizeStep( current.GetCurrentZoomRatio(), 1.0f );
   352             floatingItem.SetSizeStep( current.GetCurrentZoomRatio(), 1.0f );
   370             break;
   353             break;
   371             }
   354             }
   372         }
   355         }
   373 
   356 
   374     floatingItem.SetPositionStep( iDrawer.Widget()->View()->ItemPos(aItemTo)- 
   357     floatingItem.SetPositionStep( iDrawer.Widget()->View()->ItemPos(aItemTo)
   375             iDrawer.Widget()->View()->ItemPos(aItemFrom) );
   358             - iDrawer.Widget()->View()->ItemPos(aItemFrom) );
   376     iDrawer.AddFloatingItemL(floatingItem);
   359     iDrawer.AddFloatingItemL( floatingItem );
   377     }
   360     }
   378 
   361 
   379 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   380 //
   363 //
   381 // -----------------------------------------------------------------------------
   364 // -----------------------------------------------------------------------------
   382 // 
   365 //
   383 void CMmDrawerAnimator::AnimateItemZoomL( TInt aItemIndex, TBool aZoomIn )
   366 void CMmDrawerAnimator::AnimateItemZoomL( TInt aItemIndex, TBool aZoomIn )
   384     {
   367     {
   385     TMmFloatingItem floatingItem( aItemIndex,
   368     TMmFloatingItem floatingItem( aItemIndex,
   386             iDrawer.Widget()->View()->ItemPos( aItemIndex ),
   369             iDrawer.Widget()->View()->ItemPos( aItemIndex ),
   387             EZoomTransition, iUsualAnimationFramesCount,
   370             EZoomTransition, iUsualAnimationFramesCount,
   390     floatingItem.SetSizeStep(
   373     floatingItem.SetSizeStep(
   391             (aZoomIn) ? KNormalStateZoomRatio : KZoomStateZoomRatio,
   374             (aZoomIn) ? KNormalStateZoomRatio : KZoomStateZoomRatio,
   392             (aZoomIn) ? KZoomStateZoomRatio : KNormalStateZoomRatio );
   375             (aZoomIn) ? KZoomStateZoomRatio : KNormalStateZoomRatio );
   393 
   376 
   394     TInt animationFound = EFalse;
   377     TInt animationFound = EFalse;
   395     for(int i=0; i< iDrawer.GetFloatingItemCount(); i++)
   378     for( int i = 0; i < iDrawer.GetFloatingItemCount(); i++ )
   396         {
   379         {
   397         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex(i);
   380         TMmFloatingItem& current = iDrawer.GetFloatingItemAtIndex( i );
   398         if (current.GetFloatingItemType() == EZoomTransition &&
   381         if( current.GetFloatingItemType() == EZoomTransition
   399                 current.GetDrawnItemIndex() == aItemIndex )
   382                 && current.GetDrawnItemIndex() == aItemIndex )
   400             {
   383             {
   401             current.InvalidateFloatingItem();
   384             current.InvalidateFloatingItem();
   402             floatingItem.SetSizeStep( current.GetCurrentZoomRatio(),
   385             floatingItem.SetSizeStep( current.GetCurrentZoomRatio(),
   403                     (aZoomIn) ? KZoomStateZoomRatio : KNormalStateZoomRatio);
   386                     (aZoomIn) ? KZoomStateZoomRatio : KNormalStateZoomRatio);
   404             animationFound = ETrue;
   387             animationFound = ETrue;
       
   388             static_cast<CMmWidgetContainer*> ( iDrawer.Widget()->Parent() )->
       
   389                     SetAllowMove( EFalse );
   405             break;
   390             break;
   406             }
   391             }
   407         }
   392         }
   408     
   393 
   409     if ( (aZoomIn != EFalse || animationFound != EFalse) )
   394     if( ( aZoomIn != EFalse || animationFound != EFalse ) )
   410         {
   395         {
   411         // This covers the situation, when a zoom out animation is requested
   396         // This covers the situation, when a zoom out animation is requested
   412         // whilst no zoom in occured earlier. In this case the request is 
   397         // whilst no zoom in occured earlier. In this case the request is
   413         // neglected.
   398         // neglected.
   414         iDrawer.AddFloatingItemL( floatingItem );
   399         iDrawer.AddFloatingItemL( floatingItem );
   415         }
   400         }
   416     }
   401     }
   417 
   402 
   418 // -----------------------------------------------------------------------------
   403 // -----------------------------------------------------------------------------
   419 //
   404 //
   420 // -----------------------------------------------------------------------------
   405 // -----------------------------------------------------------------------------
   421 // 
   406 //
   422 void CMmDrawerAnimator::SetNextRedrawToWholeScreen()
   407 void CMmDrawerAnimator::SetNextRedrawToWholeScreen()
   423 	{
   408     {
   424 	iPreviousRefreshRect = iDrawer.Widget()->View()->ViewRect();
   409     iPreviousRefreshRect = iDrawer.Widget()->View()->ViewRect();
   425 	}
   410     }
   426 
   411 
   427 // -----------------------------------------------------------------------------
   412 // -----------------------------------------------------------------------------
   428 //
   413 //
   429 // -----------------------------------------------------------------------------
   414 // -----------------------------------------------------------------------------
   430 // 
   415 //
   431 void CMmDrawerAnimator::PrepareForGarbage()
   416 void CMmDrawerAnimator::PrepareForGarbage()
   432 	{
   417     {
   433 //	Cancel any outstanding requests
   418     //	Cancel any outstanding requests
   434 	Cancel();
   419     Cancel();
   435 	iPreparedForGarbage = ETrue;
   420     iPreparedForGarbage = ETrue;
   436 	}
   421     }
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 void CMmDrawerAnimator::TriggerMoveItemL()
       
   428     {
       
   429     static_cast<CMmWidgetContainer*> ( iDrawer.Widget()->Parent() )->
       
   430             TriggerMoveItemL();
       
   431     }
   437 //End of file
   432 //End of file