Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Touch observer

The Touch observer analyzes pointer events, and stores pointer information such as movement, position, velocity, and angle. The touch observer is responsible for recognizing gestures, such as flicking.

Touch observer watches events such as EVT_POINTER_DOWN, EVT_POINTER_MOVE, and EVT_POINTER_UP, to analyze pointer movements. Controllers and applications can query the touch observer for various properties that are recorded or derived, such as magnitude and angle of the movement, initial velocity, pointer up or pointer down information, or linear movement deviation.

The root container manages the touch observer instance. An application should query the root container to retrieve the touch observer. The root container passes all pointer events that it receives to the touch observer.

The following diagram shows how widgets handle touch events and recognize gestures, illustrating the use of touch observer with the root container.

Touchscreen events (EVT_POINTER_DOWN, EVT_POINTER_UP, EVT_POINTER_MOVE, EVT_POINTER_STALE_MOVE) come into the application from Brew MP's event queue via the applet's IAPPLET_HandleEvent() function. The applet is generally expected to forward all events to the root container's _HandleEvent() function. The root container is responsible for routing the events to the proper widgets for handling.

Pointer events are sent to the widget that was touched, based on the coordinates in the pointer event. (Other events are sent to the widget that has focus.) As the pointer events are propagated to the proper widget, they are localized, or adjusted in relation to the container/widget to which the event is being sent. Each widget has an associated touch controller that is responsible for processing the pointer events directed at the widget and responding with updates to the UI. Depending on the gestures of interest to the touch controller, the touch controller invokes APIs on the touch observer to start and stop observation, and get the observed gesture.

Flick support

A flick is detected through the cooperation of a widget's touch controller and the touch observer. When the widget receives a pointer up event, its touch controller asks the touch observer if the previous stream of pointer events could be classified as a linear movement. The stream of pointer events is also classified based on internal criteria of speed and duration. If the pointer stream meets all these criteria, the touch controller coordinates with the transition manager to set up a scroller transition to handle the flick.

Flick gestures are currently supported by list widgets, list containers, and viewport widgets.