akntouchgesturefw/inc/akntouchgesturefwtaprecognizer.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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:  Tap touch gesture recognizer.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_AKNTOUCHGESTUREFWTAPRECOGNIZER_H
       
    19 #define C_AKNTOUCHGESTUREFWTAPRECOGNIZER_H
       
    20 
       
    21 #include "akntouchgesturefwbaserecognizer.h"
       
    22 
       
    23 namespace AknTouchGestureFw {
       
    24 
       
    25 /**
       
    26  *  Tap touch gesture recognizer.
       
    27  *
       
    28  *  @lib akntouchgesturefw
       
    29  *  @since S60 v5.2
       
    30  */
       
    31 NONSHARABLE_CLASS( CAknTouchGestureFwTapRecognizer )
       
    32     : public CAknTouchGestureFwBaseRecognizer
       
    33     {
       
    34 
       
    35 public:
       
    36 
       
    37     /**
       
    38      * Two-phased constructor.
       
    39      *
       
    40      * @param  aEngine  The gesture recognition engine.
       
    41      */
       
    42     static CAknTouchGestureFwTapRecognizer* NewL(
       
    43             CAknTouchGestureFwRecognitionEngine& aEngine );
       
    44 
       
    45     /**
       
    46      * Two-phased constructor.
       
    47      *
       
    48      * @param  aEngine  The gesture recognition engine.
       
    49      */
       
    50     static CAknTouchGestureFwTapRecognizer* NewLC(
       
    51             CAknTouchGestureFwRecognitionEngine& aEngine );
       
    52 
       
    53     /**
       
    54      * Destructor.
       
    55      */
       
    56     virtual ~CAknTouchGestureFwTapRecognizer();
       
    57 
       
    58 public: // From base class CAknTouchGestureFwBaseRecognizer.
       
    59 
       
    60     /**
       
    61      * Returns the recognizer gesture group.
       
    62      *
       
    63      * @return @c EAknTouchGestureFwGroupTap
       
    64      */
       
    65     TAknTouchGestureFwGroup GestureGroup() const;
       
    66 
       
    67     /**
       
    68      * Cancels the gesture recognition.
       
    69      */
       
    70     void CancelRecognizing();
       
    71 
       
    72     /**
       
    73      * Handles single pointer event.
       
    74      *
       
    75      * @param  aPointerData  Pointer event related data.
       
    76      */
       
    77     void HandleSinglePointerEventL( const TPointerEventData& aPointerData );
       
    78 
       
    79     /**
       
    80      * Handles multi pointer event.
       
    81      *
       
    82      * @param  aPointerData            Pointer event related data.
       
    83      * @param  aFirstPointerPosition   First pointer position.
       
    84      * @param  aSecondPointerPosition  Second pointer position.
       
    85      */
       
    86     void HandleMultiPointerEventL( const TPointerEventData& aPointerData,
       
    87                                    const TPoint& aFirstPointerPosition,
       
    88                                    const TPoint& aSecondPointerPosition );
       
    89 
       
    90 private:
       
    91 
       
    92     /**
       
    93      * C++ constructor.
       
    94      *
       
    95      * @param  aEngine  The gesture recognition engine.
       
    96      */
       
    97     CAknTouchGestureFwTapRecognizer(
       
    98             CAknTouchGestureFwRecognitionEngine& aEngine );
       
    99 
       
   100     /**
       
   101      * Starts tap recognition.
       
   102      *
       
   103      * @param  aStartPoint  Position where pointer was pressed down.
       
   104      * @param  aTimeStamp   Pointer event time stamp.
       
   105      */
       
   106     void StartTapRecognition( const TPoint& aStartPoint,
       
   107                               const TTime& aTimeStamp );
       
   108 
       
   109     /**
       
   110      * Continues tap recognition.
       
   111      * This is called on pointer drag events, on which it's checked that
       
   112      * the pointer hasn't moved outside of the tap threshold area.
       
   113      *
       
   114      * @param  aPoint  New position.
       
   115      */
       
   116     void TapRecognize( const TPoint& aPoint );
       
   117 
       
   118     /**
       
   119      * Completes tap recognition.
       
   120      * This is called when pointer up event is received, after which
       
   121      * the possible tap gesture can be recognized.
       
   122      * 
       
   123      * @param  aTimeStamp   Pointer event time stamp.
       
   124      */
       
   125     void CompleteTapRecognitionL( const TTime& aTimeStamp );
       
   126 
       
   127     /**
       
   128      * Sends a tap gesture event
       
   129      *
       
   130      * @param  aGestureType  Type of tap gesture.
       
   131      * @param  aPointerPos   Tap position.
       
   132      */
       
   133     void SendTapEventL( TAknTouchGestureFwType aGestureType,
       
   134                         const TPoint& aPointerPos );
       
   135 
       
   136     /**
       
   137      * Called by long tap timer when the time interval is exceeded.
       
   138      *
       
   139      * @param  aThis  Self pointer.
       
   140      *
       
   141      * @return EFalse
       
   142      */
       
   143     static TInt LongTapCallback( TAny* aThis );
       
   144 
       
   145     /**
       
   146      * Handles long tap callback related actions.
       
   147      */
       
   148     void HandleLongTapCallbackL();
       
   149 
       
   150     /**
       
   151      * Internal helper method to cancel the tap recognition.
       
   152      *
       
   153      * @param  aResetFirstTapDetection  @c ETrue if double tap not allowed.
       
   154      */
       
   155     void DoCancelTapRecognition( TBool aResetFirstTapDetection );
       
   156 
       
   157     /**
       
   158      * Returns the long tap threshold.
       
   159      * Long tap threshold is the amount of time after pointer down event
       
   160      * after which the tap will be recognized as a long tap.
       
   161      *
       
   162      * @return Long tap threshold.
       
   163      */
       
   164     TInt LongTapThreshold() const;
       
   165 
       
   166     /**
       
   167      * Returns the tap threshold.
       
   168      * Tap threshold is the maximum distance in pixels that there can be
       
   169      * between the pointer down and pointer up events for a tap gesture.
       
   170      *
       
   171      * @return Tap threshold.
       
   172      */
       
   173     TInt TapThreshold() const;
       
   174 
       
   175     /**
       
   176      * Returns the maximum delay that is allowed between the two taps
       
   177      * in double tap gesture.
       
   178      *
       
   179      * @return Double tap maximum duration.
       
   180      */
       
   181     TInt DoubleTapMaximumDuration() const;
       
   182 
       
   183 private: // data
       
   184 
       
   185     /**
       
   186      * Threshold area.
       
   187      */
       
   188     TThresholdArea iThresholdArea;
       
   189 
       
   190     /**
       
   191      * Long tap timer.
       
   192      */
       
   193     CPeriodic* iLongTapTimer;
       
   194 
       
   195     /**
       
   196      * Boolean flag to indicate if first tap has been detected.
       
   197      */
       
   198     TBool iFirstTapDetected;
       
   199 
       
   200     /**
       
   201      * Time of first tap.
       
   202      */
       
   203     TTime iFirstTapTime;
       
   204 
       
   205     /**
       
   206      * Position of first tap.
       
   207      */
       
   208     TPoint iFirstTapPos;
       
   209     
       
   210     /**
       
   211      * Intensity value for long tap detection.
       
   212      */  
       
   213     TInt iLongTapIntensity;
       
   214     
       
   215     /**
       
   216      * Boolean flag to indicate if long tap feedback has been started.
       
   217      */  
       
   218     TBool iFeedBackStarted;    
       
   219     
       
   220     };
       
   221 
       
   222 } // namespace AknTouchGestureFw
       
   223 
       
   224 #endif // C_AKNTOUCHGESTUREFWTAPRECOGNIZER_H