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

Account for empty ranges in Slider and ProgressBar #527

Merged
merged 3 commits into from
Nov 26, 2020

Conversation

rubik83
Copy link
Contributor

@rubik83 rubik83 commented Sep 15, 2020

fixes #526

rubik83 and others added 3 commits November 26, 2020 03:09
change :
let active_progress_width = bounds.width * ((value - range_start) / (range_end - range_start).max(1.0))
to :
let active_progress_width = bounds.width * ((value - range_start) / (range_end - range_start).max(f32::EPSILON)).max(0.0).min(1.0)
change :
let handle_offset = (bounds.width - handle_width) * ((value - range_start) / (range_end - range_start).max(1.0))
to :
let handle_offset = (bounds.width - handle_width) * ((value - range_start) / (range_end - range_start).max(f32::EPSILON)).max(0.0).min(1.0)
@hecrj hecrj changed the title fixes #526 Account for empty ranges in Slider and ProgressBar Nov 26, 2020
@hecrj hecrj added the bug Something isn't working label Nov 26, 2020
@hecrj hecrj added this to the 0.2.0 milestone Nov 26, 2020
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

I ended up with simply adding a check for range_start >= range_end and shortcircuiting to 0.0 in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perenthenses problem in progress bar draw formula
2 participants