Table Of Contents

Previous topic

genlist Module

Next topic

grid Module

gesture_layer Module

../_images/gesturelayer-preview.png

Widget description

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).

Enumerations

Gesture states

efl.elementary.gesture_layer.ELM_GESTURE_STATE_UNDEFINED

Gesture not started

efl.elementary.gesture_layer.ELM_GESTURE_STATE_START

Gesture started

efl.elementary.gesture_layer.ELM_GESTURE_STATE_MOVE

Gesture is ongoing

efl.elementary.gesture_layer.ELM_GESTURE_STATE_END

Gesture completed

efl.elementary.gesture_layer.ELM_GESTURE_STATE_ABORT

Ongoing gesture was aborted

Gesture types

efl.elementary.gesture_layer.ELM_GESTURE_N_TAPS

N fingers single taps

efl.elementary.gesture_layer.ELM_GESTURE_N_LONG_TAPS

N fingers single long-taps

efl.elementary.gesture_layer.ELM_GESTURE_N_DOUBLE_TAPS

N fingers double-single taps

efl.elementary.gesture_layer.ELM_GESTURE_N_TRIPLE_TAPS

N fingers triple-single taps

efl.elementary.gesture_layer.ELM_GESTURE_MOMENTUM

Reports momentum in the direction of move

efl.elementary.gesture_layer.ELM_GESTURE_N_LINES

N fingers line gesture

efl.elementary.gesture_layer.ELM_GESTURE_N_FLICKS

N fingers flick gesture

efl.elementary.gesture_layer.ELM_GESTURE_ZOOM

Zoom

efl.elementary.gesture_layer.ELM_GESTURE_ROTATE

Rotate

class efl.elementary.gesture_layer.GestureLayer

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(evas.Object target)

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

cb_set(Elm_Gesture_Type idx, Elm_Gesture_State cb_type, callback, *args, **kwargs)

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:
  • idx (Gesture types) – The gesture you would like to track its state.
  • cb_type (Gesture states) – what event this callback tracks: START, MOVE, END, ABORT.
  • callback (function) – Callback function.
continues_enable

Gesture layer continues enable of an object

Type :bool

New in version 1.8.

double_tap_timeout

Gesture layer double tap timeout of an object

Type :double

New in version 1.8.

flick_time_limit_ms

Gesture layer flick time limit (in ms) of an object

Type :int

New in version 1.8.

hold_events

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
line_angular_tolerance

Gesture layer line angular tolerance of an object

Type :double

New in version 1.8.

line_distance_tolerance

Gesture layer line distance tolerance of an object

Type :int

New in version 1.8.

line_min_length

Gesture layer line min length of an object

Type :int

New in version 1.8.

long_tap_start_timeout

Gesture layer long tap start timeout of an object

Type :double

New in version 1.8.

rotate_angular_tolerance

Gesture layer rotate angular tolerance of an object

Type :double

New in version 1.8.

rotate_step

This function sets step-value for rotate action. Set step to any positive value. Cancel step setting by setting to 0

Type :float
tap_finger_size

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.

zoom_distance_tolerance

Gesture layer zoom distance tolerance of an object

Type :int

New in version 1.8.

zoom_finger_factor

Gesture layer zoom finger factor of an object

Type :double

New in version 1.8.

zoom_step

Step-value for zoom action. Set step to any positive value. Cancel step setting by setting to 0.0

Type :float
zoom_wheel_factor

Gesture layer zoom wheel factor of an object

Type :double

New in version 1.8.

class efl.elementary.gesture_layer.GestureLineInfo

Bases: object

Holds line info for user

angle

Angle (direction) of lines

Type :double
momentum

Line momentum info

Type :GestureMomentumInfo
class efl.elementary.gesture_layer.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

mx

Momentum on X

Type :int
my

Momentum on Y

Type :int
n

Number of fingers

Type :int
tx

Timestamp of start of final x-swipe

Type :int
ty

Timestamp of start of final y-swipe

Type :int
x1

Final-swipe direction starting point on X

Type :int
x2

Final-swipe direction ending point on X

Type :int
y1

Final-swipe direction starting point on Y

Type :int
y2

Final-swipe direction ending point on Y

Type :int
class efl.elementary.gesture_layer.GestureRotateInfo

Bases: object

Holds rotation info for user

angle

Rotation value: 0.0 means no rotation

Type :double
base_angle

Holds start-angle

Type :double
momentum

Rotation momentum: rotation done per second (NOT YET SUPPORTED)

Type :double
radius

Holds radius between fingers reported to user

Type :int
x

Holds zoom center point reported to user

Type :int
y

Holds zoom center point reported to user

Type :int
class efl.elementary.gesture_layer.GestureTapsInfo

Bases: object

Holds taps info for user

n

Number of fingers tapped

Type :int
timestamp

Event timestamp

Type :int
x

Holds center point between fingers

Type :int
y

Holds center point between fingers

Type :int
class efl.elementary.gesture_layer.GestureZoomInfo

Bases: object

Holds zoom info for user

momentum

Zoom momentum: zoom growth per second (NOT YET SUPPORTED)

Type :double
radius

Holds radius between fingers reported to user

Type :int
x

Holds zoom center point reported to user

Type :int
y

Holds zoom center point reported to user

Type :int
zoom

Zoom value: 1.0 means no zoom

Type :double