qstmgesturelib/recognisers/qstmzoomgesturerecogniser.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef QSTMZOOMGESTURERECOGNISER_H_
       
    20 #define QSTMZOOMGESTURERECOGNISER_H_
       
    21 
       
    22 #include <qstmgestureengine_if.h>
       
    23 #include <qstmgesture_if.h>
       
    24 #include <qstmgesturelistener_if.h>
       
    25 
       
    26 namespace qstmGesture
       
    27 {
       
    28 
       
    29 /*!
       
    30  * QStm_ZoomGestureRecogniser handles zoomin gesture: start from near lower left / upper right corner and drag
       
    31  * This is useful if one wants to implement single handed zooming so can be done using thumb
       
    32  * (no need to use pinch i.e. hold device in one hand and use two fingers of the other)
       
    33  * Current spec is:
       
    34  * - touch lower left corner and start dragging => initialize ZOOM IN
       
    35  * - touch upper right corner and start dragging => initialize ZOOM OUT
       
    36  * store the touch point and then calculate the distance until release
       
    37  * The distance is the zoom factor (probably needs some adjustment, not just the pixels...)
       
    38  */
       
    39 class QStm_ZoomGestureRecogniser : public QStm_GestureRecogniser
       
    40 {
       
    41 public:
       
    42 	static const QStm_GestureUid KUid = EGestureUidCornerZoom;
       
    43 
       
    44 	virtual ~QStm_ZoomGestureRecogniser();
       
    45 
       
    46 	virtual QStm_GestureRecognitionState recognise(int numOfActiveStreams, QStm_GestureEngineIf* ge) ;
       
    47 	virtual void release(QStm_GestureEngineIf* ge) ;
       
    48 	virtual QStm_GestureUid gestureUid() const { return KUid; }
       
    49 
       
    50 	/*!
       
    51 	 * Additional methods to set up zoom in gesture recogniser:
       
    52 	 * define the rectangle where the lower left corner is
       
    53 	 * \param theArea
       
    54 	 */
       
    55 	void setArea(const QRect& theArea) ;
       
    56 
       
    57 	/*!
       
    58 	 * Additional methods to set up zoom in gesture recogniser:
       
    59 	 * Define how close to the lower left corner the touch must happen
       
    60 	 * \param rangeInPixels
       
    61 	 */
       
    62 	void setRange(int rangeInMm) ;
       
    63 
       
    64 	QStm_ZoomGestureRecogniser(QStm_GestureListenerIf* listener) ;
       
    65 
       
    66 	float calculateDistance(const QPoint& aTp) ;
       
    67 	int adjustZoom(float& previousDistance, float newDistance) ;
       
    68 
       
    69 private:
       
    70 	QRect         m_area ;
       
    71 	int           m_rangesizeInPixels ;
       
    72 	QStm_ZoomType m_zoomtype ;
       
    73 	bool          m_zooming ;
       
    74 	QPoint        m_startingtouch ;
       
    75 	QPoint        m_previoustouch ;
       
    76 	int           m_delta ;
       
    77 
       
    78 };
       
    79 
       
    80 } // namespace
       
    81 
       
    82 #endif /* QSTMZOOMGESTURERECOGNISER_H_ */