src/hbcore/gestures/hbpangesture.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:38:12 +0300
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
permissions -rw-r--r--
Revision: 201037 Kit: 201039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/****************************************************************************
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
** All rights reserved.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
** Contact: Nokia Corporation (developer.feedback@nokia.com)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
** This file is part of the HbCore module of the UI Extensions for Mobile.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
** GNU Lesser General Public License Usage
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
** This file may be used under the terms of the GNU Lesser General Public
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
** License version 2.1 as published by the Free Software Foundation and
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
** appearing in the file LICENSE.LGPL included in the packaging of this file.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
** Please review the following information to ensure the GNU Lesser General
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
** Public License version 2.1 requirements will be met:
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
** In addition, as a special exception, Nokia gives you certain additional
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
** rights.  These rights are described in the Nokia Qt LGPL Exception
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
** If you have questions regarding the use of this file, please contact
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
** Nokia at developer.feedback@nokia.com.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
****************************************************************************/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
30
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
    26
#include "hbpangesture.h"
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
    27
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    28
#include "hbgestures_p.h"
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    29
#include "hbvelocitycalculator_p.h"
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    30
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <QPointF>
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <QVariant>
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    33
#include <QDebug>
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    35
/*!
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    36
    @hbcore
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    37
    \class HbPanGesture
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    38
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    39
    \brief The HbPanGesture class provides support for receiving a dragging
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    40
    (pan) gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    41
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    42
    HbPanGesture is an extension to the Qt standard QPanGesture. It is
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    43
    optimized for mobile touch screens, and also supports recognition of
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    44
    mouse events for development purposes. Moreover, HbPanGesture
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    45
    adds some new properties (startPos and velocity) to the existing
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    46
    QPanGesture properties, and also provides variants of all these expressed
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    47
    in scene coordinates. This removes any need for manual conversions from
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    48
    the screen (global) coordinates of the QPanGesture base class properties.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    49
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    50
    A pan gesture is used in situations where the user drags content to a new
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    51
    position. Make sure your application gives instant feedback to the user
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    52
    with each gesture update by moving the content, not only when the gesture
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    53
    is finished.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    54
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    55
    \section _usecases_hbpangesture Using the HbPanGesture class
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    56
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    57
    This example shows how to make a custom widget recognize the pan
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    58
    gesture. The custom widget in the example derives from HbWidget.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    59
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    60
    <ol>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    61
    <li>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    62
    Register for pan gestures by using the base class function
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    63
    QGraphicsObject::grabGesture(). QGraphicsObject::grabGesture() can be
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    64
    called several times with different arguments, if the widget is
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    65
    interested in other gesture types as well.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    66
   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    67
    \code
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    68
    // This widget is interested in pan and tap gestures.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    69
    grabGesture(Qt::PanGesture);
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    70
    grabGesture(Qt::TapGesture);
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    71
    \endcode
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    72
    </li>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    73
    
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    74
    <li>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    75
    Reimplement HbWidgetBase::gestureEvent() to handle gestures that are
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    76
    meaningful for your custom widget.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    77
   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    78
    \code
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    79
    void MyWidget::gestureEvent(QGestureEvent *event)
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    80
    {
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    81
        if (HbPanGesture *pan = qobject_cast<HbPanGesture *>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    82
            (event->gesture(Qt::PanGesture))) {
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    83
       
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    84
            switch (pan->state()) {
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    85
           
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    86
            case Qt::GestureStarted:
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    87
                // Visualize the active state of the widget.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    88
                // Emit a signal to move the content
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    89
                break;
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    90
            case Qt::GestureUpdated:
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    91
                // Emit a signal to move the content.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    92
                break;
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    93
            case Qt::GestureCanceled:
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    94
                // Visualize the non-active state of the widget.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    95
                // Emit a signal to return the content to the starting
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    96
                // position.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    97
                break;
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    98
            case Qt::GestureFinished:
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    99
                // Visualize the non-active state of the widget.             
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   100
                // Emit a signal to move the content.   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   101
                break;
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   102
            default:
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   103
                break;
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   104
            }           
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   105
        }
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   106
       
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   107
        // Handle other gesture types that have been grabbed. There may be
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   108
        // several, since all gestures that are active at the same moment
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   109
        // are sent within the same gesture event.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   110
        if (HbTapGesture *tap = qobject_cast<HbTapGesture *>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   111
            (event->gesture(Qt::TapGesture))) {
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   112
            // handle the tap gesture
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   113
        }
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   114
       
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   115
    }   
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   116
    \endcode
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   117
    </li>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   118
    </ol>
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   119
    
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   120
    \sa QPanGesture
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   121
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   123
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   124
    Constructor.
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   125
    \param parent Owner for gesture
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   126
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   127
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
HbPanGesture::HbPanGesture(QObject *parent) : QPanGesture(parent), d_ptr(new HbPanGesturePrivate)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
{
28
b7da29130b0e Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 6
diff changeset
   130
    d_ptr->mIgnoreMouseEvents = false;
30
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   131
    d_ptr->mTime.start();
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   134
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   135
    Constructor required by the shared d-pointer paradigm.
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   136
    \param dd Private data
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   137
    \param parent Owner for gesture
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   138
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   139
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
HbPanGesture::HbPanGesture( HbPanGesturePrivate &dd, QObject *parent )
30
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   141
    : QPanGesture(parent), d_ptr(&dd)
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
{
30
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   143
    hbWarning("Shared private not supported for HbPanGesture");
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   146
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   147
    Destructor.
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   148
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
HbPanGesture::~HbPanGesture()
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    delete d_ptr;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   154
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   155
    Returns the starting position for the gesture in global coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   156
    \sa setStartPos(), sceneStartPos()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   157
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
QPointF HbPanGesture::startPos() const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    Q_D(const HbPanGesture);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    return d->mStartPos;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   164
/*!
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   165
    Sets the starting position for the gesture in global coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   166
    This function is used by the framework gesture recognition logic,
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   167
    and it should not be used by the widget receiving the gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   168
    \sa startPos(), setSceneStartPos()
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   169
*/
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
void HbPanGesture::setStartPos(const QPointF &startPos)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
{
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    Q_D(HbPanGesture);
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    d->mStartPos = startPos;
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
}
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   176
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   177
    Returns the panning velocity in global coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   178
    The unit is pixels per millisecond.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   179
    \sa setVelocity(), sceneVelocity()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   180
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   181
QPointF HbPanGesture::velocity() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   182
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   183
    Q_D(const HbPanGesture);
