Klasse BottomSheet

Alle implementierten Schnittstellen:
PointerInterface

public class BottomSheet extends Widget
A bottom sheet with an optional bottom bar.

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

`AdwBottomSheet` has three child widgets. [property@BottomSheet:content] is
shown persistently. [property@BottomSheet:sheet] is displayed above it when
it's open, and [property@BottomSheet:bottom-bar] is displayed when it's not.

Bottom sheet and bottom bar are attached to the bottom edge of the widget.
They take the full width by default, but can only take a portion of it if
[property@BottomSheet:full-width] is set to `FALSE`. In this case,
[property@BottomSheet:align] determines where along the bottom edge they are
placed.

Bottom bar can be hidden using the [property@BottomSheet:reveal-bottom-bar]
property.

`AdwBottomSheet` can be useful for applications such as music players, that
want to have a persistent bottom bar that expands into a bottom sheet when
clicked. It's meant for cases where a bottom sheet is tightly integrated into
the UI. For more transient bottom sheets, see [class@Dialog].

To open or close the bottom sheet, use the [property@BottomSheet:open]
property.

By default, the bottom sheet has an overlaid drag handle. It can be disabled
by setting [property@BottomSheet:show-drag-handle] to `FALSE`. Note that the
handle also controls whether the sheet can be dragged using a pointer.

Bottom sheets are modal by default, meaning that the content is dimmed and
cannot be accessed while the sheet is open. Set [property@BottomSheet:modal]
to `FALSE` if this behavior is unwanted.

To disable user interactions for opening or closing the bottom sheet (such as
swipes or clicking the bottom bar or close button), set
[property@BottomSheet:can-open] or [property@BottomSheet:can-close] to
`FALSE`.

In some cases, particularly when using a full-width bottom bar, it may be
necessary to shift [property@BottomSheet:content] upwards. Use the
[property@BottomSheet:bottom-bar-height] and
[property@BottomSheet:sheet-height] for that.

`AdwBottomSheet` is not adaptive, and for larger window sizes applications
may want to replace it with another UI, such as a sidebar. This can be done
using [class@MultiLayoutView].

## Sizing

Unlike [class@Dialog] presented as a bottom sheet, `AdwBottomSheet` just
follows the content's natural size, and it's up to the applications to make
sure their content provides one. For example, when using
[class@Gtk.ScrolledWindow], make sure to set
[property@Gtk.ScrolledWindow:propagate-natural-height] to `TRUE`.

## Header Bar Integration

When placed inside an `AdwBottomSheet`, [class@HeaderBar] will not show the
title when [property@BottomSheet:show-drag-handle] is `TRUE`, regardless of
[property@HeaderBar:show-title]. This only applies to the default title,
titles set with [property@HeaderBar:title-widget] will still be shown.

## `AdwBottomSheet` as `GtkBuildable`:

