Package ch.bailu.gtk.adw
Class Leaflet
- All Implemented Interfaces:
PointerInterface
An adaptive container acting like a box or a stack.
<picture>
<source srcset="leaflet-wide-dark.png" media="(prefers-color-scheme: dark)">
<img src="leaflet-wide.png" alt="leaflet-wide">
</picture>
<picture>
<source srcset="leaflet-narrow-dark.png" media="(prefers-color-scheme: dark)">
<img src="leaflet-narrow.png" alt="leaflet-narrow">
</picture>
The `AdwLeaflet` widget can display its children like a [class@Gtk.Box] does
or like a [class@Gtk.Stack] does, adapting to size changes by switching
between the two modes.
When there is enough space the children are displayed side by side, otherwise
only one is displayed and the leaflet is said to be “folded”.
The threshold is dictated by the preferred minimum sizes of the children.
When a leaflet is folded, the children can be navigated using swipe gestures.
The “over” and “under” transition types stack the children one on top of the
other, while the “slide” transition puts the children side by side. While
navigating to a child on the side or below can be performed by swiping the
current child away, navigating to an upper child requires dragging it from
the edge where it resides. This doesn't affect non-dragging swipes.
## CSS nodes
`AdwLeaflet` has a single CSS node with name `leaflet`. The node will get the
style classes `.folded` when it is folded, `.unfolded` when it's not, or none
if it hasn't computed its fold yet.
<picture>
<source srcset="leaflet-wide-dark.png" media="(prefers-color-scheme: dark)">
<img src="leaflet-wide.png" alt="leaflet-wide">
</picture>
<picture>
<source srcset="leaflet-narrow-dark.png" media="(prefers-color-scheme: dark)">
<img src="leaflet-narrow.png" alt="leaflet-narrow">
</picture>
The `AdwLeaflet` widget can display its children like a [class@Gtk.Box] does
or like a [class@Gtk.Stack] does, adapting to size changes by switching
between the two modes.
When there is enough space the children are displayed side by side, otherwise
only one is displayed and the leaflet is said to be “folded”.
The threshold is dictated by the preferred minimum sizes of the children.
When a leaflet is folded, the children can be navigated using swipe gestures.
The “over” and “under” transition types stack the children one on top of the
other, while the “slide” transition puts the children side by side. While
navigating to a child on the side or below can be performed by swiping the
current child away, navigating to an upper child requires dragging it from
the edge where it resides. This doesn't affect non-dragging swipes.
## CSS nodes
`AdwLeaflet` has a single CSS node with name `leaflet`. The node will get the
style classes `.folded` when it is folded, `.unfolded` when it's not, or none
if it hasn't computed its fold yet.
https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Leaflet.html
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a child to @self.Implements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.Implements interfaceOrientable
.Implements interfaceSwipeable
.getAdjacentChild
(int direction) Finds the previous or next navigatable child.boolean
Gets whether gestures and shortcuts for navigating backward are enabled.boolean
Gets whether gestures and shortcuts for navigating forward are enabled.boolean
Gets whether @self can unfold.getChildByName
(Str name) Finds the child of @self with @name.getChildByName
(String name) Finds the child of @self with @name.Gets the child transition spring parameters for @self.boolean
Gets whether a child transition is currently running for @self.static ClassHandler
boolean
Gets whether @self is folded.int
Gets the fold threshold policy for @self.boolean
Gets whether @self is homogeneous.static int
int
Gets the mode transition animation duration for @self.Returns the [class@LeafletPage] object for @child.getPages()
Returns a [iface@Gio.ListModel] that contains the pages of the leaflet.static long
static TypeSystem.TypeSize
int
Gets the type of animation used for transitions between modes and children.static long
static TypeSystem.TypeSize
Gets the widget currently visible when the leaflet is folded.Gets the name of the currently visible child widget.insertChildAfter
(Widget child, Widget sibling) Inserts @child in the position after @sibling in the list of children.boolean
navigate
(int direction) Navigates to the previous or next child.Inserts @child at the first position in @self.void
Removes a child widget from @self.void
reorderChildAfter
(Widget child, Widget sibling) Moves @child to the position after @sibling in the list of children.void
setCanNavigateBack
(boolean can_navigate_back) Sets whether gestures and shortcuts for navigating backward are enabled.void
setCanNavigateForward
(boolean can_navigate_forward) Sets whether gestures and shortcuts for navigating forward are enabled.void
setCanUnfold
(boolean can_unfold) Sets whether @self can unfold.void
setChildTransitionParams
(SpringParams params) Sets the child transition spring parameters for @self.void
setFoldThresholdPolicy
(int policy) Sets the fold threshold policy for @self.void
setHomogeneous
(boolean homogeneous) Sets @self to be homogeneous or not.void
setModeTransitionDuration
(int duration) Sets the mode transition animation duration for @self.void
setTransitionType
(int transition) Sets the type of animation used for transitions between modes and children.void
setVisibleChild
(Widget visible_child) Sets the widget currently visible when the leaflet is folded.void
setVisibleChildName
(Str name) Makes the child with the name @name visible.void
setVisibleChildName
(String name) Makes the child with the name @name visible.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, 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, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Leaflet
-
Leaflet
public Leaflet()Creates a new `AdwLeaflet`.
-
-
Method Details
-
getClassHandler
-
append
Adds a child to @self.- Parameters:
child
- the widget to add- Returns:
- the [class@LeafletPage] for @child
-
getAdjacentChild
Finds the previous or next navigatable child.
This will be the same child [method@Leaflet.navigate] or swipe gestures will
navigate to.
If there's no child to navigate to, `NULL` will be returned instead.
See [property@LeafletPage:navigatable].- Parameters:
direction
- the direction- Returns:
- the previous or next child
-
getCanUnfold
public boolean getCanUnfold()Gets whether @self can unfold.- Returns:
- whether @self can unfold
-
getChildByName
Finds the child of @self with @name.
Returns `NULL` if there is no child with this name.
See [property@LeafletPage:name].- Parameters:
name
- the name of the child to find- Returns:
- the requested child of @self
-
getChildByName
Finds the child of @self with @name.
Returns `NULL` if there is no child with this name.
See [property@LeafletPage:name].- Parameters:
name
- the name of the child to find- Returns:
- the requested child of @self
-
getChildTransitionParams
Gets the child transition spring parameters for @self.- Returns:
- the child transition parameters
-
getChildTransitionRunning
public boolean getChildTransitionRunning()Gets whether a child transition is currently running for @self.- Returns:
- whether a transition is currently running
-
getFoldThresholdPolicy
public int getFoldThresholdPolicy()Gets the fold threshold policy for @self.- Returns:
-
getFolded
public boolean getFolded()Gets whether @self is folded.
The leaflet will be folded if the size allocated to it is smaller than the
sum of the minimum or natural sizes of the children (see
[property@Leaflet:fold-threshold-policy]), it will be unfolded otherwise.- Returns:
- whether @self is folded.
-
getHomogeneous
public boolean getHomogeneous()Gets whether @self is homogeneous.- Returns:
- whether @self is homogeneous
-
getModeTransitionDuration
public int getModeTransitionDuration()Gets the mode transition animation duration for @self.- Returns:
- the mode transition duration, in milliseconds.
-
getPage
Returns the [class@LeafletPage] object for @child.- Parameters:
child
- a child of @self- Returns:
- the page object for @child
-
getPages
Returns a [iface@Gio.ListModel] that contains the pages of the leaflet.
This can be used to keep an up-to-date view. The model also implements
[iface@Gtk.SelectionModel] and can be used to track and change the visible
page.- Returns:
- a `GtkSelectionModel` for the leaflet's children
-
getTransitionType
public int getTransitionType()Gets the type of animation used for transitions between modes and children.- Returns:
- the current transition type of @self
-
getVisibleChild
Gets the widget currently visible when the leaflet is folded.- Returns:
- the visible child
-
getVisibleChildName
Gets the name of the currently visible child widget.- Returns:
- the name of the visible child
-
insertChildAfter
Inserts @child in the position after @sibling in the list of children.
If @sibling is `NULL`, inserts @child at the first position.- Parameters:
child
- the widget to insertsibling
- the sibling after which to insert @child- Returns:
- the [class@LeafletPage] for @child
-
prepend
Inserts @child at the first position in @self.- Parameters:
child
- the widget to prepend- Returns:
- the [class@LeafletPage] for @child
-
remove
Removes a child widget from @self.- Parameters:
child
- the child to remove
-
reorderChildAfter
Moves @child to the position after @sibling in the list of children.
If @sibling is `NULL`, moves @child to the first position.- Parameters:
child
- the widget to move, must be a child of @selfsibling
- the sibling to move @child after
-
setCanUnfold
public void setCanUnfold(boolean can_unfold) Sets whether @self can unfold.- Parameters:
can_unfold
- whether @self can unfold
-
setChildTransitionParams
Sets the child transition spring parameters for @self.
The default value is equivalent to:
```c
adw_spring_params_new (1, 0.5, 500)
```- Parameters:
params
- the new parameters
-
setFoldThresholdPolicy
public void setFoldThresholdPolicy(int policy) Sets the fold threshold policy for @self.
If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, it 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
-
setHomogeneous
public void setHomogeneous(boolean homogeneous) Sets @self to be homogeneous or not.
If set to `FALSE`, different children can have different size along the
opposite orientation.- Parameters:
homogeneous
- whether to make @self homogeneous
-
setModeTransitionDuration
public void setModeTransitionDuration(int duration) Sets the mode transition animation duration for @self.- Parameters:
duration
- the new duration, in milliseconds
-
setTransitionType
public void setTransitionType(int transition) Sets the type of animation used for transitions between modes and children.
The transition type can be changed without problems at runtime, so it is
possible to change the animation based on the mode or child that is about to
become current.- Parameters:
transition
- the new transition type
-
setVisibleChild
Sets the widget currently visible when the leaflet is folded.
The transition is determined by [property@Leaflet:transition-type] and
[property@Leaflet:child-transition-params]. The transition can be cancelled
by the user, in which case visible child will change back to the previously
visible child.- Parameters:
visible_child
- the new child
-
setVisibleChildName
Makes the child with the name @name visible.
See [property@Leaflet:visible-child].- Parameters:
name
- the name of a child
-
setVisibleChildName
Makes the child with the name @name visible.
See [property@Leaflet:visible-child].- Parameters:
name
- the name of a child
-
asSwipeable
Implements interfaceSwipeable
. Call this to get access to interface functions.- Returns:
Swipeable
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
asOrientable
Implements interfaceOrientable
. Call this to get access to interface functions.- Returns:
Orientable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-