Module: Handy::Swipeable

Defined in:
(unknown)

Overview

An interface for swipeable widgets.

The HdySwipeable interface is implemented by all swipeable widgets. They can be synced using [classSwipeGroup].

See [classSwipeTracker] for details about implementing it.

Instance Method Summary collapse

Instance Method Details

#cancel_progressFloat

Gets the progress self will snap back to after the gesture is canceled.

Returns:

  • (Float)

    the cancel progress, unitless

#distanceFloat

Gets the swipe distance of self.

This corresponds to how many pixels 1 unit represents.

Returns:

  • (Float)

    the swipe distance in pixels

#emit_child_switched(index, duration) ⇒ nil

Emits [signalSwipeable::child-switched] signal.

This should be called when the widget switches visible child widget.

duration can be 0 if the child is switched without animation.

Parameters:

  • index (Integer)

    the index of the child to switch to

  • duration (Integer)

    animation duration, in milliseconds

Returns:

  • (nil)

#get_snap_points(n_snap_points) ⇒ Array<Float>

Gets the snap points of self.

Each snap point represents a progress value that is considered acceptable to end the swipe on.

Parameters:

  • n_snap_points (Integer)

    location to return the number of the snap points

Returns:

  • (Array<Float>)

    the snap points

#get_swipe_area(navigation_direction, is_drag, rect) ⇒ nil

Gets the area self can start a swipe from for the given direction and gesture type.

This can be used to restrict swipes to only be possible from a certain area, for example, to only allow edge swipes, or to have a draggable element and ignore swipes elsewhere.

Swipe area is only considered for direct swipes (as in, not initiated by [classSwipeGroup]).

If not implemented, the default implementation returns the allocation of self, allowing swipes from anywhere.

Parameters:

  • navigation_direction (Handy::NavigationDirection)

    the direction of the swipe

  • is_drag (Boolean)

    whether the swipe is caused by a dragging gesture

  • rect (Gdk::Rectangle)

    a pointer to a rectangle to store the swipe area

Returns:

  • (nil)

#progressFloat

Gets the current progress of self.

Returns:

  • (Float)

    the current progress, unitless

#swipe_trackerHandy::SwipeTracker

Gets the [classSwipeTracker] used by this swipeable widget.

Returns:

#switch_child(index, duration) ⇒ nil

Switches to child with index index.

See [signalSwipeable::child-switched].

Parameters:

  • index (Integer)

    the index of the child to switch to

  • duration (Integer)

    animation duration, in milliseconds

Returns:

  • (nil)