HdySwipeable

HdySwipeable — An interface for swipeable widgets.

Functions

Properties

gboolean allow-mouse-drag Read / Write
gboolean enabled Read / Write
gboolean reversed Read / Write
HdySwipeable * swipeable Read / Write / Construct Only

Signals

Types and Values

Object Hierarchy

    GInterface
    ╰── HdySwipeable
    GObject
    ╰── HdySwipeTracker

Prerequisites

HdySwipeable requires GtkWidget.

Implemented Interfaces

HdySwipeTracker implements GtkOrientable.

Known Implementations

HdySwipeable is implemented by HdyCarousel, HdyDeck and HdyLeaflet.

Description

The HdySwipeable interface is implemented by all swipeable widgets. They can be synced using HdySwipeGroup.

See HdySwipeTracker for details about implementing it.

Functions

hdy_swipeable_switch_child ()

void
hdy_swipeable_switch_child (HdySwipeable *self,
                            guint index,
                            gint64 duration);

See HdySwipeable::child-switched.

Parameters

self

a HdySwipeable

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

Since: 1.0


hdy_swipeable_emit_child_switched ()

void
hdy_swipeable_emit_child_switched (HdySwipeable *self,
                                   guint index,
                                   gint64 duration);

Emits HdySwipeable::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

self

a HdySwipeable

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

Since: 1.0


hdy_swipeable_get_swipe_tracker ()

HdySwipeTracker *
hdy_swipeable_get_swipe_tracker (HdySwipeable *self);

Gets the HdySwipeTracker used by this swipeable widget.

Parameters

self

a HdySwipeable

 

Returns

the swipe tracker.

[transfer none]

Since: 1.0


hdy_swipeable_get_distance ()

gdouble
hdy_swipeable_get_distance (HdySwipeable *self);

Gets the swipe distance of self . This corresponds to how many pixels 1 unit represents.

Parameters

self

a HdySwipeable

 

Returns

the swipe distance in pixels

Since: 1.0


hdy_swipeable_get_snap_points ()

gdouble *
hdy_swipeable_get_snap_points (HdySwipeable *self,
                               gint *n_snap_points);

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

[virtual get_snap_points]

Parameters

self

a HdySwipeable

 

n_snap_points

location to return the number of the snap points.

[out]

Returns

the snap points of self . The array must be freed with g_free().

[array length=n_snap_points][transfer full]

Since: 1.0


hdy_swipeable_get_progress ()

gdouble
hdy_swipeable_get_progress (HdySwipeable *self);

Gets the current progress of self

Parameters

self

a HdySwipeable

 

Returns

the current progress, unitless

Since: 1.0


hdy_swipeable_get_cancel_progress ()

gdouble
hdy_swipeable_get_cancel_progress (HdySwipeable *self);

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

Parameters

self

a HdySwipeable

 

Returns

the cancel progress, unitless

Since: 1.0


hdy_swipeable_get_swipe_area ()

void
hdy_swipeable_get_swipe_area (HdySwipeable *self,
                              GdkRectangle *rect);

Gets the area self can start a swipe from. 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 HdySwipeGroup).

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

Parameters

self

a HdySwipeable

 

rect

a pointer to a GdkRectangle to store the swipe area.

[out]

Since: 1.0

Types and Values

HDY_TYPE_SWIPEABLE

#define HDY_TYPE_SWIPEABLE (hdy_swipeable_get_type ())

struct HdySwipeableInterface

struct HdySwipeableInterface {
  GTypeInterface parent;

  void (*switch_child) (HdySwipeable *self,
                        guint         index,
                        gint64        duration);

  HdySwipeTracker * (*get_swipe_tracker)   (HdySwipeable *self);
  gdouble           (*get_distance)        (HdySwipeable *self);
  gdouble *         (*get_snap_points)     (HdySwipeable *self,
                                            gint         *n_snap_points);
  gdouble           (*get_progress)        (HdySwipeable *self);
  gdouble           (*get_cancel_progress) (HdySwipeable *self);
  void              (*get_swipe_area)      (HdySwipeable *self,
                                            GdkRectangle *rect);
};

An interface for swipeable widgets.

Members

GTypeInterface parent;

The parent interface.

 

switch_child ()

Switches visible child.

 

get_swipe_tracker ()

Gets the swipe tracker.

 

get_distance ()

Gets the swipe distance.

 

get_snap_points ()

Gets the snap points

 

get_progress ()

Gets the current progress.

 

get_cancel_progress ()

Gets the cancel progress.

 

get_swipe_area ()

Gets the swipeable rectangle.

 

Since: 1.0


HdySwipeTracker

typedef struct _HdySwipeTracker HdySwipeTracker;

HdySwipeable

typedef struct _HdySwipeable HdySwipeable;

Property Details

The “allow-mouse-drag” property

  “allow-mouse-drag”         gboolean

Whether to allow dragging with mouse pointer. This should usually be FALSE.

Owner: HdySwipeTracker

Flags: Read / Write

Default value: FALSE

Since: 1.0


The “enabled” property

  “enabled”                  gboolean

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.

Owner: HdySwipeTracker

Flags: Read / Write

Default value: TRUE

Since: 1.0


The “reversed” property

  “reversed”                 gboolean

Whether to reverse the swipe direction. If the swipe tracker is horizontal, it can be used for supporting RTL text direction.

Owner: HdySwipeTracker

Flags: Read / Write

Default value: FALSE

Since: 1.0


The “swipeable” property

  “swipeable”                HdySwipeable *

The widget the swipe tracker is attached to. Must not be NULL.

Owner: HdySwipeTracker

Flags: Read / Write / Construct Only

Since: 1.0

Signal Details

The “begin-swipe” signal

void
user_function (HdySwipeTracker       *self,
               HdyNavigationDirection direction,
               gboolean               direct,
               gpointer               user_data)

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

self

The HdySwipeTracker instance

 

direction

The direction of the swipe

 

direct

TRUE if the swipe is directly triggered by a gesture, FALSE if it's triggered via a HdySwipeGroup

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 1.0


The “end-swipe” signal

void
user_function (HdySwipeTracker *self,
               gint64           duration,
               double           to,
               gpointer         user_data)

This signal is emitted as soon as the gesture has stopped.

Parameters

self

The HdySwipeTracker instance

 

duration

Snap-back animation duration in milliseconds

 

to

The progress value to animate to

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 1.0


The “update-swipe” signal

void
user_function (HdySwipeTracker *self,
               double           progress,
               gpointer         user_data)

This signal is emitted every time the progress value changes.

Parameters

self

The HdySwipeTracker instance

 

progress

The current animation progress value

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 1.0


The “child-switched” signal

void
user_function (HdySwipeable *self,
               guint         index,
               gint64        duration,
               gpointer      user_data)

This signal should be emitted when the widget's visible child is changed.

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

This is used by HdySwipeGroup, applications should not connect to it.

Parameters

self

The HdySwipeable instance

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 1.0

See Also

HdyCarousel, HdyDeck, HdyLeaflet, HdySwipeGroup