Class Carousel

All Implemented Interfaces:
Swipeable, Accessible, Buildable, ConstraintTarget, Orientable, Proxy

@Generated("org.javagi.JavaGI") public final class Carousel extends Widget implements Swipeable, Accessible, Buildable, ConstraintTarget, Orientable

A paginated scrolling widget.

carousel

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.

  • Constructor Details

    • Carousel

      public Carousel(MemorySegment address)
      Create a Carousel instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Carousel

      public Carousel()
      Create a new Carousel.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Carousel class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Carousel asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • append

      public void append(Widget child)
      Appends child to self.
      Parameters:
      child - a widget to add
    • getAllowLongSwipes

      public boolean getAllowLongSwipes()
      Gets whether to allow swiping for more than one page at a time.
      Returns:
      TRUE if 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:
      TRUE if 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 in self.
      Returns:
      the number of pages in this Carousel
    • getNthPage

      public Widget getNthPage(int n)
      Gets the page at position n.
      Parameters:
      n - index of the page
      Returns:
      the page
    • getPosition

      public double getPosition()

      Gets current scroll position in self, unitless.

      1 matches 1 page. Use scrollTo(Widget, boolean) for changing it.

      Returns:
      the scroll position
    • getRevealDuration

      public int getRevealDuration()
      Gets the page reveal duration, in milliseconds.
      Returns:
      the duration
    • getScrollParams

      public SpringParams getScrollParams()
      Gets the scroll animation spring parameters for self.
      Returns:
      the animation parameters
    • getSpacing

      public int getSpacing()
      Gets spacing between pages in pixels.
      Returns:
      spacing between pages
    • insert

      public void insert(Widget child, int position)

      Inserts child into this Carousel at position position.

      If position is -1, or larger than the number of pages, child will be appended to the end.

      Parameters:
      child - a widget to add
      position - the position to insert child at
    • prepend

      public void prepend(Widget child)
      Prepends child to self.
      Parameters:
      child - a widget to add
    • remove

      public void remove(Widget child)
      Removes child from self.
      Parameters:
      child - a widget to remove
    • reorder

      public void reorder(Widget child, int position)

      Moves child into position position.

      If position is -1, or larger than the number of pages, child will be moved at the end.

      Parameters:
      child - a widget to add
      position - the position to move child to
    • scrollTo

      public void scrollTo(Widget widget, boolean animate)

      Scrolls to widget.

      If animate is TRUE, the transition will be animated.

      Parameters:
      widget - a child of this Carousel
      animate - 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 allowLongSwipes is FALSE, 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 allowMouseDrag is FALSE, 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 allowScrollWheel is FALSE, 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

      public void setScrollParams(SpringParams params)

      Sets the scroll animation spring parameters for self.

      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

      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. See onPageChanged(Carousel.PageChangedCallback).
    • builder

      public static Carousel.Builder<? extends Carousel.Builder> builder()
      A Carousel.Builder object constructs a Carousel with the specified properties. Use the various set...() methods to set properties, and finish construction with Carousel.Builder.build().
      Returns:
      the builder object