HdyFlap

HdyFlap — An adaptive container acting like a box or an overlay.

Functions

Properties

GtkWidget * content Read / Write
GtkWidget * flap Read / Write
GtkPackType flap-position Read / Write
guint fold-duration Read / Write
HdyFlapFoldPolicy fold-policy Read / Write
gboolean folded Read
gboolean locked Read / Write
gboolean modal Read / Write
guint reveal-duration Read / Write
gboolean reveal-flap Read / Write
gdouble reveal-progress Read
GtkWidget * separator Read / Write
gboolean swipe-to-close Read / Write
gboolean swipe-to-open Read / Write
HdyFlapTransitionType transition-type Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── HdyFlap

Implemented Interfaces

HdyFlap implements AtkImplementorIface, GtkBuildable, GtkOrientable and HdySwipeable.

Description

The HdyFlap widget can display its children like a GtkBox does or like a GtkOverlay does, according to the “fold-policy” value.

HdyFlap has at most three children: “content”, “flap” and “separator”. Content is the primary child, flap is displayed next to it when unfolded, or overlays it when folded. Flap can be shown or hidden by changing the “reveal-flap” value, as well as via swipe gestures if “swipe-to-open” and/or “swipe-to-close” are set to TRUE.

Optionally, a separator can be provided, which would be displayed between the content and the flap when there's no shadow to separate them, depending on the transition type.

“flap” is transparent by default; add the .background style class to it if this is unwanted.

If “modal” is set to TRUE, content becomes completely inaccessible when the flap is revealed when folded.

The position of the flap and separator children relative to the content is determined by orientation, as well as “flap-position” value.

Folding the flap will automatically hide the flap widget, and unfolding it will automatically reveal it. If this behavior is not desired, the “locked” property can be used to override it.

Common use cases include sidebars, header bars that need to be able to overlap the window content (for example, in fullscreen mode) and bottom sheets.

HdyFlap as GtkBuildable

The HdyFlap implementation of the GtkBuildable interface supports setting the flap child by specifying “flap” as the “type” attribute of a <child> element, and separator by specifying “separator”. Specifying “content” child type or omitting it results in setting the content child.


CSS nodes

HdyFlap has a single CSS node with name flap. The node will get the style classes .folded when it is folded, and .unfolded when it's not.

Functions

hdy_flap_new ()

GtkWidget *
hdy_flap_new (void);

Creates a new HdyFlap.

Returns

a new HdyFlap

Since: 1.2


hdy_flap_get_content ()

GtkWidget *
hdy_flap_get_content (HdyFlap *self);

Gets the content widget for self

Parameters

self

a HdyFlap

 

Returns

the content widget for self .

[transfer none][nullable]

Since: 1.2


hdy_flap_set_content ()

void
hdy_flap_set_content (HdyFlap *self,
                      GtkWidget *content);

Sets the content widget for self , always displayed when unfolded, and partially visible when folded.

Parameters

self

a HdyFlap

 

content

the content widget, or NULL.

[nullable]

Since: 1.2


hdy_flap_get_flap ()

GtkWidget *
hdy_flap_get_flap (HdyFlap *self);

Gets the flap widget for self

Parameters

self

a HdyFlap

 

Returns

the flap widget for self .

[transfer none][nullable]

Since: 1.2


hdy_flap_set_flap ()

void
hdy_flap_set_flap (HdyFlap *self,
                   GtkWidget *flap);

Sets the flap widget for self , only visible when “reveal-progress” is greater than 0.

Parameters

self

a HdyFlap

 

flap

the flap widget, or NULL.

[nullable]

Since: 1.2


hdy_flap_get_separator ()

GtkWidget *
hdy_flap_get_separator (HdyFlap *self);

Gets the separator widget for self .

Parameters

self

a HdyFlap

 

Returns

the separator widget for self .

[transfer none][nullable]

Since: 1.2


hdy_flap_set_separator ()

void
hdy_flap_set_separator (HdyFlap *self,
                        GtkWidget *separator);

