taskswitcher/taskswitcherui/taskswitcherapp/inc/tsphysics.h
changeset 4 4d54b72983ae
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Application class
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TSPHYSICS_H
       
    20 #define TSPHYSICS_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32std.h>
       
    24 
       
    25 class MAknPhysicsObserver;
       
    26 
       
    27 /**
       
    28  * Simple physics for grid animation
       
    29  */
       
    30 class CTsPhysics : public CActive
       
    31     {
       
    32 public:
       
    33     /*
       
    34      * Destructor
       
    35      */
       
    36     ~CTsPhysics();
       
    37 
       
    38     /**
       
    39      * Two-phased constructor.
       
    40      */
       
    41     static CTsPhysics* NewL( MAknPhysicsObserver& aObserver );
       
    42 
       
    43     /**
       
    44      * Two-phased constructor.
       
    45      */
       
    46     static CTsPhysics* NewLC( MAknPhysicsObserver& aObserver );
       
    47 
       
    48 public: // New functions
       
    49     
       
    50     /**
       
    51      * Starts animation
       
    52      * 
       
    53      * @param  aDrag       next drag point
       
    54      * @param  aStartTime  when animation should be started
       
    55      */
       
    56     void StartPhysics( const TPoint& aTarget );
       
    57 
       
    58     /**
       
    59      * Stops animation
       
    60      */
       
    61     void StopPhysics();
       
    62     
       
    63 private:
       
    64     
       
    65     /**
       
    66      * C++ constructor
       
    67      */
       
    68     CTsPhysics( MAknPhysicsObserver& aObserver );
       
    69 
       
    70     /**
       
    71      * Second-phase constructor
       
    72      */
       
    73     void ConstructL();
       
    74 
       
    75 private: // From CActive
       
    76     
       
    77     /**
       
    78      * Handles completion
       
    79      */
       
    80     void RunL();
       
    81 
       
    82     /**
       
    83      * Called when cancelled
       
    84      */
       
    85     void DoCancel();
       
    86 
       
    87     /**
       
    88      * Hanldes error
       
    89      */
       
    90     TInt RunError( TInt aError );
       
    91     
       
    92 private: // New functions
       
    93     
       
    94     /**
       
    95      * Calculates animation steps
       
    96      */
       
    97     TInt CalculateAnimationSteps( const TPoint& aTarget );
       
    98 
       
    99 private:
       
   100 
       
   101     enum TPhysicsStatus
       
   102         {
       
   103         EStopped,
       
   104         ERunning,
       
   105         EFinished
       
   106         };
       
   107     
       
   108     /**
       
   109      * Observer
       
   110      */
       
   111     MAknPhysicsObserver& iObserver;
       
   112     
       
   113     /**
       
   114      * Animation timer
       
   115      */
       
   116     RTimer iTimer;
       
   117     
       
   118     /**
       
   119      * Animation state
       
   120      */
       
   121     TPhysicsStatus iPhysicsState;
       
   122     
       
   123     /**
       
   124      * Controls animation refresh rate
       
   125      */
       
   126     TTimeIntervalMicroSeconds32 iAnimationTickTime;
       
   127     
       
   128     /**
       
   129      * Animation ticks counter
       
   130      */
       
   131     TInt iAnimationTicks;
       
   132     
       
   133     /**
       
   134      * Offset of how much view should be moved
       
   135      */
       
   136     RArray<TPoint> iAnimationSteps;
       
   137 
       
   138     };
       
   139 
       
   140 #endif // TSPHYSICS_H