webengine/osswebengine/webkit/s60/webview/WebGestureInterface.cpp
branchRCL_3
changeset 49 919f36ff910f
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
       
     1 /*
       
     2 * Copyright (c) 2008 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <Browser_platform_variant.hrh>
       
    21 #include "config.h"
       
    22 #include "../../bidi.h"
       
    23 #include <coemain.h>
       
    24 #include "brctl.h"
       
    25 #include <brctldefs.h>
       
    26 #include "WebGestureInterface.h"
       
    27 #include "WebView.h"
       
    28 #include "WebPointerEventHandler.h"
       
    29 
       
    30 const TInt TOUCH_AREA_TIMEOUT = 200;
       
    31 const TInt TOUCH_TIME_AREA_TIMEOUT = 0;
       
    32 const TInt HOLD_AREA_TIMEOUT = 1500;
       
    33 const TInt DOUBLE_TAP_TIMEOUT = 400;
       
    34 const TInt SUPPRESS_TIMEOUT = 0;
       
    35 const TInt MOVE_SUPPRESS_TIMEOUT = 0;
       
    36 
       
    37 const TInt TOUCH_TIME_AREA_WIDTH = 4;
       
    38 const TInt TOUCH_AREA_WIDTH = 4;
       
    39 const TInt HOLD_AREA_WIDTH = 4;
       
    40 
       
    41 const TInt PAN_SPEED_LOW = 0;
       
    42 const TInt PAN_SPEED_HIGH = 400;
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CgesturetestAppView::NewL()
       
    48 // Two-phased constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 WebGestureInterface* WebGestureInterface::NewL(WebView* view)
       
    52 {
       
    53     WebGestureInterface* self = WebGestureInterface::NewLC(view);
       
    54     CleanupStack::Pop(self);
       
    55     return self;
       
    56 }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CgesturetestAppView::NewLC()
       
    60 // Two-phased constructor.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 WebGestureInterface* WebGestureInterface::NewLC(WebView* view)
       
    64 {
       
    65     WebGestureInterface* self = new (ELeave) WebGestureInterface(view);
       
    66     CleanupStack::PushL(self);
       
    67     self->ConstructL();
       
    68     return self;
       
    69 }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // WebGestureInterface::WebGestureInterface
       
    73 // C++ default constructor
       
    74 //
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 WebGestureInterface::WebGestureInterface(WebView* view)
       
    78 : m_webview(view)
       
    79 {
       
    80 }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // WebGestureInterface::~WebGestureInterface
       
    84 // -----------------------------------------------------------------------------
       
    85 WebGestureInterface::~WebGestureInterface()
       
    86 {
       
    87     iGestureContext->Deactivate();
       
    88     iGestureContext->RemoveListener(this);
       
    89     delete iGestureEngine;
       
    90 }
       
    91 // -----------------------------------------------------------------------------
       
    92 // WebGestureInterface::ConstructL
       
    93 // Symbian 2nd phase constructor can leave.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void WebGestureInterface::ConstructL()
       
    97 {
       
    98     iGestureEngine = CStmGestureEngine::NewL();
       
    99     iGestureContext = iGestureEngine->CreateContextL(TInt(this));
       
   100     iGestureContext->SetContext(m_webview);
       
   101     iGestureContext->AddListenerL(this);
       
   102 
       
   103     CStmGestureParameters& gestureParams = iGestureContext->Config();
       
   104     //Enable the Gestures needed
       
   105     gestureParams.SetEnabled(stmGesture::EGestureUidTouch, ETrue);
       
   106     gestureParams.SetEnabled(stmGesture::EGestureUidTap, ETrue);
       
   107     gestureParams.SetEnabled(stmGesture::EGestureUidRelease, ETrue);
       
   108     gestureParams.SetEnabled(stmGesture::EGestureUidPan, ETrue);
       
   109     gestureParams.SetEnabled(stmGesture::EGestureUidFlick, ETrue);
       
   110     gestureParams.SetEnabled(stmGesture::EGestureUidLongPress, ETrue);
       
   111 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   112     if (m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityPinchZoom) {
       
   113         gestureParams.SetEnabled(stmGesture::EGestureUidPinch, ETrue);
       
   114     }
       
   115     else {
       
   116         gestureParams.SetEnabled(stmGesture::EGestureUidPinch, EFalse);
       
   117     }
       
   118 #else
       
   119     gestureParams.SetEnabled(stmGesture::EGestureUidPinch, EFalse);
       
   120 #endif
       
   121 
       
   122     //Set other parameters
       
   123 
       
   124     TStmGestureArea& touchTimeArea = *gestureParams.Area(stmGesture::ETouchTimeArea);
       
   125     TStmGestureArea& touchArea = *gestureParams.Area(stmGesture::ETouchArea);
       
   126     TStmGestureArea& holdArea  = *gestureParams.Area(stmGesture::EHoldArea);
       
   127 
       
   128     touchTimeArea.iShape = TStmGestureArea::ERectangle;
       
   129     touchTimeArea.iTimeout =  TOUCH_TIME_AREA_TIMEOUT;
       
   130     touchTimeArea.iSize.iWidth = TOUCH_TIME_AREA_WIDTH;
       
   131 
       
   132     touchArea.iShape = TStmGestureArea::ERectangle;
       
   133     touchArea.iTimeout =  TOUCH_AREA_TIMEOUT;
       
   134     touchArea.iSize.iWidth = TOUCH_AREA_WIDTH;
       
   135 
       
   136     holdArea.iShape = TStmGestureArea::ERectangle;
       
   137     holdArea.iTimeout =  HOLD_AREA_TIMEOUT;
       
   138     holdArea.iSize.iWidth = HOLD_AREA_WIDTH;
       
   139     
       
   140     //Double tap functionality is enabled based on ECapabilityFitToScreen capability.
       
   141     //setting the doubletap timeout to ZERO if this cap is not defined
       
   142     if (m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityFitToScreen) 
       
   143         gestureParams[stmGesture::EDoubleTapTimeout   ] = DOUBLE_TAP_TIMEOUT;
       
   144     else
       
   145         gestureParams[stmGesture::EDoubleTapTimeout   ] = 0;    
       
   146 
       
   147     gestureParams[stmGesture::ESuppressTimeout    ] = SUPPRESS_TIMEOUT;
       
   148     gestureParams[stmGesture::EMoveSuppressTimeout] = MOVE_SUPPRESS_TIMEOUT;
       
   149     gestureParams[stmGesture::EPanSpeedLow        ] = PAN_SPEED_LOW;
       
   150     gestureParams[stmGesture::EPanSpeedHigh       ] = PAN_SPEED_HIGH;
       
   151 
       
   152     gestureParams[stmGesture::EEnableFiltering    ] = ETrue;
       
   153 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   154     gestureParams[stmGesture::ECapacitiveUpUsed   ] = ETrue;
       
   155 #ifndef __WINSCW__    
       
   156     gestureParams[stmGesture::EAdjustYPos         ] = ETrue;
       
   157 #endif    
       
   158 #else
       
   159     gestureParams[stmGesture::ECapacitiveUpUsed   ] = EFalse;
       
   160     gestureParams[stmGesture::EAdjustYPos         ] = EFalse;
       
   161 #endif
       
   162     iGestureContext->ActivateL();
       
   163 
       
   164 }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // HandlePointerEventL
       
   168 // -----------------------------------------------------------------------------
       
   169 void WebGestureInterface::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   170 {
       
   171     iGestureEngine->HandlePointerEventL(aPointerEvent, m_webview);
       
   172 }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // HandleGestureEventL
       
   176 // -----------------------------------------------------------------------------
       
   177 void  WebGestureInterface::HandleGestureEventL(const TStmGestureEvent& aGesture)
       
   178 {
       
   179      m_webview->pointerEventHandler()->HandleGestureEventL(aGesture);
       
   180 }
       
   181 
       
   182 
       
   183