Sets the separator widget for self , displayed between content and flap when there's no shadow to display. When exactly it's visible depends on the “transition-type” value. If NULL, no separator will be used.

Parameters

self

a HdyFlap

 

separator

the separator widget, or NULL.

[nullable]

Since: 1.2


hdy_flap_get_flap_position ()

GtkPackType
hdy_flap_get_flap_position (HdyFlap *self);

Gets the flap position for self .

Parameters

self

a HdyFlap

 

Returns

the flap position for self

Since: 1.2


hdy_flap_set_flap_position ()

void
hdy_flap_set_flap_position (HdyFlap *self,
                            GtkPackType position);

Sets the flap position for self . If GTK_PACK_START , the flap is displayed before the content, if GTK_PACK_END , it's displayed after the content.

Parameters

self

a HdyFlap

 

position

the new value

 

Since: 1.2


hdy_flap_get_reveal_flap ()

gboolean
hdy_flap_get_reveal_flap (HdyFlap *self);

Gets whether the flap widget is revealed for self .

Parameters

self

a HdyFlap

 

Returns

TRUE if the flap widget is revealed, FALSE otherwise.

Since: 1.2


hdy_flap_set_reveal_flap ()

void
hdy_flap_set_reveal_flap (HdyFlap *self,
                          gboolean reveal_flap);

Sets whether the flap widget is revealed for self .

Parameters

self

a HdyFlap

 

reveal_flap

TRUE to reveal the flap widget, FALSE otherwise

 

Since: 1.2


hdy_flap_get_reveal_duration ()

guint
hdy_flap_get_reveal_duration (HdyFlap *self);

Returns the amount of time (in milliseconds) that reveal transitions in self will take.

Parameters

self

a HdyFlap

 

Returns

the reveal transition duration

Since: 1.2


hdy_flap_set_reveal_duration ()

void
hdy_flap_set_reveal_duration (HdyFlap *self,
                              guint duration);

Sets the duration that reveal transitions in self will take.

Parameters

self

a HdyFlap

 

duration

the new duration, in milliseconds

 

Since: 1.2


hdy_flap_get_reveal_progress ()

gdouble
hdy_flap_get_reveal_progress (HdyFlap *self);

Gets the current reveal transition progress for self . 0 means fully hidden, 1 means fully revealed. See “reveal-flap”.

Parameters

self

a HdyFlap

 

Returns

the current reveal progress for self

Since: 1.2


hdy_flap_get_fold_policy ()

HdyFlapFoldPolicy
hdy_flap_get_fold_policy (HdyFlap *self);

Gets the current fold policy of self . See hdy_flap_set_fold_policy().

Parameters

self

a HdyFlap

 

Returns

the current fold policy of self

Since: 1.2


hdy_flap_set_fold_policy ()

void
hdy_flap_set_fold_policy (HdyFlap *self,
                          HdyFlapFoldPolicy policy);

Sets the current fold policy for self . See HdyFlapFoldPolicy for available policies.

Parameters

self

a HdyFlap

 

policy

Fold policy

 

Since: 1.2


hdy_flap_get_fold_duration ()

guint
hdy_flap_get_fold_duration (HdyFlap *self);

Returns the amount of time (in milliseconds) that fold transitions in self will take.

Parameters

self

a HdyFlap

 

Returns

the fold transition duration

Since: 1.2


hdy_flap_set_fold_duration ()

void
hdy_flap_set_fold_duration (HdyFlap *self,
                            guint duration);

Sets the duration that fold transitions in self will take.

Parameters

self

a HdyFlap

 

duration

the new duration, in milliseconds

 

Since: 1.2


hdy_flap_get_folded ()

gboolean
hdy_flap_get_folded (HdyFlap *self);

Gets whether self is currently folded.

See “fold-policy”.

Parameters

self

a HdyFlap

 

Returns

TRUE if self is currently folded, FALSE otherwise

Since: 1.2


hdy_flap_get_locked ()

gboolean
hdy_flap_get_locked (HdyFlap *self);

Gets whether self is locked.

Parameters

self

a HdyFlap

 

Returns

