Class BottomSheet
- All Implemented Interfaces:
Swipeable,Accessible,Buildable,ConstraintTarget,Proxy
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.
Bottom bar can be hidden using the 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 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.
- Since:
- 1.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classBottomSheet.Builder<B extends BottomSheet.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theCloseAttemptCallbackcallback.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.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterfaceNested classes/interfaces inherited from interface org.gnome.adw.Swipeable
Swipeable.Swipeable$Impl, Swipeable.SwipeableInterface -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new BottomSheet.BottomSheet(MemorySegment address) Create a BottomSheet proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected BottomSheetasParent()Returns this instance as if it were its parent type.static BottomSheet.Builder<? extends BottomSheet.Builder> builder()ABottomSheet.Builderobject constructs aBottomSheetwith the specified properties.voidEmits the "close-attempt" signal.floatgetAlign()Gets horizontal alignment of the bottom sheet.@Nullable WidgetGets the bottom bar widget forself.intGets the current bottom bar height.booleanGets whether the bottom sheet can be closed by user.booleanGets whether the bottom sheet can be opened by user.@Nullable WidgetGets the content widget forself.booleanGets whether the bottom sheet takes the full width.booleangetModal()Gets whether the bottom sheet is modal.booleangetOpen()Gets whether the bottom sheet is open.booleanGets whether the bottom bar is revealed.@Nullable WidgetgetSheet()Gets the bottom sheet widget forself.intGets the current bottom sheet height.booleanGets whether to show a drag handle in the bottom sheet.static @Nullable TypegetType()Get the GType of the BottomSheet classEmitted when the close button or shortcut is used whileDialog:can-closeis set toFALSE.voidsetAlign(float align) Sets horizontal alignment of the bottom sheet.voidsetBottomBar(@Nullable Widget bottomBar) Sets the bottom bar widget forself.voidsetCanClose(boolean canClose) Sets whether the bottom sheet can be closed by user.voidsetCanOpen(boolean canOpen) Sets whether the bottom sheet can be opened by user.voidsetContent(@Nullable Widget content) Sets the content widget forself.voidsetFullWidth(boolean fullWidth) Sets whether the bottom sheet takes the full width.voidsetModal(boolean modal) Sets whether the bottom sheet is modal.voidsetOpen(boolean open) Sets whether the bottom sheet is open.voidsetRevealBottomBar(boolean reveal) Sets whether to reveal the bottom bar.voidSets the bottom sheet widget forself.voidsetShowDragHandle(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, getLimitEvents, 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, setLimitEvents, 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, unsetStateFlagsMethods 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods inherited from interface org.gnome.gtk.Buildable
getBuildableIdMethods 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 new BottomSheet.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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
- Since:
- 1.6
-
getBottomBar
Gets the bottom bar widget forself.- Returns:
- the bottom bar widget
- Since:
- 1.6
-
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
- Since:
- 1.6
-
getCanClose
public boolean getCanClose()Gets whether the bottom sheet can be closed by user.- Returns:
- whether the sheet can be closed by user
- Since:
- 1.6
-
getCanOpen
public boolean getCanOpen()Gets whether the bottom sheet can be opened by user.- Returns:
- whether the sheet can be opened by user.
- Since:
- 1.6
-
getContent
Gets the content widget forself.- Returns:
- the content widget
- Since:
- 1.6
-
getFullWidth
public boolean getFullWidth()Gets whether the bottom sheet takes the full width.- Returns:
- whether the sheet takes up the full width
- Since:
- 1.6
-
getModal
public boolean getModal()Gets whether the bottom sheet is modal.- Returns:
- whether the sheet is modal
- Since:
- 1.6
-
getOpen
public boolean getOpen()Gets whether the bottom sheet is open.- Returns:
- whether the sheet is open
- Since:
- 1.6
-
getRevealBottomBar
public boolean getRevealBottomBar()Gets whether the bottom bar is revealed.- Returns:
- whether the bottom bar is revealed
- Since:
- 1.7
-
getSheet
Gets the bottom sheet widget forself.- Returns:
- the sheet widget
- Since:
- 1.6
-
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
- Since:
- 1.6
-
getShowDragHandle
public boolean getShowDragHandle()Gets whether to show a drag handle in the bottom sheet.- Returns:
- whether to show the drag handle
- Since:
- 1.6
-
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-widthis set toFALSE.- Parameters:
align- the new alignment- Since:
- 1.6
-
setBottomBar
Sets the bottom bar widget forself.Shown when
BottomSheet:openisFALSE. When open, morphs into theBottomSheet:sheet.Bottom bar can be temporarily hidden using the
BottomSheet:reveal-bottom-barproperty.- Parameters:
bottomBar- the bottom bar widget- Since:
- 1.6
-
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
Escapeor 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- Since:
- 1.6
-
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-baris not set.Bottom sheet can still be opened using
BottomSheet:open.- Parameters:
canOpen- whether the sheet can be opened by user.- Since:
- 1.6
-
setContent
Sets the content widget forself.It's always shown, and the bottom sheet is overlaid over it.
- Parameters:
content- the content widget- Since:
- 1.6
-
setFullWidth
public void setFullWidth(boolean fullWidth) Sets whether the bottom sheet takes the full width.When full width,
BottomSheet:alignis ignored.- Parameters:
fullWidth- whether the sheet takes up the full width- Since:
- 1.6
-
setModal
public void setModal(boolean modal) Sets whether the bottom sheet is modal.When modal,
BottomSheet:contentwill 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- Since:
- 1.6
-
setOpen
public void setOpen(boolean open) Sets whether the bottom sheet is open.- Parameters:
open- whether to open the sheet- Since:
- 1.6
-
setRevealBottomBar
public void setRevealBottomBar(boolean reveal) Sets whether to reveal the bottom bar.The transition will be animated.
See
BottomSheet:bottom-barandBottomSheet:bottom-bar-height.- Parameters:
reveal- whether to reveal the bottom bar- Since:
- 1.7
-
setSheet
Sets the bottom sheet widget forself.Only shown when
BottomSheet:openisTRUE.- Parameters:
sheet- the sheet widget- Since:
- 1.6
-
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,
HeaderBarwill hide its default title, andToolbarViewwill 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- Since:
- 1.6
-
onCloseAttempt
public SignalConnection<BottomSheet.CloseAttemptCallback> onCloseAttempt(BottomSheet.CloseAttemptCallback handler) Emitted when the close button or shortcut is used whileDialog:can-closeis set toFALSE.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- Since:
- 1.6
- See Also:
-
emitCloseAttempt
public void emitCloseAttempt()Emits the "close-attempt" signal. SeeonCloseAttempt(org.gnome.adw.BottomSheet.CloseAttemptCallback). -
builder
ABottomSheet.Builderobject constructs aBottomSheetwith the specified properties. Use the variousset...()methods to set properties, and finish construction withBottomSheet.Builder.build().- Returns:
- the builder object
-