taskswitcher/teleportui/hgteleportapp/inc/hgteleportphysics.h
changeset 4 4d54b72983ae
parent 3 fb3763350a08
child 5 c743ef5928ba
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
     1 /*
       
     2  * ============================================================================
       
     3  *  Name        : hgteleportphysics.h
       
     4  *  Part of     : Hg Teleport
       
     5  *  Description : Application class
       
     6  *  Version     : %version:  %
       
     7  *
       
     8  *  Copyright © 2009 Nokia.  All rights reserved.
       
     9  *  This material, including documentation and any related computer
       
    10  *  programs, is protected by copyright controlled by Nokia.  All
       
    11  *  rights are reserved.  Copying, including reproducing, storing,
       
    12  *  adapting or translating, any or all of this material requires the
       
    13  *  prior written consent of Nokia.  This material also contains
       
    14  *  confidential information which may not be disclosed to others
       
    15  *  without the prior written consent of Nokia.
       
    16  * ============================================================================
       
    17  * 
       
    18  */
       
    19 
       
    20 #ifndef HGTELEPORTPHYSICS_H
       
    21 #define HGTELEPORTPHYSICS_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <e32std.h>
       
    25 
       
    26 class MAknPhysicsObserver;
       
    27 
       
    28 /**
       
    29  * Simple physics for grid animation
       
    30  */
       
    31 class CHgTeleportPhysics : public CActive
       
    32     {
       
    33 public:
       
    34     /*
       
    35      * Destructor
       
    36      */
       
    37     ~CHgTeleportPhysics();
       
    38 
       
    39     /**
       
    40      * Two-phased constructor.
       
    41      */
       
    42     static CHgTeleportPhysics* NewL( MAknPhysicsObserver& aObserver );
       
    43 
       
    44     /**
       
    45      * Two-phased constructor.
       
    46      */
       
    47     static CHgTeleportPhysics* NewLC( MAknPhysicsObserver& aObserver );
       
    48 
       
    49 public: // New functions
       
    50     
       
    51     /**
       
    52      * Starts animation
       
    53      * 
       
    54      * @param  aDrag       next drag point
       
    55      * @param  aStartTime  when animation should be started
       
    56      */
       
    57     void StartPhysics( const TPoint& aTarget );
       
    58 
       
    59     /**
       
    60      * Stops animation
       
    61      */
       
    62     void StopPhysics();
       
    63     
       
    64 private:
       
    65     
       
    66     /**
       
    67      * C++ constructor
       
    68      */
       
    69     CHgTeleportPhysics( MAknPhysicsObserver& aObserver );
       
    70 
       
    71     /**
       
    72      * Second-phase constructor
       
    73      */
       
    74     void ConstructL();
       
    75 
       
    76 private: // From CActive
       
    77     
       
    78     /**
       
    79      * Handles completion
       
    80      */
       
    81     void RunL();
       
    82 
       
    83     /**
       
    84      * Called when cancelled
       
    85      */
       
    86     void DoCancel();
       
    87 
       
    88     /**
       
    89      * Hanldes error
       
    90      */
       
    91     TInt RunError( TInt aError );
       
    92     
       
    93 private: // New functions
       
    94     
       
    95     /**
       
    96      * Calculates animation steps
       
    97      */
       
    98     TInt CalculateAnimationSteps( const TPoint& aTarget );
       
    99 
       
   100 private:
       
   101 
       
   102     enum TPhysicsStatus
       
   103         {
       
   104         EStopped,
       
   105         ERunning,
       
   106         EFinished
       
   107         };
       
   108     
       
   109     /**
       
   110      * Observer
       
   111      */
       
   112     MAknPhysicsObserver& iObserver;
       
   113     
       
   114     /**
       
   115      * Animation timer
       
   116      */
       
   117     RTimer iTimer;
       
   118     
       
   119     /**
       
   120      * Animation state
       
   121      */
       
   122     TPhysicsStatus iPhysicsState;
       
   123     
       
   124     /**
       
   125      * Controls animation refresh rate
       
   126      */
       
   127     TTimeIntervalMicroSeconds32 iAnimationTickTime;
       
   128     
       
   129     /**
       
   130      * Animation ticks counter
       
   131      */
       
   132     TInt iAnimationTicks;
       
   133     
       
   134     /**
       
   135      * Offset of how much view should be moved
       
   136      */
       
   137     RArray<TPoint> iAnimationSteps;
       
   138 
       
   139     };
       
   140 
       
   141 #endif // HGTELEPORTPHYSICS_H