30
80e4d18b72f5 Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   184
    return HbVelocityCalculator( d->mAxisX, d->mAxisY ).velocity( d->mLastTimeStamp );
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   185
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   186
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   187
/*!
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   188
    Sets the panning velocity in global coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   189
    This function is used by the framework gesture recognition logic,
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   190
    and it should not be used by the widget receiving the gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   191
    \sa velocity()
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   192
*/
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   193
void HbPanGesture::setVelocity(const QPointF &)
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   194
{
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   195
    Q_ASSERT(false);
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   196
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   197
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   198
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   199
    Returns the total offset from start position to second last position
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   200
    in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   201
    \sa setSceneLastOffset(), QPanGesture::lastOffset()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   202
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   203
QPointF HbPanGesture::sceneLastOffset() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   204
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   205
    Q_D(const HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   206
    return d->mSceneLastOffset;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   207
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   208
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   209
/*!
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   210
    Sets the total offset from start position to second last position
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   211
    in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   212
    This function is used by the framework gesture recognition logic,
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   213
    and it should not be used by the widget receiving the gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   214
    \sa sceneLastOffset(), QPanGesture::setLastOffset()
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   215
*/
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   216
void HbPanGesture::setSceneLastOffset(const QPointF &lastOffset)
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   217
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   218
    Q_D(HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   219
    d->mSceneStartPos = lastOffset;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   220
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   221
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   222
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   223
    Returns the total offset from start position to current position
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   224
    in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   225
    \sa setSceneOffset(), QPanGesture::offset()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   226
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   227
QPointF HbPanGesture::sceneOffset() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   228
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   229
    Q_D(const HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   230
    return d->mSceneOffset;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   231
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   232
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   233
/*!
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   234
    Sets the total offset from start position to current position
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   235
    in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   236
    This function is used by the framework gesture recognition logic,
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   237
    and it should not be used by the widget receiving the gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   238
    \sa sceneOffset(), QPanGesture::setOffset()
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   239
*/
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   240
void HbPanGesture::setSceneOffset(const QPointF &offset)
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   241
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   242
    Q_D(HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   243
    d->mSceneOffset = offset;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   244
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   245
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   246
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   247
    Returns the starting position for the gesture in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   248
    \sa setSceneStartPos(), startPos()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   249
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   250
QPointF HbPanGesture::sceneStartPos() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   251
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   252
    Q_D(const HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   253
    return d->mSceneStartPos;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   254
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   255
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   256
/*!
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   257
    Sets the starting position for the gesture in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   258
    This function is used by the framework gesture recognition logic,
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   259
    and it should not be used by the widget receiving the gesture.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   260
    \sa sceneStartPos(), setStartPos()
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   261
*/
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   262
void HbPanGesture::setSceneStartPos(const QPointF &startPos)
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   263
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   264
    Q_D(HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   265
    d->mSceneStartPos = startPos;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   266
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   267
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   268
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   269
    Returns the panning velocity in scene coordinates.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   270
    The unit is pixels per millisecond.
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   271
    \sa velocity()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   272
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   273
QPointF HbPanGesture::sceneVelocity() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   274
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   275
    Q_D(const HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   276
    return HbVelocityCalculator(d->mSceneAxisX, d->mSceneAxisY).velocity( d->mLastTimeStamp );
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   277
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   278
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   279
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   280
    Returns the panning acceleration in scene coordinates.
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   281
    \sa QPanGesture::acceleration()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   282
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   283
QPointF HbPanGesture::sceneAcceleration() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   284
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   285
    return QPointF(0,0);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   286
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   287
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   288
/*!
6
c3690ec91ef8 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
   289
    Returns the distance between the last two points in scene coordinates.
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   290
    \sa QPanGesture::delta()
1
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   291
*/
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   292
QPointF HbPanGesture::sceneDelta() const
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   293
{
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   294
    Q_D(const HbPanGesture);
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   295
    return d->mSceneOffset - d->mSceneLastOffset;
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   296
}
f7ac710697a9 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   297