Package arc.scene.ui
Class Slider
java.lang.Object
arc.scene.Element
arc.scene.ui.ProgressBar
arc.scene.ui.Slider
- All Implemented Interfaces:
Disableable
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.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.
-
Nested Class Summary
Nested classes/interfaces inherited from class arc.scene.ui.ProgressBar
ProgressBar.ProgressBarStyle
-
Field Summary
Fields inherited from class arc.scene.Element
color, cullable, fillParent, height, name, originX, originY, parent, parentAlpha, rotation, scaleX, scaleY, touchable, touchablility, translation, userObject, visibility, visible, width, x, y
-
Constructor Summary
ConstructorDescriptionSlider
(float min, float max, float stepSize, boolean vertical) Slider
(float min, float max, float stepSize, boolean vertical, Slider.SliderStyle style) Creates a new slider. -
Method Summary
Modifier and TypeMethodDescriptionprotected Drawable
getStyle()
Returns the slider's style.boolean
Returns true if the slider is being dragged.void
void
setSnapToValues
(float[] values, float threshold) Will make this progress bar snap to the specified values, if the knob is within the threshold.void
setStyle
(Slider.SliderStyle style) void
setVisualInterpolationInverse
(Interp interpolation) Sets the inverse interpolation to use for display.protected float
snap
(float value) Returns a snapped value.Methods inherited from class arc.scene.ui.ProgressBar
act, clamp, draw, getKnobPosition, getMaxValue, getMinValue, getPercent, getPrefHeight, getPrefWidth, getStepSize, getValue, getVisualPercent, getVisualValue, isDisabled, isVertical, setAnimateDuration, setAnimateInterpolation, setDisabled, setRange, setRound, setStepSize, setStyle, setValue, setVisualInterpolation
Methods inherited from class arc.scene.Element
actions, addAction, addCaptureListener, addListener, change, changed, clear, clearActions, clearListeners, clicked, clicked, clicked, clicked, clipBegin, clipBegin, clipEnd, dragged, exited, fire, fireClick, getActions, getCaptureListeners, getHeight, getListeners, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getRight, getRotation, getScene, getTop, getWidth, getX, getY, getZIndex, hasActions, hasKeyboard, hasMouse, hasParent, hasScroll, hit, hovered, invalidate, invalidateHierarchy, isAscendantOf, isDescendantOf, isDescendantOf, isTouchable, keepInStage, keyDown, keyDown, layout, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, needsLayout, notify, pack, parentToLocalCoordinates, released, remove, removeAction, removeCaptureListener, removeListener, requestKeyboard, requestScroll, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, scrolled, setBounds, setColor, setColor, setFillParent, setHeight, setLayoutEnabled, setOrigin, setOrigin, setPosition, setPosition, setRotation, setRotationOrigin, setScale, setScale, setScene, setSize, setSize, setTranslation, setWidth, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, tapped, toBack, toFront, toString, touchable, update, updateVisibility, validate, visible
-
Constructor Details
-
Slider
public Slider(float min, float max, float stepSize, boolean vertical) -
Slider
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 sliderNinePatch
or 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 Details
-
getStyle
Returns the slider's style. Modifying the returned style may not have an effect untilsetStyle(SliderStyle)
is called.- Overrides:
getStyle
in classProgressBar
-
setStyle
-
getKnobDrawable
- Overrides:
getKnobDrawable
in classProgressBar
-
moved
-
snap
protected float snap(float value) Returns a snapped value. -
setSnapToValues
public void setSnapToValues(float[] values, float threshold) Will make this progress bar snap to the specified values, if the knob is within the threshold.- Parameters:
values
- May be null.
-
isDragging
public boolean isDragging()Returns true if the slider is being dragged. -
setVisualInterpolationInverse
Sets the inverse interpolation to use for display. This should perform the inverse of thevisual interpolation
.
-