webengine/webkitutils/stmgesturefw/inc/zoomgesturerecogniser.h
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 66 cacf6ee57968
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
     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: Zoom Gesture Recognizer
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef ZOOMGESTURERECOGNISER_H_
       
    19 #define ZOOMGESTURERECOGNISER_H_
       
    20 
       
    21 #include "rt_gestureengineif.h"
       
    22 #include <rt_gestureif.h>
       
    23 #include <rt_gesturelistener.h>
       
    24 
       
    25 class CCoeControl ;
       
    26 
       
    27 namespace stmGesture
       
    28 {
       
    29 
       
    30 /*!
       
    31  * CZoomGestureRecogniser handles zoomin gesture: start from near lower left / upper right corner and drag
       
    32  * This is useful if one wants to implement single handed zooming so can be done using thumb
       
    33  * (no need to use pinch i.e. hold device in one hand and use two fingers of the other)
       
    34  * Current spec is:
       
    35  * - touch lower left corner and start dragging => initialize ZOOM IN
       
    36  * - touch upper right corner and start dragging => initialize ZOOM OUT
       
    37  * store the touch point and then calculate the distance until release
       
    38  * The distance is the zoom factor (probably needs some adjustment, not just the pixels...)
       
    39  */
       
    40 NONSHARABLE_CLASS( CZoomGestureRecogniser ): public CGestureRecogniser
       
    41 {
       
    42 public:
       
    43 	static const TGestureUid KUid = EGestureUidCornerZoom;
       
    44 
       
    45 	/** Two-phase constructor */
       
    46 	static CZoomGestureRecogniser* NewL(MGestureListener* aListener);
       
    47 	virtual ~CZoomGestureRecogniser();
       
    48 
       
    49 	/*!
       
    50 	 * MGestureRecogniserIf methods
       
    51 	 */
       
    52 	virtual TGestureRecognitionState recognise(int numOfActiveStreams, MGestureEngineIf* ge) ;
       
    53 	virtual void release(MGestureEngineIf* ge) ;
       
    54 	virtual TGestureUid gestureUid() const
       
    55 	{
       
    56 		return KUid;
       
    57 	}
       
    58 
       
    59 	/*!
       
    60 	 * Additional methods to set up zoom in gesture recogniser:
       
    61 	 * define the rectangle where the lower left corner is
       
    62 	 * \param theArea
       
    63 	 */
       
    64 	void setArea(const TRect& theArea) ;
       
    65 
       
    66 	/*!
       
    67 	 * Additional methods to set up zoom in gesture recogniser:
       
    68 	 * Define how close to the lower left corner the touch must happen
       
    69 	 * \param rangeInPixels
       
    70 	 */
       
    71 	void setRange(int rangeInPixels) ;
       
    72 
       
    73 private:
       
    74 	CZoomGestureRecogniser(MGestureListener* aListener) ;
       
    75 
       
    76 	float calculateDistance(const TPoint& aTp) ;
       
    77 	int adjustZoom(float& aPreviousDistance, float aNewDistance) ;
       
    78 
       
    79 private:
       
    80 	TRect m_area ;
       
    81 	int  m_rangesizeInPixels ;
       
    82 	TZoomType m_zoomtype ;
       
    83 	bool m_zooming ;
       
    84 	TPoint m_startingtouch ;
       
    85 	TPoint m_previoustouch ;
       
    86 	int m_delta ;
       
    87 
       
    88 };
       
    89 
       
    90 } // namespace
       
    91 
       
    92 #endif /* ZOOMGESTURERECOGNISER_H_ */