taskswitcher/taskswitcherui/taskswitcherapp/inc/tseventcontroler.h
changeset 4 4d54b72983ae
child 15 ff572dfe6d86
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Gesture and physics helper declaration
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TSEVENTCONTROLER_H
       
    20 #define TSEVENTCONTROLER_H
       
    21 
       
    22 #include "tseventcontrolerobserver.h"
       
    23 #include <akntouchgesturefw.h>
       
    24 #include <aknphysicsobserveriface.h>
       
    25 
       
    26 class CTsPhysicsEngine;
       
    27 using namespace AknTouchGestureFw;
       
    28 /**
       
    29  * CTsEventControler
       
    30  * Input events handler. Class analyse pointer events and translate it to gesture. Procerss animations physics
       
    31  */
       
    32 NONSHARABLE_CLASS(CTsEventControler): 
       
    33     public CBase,
       
    34     public MAknTouchGestureFwObserver,
       
    35     public MAknPhysicsObserver
       
    36     {
       
    37 public:
       
    38     /**
       
    39      * Two phase constructor. Instance is pushed on cleanup stack.
       
    40      * @param aObs - reference to controler observer
       
    41      * @param aEventSrc - reference to control which provide pointer events
       
    42      * @return address of controler instance
       
    43      */
       
    44     static CTsEventControler* NewLC(MTsEventControlerObserver& aObs, 
       
    45                                             CCoeControl& aEventSrc);
       
    46     
       
    47     /**
       
    48      * Two phase constructor.
       
    49      * @param aObs - reference to control observer
       
    50      * @param aEventSrc - reference to control which provide pointer events
       
    51      * @return address of controler instance
       
    52      */
       
    53     static CTsEventControler* NewL(MTsEventControlerObserver& aObs, 
       
    54                                            CCoeControl& aEventSrc);
       
    55     
       
    56     /**
       
    57      * Destructor
       
    58      */
       
    59     ~CTsEventControler();
       
    60 
       
    61 private:
       
    62     /**
       
    63      * First phase construction
       
    64      */
       
    65     CTsEventControler(MTsEventControlerObserver& aObserver);
       
    66     
       
    67     /**
       
    68      * Second phase construction
       
    69      * @param aEventSrc - control that provides pointer ivents to handler
       
    70      */
       
    71     void ConstructL(CCoeControl& aEventSrc);
       
    72     
       
    73     /**
       
    74      * Implements gesture handling
       
    75      * @param aEvent - gesture event
       
    76      * @see MAknTouchGestureFwObserver
       
    77      */
       
    78     void HandleTouchGestureL(MAknTouchGestureFwEvent& aEvent);
       
    79     
       
    80     /**
       
    81      * Implements tap gesture handling ( short tap, double tap, long tap )
       
    82      * @param aEvent - tap event
       
    83      */
       
    84     void HandleTapEventL(MAknTouchGestureFwTapEvent& aEvent);
       
    85     
       
    86     /**
       
    87      * Implements drag gesture handling
       
    88      * @param aEvent - drag event
       
    89      */
       
    90     void HandleDragEventL(MAknTouchGestureFwDragEvent& aEvent);
       
    91     
       
    92     /**
       
    93      * Implements flick gesture handling
       
    94      * @param aEvent - drag event
       
    95      */
       
    96     void HandleFlickEventL(MAknTouchGestureFwFlickEvent& aEvent);
       
    97     
       
    98     //From MAknPhysicsObserver
       
    99 public:
       
   100     /**
       
   101      * Physics emulation has moved the view.
       
   102      * 
       
   103      * When this method is called client should update its visual and logical
       
   104      * states to reflect the changes caused by view move. Note that if the
       
   105      * parameter @c aDrawNow is @c EFalse client is not allowed to redraw the
       
   106      * display but should only update its logical state.
       
   107      * Physics engine will ensure that the last frame is always drawn.
       
   108      *
       
   109      * @since S60 v5.0
       
   110      *
       
   111      * @param  aNewPosition  The new position of the view.
       
   112      * @param  aDrawNow      @c ETrue if client should redraw the screen,
       
   113      *                       otherwise @c EFalse.
       
   114      * @param  aFlags        Additional flags, not used currently.
       
   115      */
       
   116     virtual void ViewPositionChanged( const TPoint& aNewPosition,
       
   117                               TBool aDrawNow,
       
   118                               TUint aFlags );
       
   119         
       
   120     /**
       
   121      * Physics emulation has stopped moving the view
       
   122      *
       
   123      * @since S60 v5.0
       
   124      */
       
   125     virtual void PhysicEmulationEnded();
       
   126 
       
   127     /**
       
   128      * Returns the observer's view position.
       
   129      *
       
   130      * @since S60 v5.0
       
   131      *
       
   132      * @return Physics observer's view position.
       
   133      */
       
   134     virtual TPoint ViewPosition() const;
       
   135     
       
   136 public:
       
   137     
       
   138     /**
       
   139      * Initialize animation between current position and destination point
       
   140      * @param aPoint - destination point 
       
   141      */
       
   142     void Animate(const TPoint& aPoint);
       
   143 
       
   144     /**
       
   145      * 
       
   146      * @param aWorldSize Physics world size.
       
   147      * @param aViewSize Physics (visible) view size.
       
   148      * @param aLandscape ETrue if physics should work in landscape.     
       
   149      **/
       
   150     void ReInitPhysicsL(const TSize& aWorldSize, 
       
   151                         const TSize& aViewSize,
       
   152                         TBool aLandscape);
       
   153     
       
   154     /**
       
   155      * Stops currently ongoing animation
       
   156      */
       
   157     void StopAnimation();
       
   158     
       
   159 private:
       
   160     /**
       
   161      * Controler observer. Not own
       
   162      */
       
   163     MTsEventControlerObserver& iObserver;
       
   164     
       
   165     /**
       
   166      * Gesture recognition helper. Own
       
   167      */
       
   168     CAknTouchGestureFw* iGestureHelper;
       
   169     
       
   170     /**
       
   171      * Physics helper. Own
       
   172      */
       
   173     CTsPhysicsEngine* iPhysicsHelper;
       
   174     };
       
   175 
       
   176 #endif // TSEVENTCONTROLER_H