WebCore::GestureRecognizer Class Reference

Base class for gesture recognizers. More...

#include <GestureRecognizer.h>

Inheritance diagram for WebCore::GestureRecognizer:
Inheritance graph
[legend]

List of all members.

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

Detailed Description

Base class for gesture recognizers.

Depending on gesture type, calculates corresponding gesture data.

Definition at line 28 of file GestureRecognizer.h.


Constructor & Destructor Documentation

WebCore::GestureRecognizer::GestureRecognizer (  ) 

Constructor.

Definition at line 27 of file GestureRecognizer.cpp.

References reset().

Here is the call graph for this function:


Member Function Documentation

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.

See also:
selectValidPoints
Parameters:
p1 First point.
p2 Second point.
Returns:
the distance between the points.

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.

Returns:
the touch point index in the vector.
Parameters:
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.

Returns:
pointer to the first valid touch point.
See also:
secondTouchPoint

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.

References m_id1i, m_id2i, and m_refresh.

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.

Returns:
pointer to the second valid touch point.
See also:
firstTouchPoint

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.

See also:
setMinDistForTouchPoints
Parameters:
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.

Here is the call graph for this function:

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.

Parameters:
d distance in pixels.
See also:
selectValidPoints
DEFAULT_MIN_DIST_FOR_TOUCH_POINTS

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.

Parameters:
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.

Here is the call graph for this function:


Member Data Documentation

Definition at line 52 of file GestureRecognizer.h.

Definition at line 53 of file GestureRecognizer.h.

Definition at line 54 of file GestureRecognizer.h.

Definition at line 55 of file GestureRecognizer.h.

Definition at line 58 of file GestureRecognizer.h.

Definition at line 51 of file GestureRecognizer.h.


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208