APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.ui

public Class Slider

extends ProgressBar
Class Inheritance
Imports
com.badlogic.gdx.Gdx, .Input.Keys, com.badlogic.gdx.graphics.g2d.NinePatch, .TextureRegion, com.badlogic.gdx.math.Interpolation, com.badlogic.gdx.scenes.scene2d.Actor, .InputEvent, .InputListener, com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent, .Drawable, com.badlogic.gdx.utils.Null

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.

ChangeEvent is 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.

Authors
mzechner, Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Slider.SliderStyle

The style for a slider, see Slider.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int
pack-priv boolean
private float[]
private float
private Interpolation
Inherited from com.badlogic.gdx.scenes.scene2d.ui.ProgressBar:
disabledmaxminpositionstepSizevertical

Constructor Summary

AccessConstructor and Description
public
Slider(float min, float max, float stepSize, boolean vertical, Skin skin)

public
Slider(float min, float max, float stepSize, boolean vertical, Skin skin, String styleName)

public
Slider(float
the minimum value
min
,
float
the maximum value
max
,
float
the step size between values
stepSize
,
boolean vertical, Slider.SliderStyle style)

Creates a new slider.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
calculatePositionAndValue(float x, float y)

protected Drawable
protected Drawable
protected Drawable
protected Drawable
public float[]
public float
public Slider.SliderStyle
public boolean
isDragging()

Returns true if the slider is being dragged.

public boolean
public void
setButton(int button)

Sets the mouse button, which can trigger a change of the slider.

public void
setSnapToValues(float threshold, float...
May be null to disable snapping.
values
)

Makes this slider snap to the specified values when the knob is within the threshold.

public void
setSnapToValues(float[]
May be null to disable snapping.
values
,
float threshold)

Makes this progress bar snap to the specified values, if the knob is within the threshold.

public void
setVisualInterpolationInverse(Interpolation interpolation)

Sets the inverse interpolation to use for display.

public void
setVisualPercent(float percent)

Sets the value using the specified visual percent.

protected float
snap(float value)

Returns a snapped value from a value calculated from the mouse position.

Inherited from com.badlogic.gdx.scenes.scene2d.ui.ProgressBar:
actclampdrawgetKnobPositiongetMaxValuegetMinValuegetPercentgetPrefHeightgetPrefWidthgetProgrammaticChangeEventsgetStepSizegetValuegetVisualPercentgetVisualValueisAnimatingisDisabledisVerticalroundsetAnimateDurationsetAnimateInterpolationsetDisabledsetProgrammaticChangeEventssetRangesetRoundsetStepSizesetStylesetValuesetVisualInterpolationupdateVisualValue

Field Detail

buttonback to summary
pack-priv int button
draggingPointerback to summary
pack-priv int draggingPointer
mouseOverback to summary
pack-priv boolean mouseOver
snapValuesback to summary
private float[] snapValues
thresholdback to summary
private float threshold
visualInterpolationInverseback to summary
private Interpolation visualInterpolationInverse

Constructor Detail

Sliderback to summary
public Slider(float min, float max, float stepSize, boolean vertical, Skin skin)
Sliderback to summary
public Slider(float min, float max, float stepSize, boolean vertical, Skin skin, String styleName)
Sliderback to summary
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 slider 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.

Parameters
min:float

the minimum value

max:float

the maximum value

stepSize:float

the step size between values

style:Slider.SliderStyle

the SliderStyle

Method Detail

calculatePositionAndValueback to summary
pack-priv boolean calculatePositionAndValue(float x, float y)
getBackgroundDrawableback to summary
protected Drawable getBackgroundDrawable()

Overrides com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.getBackgroundDrawable.

Annotations
@Null
getKnobAfterDrawableback to summary
protected Drawable getKnobAfterDrawable()

Overrides com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.getKnobAfterDrawable.

getKnobBeforeDrawableback to summary
protected Drawable getKnobBeforeDrawable()

Overrides com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.getKnobBeforeDrawable.

getKnobDrawableback to summary
protected Drawable getKnobDrawable()

Overrides com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.getKnobDrawable.

Annotations
@Null
getSnapToValuesback to summary
public float[] getSnapToValues()
Annotations
@Null
getSnapToValuesThresholdback to summary
public float getSnapToValuesThreshold()
getStyleback to summary
public Slider.SliderStyle getStyle()

Overrides com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.getStyle.

Implements com.badlogic.gdx.scenes.scene2d.ui.Styleable.getStyle.

Returns the slider's style. Modifying the returned style may not have an effect until setStyle(ProgressBarStyle) is called.

isDraggingback to summary
public boolean isDragging()

Returns true if the slider is being dragged.

isOverback to summary
public boolean isOver()
setButtonback to summary
public void setButton(int button)

Sets the mouse button, which can trigger a change of the slider. Is -1, so every button, by default.

setSnapToValuesback to summary
public void setSnapToValues(float threshold, float... values)

Makes this slider snap to the specified values when the knob is within the threshold.

Parameters
values:float[]

May be null to disable snapping.

setSnapToValuesback to summary
public void setSnapToValues(float[] values, float threshold)

Makes this progress bar snap to the specified values, if the knob is within the threshold.

Parameters
values:float[]

May be null to disable snapping.

Annotations
@Deprecated
setVisualInterpolationInverseback to summary
public void setVisualInterpolationInverse(Interpolation interpolation)

Sets the inverse interpolation to use for display. This should perform the inverse of the visual interpolation.

setVisualPercentback to summary
public void setVisualPercent(float percent)

Sets the value using the specified visual percent.

See Also
setVisualInterpolation(Interpolation)
snapback to summary
protected float snap(float value)

Returns a snapped value from a value calculated from the mouse position. The default implementation uses setSnapToValues(float, float...).

com.badlogic.gdx.scenes.scene2d.ui back to summary

public Class Slider.SliderStyle

extends ProgressBarStyle
Class Inheritance

The style for a slider, see Slider.
Authors
mzechner, Nathan Sweet

Field Summary

Modifier and TypeField and Description
public Drawable
public Drawable
public Drawable
public Drawable
public Drawable
public Drawable
public Drawable
public Drawable
Inherited from com.badlogic.gdx.scenes.scene2d.ui.ProgressBar.ProgressBarStyle:
backgrounddisabledBackgrounddisabledKnobdisabledKnobAfterdisabledKnobBeforeknobknobAfterknobBefore

Constructor Summary

AccessConstructor and Description
public
public
SliderStyle(Drawable background, Drawable knob)

public

Field Detail

backgroundDownback to summary
public Drawable backgroundDown
Annotations
@Null
backgroundOverback to summary
public Drawable backgroundOver
Annotations
@Null
knobAfterDownback to summary
public Drawable knobAfterDown
Annotations
@Null
knobAfterOverback to summary
public Drawable knobAfterOver
Annotations
@Null
knobBeforeDownback to summary
public Drawable knobBeforeDown
Annotations
@Null
knobBeforeOverback to summary
public Drawable knobBeforeOver
Annotations
@Null
knobDownback to summary
public Drawable knobDown
Annotations
@Null
knobOverback to summary
public Drawable knobOver
Annotations
@Null

Constructor Detail

SliderStyleback to summary
public SliderStyle()
SliderStyleback to summary
public SliderStyle(Drawable background, Drawable knob)
SliderStyleback to summary
public SliderStyle(Slider.SliderStyle style)