Class BottomSheet
- All Implemented Interfaces:
Proxy
,Swipeable
,Accessible
,Buildable
,ConstraintTarget
AdwBottomSheet
has three child widgets. BottomSheet:content
is
shown persistently. BottomSheet:sheet
is displayed above it when
it's open, and 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
BottomSheet:full-width
is set to FALSE
. In this case,
BottomSheet:align
determines where along the bottom edge they are
placed.
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 Dialog
.
To open or close the bottom sheet, use the BottomSheet:open
property.
By default, the bottom sheet has an overlaid drag handle. It can be disabled
by setting 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 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
BottomSheet:can-open
or BottomSheet:can-close
to
FALSE
.
In some cases, particularly when using a full-width bottom bar, it may be
necessary to shift BottomSheet:content
upwards. Use the
BottomSheet:bottom-bar-height
and
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 MultiLayoutView
.
Sizing
Unlike 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
ScrolledWindow
, make sure to set
Gtk.ScrolledWindow:propagate-natural-height
to TRUE
.
Header Bar Integration
When placed inside an AdwBottomSheet
, HeaderBar
will not show the
title when BottomSheet:show-drag-handle
is TRUE
, regardless of
HeaderBar:show-title
. This only applies to the default title,
titles set with HeaderBar:title-widget
will still be shown.
AdwBottomSheet
as GtkBuildable
:
The AdwBottomSheet
implementation of the 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
BottomSheet.Builder<B extends BottomSheet.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCloseAttemptCallback
callback.Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.adw.Swipeable
Swipeable.SwipeableImpl, Swipeable.SwipeableInterface
-
Constructor Summary
ConstructorDescriptionCreates a newAdwBottomSheet
.BottomSheet
(MemorySegment address) Create a BottomSheet proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected BottomSheet
asParent()
Returns this instance as if it were its parent type.static BottomSheet.Builder
<? extends BottomSheet.Builder> builder()
ABottomSheet.Builder
object constructs aBottomSheet
with the specified properties.void
Emits the "close-attempt" signal.float
getAlign()
Gets horizontal alignment of the bottom sheet.Gets the bottom bar widget for this BottomSheet.int
Gets the current bottom bar height.boolean
Gets whether the bottom sheet can be closed by user.boolean
Gets whether the bottom sheet can be opened by user.Gets the content widget for this BottomSheet.boolean
Gets whether the bottom sheet takes the full width.boolean
getModal()
Gets whether the bottom sheet is modal.boolean
getOpen()
Gets whether the bottom sheet is open.getSheet()
Gets the bottom sheet widget for this BottomSheet.int
Gets the current bottom sheet height.boolean
Gets whether to show a drag handle in the bottom sheet.static Type
getType()
Get the GType of the BottomSheet classEmitted when the close button or shortcut is used whileDialog:can-close
is set toFALSE
.void
setAlign
(float align) Sets horizontal alignment of the bottom sheet.void
setBottomBar
(@Nullable Widget bottomBar) Sets the bottom bar widget for this BottomSheet.void
setCanClose
(boolean canClose) Sets whether the bottom sheet can be closed by user.void
setCanOpen
(boolean canOpen) Sets whether the bottom sheet can be opened by user.void
setContent
(@Nullable Widget content) Sets the content widget for this BottomSheet.void
setFullWidth
(boolean fullWidth) Sets whether the bottom sheet takes the full width.void
setModal
(boolean modal) Sets whether the bottom sheet is modal.void
setOpen
(boolean open) Sets whether the bottom sheet is open.void
Sets the bottom sheet widget for this BottomSheet.void
setShowDragHandle
(boolean showDragHandle) Sets whether to show a drag handle in the bottom sheet.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.adw.Swipeable
getCancelProgress, getDistance, getProgress, getSnapPoints, getSwipeArea
-
Constructor Details
-
BottomSheet
Create a BottomSheet proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
BottomSheet
public BottomSheet()Creates a newAdwBottomSheet
.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getAlign
public float getAlign()Gets horizontal alignment of the bottom sheet.- Returns:
- the horizontal alignment
-
getBottomBar
Gets the bottom bar widget for this BottomSheet.- Returns:
- 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.
- Returns:
- the bottom bar height
-
getCanClose
public boolean getCanClose()Gets whether the bottom sheet can be closed by user.- Returns:
- whether the sheet can be closed by user
-
getCanOpen
public boolean getCanOpen()Gets whether the bottom sheet can be opened by user.- Returns:
- whether the sheet can be opened by user.
-
getContent
Gets the content widget for this BottomSheet.- Returns:
- the content widget
-
getFullWidth
public boolean getFullWidth()Gets whether the bottom sheet takes the full width.- Returns:
- whether the sheet takes up the full width
-
getModal
public boolean getModal()Gets whether the bottom sheet is modal.- Returns:
- whether the sheet is modal
-
getOpen
public boolean getOpen()Gets whether the bottom sheet is open.- Returns:
- whether the sheet is open
-
getSheet
Gets the bottom sheet widget for this BottomSheet.- Returns:
- 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.
- Returns:
- the sheet height
-
getShowDragHandle
public boolean getShowDragHandle()Gets whether to show a drag handle in the bottom sheet.- Returns:
- 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
BottomSheet:full-width
is set toFALSE
.- Parameters:
align
- the new alignment
-
setBottomBar
Sets the bottom bar widget for this BottomSheet.Shown when
BottomSheet:open
isFALSE
. When open, morphs into theBottomSheet:sheet
.- Parameters:
bottomBar
- the bottom bar widget
-
setCanClose
public void setCanClose(boolean canClose) Sets whether the bottom sheet can be closed by user.It can be closed via the close button, swiping down, pressing
Escape
or clicking the content dimming (when modal).Bottom sheet can still be closed using
BottomSheet:open
.- Parameters:
canClose
- whether the sheet can be closed by user
-
setCanOpen
public void setCanOpen(boolean canOpen) 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
BottomSheet:bottom-bar
is not set.Bottom sheet can still be opened using
BottomSheet:open
.- Parameters:
canOpen
- whether the sheet can be opened by user.
-
setContent
Sets the content widget for this BottomSheet.It's always shown, and the bottom sheet is overlaid over it.
- Parameters:
content
- the content widget
-
setFullWidth
public void setFullWidth(boolean fullWidth) Sets whether the bottom sheet takes the full width.When full width,
BottomSheet:align
is ignored.- Parameters:
fullWidth
- whether the sheet takes up the full width
-
setModal
public void setModal(boolean modal) Sets whether the bottom sheet is modal.When modal,
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.
- Parameters:
modal
- whether the sheet is modal
-
setOpen
public void setOpen(boolean open) Sets whether the bottom sheet is open.- Parameters:
open
- whether to open the sheet
-
setSheet
Sets the bottom sheet widget for this BottomSheet.Only shown when
BottomSheet:open
isTRUE
.- Parameters:
sheet
- the sheet widget
-
setShowDragHandle
public void setShowDragHandle(boolean showDragHandle) Sets whether to show a drag handle in the bottom sheet.The handle will be overlaid over
BottomSheet:sheet
.When the handle is shown,
HeaderBar
will hide its default title, andToolbarView
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.
- Parameters:
showDragHandle
- whether to show the drag handle
-
onCloseAttempt
public SignalConnection<BottomSheet.CloseAttemptCallback> onCloseAttempt(BottomSheet.CloseAttemptCallback handler) Emitted when the close button or shortcut is used whileDialog:can-close
is set toFALSE
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCloseAttempt
public void emitCloseAttempt()Emits the "close-attempt" signal. SeeonCloseAttempt(org.gnome.adw.BottomSheet.CloseAttemptCallback)
. -
builder
ABottomSheet.Builder
object constructs aBottomSheet
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withBottomSheet.Builder.build()
.
-