public class ProgressBar extends Widget implements Disableable
ChangeListener.ChangeEvent
is fired when the progress bar knob is moved. Cancelling 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.
Modifier and Type | Class and Description |
---|---|
static class |
ProgressBar.ProgressBarStyle
The style for a progress bar, see
ProgressBar . |
Constructor and Description |
---|
ProgressBar(float min,
float max,
float stepSize,
boolean vertical,
ProgressBar.ProgressBarStyle style)
Creates a new progress bar.
|
ProgressBar(float min,
float max,
float stepSize,
boolean vertical,
Skin skin) |
ProgressBar(float min,
float max,
float stepSize,
boolean vertical,
Skin skin,
String styleName) |
Modifier and Type | Method and Description |
---|---|
void |
act(float delta)
Updates the actor based on time.
|
void |
draw(Batch 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 |
getPercent() |
float |
getPrefHeight() |
float |
getPrefWidth() |
float |
getStepSize() |
ProgressBar.ProgressBarStyle |
getStyle()
Returns the progress bar's style.
|
float |
getValue() |
float |
getVisualPercent() |
float |
getVisualValue()
If
animating the progress bar value, this returns the value current displayed. |
boolean |
isAnimating() |
boolean |
isDisabled() |
boolean |
isVertical()
True if the progress bar is vertical, false if it is horizontal.
|
void |
setAnimateDuration(float duration)
If > 0, changes to the progress bar value via
setValue(float) will happen over this duration in seconds. |
void |
setAnimateInterpolation(Interpolation animateInterpolation)
Sets the interpolation to use for
setAnimateDuration(float) . |
void |
setDisabled(boolean disabled) |
void |
setProgrammaticChangeEvents(boolean programmaticChangeEvents)
If false,
setValue(float) will not fire ChangeListener.ChangeEvent . |
void |
setRange(float min,
float max)
Sets the range of this progress bar.
|
void |
setRound(boolean round)
If true (the default), inner Drawable positions and sizes are rounded to integers.
|
void |
setStepSize(float stepSize) |
void |
setStyle(ProgressBar.ProgressBarStyle style) |
boolean |
setValue(float value)
Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values.
|
void |
setVisualInterpolation(Interpolation interpolation)
Sets the interpolation to use for display.
|
void |
updateVisualValue()
Sets the visual value equal to the actual value.
|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, validate
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, 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, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
public ProgressBar(float min, float max, float stepSize, boolean vertical, Skin skin)
public ProgressBar(float min, float max, float stepSize, boolean vertical, Skin skin, String styleName)
public ProgressBar(float min, float max, float stepSize, boolean vertical, ProgressBar.ProgressBarStyle style)
NinePatch
or progress bar handle TextureRegion
. The
min and max values determine the range the values of this progress bar 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 ProgressBar.ProgressBarStyle
public void setStyle(ProgressBar.ProgressBarStyle style)
public ProgressBar.ProgressBarStyle getStyle()
setStyle(ProgressBarStyle)
is called.public void act(float delta)
Actor
Stage.act(float)
.
The default implementation calls Action.act(float)
on each action and removes actions that are complete.
public void draw(Batch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.public float getValue()
public float getVisualValue()
animating
the progress bar value, this returns the value current displayed.public void updateVisualValue()
public float getPercent()
public float getVisualPercent()
public boolean setValue(float value)
clamp(float)
can be overridden to allow values outside of the progress bar's min/max range.public void setRange(float min, float max)
public void setStepSize(float stepSize)
public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public 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)
.public void setVisualInterpolation(Interpolation interpolation)
public void setRound(boolean round)
public void setDisabled(boolean disabled)
setDisabled
in interface Disableable
public boolean isAnimating()
public boolean isDisabled()
isDisabled
in interface Disableable
public boolean isVertical()
public void setProgrammaticChangeEvents(boolean programmaticChangeEvents)
setValue(float)
will not fire ChangeListener.ChangeEvent
. The event will only be fired when the user changes
the slider.Copyright © 2021. All rights reserved.