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