TRUE if self is locked, FALSE otherwise

Since: 1.2


hdy_flap_set_locked ()

void
hdy_flap_set_locked (HdyFlap *self,
                     gboolean locked);

Sets whether self is locked.

If FALSE, folding self when the flap is revealed automatically closes it, and unfolding it when the flap is not revealed opens it. If TRUE, “reveal-flap” value never changes on its own.

Parameters

self

a HdyFlap

 

locked

the new value

 

Since: 1.2


hdy_flap_get_transition_type ()

HdyFlapTransitionType
hdy_flap_get_transition_type (HdyFlap *self);

Gets the type of animation that will be used for reveal and fold transitions in self .

Parameters

self

a HdyFlap

 

Returns

the current transition type of self

Since: 1.2


hdy_flap_set_transition_type ()

void
hdy_flap_set_transition_type (HdyFlap *self,
                              HdyFlapTransitionType transition_type);

Sets the type of animation that will be used for reveal and fold transitions in self .

“flap” is transparent by default, which means the content will be seen through it with HDY_FLAP_TRANSITION_TYPE_OVER transitions; add the .background style class to it if this is unwanted.

Parameters

self

a HdyFlap

 

transition_type

the new transition type

 

Since: 1.2


hdy_flap_get_modal ()

gboolean
hdy_flap_get_modal (HdyFlap *self);

Gets whether the self is modal. See hdy_flap_set_modal().

Parameters

self

a HdyFlap

 

Returns

TRUE if self is modal

Since: 1.2


hdy_flap_set_modal ()

void
hdy_flap_set_modal (HdyFlap *self,
                    gboolean modal);

Sets whether the self can be closed with a click.

If modal is TRUE, clicking the content widget while flap is revealed, or pressing Escape key, will close the flap. If FALSE, clicks are passed through to the content widget.

Parameters

self

a HdyFlap

 

modal

Whether self can be closed with a click

 

Since: 1.2


hdy_flap_get_swipe_to_open ()

gboolean
hdy_flap_get_swipe_to_open (HdyFlap *self);

Gets whether self can be opened with a swipe gesture.

Parameters

self

a HdyFlap

 

Returns

TRUE if self can be opened with a swipe gesture

Since: 1.2


hdy_flap_set_swipe_to_open ()

void
hdy_flap_set_swipe_to_open (HdyFlap *self,
                            gboolean swipe_to_open);

Sets whether self can be opened with a swipe gesture.

The area that can be swiped depends on the “transition-type” value.

Parameters

self

a HdyFlap

 

swipe_to_open

Whether self can be opened with a swipe gesture

 

Since: 1.2


hdy_flap_get_swipe_to_close ()

gboolean
hdy_flap_get_swipe_to_close (HdyFlap *self);

Gets whether self can be closed with a swipe gesture.

Parameters

self

a HdyFlap

 

Returns

TRUE if self can be closed with a swipe gesture

Since: 1.2


hdy_flap_set_swipe_to_close ()

void
hdy_flap_set_swipe_to_close (HdyFlap *self,
                             gboolean swipe_to_close);

Sets whether self can be closed with a swipe gesture.

The area that can be swiped depends on the “transition-type” value.

Parameters

self

a HdyFlap

 

swipe_to_close

Whether self can be closed with a swipe gesture

 

Since: 1.2

Types and Values

HDY_TYPE_FLAP

#define HDY_TYPE_FLAP (hdy_flap_get_type ())

enum HdyFlapFoldPolicy

These enumeration values describe the possible folding behavior in a HdyFlap widget.

Members

HDY_FLAP_FOLD_POLICY_NEVER

Disable folding, the flap cannot reach narrow sizes.

 

HDY_FLAP_FOLD_POLICY_ALWAYS

Keep the flap always folded.

 

HDY_FLAP_FOLD_POLICY_AUTO

Fold and unfold the flap based on available space.

 

Since: 1.2


enum HdyFlapTransitionType

These enumeration values describe the possible transitions between children in a HdyFlap widget, as well as which areas can be swiped via “swipe-to-open” and “swipe-to-close”.

