Class SwipeTracker

All Implemented Interfaces:
Orientable, Proxy

@Generated("org.javagi.JavaGI") public final class SwipeTracker extends GObject implements Orientable

A swipe tracker used in Carousel, NavigationView and OverlaySplitView.

The AdwSwipeTracker object can be used for implementing widgets with swipe gestures. It supports touch-based swipes, pointer dragging, and touchpad scrolling.

The widgets will probably want to expose the SwipeTracker:enabled property. If they expect to use horizontal orientation, SwipeTracker:reversed can be used for supporting RTL text direction.

  • Constructor Details

    • SwipeTracker

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

      public SwipeTracker(Swipeable swipeable)
      Creates a new AdwSwipeTracker for widget.
      Parameters:
      swipeable - a widget to add the tracker on
    • SwipeTracker

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

    • getType

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

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

      protected SwipeTracker 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 GObject
      Returns:
      the instance as if it were its parent type
    • getAllowLongSwipes

      public boolean getAllowLongSwipes()
      Gets whether to allow swiping for more than one snap point at a time.
      Returns:
      whether long swipes are allowed
    • getAllowMouseDrag

      public boolean getAllowMouseDrag()
      Gets whether this SwipeTracker can be dragged with mouse pointer.
      Returns:
      whether mouse dragging is allowed
    • getAllowWindowHandle

      public boolean getAllowWindowHandle()
      Gets whether to allow touchscreen swiping from GtkWindowHandle.
      Returns:
      whether swiping from window handles is allowed
      Since:
      1.5
    • getEnabled

      public boolean getEnabled()
      Gets whether this SwipeTracker is enabled.
      Returns:
      whether this SwipeTracker is enabled
    • getLowerOvershoot

      public boolean getLowerOvershoot()
      Gets whether to allow swiping past the first available snap point.
      Returns:
      whether to allow swiping past the first available snap point
      Since:
      1.4
    • getReversed

      public boolean getReversed()
      Gets whether this SwipeTracker is reversing the swipe direction.
      Returns:
      whether the direction is reversed
    • getSwipeable

      public Swipeable getSwipeable()
      Get the widget this SwipeTracker is attached to.
      Returns:
      the swipeable widget
    • getUpperOvershoot

      public boolean getUpperOvershoot()
      Gets whether to allow swiping past the last available snap point.
      Returns:
      whether to allow swiping past the last available snap point
      Since:
      1.4
    • setAllowLongSwipes

      public void setAllowLongSwipes(boolean allowLongSwipes)

      Sets whether to allow swiping for more than one snap point at a time.

      If the value is FALSE, each swipe can only move to the adjacent snap points.

      Parameters:
      allowLongSwipes - whether to allow long swipes
    • setAllowMouseDrag

      public void setAllowMouseDrag(boolean allowMouseDrag)
      Sets whether this SwipeTracker can be dragged with mouse pointer.
      Parameters:
      allowMouseDrag - whether to allow mouse dragging
    • setAllowWindowHandle

      public void setAllowWindowHandle(boolean allowWindowHandle)

      Sets whether to allow touchscreen swiping from GtkWindowHandle.

      Setting it to TRUE will make dragging the window impossible.

      Parameters:
      allowWindowHandle - whether to allow swiping from window handles
      Since:
      1.5
    • setEnabled

      public void setEnabled(boolean enabled)

      Sets whether this SwipeTracker is enabled.

      When it's not enabled, no events will be processed. Usually widgets will want to expose this via a property.

      Parameters:
      enabled - whether this SwipeTracker is enabled
    • setLowerOvershoot

      public void setLowerOvershoot(boolean overshoot)
      Sets whether to allow swiping past the first available snap point.
      Parameters:
      overshoot - whether to allow swiping past the first available snap point
      Since:
      1.4
    • setReversed

      public void setReversed(boolean reversed)

      Sets whether to reverse the swipe direction.

      If the swipe tracker is horizontal, it can be used for supporting RTL text direction.

      Parameters:
      reversed - whether to reverse the swipe direction
    • setUpperOvershoot

      public void setUpperOvershoot(boolean overshoot)
      Sets whether to allow swiping past the last available snap point.
      Parameters:
      overshoot - whether to allow swiping past the last available snap point
      Since:
      1.4
    • shiftPosition

      public void shiftPosition(double delta)

      Moves the current progress value by delta.

      This can be used to adjust the current position if snap points move during the gesture.

      Parameters:
      delta - the position delta
    • onBeginSwipe

      This signal is emitted right before a swipe will be started, after the drag threshold has been passed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitBeginSwipe

      public void emitBeginSwipe()
      Emits the "begin-swipe" signal. See onBeginSwipe(SwipeTracker.BeginSwipeCallback).
    • onEndSwipe

      This signal is emitted as soon as the gesture has stopped.

      The user is expected to animate the deceleration from the current progress value to to with an animation using velocity as the initial velocity, provided in pixels per second. SpringAnimation is usually a good fit for this.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitEndSwipe

      public void emitEndSwipe(double velocity, double to)
      Emits the "end-swipe" signal. See onEndSwipe(SwipeTracker.EndSwipeCallback).
    • onPrepare

      This signal is emitted when a possible swipe is detected.

      The direction value can be used to restrict the swipe to a certain direction.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitPrepare

      public void emitPrepare(NavigationDirection direction)
      Emits the "prepare" signal. See onPrepare(SwipeTracker.PrepareCallback).
    • onUpdateSwipe

      This signal is emitted every time the progress value changes.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitUpdateSwipe

      public void emitUpdateSwipe(double progress)
      Emits the "update-swipe" signal. See onUpdateSwipe(SwipeTracker.UpdateSwipeCallback).
    • builder

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