taskswitcher/taskswitcherui/taskswitcherapp/inc/tsphysicsengine.h
author Simon Howkins <simonh@symbian.org>
Tue, 16 Nov 2010 11:12:20 +0000
branchRCL_3
changeset 108 cf9be2d674f1
parent 83 5456b4e8b3a8
permissions -rw-r--r--
Fixed path to files to be exported

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Taskswitcher physic engine
 *
*/


#ifndef TSPHYSICSENGINE_H_
#define TSPHYSICSENGINE_H_

#include <e32base.h>
#include <akntouchgesturefw.h>
// CLASS DECLARATION
class CAknPhysics;
class CTsPhysics;
/**
 * Taskswitcher physic engine implementation
 */
class CTsPhysicsEngine: public CBase
    {
public:
    // Constructors and destructor

    /**
     * Destructor.
     */
    ~CTsPhysicsEngine();

    /**
     * Two-phased constructor.
     */
    static CTsPhysicsEngine* NewL(MAknPhysicsObserver& aPhysicObserver,
            CCoeControl& aViewControl);

    /**
     * Two-phased constructor.
     */
    static CTsPhysicsEngine* NewLC(MAknPhysicsObserver& aPhysicObserver,
            CCoeControl& aViewControl);

private:

    /**
     * Constructor for performing 1st stage construction
     */
    CTsPhysicsEngine();

    /**
     * EPOC default constructor for performing 2nd stage construction
     */
    void ConstructL(MAknPhysicsObserver& aPhysicObserver,
            CCoeControl& aViewControl);
    
    
public:
    /**
     * Implements drag gesture handling
     * @param aEvent - drag event
     */
    void HandleDragEvent(AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent);
    
    /**
     * Checks if the physics is running
     */
    TBool IsRunning() const;
    
    /**
     * Stops physics
     */
    void Stop();
    
    /**
     * Initialize animation between current position and destination point
     * @param aPoint - destination point 
     */
    void AnimateToTarget(const TPoint& aPoint);
    
    /**
     * 
     * @param aWorldSize Physics world size.
     * @param aViewSize Physics (visible) view size.
     * @param aLandscape ETrue if physics should work in landscape.     
     **/
    void ReInitPhysicsL(const TSize& aWorldSize, 
                        const TSize& aViewSize,
                        TBool aLandscape);
    
private:
    /**
     * Physics. 
     * Own.
     */
    CAknPhysics* iPhysics;

    /**
     * Drag start time
     */
    TTime iStartTime;
    
    /**
     * Drag start position
     */
    TPoint iStartPosition;
    
    /**
     * Taskswitcher physics for item switch animation
     */
    CTsPhysics* iTaskswitcherPhysics;
    
    /**
     * Marks direction in which drag events are made:
     * Values: 0 - uninitialized
     *         1 - drag right
     *        -1 - drag left 
     */
    TInt iDragDirection;

    };

#endif /* TSPHYSICSENGINE_H_*/