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