akntouchgesturefw/inc/akntouchgesturefwdragrecognizer.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:  Drag touch gesture recognizer.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_AKNTOUCHGESTUREFWDRAGRECOGNIZER_H
       
    19 #define C_AKNTOUCHGESTUREFWDRAGRECOGNIZER_H
       
    20 
       
    21 
       
    22 #include "akntouchgesturefwbaserecognizer.h"
       
    23 
       
    24 namespace AknTouchGestureFw {
       
    25 
       
    26 /**
       
    27  *  Drag touch gesture recognizer.
       
    28  *
       
    29  *  @lib akntouchgesturefw
       
    30  *  @since S60 v5.2
       
    31  */
       
    32 NONSHARABLE_CLASS( CAknTouchGestureFwDragRecognizer )
       
    33     : public CAknTouchGestureFwBaseRecognizer
       
    34     {
       
    35 
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Two-phased constructor.
       
    40      *
       
    41      * @param  aEngine  The gesture recognition engine.
       
    42      */
       
    43     static CAknTouchGestureFwDragRecognizer* NewL(
       
    44             CAknTouchGestureFwRecognitionEngine& aEngine );
       
    45 
       
    46     /**
       
    47      * Two-phased constructor.
       
    48      *
       
    49      * @param  aEngine  The gesture recognition engine.
       
    50      */
       
    51     static CAknTouchGestureFwDragRecognizer* NewLC(
       
    52             CAknTouchGestureFwRecognitionEngine& aEngine );
       
    53 
       
    54     /**
       
    55      * Destructor.
       
    56      */
       
    57     virtual ~CAknTouchGestureFwDragRecognizer();
       
    58 
       
    59 public: // From base class CAknTouchGestureFwBaseRecognizer.
       
    60 
       
    61     /**
       
    62      * Returns the recognizer's gesture group.
       
    63      *
       
    64      * @return Gesture group.
       
    65      */
       
    66     TAknTouchGestureFwGroup GestureGroup() const;
       
    67 
       
    68     /**
       
    69      * Cancels gesture recognition.
       
    70      */
       
    71     void CancelRecognizing();
       
    72 
       
    73     /**
       
    74      * Handles single pointer event.
       
    75      *
       
    76      * @param  aPointerData  Pointer event related data.
       
    77      */
       
    78     void HandleSinglePointerEventL( const TPointerEventData& aPointerData );
       
    79 
       
    80     /**
       
    81      * Handles multi pointer event.
       
    82      *
       
    83      * @param  aPointerData            Pointer event related data.
       
    84      * @param  aFirstPointerPosition   First pointer position.
       
    85      * @param  aSecondPointerPosition  Second pointer position.
       
    86      */
       
    87     void HandleMultiPointerEventL( const TPointerEventData& aPointerData,
       
    88                                    const TPoint& aFirstPointerPosition,
       
    89                                    const TPoint& aSecondPointerPosition );
       
    90 
       
    91 private:
       
    92 
       
    93     /**
       
    94      * C++ constructor.
       
    95      *
       
    96      * @param  aEngine  The gesture recognition engine.
       
    97      */
       
    98     CAknTouchGestureFwDragRecognizer(
       
    99             CAknTouchGestureFwRecognitionEngine& aEngine );
       
   100 
       
   101     /**
       
   102      * Starts single-touch recognition.
       
   103      *
       
   104      * @param  aPointerPos  Current pointer position.
       
   105      */
       
   106     void StartSingleRecognizing( const TPoint& aPointerPos );
       
   107 
       
   108     /**
       
   109      * Handles single-touch recognition cycle.
       
   110      * Called for every drag event when one pointer is down.
       
   111      *
       
   112      * @param  aPointerPos  New position of pointer.
       
   113      */
       
   114     void SingleRecognizeL( const TPoint& aPointerPos );
       
   115 
       
   116     /**
       
   117      * Completes single-touch recognition.
       
   118      */
       
   119     void CompleteSingleRecognizingL();
       
   120 
       
   121     /**
       
   122      * Asks engine to send drag event to observer.
       
   123      *
       
   124      * @param  aGestureState  Drag gesture state.
       
   125      */
       
   126     void SendDragEventL( TAknTouchGestureFwState aGestureState );
       
   127 
       
   128     /**
       
   129      * Resets the recognizer.
       
   130      */
       
   131     void Reset();
       
   132 
       
   133     /**
       
   134      * Returns current gesture position.
       
   135      *
       
   136      * @return Current gesture position.
       
   137      */
       
   138     TPoint CurrentPos() const;
       
   139 
       
   140     /**
       
   141      * Returns previous gesture position.
       
   142      *
       
   143      * @return Previous gesture position.
       
   144      */
       
   145     TPoint PreviousPos() const;
       
   146 
       
   147 private: // data
       
   148 
       
   149     /**
       
   150      * Start position of gesture.
       
   151      */
       
   152     TPoint iStartPosition;
       
   153 
       
   154     /**
       
   155      * Current position of gesture.
       
   156      */
       
   157     TPoint iCurrentPosition;
       
   158 
       
   159     /**
       
   160      * Previous position of gesture.
       
   161      */
       
   162     TPoint iPreviousPosition;
       
   163 
       
   164     /**
       
   165      * ETrue if drag gesture already detected.
       
   166      */
       
   167     TBool iDragDetected;
       
   168 
       
   169     /**
       
   170      * Drag threshold area.
       
   171      */
       
   172     TThresholdArea iDragArea;
       
   173     
       
   174     /**
       
   175      * Boolean flag to indicate if drag recognition
       
   176      * should be started upon single touch drag.
       
   177      * This flag may be set when multi touch changes to
       
   178      * single (i.e. another pointer was released).
       
   179      */
       
   180     TBool iStartOnSingleTouchDrag;
       
   181     
       
   182     /**
       
   183      * ETrue if continuous feedback ongoing.
       
   184      */
       
   185     TBool iContinuousFeedback;
       
   186     };
       
   187 
       
   188 } // namespace AknTouchGestureFw
       
   189 
       
   190 #endif // C_AKNTOUCHGESTUREFWDRAGRECOGNIZER_H