akntouchgesturefw/src/akntouchgesturefwpinchrecognizer.cpp
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:  Pinch touch gesture recognizer.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "akntouchgesturefwdefs.h"
       
    19 #include "akntouchgesturefwevent.h"
       
    20 #include "akntouchgesturefwpinchrecognizer.h"
       
    21 #include "akntouchgesturefwsettings.h"
       
    22 
       
    23 using namespace AknTouchGestureFw;
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Two-phased constructor.
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CAknTouchGestureFwPinchRecognizer* CAknTouchGestureFwPinchRecognizer::NewL(
       
    32     CAknTouchGestureFwRecognitionEngine& aEngine )
       
    33     {
       
    34     CAknTouchGestureFwPinchRecognizer* self =
       
    35         CAknTouchGestureFwPinchRecognizer::NewLC( aEngine );
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // Two-phased constructor.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CAknTouchGestureFwPinchRecognizer* CAknTouchGestureFwPinchRecognizer::NewLC(
       
    46         CAknTouchGestureFwRecognitionEngine& aEngine )
       
    47     {
       
    48     CAknTouchGestureFwPinchRecognizer* self
       
    49         = new ( ELeave ) CAknTouchGestureFwPinchRecognizer( aEngine );
       
    50     CleanupStack::PushL( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Destructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CAknTouchGestureFwPinchRecognizer::~CAknTouchGestureFwPinchRecognizer()
       
    60     {
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Returns the pinch gesture group.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 TAknTouchGestureFwGroup CAknTouchGestureFwPinchRecognizer::GestureGroup() const
       
    69     {
       
    70     return EAknTouchGestureFwGroupPinch;
       
    71     }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Cancels the gesture recognition.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CAknTouchGestureFwPinchRecognizer::CancelRecognizing()
       
    79     {
       
    80     if ( iContinuousFeedback )
       
    81         {
       
    82         StopContinuousFeedback();
       
    83         iContinuousFeedback = EFalse;
       
    84         }
       
    85     
       
    86     if ( iPinchDetected )
       
    87         {
       
    88         // We ignore the possible leave in order to ensure that the
       
    89         // state gets reset.
       
    90         TRAP_IGNORE( SendPinchEventL( EAknTouchGestureFwStop, 0 ) );
       
    91         }
       
    92     Reset();
       
    93     }
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Handles single-touch pointer events.
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CAknTouchGestureFwPinchRecognizer::HandleSinglePointerEventL(
       
   101         const TPointerEventData& /*aPointerData*/ )
       
   102     {
       
   103     // No single touch event handling in pinch recognizer
       
   104     }
       
   105 
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // Handles multi-touch pointer events.
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CAknTouchGestureFwPinchRecognizer::HandleMultiPointerEventL(
       
   112         const TPointerEventData& aPointerData,
       
   113         const TPoint& aFirstPointerPosition,
       
   114         const TPoint& aSecondPointerPosition )
       
   115     {
       
   116     // Handle event
       
   117     switch ( aPointerData.iPointerEvent.iType )
       
   118         {
       
   119         case TPointerEvent::EButton1Down:
       
   120             {
       
   121             StartMultiRecognizing( 
       
   122                 aFirstPointerPosition,
       
   123                 aSecondPointerPosition );
       
   124             break;
       
   125             }
       
   126             
       
   127         case TPointerEvent::EDrag:
       
   128             {
       
   129             MultiRecognizeL( 
       
   130                 aPointerData.iTimeStamp,
       
   131                 aFirstPointerPosition,
       
   132                 aSecondPointerPosition );
       
   133             break;
       
   134             }
       
   135         case TPointerEvent::EButton1Up:
       
   136             {
       
   137             CompleteMultiRecognizingL( aPointerData.iTimeStamp );
       
   138             break;
       
   139             }
       
   140         default:
       
   141             {
       
   142             break;
       
   143             }
       
   144         }
       
   145     }
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // C++ constructor.
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 CAknTouchGestureFwPinchRecognizer::CAknTouchGestureFwPinchRecognizer(
       
   153     CAknTouchGestureFwRecognitionEngine& aEngine )
       
   154     : CAknTouchGestureFwBaseRecognizer( aEngine )
       
   155     {
       
   156     Reset();
       
   157     }
       
   158 
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // Starts recognizing the pinch gesture.
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CAknTouchGestureFwPinchRecognizer::StartMultiRecognizing(
       
   165         const TPoint& aFirstPointerPos,
       
   166         const TPoint& aSecondPointerPos )
       
   167     {
       
   168     // Initialize members for multi recognition.
       
   169     Reset();
       
   170     
       
   171     iPinchRect = CalculateBoundingRect( aFirstPointerPos, aSecondPointerPos );
       
   172 
       
   173     TTouchFeedbackType feedbackType( FeedbackType( EAknTouchGestureFwPinch ) );
       
   174     if ( feedbackType )
       
   175         {
       
   176         ImmediateFeedback( ETouchFeedbackSensitive, feedbackType );
       
   177         ImmediateFeedback( ETouchFeedbackSensitive, feedbackType );
       
   178         }
       
   179     }
       
   180 
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // Continues recognizing the pinch gesture.
       
   184 // Called for every drag-event when more than one pointer is down.
       
   185 // Threshold handling for pinch is implemented here.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void CAknTouchGestureFwPinchRecognizer::MultiRecognizeL(
       
   189         const TTime& aEventTime,
       
   190         const TPoint& aFirstPointerPos,
       
   191         const TPoint& aSecondPointerPos )
       
   192     {    
       
   193     const TInt pinchThreshold = iPinchDetected ? 
       
   194         PinchMovementThreshold() : PinchInitialThreshold();
       
   195 
       
   196     // We use boundingRect instead of individual positions, because
       
   197     // those positions are not stable with all HW. Instead, bounding rect is.
       
   198     TRect boundingRect = 
       
   199         CalculateBoundingRect( aFirstPointerPos, aSecondPointerPos );
       
   200 
       
   201     // Snap to iPinchRect values.
       
   202     TRect normalizedRect = boundingRect;
       
   203     NormalizeValue( normalizedRect.iTl.iX, iPinchRect.iTl.iX, pinchThreshold );
       
   204     NormalizeValue( normalizedRect.iTl.iY, iPinchRect.iTl.iY, pinchThreshold );
       
   205     NormalizeValue( normalizedRect.iBr.iX, iPinchRect.iBr.iX, pinchThreshold );
       
   206     NormalizeValue( normalizedRect.iBr.iY, iPinchRect.iBr.iY, pinchThreshold );
       
   207 
       
   208     // Determine if width or height should be ignored. 
       
   209     // If length of a dimension is close to zero, it's assumed that 
       
   210     // those values may be unreliable.
       
   211     const TInt dimensionThreshold = PinchDimensionThreshold();
       
   212     TBool ignoreWidth =
       
   213         ( boundingRect.Width() < dimensionThreshold ) ||
       
   214         ( normalizedRect.Width() < dimensionThreshold ) ||
       
   215         ( iPinchRect.Width() < dimensionThreshold );
       
   216     TBool ignoreHeight =
       
   217         ( boundingRect.Height() < dimensionThreshold ) ||
       
   218         ( normalizedRect.Height() < dimensionThreshold ) ||
       
   219         ( iPinchRect.Height() < dimensionThreshold );
       
   220 
       
   221     // Calculate change in width & height.
       
   222     TInt widthDelta = ( normalizedRect.Width() - iPinchRect.Width() );
       
   223     TInt heightDelta = ( normalizedRect.Height() - iPinchRect.Height() );
       
   224        
       
   225     TBool handleEvent = EFalse;
       
   226     if ( normalizedRect != iPinchRect )
       
   227         {
       
   228         handleEvent = ETrue;
       
   229         iPinchRect = normalizedRect;
       
   230         }
       
   231 
       
   232     if ( ignoreWidth )
       
   233         {
       
   234         widthDelta = 0;
       
   235         iStoredWidthDelta = 0;
       
   236         }
       
   237     
       
   238     if ( ignoreHeight )
       
   239         {
       
   240         heightDelta = 0;
       
   241         iStoredHeightDelta = 0;
       
   242         }
       
   243 
       
   244     // Pinch values are sent in a slight delay in order to prevent
       
   245     // sending of incorrect values when pointer coordinates are
       
   246     // snapped to horizontal/vertical line as snapping tends to
       
   247     // happen with two events (one for each pointer).
       
   248     //
       
   249     // Events are sent here.
       
   250 
       
   251     TInt oldStoredWidthDelta = iStoredWidthDelta;
       
   252     TInt oldStoredHeightDelta = iStoredHeightDelta;
       
   253 
       
   254     if ( oldStoredWidthDelta || oldStoredHeightDelta )
       
   255         {
       
   256         iStoredWidthDelta = 0;
       
   257         iStoredHeightDelta = 0;
       
   258     
       
   259         TInt movement = 0;
       
   260         
       
   261         if ( CheckDurationThreshold( aEventTime ) )
       
   262             {
       
   263             movement = 
       
   264                 CalculateMovement( 
       
   265                     oldStoredWidthDelta,
       
   266                     oldStoredHeightDelta );
       
   267             }
       
   268             
       
   269     
       
   270         if ( movement )
       
   271             {
       
   272             if ( iPinchDetected )
       
   273                 {
       
   274                 SendPinchEventL( EAknTouchGestureFwOn, movement );
       
   275                 }
       
   276             else
       
   277                 {
       
   278                 iPinchDetected = ETrue;
       
   279                 SendPinchEventL( EAknTouchGestureFwStart, movement );
       
   280                 }
       
   281             }
       
   282         }
       
   283 
       
   284     if ( !handleEvent )
       
   285         {
       
   286         // No change, no need to continue
       
   287         return;
       
   288         }
       
   289     
       
   290     // Now it is guaranteed that widthDelta or heightDelta does not equal
       
   291     // to zero.
       
   292 
       
   293     // Update width direction tracer
       
   294     if ( !ignoreWidth )
       
   295         {
       
   296         iPinchWidthTracer.Update( 
       
   297             widthDelta, 
       
   298             PinchDirectionChangeSensitivity() );
       
   299         }
       
   300     else
       
   301         {
       
   302         // Cannot say anything about this direction - snapped together
       
   303         iPinchWidthTracer.Reset();
       
   304         }
       
   305     
       
   306     // Update height direction tracer
       
   307     if ( !ignoreHeight )
       
   308         {
       
   309         iPinchHeightTracer.Update( 
       
   310             heightDelta, 
       
   311             PinchDirectionChangeSensitivity() );
       
   312         }
       
   313     else
       
   314         {
       
   315         // Cannot say anything about this direction - snapped together
       
   316         iPinchHeightTracer.Reset();
       
   317         }
       
   318 
       
   319     // Reset direction tracer if height changes but width stays the same.
       
   320     if ( widthDelta )
       
   321         {
       
   322         iResetPinchWidthTracer = 0;
       
   323         }
       
   324 
       
   325     if ( !widthDelta && heightDelta )
       
   326         {
       
   327         if ( iResetPinchWidthTracer >= PinchDirectionResetSensitivity() )
       
   328             {
       
   329             iPinchWidthTracer.Reset();
       
   330             iResetPinchWidthTracer = 0;
       
   331             }
       
   332         else
       
   333             {
       
   334             iResetPinchWidthTracer++;
       
   335             }
       
   336         }
       
   337 
       
   338     // Reset direction tracer if width changes but height stays the same.
       
   339     if ( heightDelta )
       
   340         {
       
   341         iResetPinchHeightTracer = 0;
       
   342         }
       
   343             
       
   344     if ( !heightDelta && widthDelta )
       
   345         {
       
   346         if ( iResetPinchHeightTracer >= PinchDirectionResetSensitivity() )
       
   347             {
       
   348             iPinchHeightTracer.Reset();
       
   349             iResetPinchHeightTracer = 0;
       
   350             }
       
   351         else
       
   352             {
       
   353             iResetPinchHeightTracer++;
       
   354             }
       
   355         }
       
   356 
       
   357     TInt pinchWidthDelta = 0;
       
   358     TInt pinchHeightDelta = 0;
       
   359 
       
   360     if ( widthDelta >= 0 && heightDelta >= 0 )
       
   361         {
       
   362         TDirectionTracer::TDirection widthDir = 
       
   363             iPinchWidthTracer.Direction();
       
   364         TDirectionTracer::TDirection heightDir = 
       
   365             iPinchHeightTracer.Direction();
       
   366                 
       
   367         if ( ( widthDir == TDirectionTracer::EDirectionPositive && 
       
   368                heightDir != TDirectionTracer::EDirectionNegative ) || 
       
   369              ( heightDir == TDirectionTracer::EDirectionPositive && 
       
   370                widthDir != TDirectionTracer::EDirectionNegative ) )
       
   371             {
       
   372             pinchWidthDelta = widthDelta; 
       
   373             pinchHeightDelta = heightDelta; 
       
   374             }
       
   375         }
       
   376     else if ( widthDelta <= 0 && heightDelta <= 0 )
       
   377         {
       
   378         TDirectionTracer::TDirection widthDir = 
       
   379             iPinchWidthTracer.Direction();
       
   380         TDirectionTracer::TDirection heightDir = 
       
   381             iPinchHeightTracer.Direction();
       
   382                 
       
   383         if ( ( widthDir == TDirectionTracer::EDirectionNegative && 
       
   384                heightDir != TDirectionTracer::EDirectionPositive ) || 
       
   385              ( heightDir == TDirectionTracer::EDirectionNegative && 
       
   386                widthDir != TDirectionTracer::EDirectionPositive ) )
       
   387             {
       
   388             pinchWidthDelta = widthDelta;
       
   389             pinchHeightDelta = heightDelta;
       
   390             }                
       
   391         }
       
   392     else
       
   393         {
       
   394         // Ignore mixed changes.
       
   395         }
       
   396 
       
   397     // Pinch values are sent in a slight delay in order to prevent
       
   398     // sending of incorrect values when pointer coordinates are
       
   399     // snapped to horizontal/vertical line.
       
   400     //
       
   401     // Now just store delta values here.
       
   402     
       
   403     iStoredTime = aEventTime;
       
   404     iStoredWidthDelta = pinchWidthDelta;
       
   405     iStoredHeightDelta = pinchHeightDelta;
       
   406     }
       
   407 
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // Ends the recognition of the pinch gesture.
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 void CAknTouchGestureFwPinchRecognizer::CompleteMultiRecognizingL(
       
   414         const TTime& aEventTime )
       
   415     {
       
   416     if ( iContinuousFeedback )
       
   417         {
       
   418         StopContinuousFeedback();
       
   419         iContinuousFeedback = EFalse;
       
   420         }
       
   421     // Send Pinch stopped event only if pinch was detected
       
   422     if ( iPinchDetected )
       
   423         {
       
   424         TInt movement = 0;
       
   425         
       
   426         if ( CheckDurationThreshold( aEventTime ) )
       
   427             {
       
   428             movement = 
       
   429                 CalculateMovement( 
       
   430                     iStoredWidthDelta, 
       
   431                     iStoredHeightDelta );
       
   432             }
       
   433 
       
   434         iStoredWidthDelta = 0;
       
   435         iStoredHeightDelta = 0;
       
   436 
       
   437         SendPinchEventL( EAknTouchGestureFwStop, movement );
       
   438         }
       
   439     }
       
   440 
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // Resets the recognizer state.
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 void CAknTouchGestureFwPinchRecognizer::Reset()
       
   447     {
       
   448     iPinchDetected = EFalse;
       
   449     iPinchRect.SetRect( 0, 0, 0, 0 );
       
   450     iPinchWidthTracer.Reset();
       
   451     iPinchHeightTracer.Reset();
       
   452     iResetPinchWidthTracer = 0;
       
   453     iResetPinchHeightTracer = 0;
       
   454     iStoredWidthDelta = 0;
       
   455     iStoredHeightDelta = 0;
       
   456     }
       
   457 
       
   458 
       
   459 // ---------------------------------------------------------------------------
       
   460 // Sends a pinch gesture event to the observer.
       
   461 // ---------------------------------------------------------------------------
       
   462 //
       
   463 void CAknTouchGestureFwPinchRecognizer::SendPinchEventL(
       
   464     TAknTouchGestureFwState aGestureState,
       
   465     TInt aMovementDelta )
       
   466     {
       
   467     if ( aGestureState != EAknTouchGestureFwStop )
       
   468         {
       
   469         TTouchFeedbackType feedbackType(
       
   470             FeedbackType( EAknTouchGestureFwPinch ) );
       
   471     
       
   472         if ( feedbackType & ETouchFeedbackVibra )
       
   473             {
       
   474             StartContinuousFeedback( ETouchContinuousSmooth,
       
   475                 KAknTouchGestureFwFeedbackIntensity,
       
   476                 KAknTouchGestureFwPinchFeedbackTimeout );
       
   477             iContinuousFeedback = ETrue;
       
   478             }
       
   479         }
       
   480         
       
   481     TAknTouchGestureFwPinchEvent pinch;
       
   482     pinch.SetState( aGestureState );
       
   483     pinch.SetMovement( aMovementDelta );
       
   484     SendGestureEventL( pinch );
       
   485     }
       
   486 
       
   487 
       
   488 // ----------------------------------------------------------------------------
       
   489 // Returns pinch initial threshold.
       
   490 // ----------------------------------------------------------------------------
       
   491 //
       
   492 TInt CAknTouchGestureFwPinchRecognizer::PinchInitialThreshold() const
       
   493     {
       
   494     return Settings().PinchInitialThreshold();    
       
   495     }
       
   496 
       
   497 
       
   498 // ----------------------------------------------------------------------------
       
   499 // Returns pinch movement threshold.
       
   500 // ----------------------------------------------------------------------------
       
   501 //
       
   502 TInt CAknTouchGestureFwPinchRecognizer::PinchMovementThreshold() const
       
   503     {
       
   504     return Settings().PinchMovementThreshold();
       
   505     }
       
   506 
       
   507 
       
   508 // ----------------------------------------------------------------------------
       
   509 // Returns pinch direction change sensitivity.
       
   510 // ----------------------------------------------------------------------------
       
   511 //
       
   512 TInt CAknTouchGestureFwPinchRecognizer::PinchDirectionChangeSensitivity() const
       
   513     {
       
   514     return Settings().PinchDirectionChangeSensitivity();
       
   515     }
       
   516 
       
   517 
       
   518 // ----------------------------------------------------------------------------
       
   519 // Returns pinch direction reset sensitivity.
       
   520 // ----------------------------------------------------------------------------
       
   521 //
       
   522 TInt CAknTouchGestureFwPinchRecognizer::PinchDirectionResetSensitivity() const
       
   523     {
       
   524     return Settings().PinchDirectionResetSensitivity();
       
   525     }
       
   526 
       
   527 
       
   528 // ----------------------------------------------------------------------------
       
   529 // Returns pinch dimension threshold.
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 TInt CAknTouchGestureFwPinchRecognizer::PinchDimensionThreshold() const
       
   533     {
       
   534     return Settings().PinchDimensionThreshold();
       
   535     }
       
   536 
       
   537 // ----------------------------------------------------------------------------
       
   538 // Returns pinch maximum confirmation duration.
       
   539 // ----------------------------------------------------------------------------
       
   540 //
       
   541 TInt CAknTouchGestureFwPinchRecognizer::PinchMaximumConfirmationDuration() 
       
   542     const
       
   543     {
       
   544     return Settings().PinchMaximumConfirmationDuration() * 
       
   545            KMicroSecondsInMilliSecond;
       
   546     }
       
   547 
       
   548 
       
   549 // ---------------------------------------------------------------------------
       
   550 // Calculates bounding rect so that both aPoint1 and aPoint2 are inside
       
   551 // the rectangle.
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 TRect CAknTouchGestureFwPinchRecognizer::CalculateBoundingRect( 
       
   555         const TPoint& aPoint1, 
       
   556         const TPoint& aPoint2 )
       
   557     {
       
   558     TRect result;
       
   559     result.iTl.iX = Min( aPoint1.iX, aPoint2.iX );
       
   560     result.iTl.iY = Min( aPoint1.iY, aPoint2.iY );
       
   561     result.iBr.iX = Max( aPoint1.iX, aPoint2.iX ) + 1;  
       
   562     result.iBr.iY = Max( aPoint1.iY, aPoint2.iY ) + 1;
       
   563     return result;
       
   564     }
       
   565 
       
   566 
       
   567 // ---------------------------------------------------------------------------
       
   568 // Snaps aValue to aReference if they are sufficiently close 
       
   569 // (defined by aMargin).
       
   570 // ---------------------------------------------------------------------------
       
   571 //
       
   572 void CAknTouchGestureFwPinchRecognizer::NormalizeValue( 
       
   573         TInt& aValue, 
       
   574         TInt aReference, 
       
   575         TInt aMargin )
       
   576     {
       
   577     if ( Abs( aReference - aValue ) < aMargin )
       
   578         {
       
   579         aValue = aReference;
       
   580         }
       
   581     }
       
   582 
       
   583 // ---------------------------------------------------------------------------
       
   584 // Calculates movement value 
       
   585 // ---------------------------------------------------------------------------
       
   586 //
       
   587 TInt CAknTouchGestureFwPinchRecognizer::CalculateMovement( 
       
   588         TInt aWidthDelta, 
       
   589         TInt aHeightDelta )
       
   590     {
       
   591     TInt result = 0;
       
   592     
       
   593     if ( aWidthDelta >= 0 && aHeightDelta >= 0 )
       
   594         {
       
   595         result = Max( aWidthDelta, aHeightDelta );
       
   596         }
       
   597     else if ( aWidthDelta <= 0 && aHeightDelta <= 0 )
       
   598         {
       
   599         result = Min( aWidthDelta, aHeightDelta );
       
   600         }
       
   601     else
       
   602         {
       
   603         // Mixed case, return 'no movement'.
       
   604         }
       
   605 
       
   606     return result;
       
   607     }
       
   608 
       
   609 // ---------------------------------------------------------------------------
       
   610 // Checks duration threshold. 
       
   611 // ---------------------------------------------------------------------------
       
   612 //
       
   613 TBool CAknTouchGestureFwPinchRecognizer::CheckDurationThreshold( 
       
   614         const TTime& aEventTime ) const
       
   615     {
       
   616     TTimeIntervalMicroSeconds duration = 
       
   617         aEventTime.MicroSecondsFrom( iStoredTime );
       
   618     TTimeIntervalMicroSeconds durationThreshold( 
       
   619         PinchMaximumConfirmationDuration() );
       
   620     
       
   621     return ( duration < durationThreshold );
       
   622     }
       
   623 
       
   624 // End of File