Skip to content

ProgressBar requires knobBefore #1951

@dermetfan

Description

@dermetfan

The documentation of ProgressBarStyle says knobBefore is optional, but not setting it/null will result in a crash because the ProgressBar does this in draw(Batch, float):

if (min != max) {
    if (knob == null) {
        knobWidthHalf = knobBefore.getMinWidth() * 0.5f; // knobBefore may be null here
        // code ...
    } else {
        // code ...
    }
    // code ...
}

if (knobBefore != null) { // if it was really null it already crashed here
    // code ...
}

Either knobBefore has to be required in which case that should be corrected in the documentation or it should really be made optional. In my humble opinion it should be optional because the Slider, a subclass of ProgressBar as you know, should not require knobBefore.

Also a side note that's not worth opening another issue:
The ProgressBarStyle copy constructor does not copy all variables but just background and knobBefore. Not sure if that's on purpose, but in my opinion this is unexpected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions