public class Slider extends Widget
ChangeListener.ChangeEvent is fired when the slider knob is moved. Cancelling the event will move the knob to where it was previously.
The preferred height of a slider is determined by the larger of the knob and background. The preferred width of a slider is 140, a relatively arbitrary size.
| Modifier and Type | Class and Description |
|---|---|
static class |
Slider.SliderStyle
The style for a slider, see
Slider. |
| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
act(float delta)
Updates the actor based on time.
|
void |
draw(SpriteBatch batch,
float parentAlpha)
If this method is overridden, the super method or
Widget.validate() should be called to ensure the widget is laid out. |
float |
getMaxValue() |
float |
getMinValue() |
float |
getPrefHeight() |
float |
getPrefWidth() |
float |
getStepSize() |
Slider.SliderStyle |
getStyle()
Returns the slider's style.
|
float |
getValue() |
float |
getVisualValue()
If
animating the slider value, this returns the value current displayed. |
boolean |
isDragging()
Returns true if the slider is being dragged.
|
void |
setAnimateDuration(float duration)
If > 0, changes to the slider value via
setValue(float) will happen over this duration in seconds. |
void |
setAnimateInterpolation(Interpolation animateInterpolation)
Sets the interpolation to use for
setAnimateDuration(float). |
void |
setRange(float min,
float max)
Sets the range of this slider.
|
void |
setStepSize(float stepSize)
Sets the step size of the slider
|
void |
setStyle(Slider.SliderStyle style) |
void |
setValue(float value)
Sets the slider position, rounded to the nearest step size and clamped to the minumum and maximim values.
|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, validateaddAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, hit, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translatepublic Slider(float min,
float max,
float stepSize,
boolean vertical,
Skin skin)
public Slider(float min,
float max,
float stepSize,
boolean vertical,
Skin skin,
java.lang.String styleName)
public Slider(float min,
float max,
float stepSize,
boolean vertical,
Slider.SliderStyle style)
NinePatch or slider handle TextureRegion. 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.min - the minimum valuemax - the maximum valuestepSize - the step size between valuesstyle - the Slider.SliderStylepublic void setStyle(Slider.SliderStyle style)
public Slider.SliderStyle getStyle()
setStyle(SliderStyle) is
called.public void act(float delta)
ActorStage.act(float).
The default implementation calls Action.act(float) on each action and removes actions that are complete.
public void draw(SpriteBatch batch, float parentAlpha)
WidgetWidget.validate() should be called to ensure the widget is laid out.public boolean isDragging()
public float getValue()
public float getVisualValue()
animating the slider value, this returns the value current displayed.public void setValue(float value)
public void setRange(float min,
float max)
public void setStepSize(float stepSize)
public float getPrefWidth()
getPrefWidth in interface LayoutgetPrefWidth in class Widgetpublic float getPrefHeight()
getPrefHeight in interface LayoutgetPrefHeight in class Widgetpublic float getMinValue()
public float getMaxValue()
public float getStepSize()
public void setAnimateDuration(float duration)
setValue(float) will happen over this duration in seconds.public void setAnimateInterpolation(Interpolation animateInterpolation)
setAnimateDuration(float).