Interface SliderState


public interface SliderState
The primary interface for managing getting and setting the position of slider elements.

Created by brandon3055 on 01/09/2023

  • Method Details

    • getPos

      double getPos()
      Returns:
      the current position. (Between 0 and 1)
    • setPos

      void setPos(double pos)
      Set the current slide position, When using this method, make sure the provided value can not go outside the valid range of 0 to 1.
      Parameters:
      pos - Set the current position (Between 0 and 1)
    • sliderRatio

      default double sliderRatio()
      The slider ratio is computed by dividing the length of the slider element by the total length of the slider track. This is primarily for things like setting the size of scroll bar sliders, and calibrating scrolling via middle-click + drag.
      Returns:
      scroll ratio, viewable content size / total content size (Range 0 to 1)
    • scrollSpeed

      default double scrollSpeed()
      For controlling a slider via mouse scroll wheel. You can return a negative value to invert the scroll direction.
      Returns:
      The amount added to the position per scroll increment.
    • canScroll

      default boolean canScroll(Axis scrollAxis)
      Parameters:
      scrollAxis - The moving axis of the slider element.
      Returns:
      true if the current scroll wheel event should affect this slider.
    • create

      static SliderState create(double speed)
      Creates a basic slide state which stores its position internally. Useful for things like simple slide control elements.
    • create

      static SliderState create(double speed, @Nullable @Nullable Consumer<Double> changeListener)
      Creates a basic slide state which stores its position internally. And allows you to attach a change listener. Useful for things like simple slide control elements.
    • forScrollBar

      static SliderState forScrollBar(Supplier<Double> getPos, Consumer<Double> setPos, Supplier<Double> getRatio)
    • forSlider

      static SliderState forSlider(Supplier<Double> getPos, Consumer<Double> setPos, Supplier<Double> getSpeed)