Class Flap

All Implemented Interfaces:
PointerInterface

public class Flap extends Widget
An adaptive container acting like a box or an overlay.

<picture>
<source srcset="flap-wide-dark.png" media="(prefers-color-scheme: dark)">
<img src="flap-wide.png" alt="flap-wide">
</picture>
<picture>
<source srcset="flap-narrow-dark.png" media="(prefers-color-scheme: dark)">
<img src="flap-narrow.png" alt="flap-narrow">
</picture>

The `AdwFlap` widget can display its children like a [class@Gtk.Box] does or
like a [class@Gtk.Overlay] does, according to the
[property@Flap:fold-policy] value.

`AdwFlap` has at most three children: [property@Flap:content],
[property@Flap:flap] and [property@Flap: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
[property@Flap:reveal-flap] value, as well as via swipe gestures if
[property@Flap:swipe-to-open] and/or [property@Flap: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.

[property@Flap:flap] is transparent by default; add the
[`.background`](style-classes.html#background) style class to it if this is
unwanted.

If [property@Flap:modal] is set to `TRUE`, content becomes completely
inaccessible when the flap is revealed while folded.

The position of the flap and separator children relative to the content is
determined by orientation, as well as the [property@Flap: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
[property@Flap: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.

## AdwFlap as GtkBuildable

The `AdwFlap` implementation of the [iface@Gtk.Buildable] 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

`AdwFlap` 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.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Flap.html

  • Constructor Details

    • Flap

      public Flap(PointerContainer pointer)
    • Flap

      public Flap()
      Creates a new `AdwFlap`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getContent

      public Widget getContent()
      Gets the content widget for @self.
      Returns:
      the content widget for @self
    • getFlap

      public Widget getFlap()
      Gets the flap widget for @self.
      Returns:
      the flap widget for @self
    • getFlapPosition

      public int getFlapPosition()
      Gets the flap position for @self.
      Returns:
      the flap position for @self
    • getFoldDuration

      public int getFoldDuration()
      Gets the fold transition animation duration for @self, in milliseconds.
      Returns:
      the fold transition duration
    • getFoldPolicy

      public int getFoldPolicy()
      Gets the fold policy for @self.
      Returns:
      the fold policy for @self
    • getFoldThresholdPolicy

      public int getFoldThresholdPolicy()
      Gets the fold threshold policy for @self.
      Returns:
    • getFolded

      public boolean getFolded()
      Gets whether @self is currently folded.

      See [property@Flap:fold-policy].
      Returns:
      `TRUE` if @self is currently folded
    • getLocked

      public boolean getLocked()
      Gets whether @self is locked.
      Returns:
      `TRUE` if @self is locked
    • getModal

      public boolean getModal()
      Gets whether @self is modal.
      Returns:
      `TRUE` if @self is modal
    • getRevealFlap

      public boolean getRevealFlap()
      Gets whether the flap widget is revealed for @self.
      Returns:
      `TRUE` if the flap widget is revealed
    • getRevealParams

      public SpringParams getRevealParams()
      Gets the reveal animation spring parameters for @self.
      Returns:
      the reveal animation parameters
    • getRevealProgress

      public double getRevealProgress()
      Gets the current reveal progress for @self.

      0 means fully hidden, 1 means fully revealed.

      See [property@Flap:reveal-flap].
      Returns:
      the current reveal progress for @self
    • getSeparator

      public Widget getSeparator()
      Gets the separator widget for @self.
      Returns:
      the separator widget for @self
    • getSwipeToClose

      public boolean getSwipeToClose()
      Gets whether @self can be closed with a swipe gesture.
      Returns:
      `TRUE` if @self can be closed with a swipe gesture
    • getSwipeToOpen

      public boolean getSwipeToOpen()
      Gets whether @self can be opened with a swipe gesture.
      Returns:
      `TRUE` if @self can be opened with a swipe gesture
    • getTransitionType

      public int getTransitionType()
      Gets the type of animation used for reveal and fold transitions in @self.
      Returns:
      the current transition type of @self
    • setContent

      public void setContent(@Nullable Widget content)
      Sets the content widget for @self.

      It's always displayed when unfolded, and partially visible when folded.
      Parameters:
      content - the content widget
    • setFlap

      public void setFlap(@Nullable Widget flap)
      Sets the flap widget for @self.

      It's only visible when [property@Flap:reveal-progress] is greater than 0.
      Parameters:
      flap - the flap widget
    • setFlapPosition

      public void setFlapPosition(int position)
      Sets the flap position for @self.

      If it's set to `GTK_PACK_START`, the flap is displayed before the content,
      if `GTK_PACK_END`, it's displayed after the content.
      Parameters:
      position - the new value
    • setFoldDuration

      public void setFoldDuration(int duration)
      Sets the fold transition animation duration for @self, in milliseconds.
      Parameters:
      duration - the new duration, in milliseconds
    • setFoldPolicy

      public void setFoldPolicy(int policy)
      Sets the fold policy for @self.
      Parameters:
      policy - the fold policy
    • setFoldThresholdPolicy

      public void setFoldThresholdPolicy(int policy)
      Sets the fold threshold policy for @self.

      If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, flap will only fold when the
      children cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`, it
      will fold as soon as children don't get their natural size.

      This can be useful if you have a long ellipsizing label and want to let it
      ellipsize instead of immediately folding.
      Parameters:
      policy - the policy to use
    • setLocked

      public void setLocked(boolean locked)
      Sets whether @self 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`,
      [property@Flap:reveal-flap] value never changes on its own.
      Parameters:
      locked - the new value
    • setModal

      public void setModal(boolean modal)
      Sets whether @self is modal.

      If `TRUE`, clicking the content widget while flap is revealed, as well as
      pressing the <kbd>Esc</kbd> key, will close the flap. If `FALSE`, clicks are
      passed through to the content widget.
      Parameters:
      modal - whether @self is modal
    • setRevealFlap

      public void setRevealFlap(boolean reveal_flap)
      Sets whether the flap widget is revealed for @self.
      Parameters:
      reveal_flap - whether to reveal the flap widget
    • setRevealParams

      public void setRevealParams(@Nonnull SpringParams params)
      Sets the reveal animation spring parameters for @self.

      The default value is equivalent to:

      ```c
      adw_spring_params_new (1, 0.5, 500)
      ```
      Parameters:
      params - the new parameters
    • setSeparator

      public void setSeparator(@Nullable Widget separator)
      Sets the separator widget for @self.

      It's displayed between content and flap when there's no shadow to display.
      When exactly it's visible depends on the [property@Flap:transition-type]
      value.
      Parameters:
      separator - the separator widget
    • setSwipeToClose

      public void setSwipeToClose(boolean swipe_to_close)
      Sets whether @self can be closed with a swipe gesture.

      The area that can be swiped depends on the [property@Flap:transition-type]
      value.
      Parameters:
      swipe_to_close - whether @self can be closed with a swipe gesture
    • setSwipeToOpen

      public void setSwipeToOpen(boolean swipe_to_open)
      Sets whether @self can be opened with a swipe gesture.

      The area that can be swiped depends on the [property@Flap:transition-type]
      value.
      Parameters:
      swipe_to_open - whether @self can be opened with a swipe gesture
    • setTransitionType

      public void setTransitionType(int transition_type)
      Sets the type of animation used for reveal and fold transitions in @self.

      [property@Flap:flap] is transparent by default, which means the content will
      be seen through it with `ADW_FLAP_TRANSITION_TYPE_OVER` transitions; add the
      [`.background`](style-classes.html#background) style class to it if this is
      unwanted.
      Parameters:
      transition_type - the new transition type
    • asSwipeable

      public Swipeable asSwipeable()
      Implements interface Swipeable. Call this to get access to interface functions.
      Returns:
      Swipeable
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • asOrientable

      public Orientable asOrientable()
      Implements interface Orientable. Call this to get access to interface functions.
      Returns:
      Orientable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()