webengine/webkitutils/rt_gesturehelper/src/gesture.cpp
changeset 1 7c90e6132015
parent 0 dd21522fd290
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
    71     /**
    71     /**
    72      * @param aRelevantAxis See @ref MGestureEvent::Code
    72      * @param aRelevantAxis See @ref MGestureEvent::Code
    73      * @return gesture code by analysing the sequence of points
    73      * @return gesture code by analysing the sequence of points
    74      */
    74      */
    75     TGestureCode CodeFromPoints( const RArray< TPointEntry >& aPoints, 
    75     TGestureCode CodeFromPoints( const RArray< TPointEntry >& aPoints, 
    76             MGestureEvent::TAxis aRelevantAxis ) 
    76                                  TAxis aRelevantAxis ) 
    77         {
    77         {
    78         // select the correct filter based on aRelevantAxis
    78         // select the correct filter based on aRelevantAxis
    79         // these filter_ objects are array decorators that will eliminate either 
    79         // these filter_ objects are array decorators that will eliminate either 
    80         // x, y or neither coordinate of each point
    80         // x, y or neither coordinate of each point
    81         TXAxisPointArray filterY( aPoints );
    81         TXAxisPointArray filterY( aPoints );
    82         TYAxisPointArray filterX( aPoints );
    82         TYAxisPointArray filterX( aPoints );
    83         TPointArray filterNone( aPoints );
    83         TPointArray filterNone( aPoints );
    84         TPointArray& filter = 
    84         TPointArray& filter = 
    85             aRelevantAxis == MGestureEvent::EAxisHorizontal ? static_cast< TPointArray& >( filterY ) : 
    85             aRelevantAxis == EAxisHorizontal ? static_cast< TPointArray& >( filterY ) : 
    86             aRelevantAxis == MGestureEvent::EAxisVertical   ? static_cast< TPointArray& >( filterX ) :
    86             aRelevantAxis == EAxisVertical   ? static_cast< TPointArray& >( filterX ) :
    87             /* otherwise EAxisBoth */                         filterNone;
    87             /* otherwise EAxisBoth */                         filterNone;
    88                             
    88                             
    89         // currently the gesture recogniser does not have any state, so it is fast
    89         // currently the gesture recogniser does not have any state, so it is fast
    90         // to instantiate. The call is not static however, to allow the recogniser
    90         // to instantiate. The call is not static however, to allow the recogniser
    91         // to be replaced by a more complicated implementation that has state.
    91         // to be replaced by a more complicated implementation that has state.
   124     {
   124     {
   125     iPoints.Reset();
   125     iPoints.Reset();
   126     iHoldingState = ENotHolding;
   126     iHoldingState = ENotHolding;
   127     iState = ENotComplete;
   127     iState = ENotComplete;
   128     iHoldingPointIndex = 0;
   128     iHoldingPointIndex = 0;
   129     iVisual = NULL;
       
   130     iIsDoubleTap = EFalse;
   129     iIsDoubleTap = EFalse;
   131     iIsLongTap = EFalse;
   130     iIsLongTap = EFalse;
   132     }
   131     }
   133     
   132     
   134 // ----------------------------------------------------------------------------
   133 // ----------------------------------------------------------------------------
   155 
   154 
   156 // ----------------------------------------------------------------------------
   155 // ----------------------------------------------------------------------------
   157 // SetVisual
   156 // SetVisual
   158 // ----------------------------------------------------------------------------
   157 // ----------------------------------------------------------------------------
   159 //
   158 //
   160 void CGesture::SetVisual( CAlfVisual* aVisual )
   159 
   161     {
       
   162     iVisual = aVisual;
       
   163     }
       
   164 
   160 
   165 // ----------------------------------------------------------------------------
   161 // ----------------------------------------------------------------------------
   166 // IsNearHoldingPoint
   162 // IsNearHoldingPoint
   167 // ----------------------------------------------------------------------------
   163 // ----------------------------------------------------------------------------
   168 //
   164 //
   271 // IsTap
   267 // IsTap
   272 // ----------------------------------------------------------------------------
   268 // ----------------------------------------------------------------------------
   273 //
   269 //
   274 TBool CGesture::IsTap() const
   270 TBool CGesture::IsTap() const
   275     {
   271     {
   276     return CodeFromPoints( iPoints, MGestureEvent::EAxisBoth ) == EGestureTap;
   272     return CodeFromPoints( iPoints, EAxisBoth ) == EGestureTap;
   277     }
   273     }
   278 
   274 
   279 /**
   275 /**
   280  * Translates a non-holding code into a holding code
   276  * Translates a non-holding code into a holding code
   281  * @param aCode original gesture code
   277  * @param aCode original gesture code
   295     
   291     
   296 // ----------------------------------------------------------------------------
   292 // ----------------------------------------------------------------------------
   297 // Code
   293 // Code
   298 // ----------------------------------------------------------------------------
   294 // ----------------------------------------------------------------------------
   299 //
   295 //
   300 TGestureCode CGesture::Code( MGestureEvent::TAxis aRelevantAxis ) /* const */
   296 TGestureCode CGesture::Code( TAxis aRelevantAxis ) /* const */
   301     {
   297     {
   302     TGestureCode code;
   298     TGestureCode code;
   303     
   299     
   304     switch ( iState )
   300     switch ( iState )
   305         {
   301         {
   684 
   680 
   685 // ----------------------------------------------------------------------------
   681 // ----------------------------------------------------------------------------
   686 // Visual
   682 // Visual
   687 // ----------------------------------------------------------------------------
   683 // ----------------------------------------------------------------------------
   688 //
   684 //
   689 CAlfVisual* CGesture::Visual() const
       
   690     {
       
   691     return iVisual;
       
   692     }
       
   693 
   685 
   694 // ----------------------------------------------------------------------------
   686 // ----------------------------------------------------------------------------
   695 // TimeFromPreviousPoint
   687 // TimeFromPreviousPoint
   696 // ----------------------------------------------------------------------------
   688 // ----------------------------------------------------------------------------
   697 //
   689 //