Base class for gesture recognizers. More...
#include <GestureRecognizer.h>

Public Member Functions | |
| GestureRecognizer () | |
| Constructor. | |
| virtual void | reset () |
| Reset the gesture. | |
| virtual void | touchEvent (const PlatformTouchEvent &)=0 |
| Feed new data. | |
| const PlatformTouchPoint * | firstTouchPoint (const PlatformTouchEvent &) const |
| Get the first valid touch point. | |
| const PlatformTouchPoint * | secondTouchPoint (const PlatformTouchEvent &) const |
| Get the second valid touch point. | |
| void | setMinDistForTouchPoints (int d) |
| Set the minimum pixel distance for touch point validity. | |
Protected Member Functions | |
| int | findTouchPoint (const Vector< PlatformTouchPoint > &ps, const int id) |
| Find a touch point by id. | |
| void | selectValidPoints (const Vector< PlatformTouchPoint > &ps) |
| Select the first two valid touch points. | |
| float | calcDistance (const IntPoint &p1, const IntPoint &p2) const |
| Calculate distance between two points. | |
| void | updateRefreshState (const PlatformTouchEvent &ev) |
| Check whether a refresh is needed. | |
Protected Attributes | |
| bool | m_refresh |
| int | m_id1 |
| int | m_id1i |
| int | m_id2 |
| int | m_id2i |
Private Attributes | |
| int | m_minDistForTouchPoints |
Base class for gesture recognizers.
Depending on gesture type, calculates corresponding gesture data.
Definition at line 28 of file GestureRecognizer.h.
| WebCore::GestureRecognizer::GestureRecognizer | ( | ) |
Constructor.
Definition at line 27 of file GestureRecognizer.cpp.
References reset().

| float WebCore::GestureRecognizer::calcDistance | ( | const IntPoint & | p1, | |
| const IntPoint & | p2 | |||
| ) | const [protected] |
Calculate distance between two points.
Calculates the distance between the given points. selectValidPoints uses this function to determine which points are too close to each other.
| p1 | First point. | |
| p2 | Second point. |
Definition at line 158 of file GestureRecognizer.cpp.
| int WebCore::GestureRecognizer::findTouchPoint | ( | const Vector< PlatformTouchPoint > & | ps, | |
| const int | id | |||
| ) | [protected] |
Find a touch point by id.
Find the index of the touch point with the given id.
| ps | Vector of touch points to search. | |
| id | ID of the touch point to search. |
Definition at line 114 of file GestureRecognizer.cpp.
| const PlatformTouchPoint * WebCore::GestureRecognizer::firstTouchPoint | ( | const PlatformTouchEvent & | ev | ) | const |
Get the first valid touch point.
Gets the first valid touch point in the touch event. Valid touch points are calculated by merging touch points that are too close to each other. touchEvent must be called with the same event before calling.
Definition at line 174 of file GestureRecognizer.cpp.
References m_id1i.
| void WebCore::GestureRecognizer::reset | ( | ) | [virtual] |
Reset the gesture.
Resets the gesture data when eg. the gesture starts over.
Reimplemented in WebCore::PanRecognizer, WebCore::PinchRecognizer, WebCore::PointerRecognizer, and WebCore::RotateRecognizer.
Definition at line 38 of file GestureRecognizer.cpp.
| const PlatformTouchPoint * WebCore::GestureRecognizer::secondTouchPoint | ( | const PlatformTouchEvent & | ev | ) | const |
Get the second valid touch point.
Gets the second valid touch point in the touch event. Valid touch points are calculated by merging touch points that are too close to each other. touchEvent must be called with the same event before calling.
Definition at line 191 of file GestureRecognizer.cpp.
References m_id2i.
| void WebCore::GestureRecognizer::selectValidPoints | ( | const Vector< PlatformTouchPoint > & | ps | ) | [protected] |
Select the first two valid touch points.
Selects the first two valid touch points by merging touch points that are too close to each other. The selected touch points are the ones with the lowest indices after merging.
| ps | Vector of touch points to search. |
Definition at line 129 of file GestureRecognizer.cpp.
References calcDistance(), m_id1, m_id1i, m_id2, m_id2i, and m_minDistForTouchPoints.

| void WebCore::GestureRecognizer::setMinDistForTouchPoints | ( | int | d | ) | [inline] |
Set the minimum pixel distance for touch point validity.
Touch points that are too close to each other are merged. This function sets the distance for validity.
| d | distance in pixels. |
Definition at line 40 of file GestureRecognizer.h.
References m_minDistForTouchPoints.
| void WebCore::GestureRecognizer::touchEvent | ( | const PlatformTouchEvent & | ) | [pure virtual] |
Feed new data.
Processes a new touch event and calculates new data for the gesture.
Implemented in WebCore::PanRecognizer, WebCore::PinchRecognizer, WebCore::PointerRecognizer, and WebCore::RotateRecognizer.
| void WebCore::GestureRecognizer::updateRefreshState | ( | const PlatformTouchEvent & | ev | ) | [protected] |
Check whether a refresh is needed.
Updates the internal refresh flag which tells whether a state recalculation is needed. Refer to individual gesture recognizer classes to see what state is recalculated.
| ev | The touch event to check. |
Definition at line 59 of file GestureRecognizer.cpp.
References calcDistance(), findTouchPoint(), m_id1, m_id1i, m_id2, m_id2i, m_minDistForTouchPoints, and m_refresh.

int WebCore::GestureRecognizer::m_id1 [protected] |
Definition at line 52 of file GestureRecognizer.h.
int WebCore::GestureRecognizer::m_id1i [protected] |
Definition at line 53 of file GestureRecognizer.h.
int WebCore::GestureRecognizer::m_id2 [protected] |
Definition at line 54 of file GestureRecognizer.h.
int WebCore::GestureRecognizer::m_id2i [protected] |
Definition at line 55 of file GestureRecognizer.h.
int WebCore::GestureRecognizer::m_minDistForTouchPoints [private] |
Definition at line 58 of file GestureRecognizer.h.
bool WebCore::GestureRecognizer::m_refresh [protected] |
Definition at line 51 of file GestureRecognizer.h.
1.6.2-20100208