Class Range

All Implemented Interfaces:
Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable, Proxy
Direct Known Subclasses:
Scale

@Generated("org.javagi.JavaGI") public class Range extends Widget implements Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable

Base class for widgets which visualize an adjustment.

Widgets that are derived from GtkRange include Scale and Scrollbar.

Apart from signals for monitoring the parameters of the adjustment, GtkRange provides properties and methods for setting a “fill level” on range widgets. See setFillLevel(double).

Shortcuts and Gestures

The GtkRange slider is draggable. Holding the Shift key while dragging, or initiating the drag with a long-press will enable the fine-tuning mode.

  • Constructor Details

    • Range

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

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

    • getType

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

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

      protected Range 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
    • getAdjustment

      public Adjustment getAdjustment()
      Get the adjustment which is the “model” object for GtkRange.
      Returns:
      a GtkAdjustment
    • getFillLevel

      public double getFillLevel()
      Gets the current position of the fill level indicator.
      Returns:
      The current fill level
    • getFlippable

      public boolean getFlippable()

      Gets whether the GtkRange respects text direction.

      See setFlippable(boolean).

      Returns:
      true if the range is flippable
    • getInverted

      public boolean getInverted()

      Gets whether the range is inverted.

      See setInverted(boolean).

      Returns:
      true if the range is inverted
    • getRangeRect

      public void getRangeRect(Rectangle rangeRect)

      This function returns the area that contains the range’s trough, in coordinates relative to range's origin.

      This function is useful mainly for GtkRange subclasses.

      Parameters:
      rangeRect - return location for the range rectangle
    • getRestrictToFillLevel

      public boolean getRestrictToFillLevel()
      Gets whether the range is restricted to the fill level.
      Returns:
      true if this Range is restricted to the fill level.
    • getRoundDigits

      public int getRoundDigits()

      Gets the number of digits to round the value to when it changes.

      See Gtk.Range::change-value.

      Returns:
      the number of digits to round to
    • getShowFillLevel

      public boolean getShowFillLevel()
      Gets whether the range displays the fill level graphically.
      Returns:
      true if this Range shows the fill level.
    • getSliderRange

      public void getSliderRange(@Nullable Out<Integer> sliderStart, @Nullable Out<Integer> sliderEnd)

      This function returns sliders range along the long dimension, in widget->window coordinates.

      This function is useful mainly for GtkRange subclasses.

      Parameters:
      sliderStart - return location for the slider's start
      sliderEnd - return location for the slider's end
    • getSliderSizeFixed

      public boolean getSliderSizeFixed()

      This function is useful mainly for GtkRange subclasses.

      See setSliderSizeFixed(boolean).

      Returns:
      whether the range’s slider has a fixed size.
    • getValue

      public double getValue()
      Gets the current value of the range.
      Returns:
      current value of the range.
    • setAdjustment

      public void setAdjustment(Adjustment adjustment)

      Sets the adjustment to be used as the “model” object for the GtkRange

      The adjustment indicates the current range value, the minimum and maximum range values, the step/page increments used for keybindings and scrolling, and the page size.

      The page size is normally 0 for GtkScale and nonzero for GtkScrollbar, and indicates the size of the visible area of the widget being scrolled. The page size affects the size of the scrollbar slider.

      Parameters:
      adjustment - a GtkAdjustment
    • setFillLevel

      public void setFillLevel(double fillLevel)

      Set the new position of the fill level indicator.

      The “fill level” is probably best described by its most prominent use case, which is an indicator for the amount of pre-buffering in a streaming media player. In that use case, the value of the range would indicate the current play position, and the fill level would be the position up to which the file/stream has been downloaded.

      This amount of prebuffering can be displayed on the range’s trough and is themeable separately from the trough. To enable fill level display, use setShowFillLevel(boolean). The range defaults to not showing the fill level.

      Additionally, it’s possible to restrict the range’s slider position to values which are smaller than the fill level. This is controlled by setRestrictToFillLevel(boolean) and is by default enabled.

      Parameters:
      fillLevel - the new position of the fill level indicator
    • setFlippable

      public void setFlippable(boolean flippable)

      Sets whether the GtkRange respects text direction.

      If a range is flippable, it will switch its direction if it is horizontal and its direction is TextDirection.RTL.

      See Widget.getDirection().

      Parameters:
      flippable - true to make the range flippable
    • setIncrements

      public void setIncrements(double step, double page)

      Sets the step and page sizes for the range.

      The step size is used when the user clicks the GtkScrollbar arrows or moves a GtkScale via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.

      Parameters:
      step - step size
      page - page size
    • setInverted

      public void setInverted(boolean setting)

      Sets whether to invert the range.

      Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.

      Parameters:
      setting - true to invert the range
    • setRange

      public void setRange(double min, double max)

      Sets the allowable values in the GtkRange.

      The range value is clamped to be between min and max. (If the range has a non-zero page size, it is clamped between min and max - page-size.)

      Parameters:
      min - minimum range value
      max - maximum range value
    • setRestrictToFillLevel

      public void setRestrictToFillLevel(boolean restrictToFillLevel)

      Sets whether the slider is restricted to the fill level.

      See setFillLevel(double) for a general description of the fill level concept.

      Parameters:
      restrictToFillLevel - Whether the fill level restricts slider movement.
    • setRoundDigits

      public void setRoundDigits(int roundDigits)

      Sets the number of digits to round the value to when it changes.

      See Gtk.Range::change-value.

      Parameters:
      roundDigits - the precision in digits, or -1
    • setShowFillLevel

      public void setShowFillLevel(boolean showFillLevel)

      Sets whether a graphical fill level is show on the trough.

      See setFillLevel(double) for a general description of the fill level concept.

      Parameters:
      showFillLevel - Whether a fill level indicator graphics is shown.
    • setSliderSizeFixed

      public void setSliderSizeFixed(boolean sizeFixed)

      Sets whether the range’s slider has a fixed size, or a size that depends on its adjustment’s page size.

      This function is useful mainly for GtkRange subclasses.

      Parameters:
      sizeFixed - true to make the slider size constant
    • setValue

      public void setValue(double value)

      Sets the current value of the range.

      If the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the Gtk.Range::value-changed signal if the value changes.

      Parameters:
      value - new value of the range
    • adjustBounds

      protected void adjustBounds(double newValue)
    • changeValue

      protected boolean changeValue(ScrollType scroll, double newValue)
    • getRangeBorder

      protected void getRangeBorder(Border border)
    • moveSlider

      protected void moveSlider(ScrollType scroll)
    • valueChanged

      protected void valueChanged()
    • onAdjustBounds

      Emitted before clamping a value, to give the application a chance to adjust the bounds.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitAdjustBounds

      public void emitAdjustBounds(double value)
      Emits the "adjust-bounds" signal. See onAdjustBounds(Range.AdjustBoundsCallback).
    • onChangeValue

      Emitted when a scroll action is performed on a range.

      It allows an application to determine the type of scroll event that occurred and the resultant new value. The application can handle the event itself and return true to prevent further processing. Or, by returning false, it can pass the event to other handlers until the default GTK handler is reached.

      The value parameter is unrounded. An application that overrides the ::change-value signal is responsible for clamping the value to the desired number of decimal digits; the default GTK handler clamps the value based on Gtk.Range:round-digits.

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

      public boolean emitChangeValue(ScrollType scroll, double value)
      Emits the "change-value" signal. See onChangeValue(Range.ChangeValueCallback).
    • onMoveSlider

      Virtual function that moves the slider.

      Used for keybindings.

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

      public void emitMoveSlider(ScrollType step)
      Emits the "move-slider" signal. See onMoveSlider(Range.MoveSliderCallback).
    • onValueChanged

      Emitted when the range value changes.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitValueChanged

      public void emitValueChanged()
      Emits the "value-changed" signal. See onValueChanged(Range.ValueChangedCallback).
    • builder

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