textinput/peninputarc/src/peninputanim/penpointereventsuppressor.cpp
branchRCL_3
changeset 56 8152b1f1763a
parent 46 bd83ceabce89
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
    18 #include <penpointereventsuppressor.h>
    18 #include <penpointereventsuppressor.h>
    19 
    19 
    20 const TInt KPenPointerEventSuppressorDefaultMaxTapDuration = 400000;	// 0.4 seconds
    20 const TInt KPenPointerEventSuppressorDefaultMaxTapDuration = 400000;	// 0.4 seconds
    21 const TInt KPenPointerEventSuppressorDefaultMinInterDragInterval = 0;
    21 const TInt KPenPointerEventSuppressorDefaultMinInterDragInterval = 0;
    22 const TInt KPenPointerEventSuppressorDefaultMovement = 6;
    22 const TInt KPenPointerEventSuppressorDefaultMovement = 6;
       
    23 
    23 
    24 
    24 const TInt KPenPointerEventSuppressorDefaultMaxDownUpDuration = 400000; // 0.4 seconds
    25 const TInt KPenPointerEventSuppressorDefaultMaxDownUpDuration = 400000; // 0.4 seconds
    25 const TInt KPenPointerEventSuppressorDefaultDownUpMovement = 7;
    26 const TInt KPenPointerEventSuppressorDefaultDownUpMovement = 7;
    26 
    27 
    27 CPenPointerEventSuppressor* CPenPointerEventSuppressor::NewL()
    28 CPenPointerEventSuppressor* CPenPointerEventSuppressor::NewL()
    45 	iMaxTapMove.iHeight = KPenPointerEventSuppressorDefaultMovement;
    46 	iMaxTapMove.iHeight = KPenPointerEventSuppressorDefaultMovement;
    46 	
    47 	
    47 	iMaxDownUpMove.iWidth = KPenPointerEventSuppressorDefaultDownUpMovement;
    48 	iMaxDownUpMove.iWidth = KPenPointerEventSuppressorDefaultDownUpMovement;
    48 	iMaxDownUpMove.iHeight = KPenPointerEventSuppressorDefaultDownUpMovement;
    49 	iMaxDownUpMove.iHeight = KPenPointerEventSuppressorDefaultDownUpMovement;
    49   	}
    50   	}
       
    51 
    50 
    52 
    51 TBool CPenPointerEventSuppressor::SuppressPointerEvent( TPointerEvent& aPointerEvent )
    53 TBool CPenPointerEventSuppressor::SuppressPointerEvent( TPointerEvent& aPointerEvent )
    52 	{
    54 	{
    53 	switch ( aPointerEvent.iType )
    55 	switch ( aPointerEvent.iType )
    54 		{
    56 		{
    92 			// this drag event should be handled
    94 			// this drag event should be handled
    93 			iLastEventTime = now;
    95 			iLastEventTime = now;
    94 			break;
    96 			break;
    95 			}
    97 			}
    96 		case TPointerEvent::EButton1Up:
    98 		case TPointerEvent::EButton1Up:
    97             {
    99 		    {
    98             TTime now;
   100 		    TTime now;
    99             now.HomeTime();
   101 		    now.HomeTime();
   100             TPoint delta = aPointerEvent.iPosition - iDownPos;
   102 		    TPoint delta = aPointerEvent.iPosition - iDownPos;
   101             if ( now.MicroSecondsFrom( iDownTime ) < iMaxDownUpDuration 
   103 		    if ( now.MicroSecondsFrom( iDownTime ) < iMaxDownUpDuration 
   102                  && Abs( delta.iX ) < iMaxDownUpMove.iWidth 
   104 		         && Abs( delta.iX ) < iMaxDownUpMove.iWidth 
   103                  && Abs( delta.iY ) < iMaxDownUpMove.iHeight )
   105 		         && Abs( delta.iY ) < iMaxDownUpMove.iHeight )
   104                 {
   106 		        {               
   105                 //within maximum movement and timeout, so move to position of down
   107                 //within maximum movement and timeout, so move to position of down
   106                 aPointerEvent.iPosition = iDownPos;
   108                 aPointerEvent.iPosition = iDownPos;
   107                 }
   109 		        }
       
   110 		    
   108 			iTap = EFalse;
   111 			iTap = EFalse;
   109 			break;
   112 			break;
   110 		    }
   113 		    }
   111 		case TPointerEvent::ENullType:
   114 		case TPointerEvent::ENullType:
   112 		    break;
   115 		    break;
   133         TTimeIntervalMicroSeconds aInterval)
   136         TTimeIntervalMicroSeconds aInterval)
   134 	{
   137 	{
   135 	iMinInterDragInterval = aInterval;
   138 	iMinInterDragInterval = aInterval;
   136 	}
   139 	}
   137 
   140 
       
   141 
   138 void CPenPointerEventSuppressor::SetMaxDownUpMove( TSize aMaxDownUpMove ) 
   142 void CPenPointerEventSuppressor::SetMaxDownUpMove( TSize aMaxDownUpMove ) 
   139     { 
   143     { 
   140     iMaxDownUpMove = aMaxDownUpMove; 
   144     iMaxDownUpMove = aMaxDownUpMove; 
   141     }
   145     }
   142 
   146 
   143 void CPenPointerEventSuppressor::SetMaxDownUpDuration( TTimeIntervalMicroSeconds aDuration ) 
   147 void CPenPointerEventSuppressor::SetMaxDownUpDuration( TTimeIntervalMicroSeconds aDuration ) 
   144     {
   148     {
   145     iMaxDownUpDuration = aDuration; 
   149     iMaxDownUpDuration = aDuration; 
   146     }
   150     }
       
   151