Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions arc-core/src/arc/scene/ui/ProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ protected float getKnobPosition(){

/**
* Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values.
* {@link #clamp(float)} can be overridden to allow values outside of the progress bar's min/max range.
* @return false if the value was not changed because the progress bar already had the value or it was canceled by a
* listener.
*/
public boolean setValue(float value){
value = clamp(Math.round(value / stepSize) * stepSize);
public boolean setValue(float value, boolean clampValue){
float val = Math.round(value / stepSize) * stepSize;
value = clampValue ? clamp(val) : val;
float oldValue = this.value;
if(value == oldValue) return false;
float oldVisualValue = getVisualValue();
Expand All @@ -255,10 +255,13 @@ else if(animateDuration > 0){
Pools.free(changeEvent);
return !cancelled;
}

public boolean setValue(float value){
return setValue(value, true);
}

/**
* Clamps the value to the progress bar's min/max range. This can be overridden to allow a range different from the progress
* bar knob's range.
* Clamps the value to the progress bar's min/max range.
*/
protected float clamp(float value){
return Mathf.clamp(value, min, max);
Expand Down