webengine/webkitutils/rt_gesturehelper/inc/rt_gesturehelper.h
changeset 1 7c90e6132015
parent 0 dd21522fd290
child 2 8de7b67c0fb3
child 5 10e98eab6f85
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
     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 the License "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:  RT Gesture helper interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _RT_GESTUREHELPER_H_
       
    20 #define _RT_GESTUREHELPER_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <rt_gestureobserver.h>
       
    24 
       
    25 class CAlfEnv;
       
    26 class CAlfDisplay;
       
    27 class TAlfEvent;
       
    28 struct TPointerEvent;
       
    29 
       
    30 namespace RT_GestureHelper
       
    31 {
       
    32 
       
    33 class CGestureHelperImpl;
       
    34 
       
    35 /** 
       
    36  * Gesture helper provides functionality to convert a stream of pointer events 
       
    37  * into a logical gesture, and to assist clients in calculation of gesture 
       
    38  * speed and distance.
       
    39  * 
       
    40  * Interfaces
       
    41  *  - CGestureHelper is a parser of pointer events. Recognises gestures from 
       
    42  *    a sequence of pointer events, and converts them to gesture commands. 
       
    43  *    For documentation of callbacks, see @ref MGestureObserver. 
       
    44  *  - MGestureObserver allows clients to get notified of gestures
       
    45  *  - MGestureEvent represents the gesture (event)
       
    46  */
       
    47 NONSHARABLE_CLASS( CGestureHelper ) : public CBase
       
    48     {
       
    49 public:
       
    50     /** 
       
    51      * The helper is expected to be a member variable, hence NewLC is not provided 
       
    52      */
       
    53     IMPORT_C static CGestureHelper* NewL( MGestureObserver& aObserver );
       
    54     
       
    55     /** Destructor */
       
    56     IMPORT_C ~CGestureHelper();
       
    57 
       
    58     /**
       
    59      * Specify whether the helper will send hold events. By default, holding is enabled.
       
    60      * "Hold" means user has held stylus/finger on the same position for a longer duration.
       
    61      * 
       
    62      * Clients that require holding to be treated with no special meaning should disable 
       
    63      * holding to simplify their event handling. 
       
    64      * For example, assume the client uses swipe left/right to control navigation, and 
       
    65      * holding is enabled. If user holds, the client gets hold left/right
       
    66      * event, and no swipe event. If user now drags left or right while still pressing 
       
    67      * stylus down, the client will not get a swipe event (since it already received a hold
       
    68      * event). Upon release event, the client no reliable way of knowing whether the 
       
    69      * user swiped left/right or cancelled the swipe. This problem is removed if the
       
    70      * client simply disables holding. In the above scenario while holding disabled,
       
    71      * the client would get only swipe events (and released event).
       
    72      * (Swipe can be cancelled by dragging towards, but not beyond, the starting position.) 
       
    73      */
       
    74     IMPORT_C void SetHoldingEnabled( TBool aEnabled );
       
    75     
       
    76     /**
       
    77      * @return whether sending hold events is currently enabled
       
    78      * ("Hold" means user has held stylus/finger on the same position for a longer duration.)
       
    79      */
       
    80     IMPORT_C TBool IsHoldingEnabled() const;
       
    81     
       
    82     /**
       
    83      * Enables/disables double tap support. Double tap is disabled by default.
       
    84      * When double tap is disabled, gesture helper emits tap events immediately when
       
    85      * user lifts stylus/finger. 
       
    86      * When double tap is enabled, tap events are emitted after the double tap timeout passes. 
       
    87      * The timeout is the maximum time within which the second tap will be treated 
       
    88      * as a double tap. That is, there is a delay (sluggishness) before client receives 
       
    89      * the tap event when double tap is enabled. 
       
    90      * tap + timeout => tap event emitted after timeout
       
    91      * tap + tap before timeout => double tap event emitted immediately after the second tap
       
    92      * tap + swipe => tap + swipe events
       
    93      * (tap + timeout + tap + timeout => two tap events)
       
    94      */
       
    95     IMPORT_C void SetDoubleTapEnabled( TBool aEnabled );
       
    96 
       
    97     /**
       
    98      * @return whether double tap is currently enabled. See SetDoubleTapEnabled
       
    99      */
       
   100     IMPORT_C TBool IsDoubleTapEnabled() const;
       
   101     
       
   102     /** 
       
   103      * Initialise pointer capture for Alfred 
       
   104      * This means that helper will receive drag events and pointer events that 
       
   105      * go outside the original visual area
       
   106      */
       
   107     IMPORT_C void InitAlfredPointerCaptureL( CAlfEnv& aEnv, CAlfDisplay& aDisplay,
       
   108         TInt aFreeControlGroupId );
       
   109     
       
   110     /** 
       
   111      * Give a pointer event to the helper, to form a part of a gesture
       
   112      * For AVKON-based client, this interface is the only option.
       
   113      * Alfred-based client should use OfferEventL, as it allows gesture events to
       
   114      * provider the visual on which the pointer event started.
       
   115      * @param aEvent pointer event
       
   116      * @return whether event was consumed or not
       
   117      *         EFalse the event is not a pointer events and if pointer up/drag 
       
   118      *				  event received without pointer down event
       
   119      *         ETrue in all the other cases of pointer event 
       
   120      */
       
   121     IMPORT_C TBool HandlePointerEventL( const TPointerEvent& aEvent );
       
   122     
       
   123     /**
       
   124      * Offer an Alf event. See HandlePointerEventL.
       
   125      * @return whether event was consumed or not
       
   126      *         EFalse the event is not a pointer events and if pointer up/drag 
       
   127      *				  event received without pointer down event
       
   128      *         ETrue in all the other cases of pointer event 
       
   129      */
       
   130     IMPORT_C TBool OfferEventL( const TAlfEvent& aEvent );
       
   131     
       
   132     /** 
       
   133      * Cancel ongoing recognision. Purges all pointer events given earlier, and
       
   134      * starts afresh. It is not necessary to call Cancel before deleting the object.
       
   135      */
       
   136     IMPORT_C void Cancel();
       
   137         
       
   138 private:
       
   139     /// interface implementation
       
   140     CGestureHelperImpl* iImpl;
       
   141     };
       
   142 
       
   143 } // namespace RT_GestureHelper
       
   144 
       
   145 #endif // _RT_GESTUREHELPER_H_