SwipeTracker
Superclasses: Object
Implemented Interfaces: Orientable
A swipe tracker used in Carousel
, NavigationView
and
OverlaySplitView
.
The AdwSwipeTracker
object can be used for implementing widgets with swipe
gestures. It supports touch-based swipes, pointer dragging, and touchpad
scrolling.
The widgets will probably want to expose the enabled
property. If they expect to use horizontal orientation,
reversed
can be used for supporting RTL text
direction.
Constructors
- class SwipeTracker
- classmethod new(swipeable: Swipeable) SwipeTracker
Creates a new
AdwSwipeTracker
forwidget
.- Parameters:
swipeable – a widget to add the tracker on
Methods
- class SwipeTracker
- get_allow_long_swipes() bool
Gets whether to allow swiping for more than one snap point at a time.
- get_allow_window_handle() bool
Gets whether to allow touchscreen swiping from
GtkWindowHandle
.Added in version 1.5.
- get_lower_overshoot() bool
Gets whether to allow swiping past the first available snap point.
Added in version 1.4.
- get_upper_overshoot() bool
Gets whether to allow swiping past the last available snap point.
Added in version 1.4.
- set_allow_long_swipes(allow_long_swipes: bool) None
Sets whether to allow swiping for more than one snap point at a time.
If the value is
FALSE
, each swipe can only move to the adjacent snap points.- Parameters:
allow_long_swipes – whether to allow long swipes
- set_allow_mouse_drag(allow_mouse_drag: bool) None
Sets whether
self
can be dragged with mouse pointer.- Parameters:
allow_mouse_drag – whether to allow mouse dragging
- set_allow_window_handle(allow_window_handle: bool) None
Sets whether to allow touchscreen swiping from
GtkWindowHandle
.Setting it to
TRUE
will make dragging the window impossible.Added in version 1.5.
- Parameters:
allow_window_handle – whether to allow swiping from window handles
- set_enabled(enabled: bool) None
Sets whether
self
is enabled.When it’s not enabled, no events will be processed. Usually widgets will want to expose this via a property.
- Parameters:
enabled – whether
self
is enabled
- set_lower_overshoot(overshoot: bool) None
Sets whether to allow swiping past the first available snap point.
Added in version 1.4.
- Parameters:
overshoot – whether to allow swiping past the first available snap point
- set_reversed(reversed: bool) None
Sets whether to reverse the swipe direction.
If the swipe tracker is horizontal, it can be used for supporting RTL text direction.
- Parameters:
reversed – whether to reverse the swipe direction
Properties
- class SwipeTracker
- props.allow_long_swipes: bool
Whether to allow swiping for more than one snap point at a time.
If the value is
FALSE
, each swipe can only move to the adjacent snap points.
- props.allow_window_handle: bool
Whether to allow touchscreen swiping from
GtkWindowHandle
.This will make dragging the window impossible.
Added in version 1.5.
- props.enabled: bool
Whether the swipe tracker is enabled.
When it’s not enabled, no events will be processed. Usually widgets will want to expose this via a property.
- props.lower_overshoot: bool
Whether to allow swiping past the first available snap point.
Added in version 1.4.
Signals
- class SwipeTracker.signals
- begin_swipe() None
This signal is emitted right before a swipe will be started, after the drag threshold has been passed.
- end_swipe(velocity: float, to: float) None
This signal is emitted as soon as the gesture has stopped.
The user is expected to animate the deceleration from the current progress value to
to
with an animation usingvelocity
as the initial velocity, provided in pixels per second.SpringAnimation
is usually a good fit for this.- Parameters:
velocity – the velocity of the swipe
to – the progress value to animate to
- prepare(direction: NavigationDirection) None
This signal is emitted when a possible swipe is detected.
The
direction
value can be used to restrict the swipe to a certain direction.- Parameters:
direction – the direction of the swipe