The `AdwBottomSheet` implementation of the [iface@Gtk.Buildable] interface
supports setting the sheet widget by specifying “sheet” as the “type”
attribute of a `<child>` element, and the bottom bar by specifying
“bottom-bar”. Specifying “content” or omitting the child type results in
setting the content child.

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

  • Felddetails

  • Konstruktordetails

    • BottomSheet

      public BottomSheet(PointerContainer pointer)
    • BottomSheet

      public BottomSheet()
      Creates a new `AdwBottomSheet`.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getAlign

      public float getAlign()
      Gets horizontal alignment of the bottom sheet.
      Gibt zurück:
      the horizontal alignment
    • getBottomBar

      public Widget getBottomBar()
      Gets the bottom bar widget for @self.
      Gibt zurück:
      the bottom bar widget
    • getBottomBarHeight

      public int getBottomBarHeight()
      Gets the current bottom bar height.

      It can be used to shift the content upwards permanently to accommodate for
      the bottom bar.
      Gibt zurück:
      the bottom bar height
    • getCanClose

      public boolean getCanClose()
      Gets whether the bottom sheet can be closed by user.
      Gibt zurück:
      whether the sheet can be closed by user
    • getCanOpen

      public boolean getCanOpen()
      Gets whether the bottom sheet can be opened by user.
      Gibt zurück:
      whether the sheet can be opened by user.
    • getContent

      public Widget getContent()
      Gets the content widget for @self.
      Gibt zurück:
      the content widget
    • getFullWidth

      public boolean getFullWidth()
      Gets whether the bottom sheet takes the full width.
      Gibt zurück:
      whether the sheet takes up the full width
    • getModal

      public boolean getModal()
      Gets whether the bottom sheet is modal.
      Gibt zurück:
      whether the sheet is modal
    • getOpen

      public boolean getOpen()
      Gets whether the bottom sheet is open.
      Gibt zurück:
      whether the sheet is open
    • getRevealBottomBar

      public boolean getRevealBottomBar()
      Gets whether the bottom bar is revealed.
      Gibt zurück:
      whether the bottom bar is revealed
    • getSheet

      public Widget getSheet()
      Gets the bottom sheet widget for @self.
      Gibt zurück:
      the sheet widget
    • getSheetHeight

      public int getSheetHeight()
      Gets the current bottom sheet height.

      It can be used to shift the content upwards when the bottom sheet is open.
      Gibt zurück:
      the sheet height
    • getShowDragHandle

      public boolean getShowDragHandle()
      Gets whether to show a drag handle in the bottom sheet.
      Gibt zurück:
      whether to show the drag handle
    • setAlign

      public void setAlign(float align)
      Sets horizontal alignment of the bottom sheet.

      0 means the bottom sheet is flush with the start edge, 1 means it's flush
      with the end edge. 0.5 means it's centered.

      Only used when [property@BottomSheet:full-width] is set to `FALSE`.
      Parameter:
      align - the new alignment
    • setBottomBar

      public void setBottomBar(@Nullable Widget bottom_bar)
      Sets the bottom bar widget for @self.

      Shown when [property@BottomSheet:open] is `FALSE`. When open, morphs into
      the [property@BottomSheet:sheet].

      Bottom bar can be temporarily hidden using the
      [property@BottomSheet:reveal-bottom-bar] property.
      Parameter:
      bottom_bar - the bottom bar widget
    • setCanClose

      public void setCanClose(boolean can_close)
      Sets whether the bottom sheet can be closed by user.

      It can be closed via the close button, swiping down, pressing
      <kbd>Escape</kbd> or clicking the content dimming (when modal).

      Bottom sheet can still be closed using [property@BottomSheet:open].
      Parameter:
      can_close - whether the sheet can be closed by user
    • setCanOpen

      public void setCanOpen(boolean can_open)
      Sets whether the bottom sheet can be opened by user.

      It can be opened via clicking or swiping up from the bottom bar.

      Does nothing if [property@BottomSheet:bottom-bar] is not set.

      Bottom sheet can still be opened using [property@BottomSheet:open].
      Parameter:
      can_open - whether the sheet can be opened by user.
    • setContent

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

      It's always shown, and the bottom sheet is overlaid over it.
      Parameter:
      content - the content widget
    • setFullWidth

      public void setFullWidth(boolean full_width)
      Sets whether the bottom sheet takes the full width.

      When full width, [property@BottomSheet:align] is ignored.
      Parameter:
      full_width - whether the sheet takes up the full width
    • setModal

      public void setModal(boolean modal)
      Sets whether the bottom sheet is modal.

      When modal, [property@BottomSheet:content] will be dimmed when the bottom
      sheet is open, and clicking it will close the bottom sheet. It also cannot be
      focused with keyboard.

      Otherwise, the content is accessible even when the bottom sheet is open.
      Parameter:
      modal - whether the sheet is modal
    • setOpen

      public void setOpen(boolean open)
      Sets whether the bottom sheet is open.
      Parameter:
      open - whether to open the sheet
    • setRevealBottomBar

      public void setRevealBottomBar(boolean reveal)
      Sets whether to reveal the bottom bar.

      The transition will be animated.

      See [property@BottomSheet:bottom-bar] and
      [property@BottomSheet:bottom-bar-height].
      Parameter:
      reveal - whether to reveal the bottom bar
    • setSheet

      public void setSheet(@Nullable Widget sheet)
      Sets the bottom sheet widget for @self.

      Only shown when [property@BottomSheet:open] is `TRUE`.
      Parameter:
      sheet - the sheet widget
    • setShowDragHandle

      public void setShowDragHandle(boolean show_drag_handle)
      Sets whether to show a drag handle in the bottom sheet.

      The handle will be overlaid over [property@BottomSheet:sheet].

      When the handle is shown, [class@HeaderBar] will hide its default title, and
      [class@ToolbarView] will reserve space if there are no top bars.

      Showing drag handle also allows to swipe the bottom sheet down (and to swipe
      the bottom bar up) with a pointer, instead of just touchscreen.
      Parameter:
      show_drag_handle - whether to show the drag handle
    • onCloseAttempt

      public SignalHandler onCloseAttempt(BottomSheet.OnCloseAttempt signal)
      Connect to signal "close-attempt".
      See BottomSheet.OnCloseAttempt.onCloseAttempt() for signal description.
      Field SIGNAL_ON_CLOSE_ATTEMPT contains original signal name and can be used as resource reference.
      Parameter:
      signal - callback function (lambda).
      Gibt zurück:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asSwipeable

      public Swipeable asSwipeable()
      Implements interface Swipeable. Call this to get access to interface functions.
      Gibt zurück:
      Swipeable
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Setzt außer Kraft:
      asAccessible in Klasse Widget
      Gibt zurück:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Setzt außer Kraft:
      asBuildable in Klasse Widget
      Gibt zurück:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Setzt außer Kraft:
      asConstraintTarget in Klasse Widget
      Gibt zurück:
      ConstraintTarget
    • 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()