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
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
cb_set()
call. By setting the callback you actually
saying to gesture layer: I would like to know when the gesture
Gesture types switches to state Gesture states.
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
cb_set()
)
The information reported by gesture layer to your callback is depending on Gesture types:
GestureTapsInfo
is the info reported for tap gestures:
GestureMomentumInfo
is info reported for momentum gestures:
GestureLineInfo
is the info reported for line gestures
(this also contains GestureMomentumInfo
internal structure):
Note that we consider a flick as a line-gesture that should be completed
in flick-time-limit as defined in
Configuration
.
GestureZoomInfo
is the info reported for ELM_GESTURE_ZOOM
gesture.
GestureRotateInfo
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).
efl.elementary.
ELM_GESTURE_STATE_UNDEFINED
¶Gesture not started
efl.elementary.
ELM_GESTURE_STATE_START
¶Gesture started
efl.elementary.
ELM_GESTURE_STATE_MOVE
¶Gesture is ongoing
efl.elementary.
ELM_GESTURE_STATE_END
¶Gesture completed
efl.elementary.
ELM_GESTURE_STATE_ABORT
¶Ongoing gesture was aborted
efl.elementary.
ELM_GESTURE_N_TAPS
¶N fingers single taps
efl.elementary.
ELM_GESTURE_N_LONG_TAPS
¶N fingers single long-taps
efl.elementary.
ELM_GESTURE_N_DOUBLE_TAPS
¶N fingers double-single taps
efl.elementary.
ELM_GESTURE_N_TRIPLE_TAPS
¶N fingers triple-single taps
efl.elementary.
ELM_GESTURE_MOMENTUM
¶Reports momentum in the direction of move
efl.elementary.
ELM_GESTURE_N_LINES
¶N fingers line gesture
efl.elementary.
ELM_GESTURE_N_FLICKS
¶N fingers flick gesture
efl.elementary.
ELM_GESTURE_ZOOM
¶Zoom
efl.elementary.
ELM_GESTURE_ROTATE
¶Rotate
efl.elementary.
GestureLayer
(Object parent, *args, **kwargs)¶Bases: efl.elementary.__init__.Object
Note
You have to call attach()
in order to ‘activate’
gesture-layer.
Parameters: |
|
---|
attach
(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
(idx, 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: |
|
---|
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.