menufw/menufwui/mmwidgets/inc/mmdraweranimator.h
changeset 0 f72a12da539e
child 38 79311d856354
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c)  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:  CMmDrawerAnimator declaration
       
    15 *  Version     : %version: MM_17.1.8 % << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_MMDRAWERANIMATOR_H
       
    21 #define C_MMDRAWERANIMATOR_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <e32std.h>
       
    25 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    26 #include <aknlistloadertfx.h>
       
    27 #include <aknlistboxtfxinternal.h>
       
    28 #include <aknlistboxtfx.h>
       
    29 #endif 
       
    30 class CMmListBoxItemDrawer;
       
    31 class TMmFloatingItem;
       
    32 
       
    33 /**
       
    34  * Zoom ratio when no zooming is performed.
       
    35  */
       
    36 const TReal KNormalStateZoomRatio = 1.0f;
       
    37 
       
    38 /**
       
    39  * Zoom ratio when zooming is performed.
       
    40  */
       
    41 const TReal KZoomStateZoomRatio = 1.25f;
       
    42 
       
    43 /**
       
    44  *  Used by Multimedia Menu to draw Animated items.
       
    45  *  Drawer animator is an active object, that forces refreshes
       
    46  *  while floating items are available in the associated CListBoxItemDrawer.
       
    47  *  When no items are available the drawer ceases to redraw the screen.
       
    48  *  Active object becomes active when a new animation is triggered.
       
    49  *
       
    50  *  @code
       
    51  *  @endcode
       
    52  *  @lib mmwidgets
       
    53  *  @since S60 v5.0
       
    54  *  @see CListBoxItemDrawer
       
    55  *  @ingroup group_mmwidgets
       
    56  */
       
    57 NONSHARABLE_CLASS( CMmDrawerAnimator ) : public CActive
       
    58     {
       
    59     
       
    60 public:
       
    61     /**
       
    62      * Two-phased constructor.
       
    63      * 
       
    64      * @since S60 v5.0
       
    65      * @param aDrawer Item drawer used to draw item.
       
    66      */
       
    67     static CMmDrawerAnimator* NewL( CMmListBoxItemDrawer& aDrawer );
       
    68 
       
    69     /**
       
    70      * Two-phased constructor.
       
    71      * 
       
    72      * @since S60 v5.0
       
    73      * @param aDrawer Item drawer used to draw item.
       
    74      */
       
    75     static CMmDrawerAnimator* NewLC( CMmListBoxItemDrawer& aDrawer );
       
    76     
       
    77     /**
       
    78      * Destructor.
       
    79      * 
       
    80      * @since S60 v5.0
       
    81      */
       
    82     virtual ~CMmDrawerAnimator();
       
    83 
       
    84     /**
       
    85      * Animates transition of the dragged item.
       
    86      * The animation starts in the current position of EDrag
       
    87      * floating item, and end in the original place of dragging
       
    88      * or destination place, if reorder occured.
       
    89      *
       
    90      * @since S60 v5.0
       
    91      */
       
    92     void AnimateDragItemTransitionL( );
       
    93     
       
    94     /**
       
    95      * Animates an item with index aItemFrom into position 
       
    96      * indexed by aItemTo.
       
    97      *
       
    98      * @since S60 v5.0
       
    99      * @param aItemFrom Which item should be animated.
       
   100      * @param aItemTo Where to should the item be animated.
       
   101      */
       
   102     void AnimateItemSwapL( TInt aItemFrom, TInt aItemTo );
       
   103 
       
   104     /**
       
   105      * Animates zooming of an item.
       
   106      *
       
   107      * @since S60 v3.0
       
   108      * @param aItemIndex Index of item to be zoomed.
       
   109      * @param aZoomIn Is zooming in or out.
       
   110      */
       
   111     void AnimateItemZoomL( TInt aItemIndex, TBool aZoomIn );
       
   112 
       
   113     /**
       
   114      * Checks if system is ready for new animation.
       
   115      *
       
   116      * @since S60 v5.0
       
   117      * @return Is system ready so new animation can proceed.
       
   118      */
       
   119     TBool IsReadyForNewAnimation();
       
   120     
       
   121     /**
       
   122      * Cancel currently running or pending animations.
       
   123      *
       
   124      * @since S60 v5.0
       
   125      */
       
   126     void CancelAnimationsL();
       
   127     
       
   128     /**
       
   129      * Triggers animation.
       
   130      * This methods sets the Activeobject into active state
       
   131      * if floating items are available
       
   132      *
       
   133      * @since S60 v5.0
       
   134      * @return Error code
       
   135      */
       
   136     TInt Trigger();
       
   137     
       
   138     /**
       
   139      * Marks next redraw to be cancelled.
       
   140      * 
       
   141      * @return Indicates if redraw occured due to cancel.
       
   142      */
       
   143     TBool CancelNextRedrawL();
       
   144     
       
   145     /**
       
   146      * Make the next animation redraw the whole screen;
       
   147      */
       
   148     void SetNextRedrawToWholeScreen();
       
   149     
       
   150     /**
       
   151      * Indicates that draweranimator is in garbage.
       
   152      * This is used when suite model has been destroyed so there isn't 
       
   153      * anything to draw, therefore any animator attempts should be 
       
   154      * dropped.
       
   155      */
       
   156     void PrepareForGarbage();
       
   157     
       
   158 private:
       
   159 	
       
   160     /**
       
   161      * Default constructor.
       
   162      * 
       
   163      * @since S60 v3.0
       
   164      * @param aDrawer Object used to draw items in widgets.
       
   165      */
       
   166     CMmDrawerAnimator( CMmListBoxItemDrawer& aDrawer );
       
   167     
       
   168     /**
       
   169      * 2nd phase constructor.
       
   170      *
       
   171      * @since S60 v3.0 
       
   172      */
       
   173     void ConstructL();
       
   174 
       
   175 private: // From CActive
       
   176 
       
   177     /**
       
   178      * Draws next animation phase.
       
   179      *
       
   180      * @since S60 v3.0
       
   181      */
       
   182     void RunL();
       
   183 
       
   184     /**
       
   185      * Cancels animation timer. Stops animation.
       
   186      *
       
   187      * @since S60 v3.0
       
   188      */
       
   189     void DoCancel();
       
   190 
       
   191     /**
       
   192      * Handles error if error an error occured.
       
   193      *
       
   194      * @since S60 v3.0
       
   195      * @param aError Error code which occurred.
       
   196      * @return Error code for error handling.
       
   197      */
       
   198     TInt RunError( TInt aError );
       
   199     
       
   200     /**
       
   201      * Adjusts rect to non touch.
       
   202      * 
       
   203      * @since S60 v3.0
       
   204      * @param aRefreshRect Refresh rect.
       
   205      * @return Adjusted rect.
       
   206      */
       
   207     TRect AdjustRefreshRectToNonTouch( const TRect& aRefreshRect );
       
   208 
       
   209 private: // Data
       
   210 	
       
   211     /**
       
   212      * Timer
       
   213      */  
       
   214     RTimer iTimer;
       
   215     
       
   216     /**
       
   217      * Associated item drawer.
       
   218      */  
       
   219     CMmListBoxItemDrawer& iDrawer;
       
   220     
       
   221     /**
       
   222      * Number of animation frames
       
   223      */  
       
   224     TInt iAnimateFrames;
       
   225 
       
   226     /**
       
   227      * Delay between redrawing.
       
   228      */  
       
   229     TTimeIntervalMicroSeconds iDelay;
       
   230    
       
   231     /**
       
   232      * Last redraw time
       
   233      */  
       
   234     TTime iLastRedrawTime;
       
   235       
       
   236     /**
       
   237      * Effects api.
       
   238      */  
       
   239     MAknListBoxTfx *iTransTfx;
       
   240     
       
   241     /**
       
   242      * Effects api.
       
   243      */  
       
   244     MAknListBoxTfxInternal *iTransTfxInternal;
       
   245     
       
   246     /**
       
   247      * Highlight noted when last redraw occured.
       
   248      */
       
   249     TInt iLastNotedHighlight;
       
   250     
       
   251     /**
       
   252      * Top item index noted when last redraw occured.
       
   253      */
       
   254     TInt iLastNotedTopItem;
       
   255     
       
   256     /**
       
   257      * Vertical offset noted when last redraw occured.
       
   258      */
       
   259     TInt iLastNotedVerticalOffset;
       
   260     
       
   261     /**
       
   262      * Holds the previous animation refresh rectangle.
       
   263      */
       
   264     TRect iPreviousRefreshRect;
       
   265     
       
   266     /**
       
   267      * Holds the number of frames to animate.
       
   268      */
       
   269     const TInt iUsualAnimationFramesCount;
       
   270     
       
   271     /**
       
   272      * Holds the previous animation refresh rectangle.
       
   273      */
       
   274     TBool iPreparedForGarbage;
       
   275     };
       
   276 
       
   277 #endif // MMDRAWERANIMATOR_H