Class Carousel
- All Implemented Interfaces:
Swipeable,Accessible,Buildable,ConstraintTarget,Orientable,Proxy
The AdwCarousel widget can be used to display a set of pages with
swipe-based navigation between them.
CarouselIndicatorDots and CarouselIndicatorLines can be used
to provide page indicators for AdwCarousel.
CSS nodes
AdwCarousel has a single CSS node with name carousel.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCarousel.Builder<B extends Carousel.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classstatic interfaceFunctional interface declaration of thePageChangedCallbackcallback.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.gtk.Orientable
Orientable.Orientable$Impl, Orientable.OrientableIfaceNested classes/interfaces inherited from interface org.gnome.adw.Swipeable
Swipeable.Swipeable$Impl, Swipeable.SwipeableInterface -
Constructor Summary
ConstructorsConstructorDescriptionCarousel()Creates a new Carousel.Carousel(MemorySegment address) Create a Carousel proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppendschildtoself.protected CarouselasParent()Returns this instance as if it were its parent type.static Carousel.Builder<? extends Carousel.Builder> builder()ACarousel.Builderobject constructs aCarouselwith the specified properties.voidemitPageChanged(int index) Emits the "page-changed" signal.booleanGets whether to allow swiping for more than one page at a time.booleanSets whether this Carousel can be dragged with mouse pointer.booleanGets whether this Carousel will respond to scroll wheel events.booleanGets whether this Carousel can be navigated.intGets the number of pages inself.getNthPage(int n) Gets the page at positionn.doubleGets current scroll position inself,unitless.intGets the page reveal duration, in milliseconds.Gets the scroll animation spring parameters forself.intGets spacing between pages in pixels.static @Nullable TypegetType()Get the GType of the Carousel classvoidInsertschildinto this Carousel at positionposition.This signal is emitted after a page has been changed.voidPrependschildtoself.voidRemoveschildfromself.voidMoveschildinto positionposition.voidScrolls towidget.voidsetAllowLongSwipes(boolean allowLongSwipes) Sets whether to allow swiping for more than one page at a time.voidsetAllowMouseDrag(boolean allowMouseDrag) Sets whether this Carousel can be dragged with mouse pointer.voidsetAllowScrollWheel(boolean allowScrollWheel) Sets whether this Carousel will respond to scroll wheel events.voidsetInteractive(boolean interactive) Sets whether this Carousel can be navigated.voidsetRevealDuration(int revealDuration) Sets the page reveal duration, in milliseconds.voidsetScrollParams(SpringParams params) Sets the scroll animation spring parameters forself.voidsetSpacing(int spacing) Sets spacing between pages in pixels.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.gtk.Orientable
getOrientation, setOrientationMethods inherited from interface org.gnome.adw.Swipeable
getCancelProgress, getDistance, getProgress, getSnapPoints, getSwipeArea
-
Constructor Details
-
Carousel
Create a Carousel proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Carousel
public Carousel()Creates a new Carousel.
-
-
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. -
append
-
getAllowLongSwipes
public boolean getAllowLongSwipes()Gets whether to allow swiping for more than one page at a time.- Returns:
TRUEif long swipes are allowed
-
getAllowMouseDrag
public boolean getAllowMouseDrag()Sets whether this Carousel can be dragged with mouse pointer.- Returns:
- whether this Carousel can be dragged with mouse pointer
-
getAllowScrollWheel
public boolean getAllowScrollWheel()Gets whether this Carousel will respond to scroll wheel events.- Returns:
TRUEif this Carousel will respond to scroll wheel events
-
getInteractive
public boolean getInteractive()Gets whether this Carousel can be navigated.- Returns:
- whether this Carousel can be navigated
-
getNPages
public int getNPages()Gets the number of pages inself.- Returns:
- the number of pages in this Carousel
-
getNthPage
Gets the page at positionn.- Parameters:
n- index of the page- Returns:
- the page
-
getPosition
public double getPosition()Gets current scroll position inself,unitless.1 matches 1 page. Use
scrollTo(org.gnome.gtk.Widget, boolean)for changing it.- Returns:
- the scroll position
-
getRevealDuration
public int getRevealDuration()Gets the page reveal duration, in milliseconds.- Returns:
- the duration
-
getScrollParams
Gets the scroll animation spring parameters forself.- Returns:
- the animation parameters
-
getSpacing
public int getSpacing()Gets spacing between pages in pixels.- Returns:
- spacing between pages
-
insert
Insertschildinto this Carousel at positionposition.If position is -1, or larger than the number of pages,
childwill be appended to the end.- Parameters:
child- a widget to addposition- the position to insertchildat
-
prepend
-
remove
-
reorder
Moveschildinto positionposition.If position is -1, or larger than the number of pages,
childwill be moved at the end.- Parameters:
child- a widget to addposition- the position to movechildto
-
scrollTo
Scrolls towidget.If
animateisTRUE, the transition will be animated.- Parameters:
widget- a child of this Carouselanimate- whether to animate the transition
-
setAllowLongSwipes
public void setAllowLongSwipes(boolean allowLongSwipes) Sets whether to allow swiping for more than one page at a time.If
allowLongSwipesisFALSE, each swipe can only move to the adjacent pages.- Parameters:
allowLongSwipes- whether to allow long swipes
-
setAllowMouseDrag
public void setAllowMouseDrag(boolean allowMouseDrag) Sets whether this Carousel can be dragged with mouse pointer.If
allowMouseDragisFALSE, dragging is only available on touch.- Parameters:
allowMouseDrag- whether this Carousel can be dragged with mouse pointer
-
setAllowScrollWheel
public void setAllowScrollWheel(boolean allowScrollWheel) Sets whether this Carousel will respond to scroll wheel events.If
allowScrollWheelisFALSE, wheel events will be ignored.- Parameters:
allowScrollWheel- whether this Carousel will respond to scroll wheel events
-
setInteractive
public void setInteractive(boolean interactive) Sets whether this Carousel can be navigated.This can be used to temporarily disable the carousel to only allow navigating it in a certain state.
- Parameters:
interactive- whether this Carousel can be navigated
-
setRevealDuration
public void setRevealDuration(int revealDuration) Sets the page reveal duration, in milliseconds.Reveal duration is used when animating adding or removing pages.
- Parameters:
revealDuration- the new reveal duration value
-
setScrollParams
Sets the scroll animation spring parameters forself.The default value is equivalent to:
adw_spring_params_new (1, 0.5, 500)- Parameters:
params- the new parameters
-
setSpacing
public void setSpacing(int spacing) Sets spacing between pages in pixels.- Parameters:
spacing- the new spacing value
-
onPageChanged
public SignalConnection<Carousel.PageChangedCallback> onPageChanged(Carousel.PageChangedCallback handler) This signal is emitted after a page has been changed.It can be used to implement "infinite scrolling" by amending the pages after every scroll.
Note An empty carousel is indicated by
(int)index == -1.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPageChanged
public void emitPageChanged(int index) Emits the "page-changed" signal. SeeonPageChanged(org.gnome.adw.Carousel.PageChangedCallback). -
builder
ACarousel.Builderobject constructs aCarouselwith the specified properties. Use the variousset...()methods to set properties, and finish construction withCarousel.Builder.build().- Returns:
- the builder object
-