666 // then it may make sense to make the recogniser a member variable. |
666 // then it may make sense to make the recogniser a member variable. |
667 return TXnGestureRecogniser().GestureCode( filter ); |
667 return TXnGestureRecogniser().GestureCode( filter ); |
668 } |
668 } |
669 |
669 |
670 // ---------------------------------------------------------------------------- |
670 // ---------------------------------------------------------------------------- |
|
671 // CodeFromPoints |
|
672 // ---------------------------------------------------------------------------- |
|
673 // |
|
674 TXnGestureCode CXnGesture::LastDirection( TAxis aRelevantAxis ) const |
|
675 { |
|
676 // select the correct filter based on aRelevantAxis |
|
677 // these filter_ objects are array decorators that will eliminate either |
|
678 // x, y or neither coordinate of each point |
|
679 TXAxisPointArray filterY( iPoints ); |
|
680 TYAxisPointArray filterX( iPoints ); |
|
681 TXnPointArray filterNone( iPoints ); |
|
682 TXnPointArray& filter = |
|
683 aRelevantAxis == EAxisHorizontal ? static_cast< TXnPointArray& >( filterY ) : |
|
684 aRelevantAxis == EAxisVertical ? static_cast< TXnPointArray& >( filterX ) : |
|
685 /* otherwise EAxisBoth */ filterNone; |
|
686 |
|
687 // currently the gesture recogniser does not have any state, so it is fast |
|
688 // to instantiate. The call is not static however, to allow the recogniser |
|
689 // to be replaced by a more complicated implementation that has state. |
|
690 // then it may make sense to make the recogniser a member variable. |
|
691 return TXnGestureRecogniser().LastDirection( filter ); |
|
692 } |
|
693 |
|
694 // ---------------------------------------------------------------------------- |
671 // return nth point from the end of the points array |
695 // return nth point from the end of the points array |
672 // ---------------------------------------------------------------------------- |
696 // ---------------------------------------------------------------------------- |
673 // |
697 // |
674 inline const TXnPointEntry& CXnGesture::NthLastEntry( TInt aOffset ) const |
698 inline const TXnPointEntry& CXnGesture::NthLastEntry( TInt aOffset ) const |
675 { |
699 { |
689 // PreviousPos |
713 // PreviousPos |
690 // ---------------------------------------------------------------------------- |
714 // ---------------------------------------------------------------------------- |
691 // |
715 // |
692 inline TPoint CXnGesture::PreviousPos() const |
716 inline TPoint CXnGesture::PreviousPos() const |
693 { |
717 { |
694 return PreviousEntry().iPos; |
718 return NthLastEntry( KPreviousPointOffset - 1 ).iPos; |
695 } |
719 } |
696 |
720 |
697 // ---------------------------------------------------------------------------- |
721 // ---------------------------------------------------------------------------- |
698 // SetComplete |
722 // SetComplete |
699 // ---------------------------------------------------------------------------- |
723 // ---------------------------------------------------------------------------- |