taskswitcher/teleportui/hgteleportapp/src/hgteleportphysicsengine.cpp
changeset 4 4d54b72983ae
parent 3 fb3763350a08
child 5 c743ef5928ba
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
     1 /*
       
     2  * ============================================================================
       
     3  *  Name        : hgteleportphysicsengine.cpp
       
     4  *  Part of     : Hg Teleport
       
     5  *  Description : Teleport physics
       
     6  *  Version     : %version:  5 %
       
     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 #include <aknphysics.h>
       
    20 
       
    21 #include "hgteleportphysicsengine.h"
       
    22 #include "hgteleportphysics.h"
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // CHgTeleportPhysicsHandler::CHgTeleportPhysicsHandler
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 CHgTeleportPhysicsEngine::CHgTeleportPhysicsEngine()
       
    29     {
       
    30     // No implementation required
       
    31     }
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CHgTeleportPhysicsEngine::~CHgTeleportPhysicsEngine
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CHgTeleportPhysicsEngine::~CHgTeleportPhysicsEngine()
       
    38     {
       
    39     delete iTeleportPhysics;
       
    40     delete iPhysics;
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CHgTeleportPhysicsEngine::NewLC
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CHgTeleportPhysicsEngine* CHgTeleportPhysicsEngine::NewLC(
       
    48         MAknPhysicsObserver& aPhysicObserver, CCoeControl& aViewControl)
       
    49     {
       
    50     CHgTeleportPhysicsEngine* self = new (ELeave) CHgTeleportPhysicsEngine();
       
    51     CleanupStack::PushL(self);
       
    52     self->ConstructL(aPhysicObserver, aViewControl);
       
    53     return self;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CHgTeleportPhysicsEngine::NewL
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CHgTeleportPhysicsEngine* CHgTeleportPhysicsEngine::NewL(
       
    61         MAknPhysicsObserver& aPhysicObserver, CCoeControl& aViewControl)
       
    62     {
       
    63     CHgTeleportPhysicsEngine* self = CHgTeleportPhysicsEngine::NewLC(
       
    64             aPhysicObserver, aViewControl);
       
    65     CleanupStack::Pop(); // self;
       
    66     return self;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CHgTeleportPhysicsEngine::ConstructL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CHgTeleportPhysicsEngine::ConstructL(MAknPhysicsObserver& aPhysicObserver,
       
    74         CCoeControl& aViewControl)
       
    75     {
       
    76     iPhysics = CAknPhysics::NewL(aPhysicObserver, &aViewControl);//TODO:
       
    77     iTeleportPhysics = CHgTeleportPhysics::NewL(aPhysicObserver);
       
    78     }
       
    79 
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CHgTeleportPhysicsEngine::IsRunning
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 TBool CHgTeleportPhysicsEngine::IsRunning() const
       
    86     {
       
    87     return iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CHgTeleportPhysicsEngine::HandleDragEvent
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CHgTeleportPhysicsEngine::HandleDragEvent(
       
    95         AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent)
       
    96     {
       
    97     if (AknTouchGestureFw::EAknTouchGestureFwStart == aEvent.State())
       
    98         {
       
    99         iPhysics->StopPhysics();
       
   100         iStartTime.HomeTime();
       
   101         }
       
   102     else if (AknTouchGestureFw::EAknTouchGestureFwOn == aEvent.State())
       
   103         {
       
   104         TPoint deltaPoint(aEvent.PreviousPosition() - aEvent.CurrentPosition());
       
   105         iPhysics->RegisterPanningPosition(deltaPoint);
       
   106         }
       
   107     else //AknTouchGestureFw::EAknTouchGestureFwStop
       
   108         {
       
   109         TPoint drag(aEvent.PreviousPosition() - aEvent.CurrentPosition());
       
   110         iPhysics->StartPhysics(drag, iStartTime);
       
   111         }
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CHgTeleportPhysicsEngine::Stop
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CHgTeleportPhysicsEngine::Stop()
       
   119     {
       
   120     iPhysics->StopPhysics();
       
   121     iTeleportPhysics->StopPhysics();
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CHgTeleportPhysicsEngine::AnimateToTargetL
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CHgTeleportPhysicsEngine::AnimateToTarget(const TPoint& aPoint)
       
   129     {
       
   130     iTeleportPhysics->StartPhysics(aPoint);
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CHgTeleportPhysicsEngine::ReInitPhysicsL
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CHgTeleportPhysicsEngine::ReInitPhysicsL(const TSize& aWorldSize,
       
   138         const TSize& aViewSize, TBool aLandscape)
       
   139     {
       
   140     iPhysics->InitPhysicsL(aWorldSize, aViewSize, aLandscape);
       
   141     }
       
   142 
       
   143 //End file