Class Slider
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.Actor
-
- com.badlogic.gdx.scenes.scene2d.ui.Widget
-
- com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
-
- com.badlogic.gdx.scenes.scene2d.ui.Slider
-
- All Implemented Interfaces:
Disableable,Layout
public class Slider extends ProgressBar
A slider is a horizontal indicator that allows a user to set a value. The slider has a range (min, max) and a stepping between each value the slider represents.ChangeListener.ChangeEventis fired when the slider knob is moved. Canceling the event will move the knob to where it was previously.For a horizontal progress bar, its preferred height is determined by the larger of the knob and background, and the preferred width is 140, a relatively arbitrary size. These parameters are reversed for a vertical progress bar.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSlider.SliderStyleThe style for a slider, seeSlider.-
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
ProgressBar.ProgressBarStyle
-
-
Constructor Summary
Constructors Constructor Description Slider(float min, float max, float stepSize, boolean vertical, Skin skin)Slider(float min, float max, float stepSize, boolean vertical, Skin skin, java.lang.String styleName)Slider(float min, float max, float stepSize, boolean vertical, Slider.SliderStyle style)Creates a new slider.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected DrawablegetBackgroundDrawable()protected DrawablegetKnobAfterDrawable()protected DrawablegetKnobBeforeDrawable()protected DrawablegetKnobDrawable()float[]getSnapToValues()floatgetSnapToValuesThreshold()Slider.SliderStylegetStyle()Returns the slider's style.booleanisDragging()Returns true if the slider is being dragged.booleanisOver()voidsetButton(int button)Sets the mouse button, which can trigger a change of the slider.voidsetSnapToValues(float[] values, float threshold)Deprecated.voidsetSnapToValues(float threshold, float... values)Makes this slider snap to the specified values when the knob is within the threshold.voidsetVisualInterpolationInverse(Interpolation interpolation)Sets the inverse interpolation to use for display.voidsetVisualPercent(float percent)Sets the value using the specified visual percent.protected floatsnap(float value)Returns a snapped value from a value calculated from the mouse position.-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.ProgressBar
act, clamp, draw, getKnobPosition, getMaxValue, getMinValue, getPercent, getPrefHeight, getPrefWidth, getStepSize, getValue, getVisualPercent, getVisualValue, isAnimating, isDisabled, isVertical, round, setAnimateDuration, setAnimateInterpolation, setDisabled, setProgrammaticChangeEvents, setRange, setRound, setStepSize, setStyle, setValue, setVisualInterpolation, updateVisualValue
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
-
-
-
-
Constructor Detail
-
Slider
public Slider(float min, float max, float stepSize, boolean vertical, Skin skin)
-
Slider
public Slider(float min, float max, float stepSize, boolean vertical, Skin skin, java.lang.String styleName)
-
Slider
public Slider(float min, float max, float stepSize, boolean vertical, Slider.SliderStyle style)Creates a new slider. If horizontal, its width is determined by the prefWidth parameter, its height is determined by the maximum of the height of either the sliderNinePatchor slider handleTextureRegion. The min and max values determine the range the values of this slider can take on, the stepSize parameter specifies the distance between individual values. E.g. min could be 4, max could be 10 and stepSize could be 0.2, giving you a total of 30 values, 4.0 4.2, 4.4 and so on.- Parameters:
min- the minimum valuemax- the maximum valuestepSize- the step size between valuesstyle- theSlider.SliderStyle
-
-
Method Detail
-
getStyle
public Slider.SliderStyle getStyle()
Returns the slider's style. Modifying the returned style may not have an effect untilProgressBar.setStyle(ProgressBarStyle)is called.- Overrides:
getStylein classProgressBar
-
isOver
public boolean isOver()
-
getBackgroundDrawable
@Null protected Drawable getBackgroundDrawable()
- Overrides:
getBackgroundDrawablein classProgressBar
-
getKnobDrawable
@Null protected Drawable getKnobDrawable()
- Overrides:
getKnobDrawablein classProgressBar
-
getKnobBeforeDrawable
protected Drawable getKnobBeforeDrawable()
- Overrides:
getKnobBeforeDrawablein classProgressBar
-
getKnobAfterDrawable
protected Drawable getKnobAfterDrawable()
- Overrides:
getKnobAfterDrawablein classProgressBar
-
snap
protected float snap(float value)
Returns a snapped value from a value calculated from the mouse position. The default implementation usessetSnapToValues(float, float...).
-
setSnapToValues
public void setSnapToValues(float threshold, @Null float... values)Makes this slider snap to the specified values when the knob is within the threshold.- Parameters:
values- May be null to disable snapping.
-
setSnapToValues
@Deprecated public void setSnapToValues(@Null float[] values, float threshold)
Deprecated.Makes this progress bar snap to the specified values, if the knob is within the threshold.- Parameters:
values- May be null to disable snapping.
-
getSnapToValues
@Null public float[] getSnapToValues()
-
getSnapToValuesThreshold
public float getSnapToValuesThreshold()
-
isDragging
public boolean isDragging()
Returns true if the slider is being dragged.
-
setButton
public void setButton(int button)
Sets the mouse button, which can trigger a change of the slider. Is -1, so every button, by default.
-
setVisualInterpolationInverse
public void setVisualInterpolationInverse(Interpolation interpolation)
Sets the inverse interpolation to use for display. This should perform the inverse of thevisual interpolation.
-
setVisualPercent
public void setVisualPercent(float percent)
Sets the value using the specified visual percent.
-
-