Fix : take `rounding` into account when using `Slider::trailing_fill` (#4308)
Handles `rounding` when doing trailing_fill on the rail of `Slider`.
We can see this by setting the rounding to around 8.0
```
ui.visuals_mut().widgets.inactive.rounding = Rounding::same(8.0);
```
Before : There is a little bit of blue painted on the left end.

After : Fix

This commit is contained in:
parent
690c3ba883
commit
d2c4269240
|
|
@ -686,12 +686,10 @@ impl<'a> Slider<'a> {
|
|||
|
||||
let rail_radius = (spacing.slider_rail_height / 2.0).at_least(0.0);
|
||||
let rail_rect = self.rail_rect(rect, rail_radius);
|
||||
let rounding = widget_visuals.inactive.rounding;
|
||||
|
||||
ui.painter().rect_filled(
|
||||
rail_rect,
|
||||
widget_visuals.inactive.rounding,
|
||||
widget_visuals.inactive.bg_fill,
|
||||
);
|
||||
ui.painter()
|
||||
.rect_filled(rail_rect, rounding, widget_visuals.inactive.bg_fill);
|
||||
|
||||
let position_1d = self.position_from_value(value, position_range);
|
||||
let center = self.marker_center(position_1d, &rail_rect);
|
||||
|
|
@ -707,13 +705,17 @@ impl<'a> Slider<'a> {
|
|||
|
||||
// The trailing rect has to be drawn differently depending on the orientation.
|
||||
match self.orientation {
|
||||
SliderOrientation::Vertical => trailing_rail_rect.min.y = center.y,
|
||||
SliderOrientation::Horizontal => trailing_rail_rect.max.x = center.x,
|
||||
SliderOrientation::Horizontal => {
|
||||
trailing_rail_rect.max.x = center.x + rounding.nw;
|
||||
}
|
||||
SliderOrientation::Vertical => {
|
||||
trailing_rail_rect.min.y = center.y - rounding.se;
|
||||
}
|
||||
};
|
||||
|
||||
ui.painter().rect_filled(
|
||||
trailing_rail_rect,
|
||||
widget_visuals.inactive.rounding,
|
||||
rounding,
|
||||
ui.visuals().selection.bg_fill,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue