Package codechicken.lib.gui.modular.lib
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 Summary
Modifier and TypeMethodDescriptiondefault booleanstatic SliderStatecreate(double speed) Creates a basic slide state which stores its position internally.static SliderStateCreates a basic slide state which stores its position internally.static SliderStatestatic SliderStatedoublegetPos()default doubleFor controlling a slider via mouse scroll wheel.voidsetPos(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.default doubleThe slider ratio is computed by dividing the length of the slider element by the total length of the slider track.
-
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
- Parameters:
scrollAxis- The moving axis of the slider element.- Returns:
- true if the current scroll wheel event should affect this slider.
-
create
Creates a basic slide state which stores its position internally. Useful for things like simple slide control elements. -
create
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
-
forSlider
-