idlehomescreen/xmluirendering/uiengine/inc/xngesturehelper.h
changeset 0 f72a12da539e
child 16 9674c1a575e9
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Gesture helper implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _XNGESTUREHELPER_H_
       
    20 #define _XNGESTUREHELPER_H_
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 
       
    25 // Forward declarations
       
    26 class CXnNode;
       
    27 struct TPointerEvent;
       
    28 
       
    29 
       
    30 /**
       
    31  * Swipe directions (left, right, none)
       
    32  */
       
    33 enum TSwipeResult
       
    34     {
       
    35     ESwipeNone = 0,
       
    36     ESwipeLeft,
       
    37     ESwipeRight
       
    38     };
       
    39 
       
    40 /**
       
    41  * XnGestureHelper namespace
       
    42  * Used for the whole gesture family - Gesture recognizer, gesture helper, 
       
    43  * Point array
       
    44  */
       
    45 namespace XnGestureHelper
       
    46     {
       
    47     
       
    48     // Forward declarations
       
    49     class CHoldingTimer;
       
    50     class CXnGesture;
       
    51     
       
    52     // Constants
       
    53     const TReal32 KGestureMinSpeedX = 300;
       
    54     const TInt KGestureMinLengthX = 100;
       
    55     const TInt KGestureMaxDeltaY = 100;
       
    56     
       
    57     /**
       
    58      *  Implementation of CGestureHelper interface
       
    59      *
       
    60      *  @ingroup group_xnlayoutengine
       
    61      */
       
    62     NONSHARABLE_CLASS( CXnGestureHelper ) : public CBase
       
    63         {
       
    64     
       
    65         /** private implementation class */
       
    66         friend class CHoldingTimer;
       
    67     
       
    68     public:
       
    69         
       
    70         /** 2-phase constructor */
       
    71         static CXnGestureHelper* NewL( CXnNode& aNode );
       
    72 
       
    73         /** Destructor */
       
    74         ~CXnGestureHelper();
       
    75 
       
    76         /** 
       
    77          * See GestureHelper, SetHoldingEnabled function
       
    78          * 
       
    79          * @see CGestureHelper::SetHoldingEnabled 
       
    80          */
       
    81         void SetHoldingEnabled( TBool aEnabled );
       
    82         
       
    83         /** 
       
    84          * See Gesturehelper, IsHoldingEnabled function
       
    85          * 
       
    86          * @see CGestureHelper::IsHoldingEnabled 
       
    87          */
       
    88         TBool IsHoldingEnabled() const;
       
    89 
       
    90         /** 
       
    91          * Gets the owner
       
    92          * 
       
    93          * @return Owner
       
    94          */                
       
    95         CXnNode* Owner() const;
       
    96         
       
    97         /** 
       
    98          * Sets destination
       
    99          * 
       
   100          * @aParam Destination
       
   101          */        
       
   102         void SetDestination( CXnNode* aDestination );
       
   103 
       
   104         /** 
       
   105          * Gets destination
       
   106          * 
       
   107          * @return Destination
       
   108          */                         
       
   109         CXnNode* Destination() const;
       
   110         
       
   111         /** 
       
   112          * See GestureHelper Handlepointervent
       
   113          * 
       
   114          * @see CGestureHelper::HandlePointerEventL 
       
   115          */ 
       
   116         TSwipeResult HandlePointerEventL( const TPointerEvent& aEvent );
       
   117         
       
   118         /** Reset helper state */
       
   119         void Reset();
       
   120 
       
   121     private:
       
   122         
       
   123         /** Constructor */
       
   124         CXnGestureHelper( CXnNode& aNode );
       
   125 
       
   126         /** 
       
   127          * Returns if the helper is processing
       
   128          *         
       
   129          * @return ETrue if the helper has not started processing a gesture
       
   130          */
       
   131         inline TBool IsIdle() const; 
       
   132         
       
   133         /** 
       
   134          * Add a point to the sequence of points that make up the gesture 
       
   135          */
       
   136         inline void AddPointL( const TPointerEvent& aEvent );
       
   137         
       
   138         /** 
       
   139          * Add a point to the sequence of points that make up the gesture
       
   140          * 
       
   141          * @return                    
       
   142          */
       
   143         inline TInt AddPoint( const TPointerEvent& aEvent );
       
   144         
       
   145         /** 
       
   146          * Activates holding and notifies observer that holding has been 
       
   147          * started 
       
   148          */
       
   149         void StartHoldingL();
       
   150         
       
   151         /** 
       
   152          * Check if swipe if between defined values 
       
   153          * 
       
   154          * @return Swiping left/right/none 
       
   155          */
       
   156         TSwipeResult ValidSwipe();
       
   157 
       
   158     private:
       
   159 
       
   160         /** 
       
   161          * Gesture owner, Not owned.
       
   162          */        
       
   163         CXnNode& iOwner;        
       
   164         
       
   165         /** 
       
   166          * Gesture is the logical representation of a sequence of points 
       
   167          * arriving at certain times
       
   168          */ 
       
   169         CXnGesture* iGesture;
       
   170 
       
   171         /** 
       
   172          * holding is activated when user keeps pointer down in the same place 
       
   173          * for a longer period. the holding timer activates off when enough 
       
   174          * time has passed.
       
   175          */
       
   176         CHoldingTimer* iHoldingTimer;
       
   177 
       
   178         /** 
       
   179          * Gesture destination, Not owned.
       
   180          */        
       
   181         CXnNode* iDestination;        
       
   182         };
       
   183     } // GestureHelper
       
   184 
       
   185 #endif // _XNGESTUREHELPER_H_