webengine/webkitutils/stmgesturefw/inc/pinchgesturerecogniser.h
changeset 28 d39add9822e2
equal deleted inserted replaced
27:6297cdf66332 28:d39add9822e2
       
     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 the License "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:Pinch Gesture Recognizer
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef PINCHGESTURERECOGNISER_H_
       
    19 #define PINCHGESTURERECOGNISER_H_
       
    20 
       
    21 #include "rt_gestureengineif.h"
       
    22 #include <rt_gestureif.h>
       
    23 #include <rt_gesturelistener.h>
       
    24 
       
    25 class CCoeControl ;
       
    26 
       
    27 namespace stmGesture
       
    28 {
       
    29 /*!
       
    30  * Recognise pinching gesture. !!! very experimental !!!
       
    31  * It seems that in capacitive touch in Symbian 9.4 touching with two
       
    32  * fingers causes fast EDrag events which are far from each other.
       
    33  * This gesture recogniser tries to use that feature
       
    34  * to determine when the gestures looks like a pinch.
       
    35  * Would requires a lot of tuning to be really useful, if at all possible.
       
    36  * With current implementation it is easy to zoom in but
       
    37  * almost impossible to zoom out.
       
    38  */
       
    39 NONSHARABLE_CLASS( CPinchGestureRecogniser ): public CGestureRecogniser
       
    40 {
       
    41 public:
       
    42     static const TGestureUid KUid = EGestureUidPinch;
       
    43 
       
    44     static CPinchGestureRecogniser* NewL(MGestureListener* aListener);
       
    45 
       
    46     virtual ~CPinchGestureRecogniser();
       
    47     /*!
       
    48      * MGestureRecogniserIf methods
       
    49      */
       
    50     virtual TGestureRecognitionState recognise(int numOfActiveStreams, MGestureEngineIf* ge) ;
       
    51     virtual void release(MGestureEngineIf* ge) ;
       
    52 
       
    53     virtual TGestureUid gestureUid() const
       
    54         {
       
    55         return KUid;
       
    56         }
       
    57 
       
    58     /* define the pinch triggering as speed value */
       
    59     /* after EHold has been seen, then any move which is faster than this will enter pinch gesture */
       
    60     /* note that the value varies depending on techology, speed is measured as pixels / ms */
       
    61     void setPinchingSpeed(float aSpeed) __SOFTFP;
       
    62 
       
    63 private:
       
    64     CPinchGestureRecogniser(MGestureListener* aListener) ;
       
    65 
       
    66     void calculateZoomingLine() ;
       
    67     float calculateDistance() ;
       
    68     int adjustPinchMove(float& aPreviousDistance, float aNewDistance) ;
       
    69 
       
    70 private:
       
    71     bool m_pinching ;
       
    72     float m_pinchingspeed ;
       
    73     TPoint m_pinchstart ;
       
    74     TPoint m_pinchend ;
       
    75 
       
    76     float m_m ;
       
    77     float m_b ;
       
    78 
       
    79     float m_ddistance ;
       
    80     bool m_holdseen ;
       
    81     TPoint m_holdseenAtPos ;
       
    82     TTime m_holdseenAtTime ;
       
    83 };
       
    84 
       
    85 }
       
    86 
       
    87 #endif /* PINCHGESTURERECOGNISER_H_ */