WebCore/page/TouchGestureHandler.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2     Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
       
     3 
       
     4     This library is free software; you can redistribute it and/or
       
     5     modify it under the terms of the GNU Library General Public
       
     6     License as published by the Free Software Foundation; either
       
     7     version 2 of the License, or (at your option) any later version.
       
     8 
       
     9     This library is distributed in the hope that it will be useful,
       
    10     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12     Library General Public License for more details.
       
    13 
       
    14     You should have received a copy of the GNU Library General Public License
       
    15     along with this library; see the file COPYING.LIB.  If not, write to
       
    16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    17     Boston, MA 02110-1301, USA.
       
    18 */
       
    19 
       
    20 #ifndef TouchGestureHandler_h
       
    21 #define TouchGestureHandler_h
       
    22 
       
    23 #include "PlatformTouchEvent.h"
       
    24 
       
    25 namespace WebCore {
       
    26 
       
    27 class TouchGestureHandler {
       
    28 
       
    29 public:
       
    30     TouchGestureHandler();
       
    31 
       
    32     void reset();
       
    33     void updateTouchPoints(const Vector<const PlatformTouchPoint*>& touchPoints);
       
    34 
       
    35     int translateX() const { return m_translate.x(); }
       
    36     int translateY() const { return m_translate.y(); }
       
    37     const IntPoint& pos() const { return m_pos; }
       
    38     const IntPoint& screenPos() const { return m_screenPos; }
       
    39     float scale() const { return m_scale; }
       
    40     float rotate() const { return m_rotate; }
       
    41 
       
    42 private:
       
    43     float calcAngle(const IntPoint& p1, const IntPoint& p2) const;
       
    44     float diffAngle(float alpha, float beta) const;
       
    45     IntPoint calcPos(const Vector<const PlatformTouchPoint*>& touchPoints) const;
       
    46     float calcDistance(const IntPoint& p1, const IntPoint& p2) const;
       
    47     void updateRefreshNeededState(const Vector<const PlatformTouchPoint*>& touchPoints);
       
    48 
       
    49     bool m_refreshNeeded;
       
    50     IntPoint m_translate;
       
    51     float m_scale;
       
    52     float m_rotate;
       
    53     IntPoint m_pos;
       
    54     IntPoint m_screenPos;
       
    55     float m_prevAngle;
       
    56     int m_prevSize;
       
    57     int m_prevIds[2];
       
    58     float m_prevDistance;
       
    59 };
       
    60 
       
    61 }
       
    62 
       
    63 #endif // TouchGestureHandler_h