Use the GestureLayer to detect gestures. The advantage is that you don’t have to implement gesture detection, just set callbacks for gesture states.
In order to use Gesture Layer you start with instantiating this class with a parent object parameter. Next ‘activate’ gesture layer with a GestureLayer.attach() call. Usually with same object as target (2nd parameter).
Now you need to tell gesture layer what gestures you follow. This is done with GestureLayer.cb_set() call. By setting the callback you actually saying to gesture layer: I would like to know when the gesture Elm_Gesture_Type switches to state Elm_Gesture_State.
Next, you need to implement the actual action that follows the input in your callback.
Note that if you like to stop being reported about a gesture, just set all callbacks referring this gesture to None. (again with GestureLayer.cb_set())
The information reported by gesture layer to your callback is depending on Elm_Gesture_Type:
Elm_Gesture_Taps_Info is the info reported for tap gestures:
- ELM_GESTURE_N_TAPS
- ELM_GESTURE_N_LONG_TAPS
- ELM_GESTURE_N_DOUBLE_TAPS
- ELM_GESTURE_N_TRIPLE_TAPS
Elm_Gesture_Momentum_Info is info reported for momentum gestures:
- ELM_GESTURE_MOMENTUM
Elm_Gesture_Line_Info is the info reported for line gestures (this also contains Elm_Gesture_Momentum_Info internal structure):
- ELM_GESTURE_N_LINES
- ELM_GESTURE_N_FLICKS
Note that we consider a flick as a line-gesture that should be completed in flick-time-limit as defined in Configuration.
Elm_Gesture_Zoom_Info is the info reported for ELM_GESTURE_ZOOM gesture.
Elm_Gesture_Rotate_Info is the info reported for ELM_GESTURE_ROTATE gesture.
Gesture Layer Tweaks:
Note that line, flick, gestures can start without the need to remove fingers from surface. When user fingers rests on same-spot gesture is ended and starts again when fingers moved.
Setting glayer_continues_enable to false in Configuration will change this behavior so gesture starts when user touches (a DOWN event) touch-surface and ends when no fingers touches surface (a UP event).
Gesture not started
Gesture started
Gesture is ongoing
Gesture completed
Ongoing gesture was aborted
N fingers single taps
N fingers single long-taps
N fingers double-single taps
N fingers triple-single taps
Reports momentum in the direction of move
N fingers line gesture
N fingers flick gesture
Zoom
Rotate
Bases: efl.elementary.object.Object
This is the class that actually implement the widget.
Call this function to construct a new gesture-layer object.
This does not activate the gesture layer. You have to call attach() in order to ‘activate’ gesture-layer.
| Parameters: | parent (Object) – The gesture layer’s parent widget. |
|---|---|
| Returns: | A new gesture layer object. |
| Return type: | GestureLayer |
Attach a given gesture layer widget to an Evas object, thus setting the widget’s target.
A gesture layer target may be whichever Evas object one chooses. This will be object obj will listen all mouse and key events from, to report the gestures made upon it back.
| Parameters: | target (Object) – The target object to attach to this object. |
|---|
Changed in version 1.8: Raise RuntimeError on failure, instead of returning a bool
Use this function to set callbacks to be notified about change of state of gesture. When a user registers a callback with this function this means this gesture has to be tested.
When ALL callbacks for a gesture are set to None it means user isn’t interested in gesture-state and it will not be tested.
The signature for the callbacks is:
func(event_info, *args, **kwargs)
Note
You should return either EVAS_EVENT_FLAG_NONE or EVAS_EVENT_FLAG_ON_HOLD from this callback.
| Parameters: |
|
|---|
Gesture layer continues enable of an object
| Type : | bool |
|---|
New in version 1.8.
Gesture layer double tap timeout of an object
| Type : | double |
|---|
New in version 1.8.
Gesture layer flick time limit (in ms) of an object
| Type : | int |
|---|
New in version 1.8.
Gesture-layer repeat events. Set to True if you like to get the raw events only if gestures were not detected. Set to false if you like gesture layer to forward events as testing gestures.
| Type : | bool |
|---|
Gesture layer line angular tolerance of an object
| Type : | double |
|---|
New in version 1.8.
Gesture layer line distance tolerance of an object
| Type : | int |
|---|
New in version 1.8.
Gesture layer line min length of an object
| Type : | int |
|---|
New in version 1.8.
Gesture layer long tap start timeout of an object
| Type : | double |
|---|
New in version 1.8.
Gesture layer rotate angular tolerance of an object
| Type : | double |
|---|
New in version 1.8.
This function sets step-value for rotate action. Set step to any positive value. Cancel step setting by setting to 0
| Type : | float |
|---|
The gesture layer finger-size for taps. If not set, this size taken from elm_config. Set to ZERO if you want GLayer to use system finger size value (default)
| Type : | int |
|---|
New in version 1.8.
Gesture layer zoom distance tolerance of an object
| Type : | int |
|---|
New in version 1.8.
Gesture layer zoom finger factor of an object
| Type : | double |
|---|
New in version 1.8.
Step-value for zoom action. Set step to any positive value. Cancel step setting by setting to 0.0
| Type : | float |
|---|
Gesture layer zoom wheel factor of an object
| Type : | double |
|---|
New in version 1.8.
Bases: object
Holds line info for user
Angle (direction) of lines
| Type : | double |
|---|
Line momentum info
| Type : | GestureMomentumInfo |
|---|
Bases: object
Holds momentum info for user x1 and y1 are not necessarily in sync x1 holds x value of x direction starting point and same holds for y1. This is noticeable when doing V-shape movement
Momentum on X
| Type : | int |
|---|
Momentum on Y
| Type : | int |
|---|
Number of fingers
| Type : | int |
|---|
Timestamp of start of final x-swipe
| Type : | int |
|---|
Timestamp of start of final y-swipe
| Type : | int |
|---|
Final-swipe direction starting point on X
| Type : | int |
|---|
Final-swipe direction ending point on X
| Type : | int |
|---|
Final-swipe direction starting point on Y
| Type : | int |
|---|
Final-swipe direction ending point on Y
| Type : | int |
|---|
Bases: object
Holds rotation info for user
Rotation value: 0.0 means no rotation
| Type : | double |
|---|
Holds start-angle
| Type : | double |
|---|
Rotation momentum: rotation done per second (NOT YET SUPPORTED)
| Type : | double |
|---|
Holds radius between fingers reported to user
| Type : | int |
|---|
Holds zoom center point reported to user
| Type : | int |
|---|
Holds zoom center point reported to user
| Type : | int |
|---|
Bases: object
Holds taps info for user
Number of fingers tapped
| Type : | int |
|---|
Event timestamp
| Type : | int |
|---|
Holds center point between fingers
| Type : | int |
|---|
Holds center point between fingers
| Type : | int |
|---|
Bases: object
Holds zoom info for user
Zoom momentum: zoom growth per second (NOT YET SUPPORTED)
| Type : | double |
|---|
Holds radius between fingers reported to user
| Type : | int |
|---|
Holds zoom center point reported to user
| Type : | int |
|---|
Holds zoom center point reported to user
| Type : | int |
|---|
Zoom value: 1.0 means no zoom
| Type : | double |
|---|