-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add option to customize progress bar rounding #2881
Conversation
To test, add e.g., egui/crates/egui_demo_lib/src/demo/widget_gallery.rs Lines 196 to 198 in eb0812a
Should I add this somewhere in the demo? |
e58d3d8
to
67fa8a9
Compare
I'm thinking that instead of setting an explicit rounding value, it could instead be a boolean that makes it use the same rounding as the other widgets, like buttons and textboxes, so it is easier to keep the UI consistent. Does that make sense? I also have to fix some visual bugs at low fill percentages before this is ready to merge. Edit: actually, the way it is currently might be better, as you can just set the rounding to one of the ui settings if you want, e.g., |
67fa8a9
to
1d96e20
Compare
1b3c235
to
fc25439
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice with a image or gif for this!
fc25439
to
c0f9a6a
Compare
Screencast.from.2023-11-10.23-25-49.webm |
outer_rect.height(), | ||
), | ||
); | ||
let min_width = 2.0 * rounding.sw.at_least(rounding.nw).at_most(corner_radius); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why only look at sw
and nw
here? Wouldn't it make sense to use something like rounding.max()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this min_width
is meant to make the rounding look right when the progress bar is empty, I figured only the left side mattered. But maybe it would be better to just use max()
. I'll do a quick test and commit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is no method Rounding::max
currently. Should I add one?
It doesn't seem to be necessary, though. The problem this min_width avoids is that the filled rect is flattened when it is too small, and then it ends up appearing outside the background rect, like this:
Actually, if there was a way to avoid this overflow without setting a minimum width, I think a lot of people would prefer that (see for example #3999). But I don't know if it's possible.
The minimum filled width is adapted to the radius and the animation is disabled so it renders correctly.
To match what it was before and make the animation look right.
Co-authored-by: Emil Ernerfeldt <[email protected]>
d996ff5
to
f121944
Compare
The minimum filled width is adapted to the radius and the animation is disabled so it renders correctly.