New values may be added to this enum over time.

Members

HDY_FLAP_TRANSITION_TYPE_OVER

The flap slides over the content, which is dimmed. When folded, only the flap can be swiped.

 

HDY_FLAP_TRANSITION_TYPE_UNDER

The content slides over the flap. Only the content can be swiped.

 

HDY_FLAP_TRANSITION_TYPE_SLIDE

The flap slides offscreen when hidden, neither the flap nor content overlap each other. Both widgets can be swiped.

 

Since: 1.2


HdyFlap

typedef struct _HdyFlap HdyFlap;

Property Details

The “content” property

  “content”                  GtkWidget *

The content widget, always displayed when unfolded, and partially visible when folded.

Flags: Read / Write

Since: 1.2


The “flap” property

  “flap”                     GtkWidget *

The flap widget, only visible when “reveal-progress” is greater than 0.

Flags: Read / Write

Since: 1.2


The “flap-position” property

  “flap-position”            GtkPackType

The flap position for self . If GTK_PACK_START , the flap is displayed before the content, if GTK_PACK_END , it's displayed after the content.

Flags: Read / Write

Default value: GTK_PACK_START

Since: 1.2


The “fold-duration” property

  “fold-duration”            guint

The fold transition animation duration, in milliseconds.

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 250

Since: 1.2


The “fold-policy” property

  “fold-policy”              HdyFlapFoldPolicy

The current fold policy. See HdyFlapFoldPolicy for available policies.

Flags: Read / Write

Default value: HDY_FLAP_FOLD_POLICY_AUTO

Since: 1.2


The “folded” property

  “folded”                   gboolean

Whether the flap is currently folded.

See “fold-policy”.

Flags: Read

Default value: FALSE

Since: 1.2


The “locked” property

  “locked”                   gboolean

Whether the flap is locked.

If FALSE, folding when the flap is revealed automatically closes it, and unfolding it when the flap is not revealed opens it. If TRUE, “reveal-flap” value never changes on its own.

Flags: Read / Write

Default value: FALSE

Since: 1.2


The “modal” property

  “modal”                    gboolean

Whether the flap is modal.

If TRUE, clicking the content widget while flap is revealed, as well as pressing Escape key, will close the flap. If FALSE, clicks are passed through to the content widget.

Flags: Read / Write

Default value: TRUE

Since: 1.2


The “reveal-duration” property

  “reveal-duration”          guint

The reveal transition animation duration, in milliseconds.

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 250

Since: 1.2


The “reveal-flap” property

  “reveal-flap”              gboolean

Whether the flap widget is revealed.

Flags: Read / Write

Default value: TRUE

Since: 1.2


The “reveal-progress” property

  “reveal-progress”          gdouble

The current reveal transition progress. 0 means fully hidden, 1 means fully revealed See “reveal-flap”.

Flags: Read

Allowed values: [0,1]

Default value: 1

Since: 1.2


The “separator” property

  “separator”                GtkWidget *

The separator widget, displayed between content and flap when there's no shadow to display. When exactly it's visible depends on the “transition-type” value. If NULL, no separator will be used.

Flags: Read / Write

Since: 1.2


The “swipe-to-close” property

  “swipe-to-close”           gboolean

Whether the flap can be closed with a swipe gesture.

The area that can be swiped depends on the “transition-type” value.

Flags: Read / Write

Default value: TRUE

Since: 1.2


The “swipe-to-open” property

  “swipe-to-open”            gboolean

Whether the flap can be opened with a swipe gesture.

The area that can be swiped depends on the “transition-type” value.

Flags: Read / Write

Default value: TRUE

Since: 1.2


The “transition-type” property

  “transition-type”          HdyFlapTransitionType

The type of animation that will be used for reveal and fold transitions in self .

“flap” is transparent by default, which means the content will be seen through it with HDY_FLAP_TRANSITION_TYPE_OVER transitions; add the .background style class to it if this is unwanted.

Flags: Read / Write

Default value: HDY_FLAP_TRANSITION_TYPE_OVER

Since: 1.2