Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProgressBar requires knobBefore #1951

Closed
dermetfan opened this issue Jun 10, 2014 · 1 comment
Closed

ProgressBar requires knobBefore #1951

dermetfan opened this issue Jun 10, 2014 · 1 comment

Comments

@dermetfan
Copy link
Contributor

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.

@cortobass
Copy link
Contributor

If Knob is null and KnobBefore is also null, then there's nothing to display. Hence the code above. One of them has to be not null.
When I fixed the issue with KnobBefore and provided this code, I didn't care of the documentation and code of ProgressBarStyle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants