Skip to content

Account for empty ranges in Slider and ProgressBar#527

Merged
hecrj merged 3 commits into
iced-rs:masterfrom
rubik83:master
Nov 26, 2020
Merged

Account for empty ranges in Slider and ProgressBar#527
hecrj merged 3 commits into
iced-rs:masterfrom
rubik83:master

Conversation

@rubik83
Copy link
Copy Markdown
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
Copy Markdown
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