Fix sliders drawing out of their bounds

This commit is contained in:
Héctor Ramón Jiménez 2023-04-20 15:25:37 +02:00
parent 4b05f42fd6
commit 2e9129582a
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 4 additions and 4 deletions

View file

@ -391,7 +391,7 @@ pub fn draw<T, R>(
let offset = if range_start >= range_end { let offset = if range_start >= range_end {
0.0 0.0
} else { } else {
(bounds.width - handle_width / 2.0) * (value - range_start) (bounds.width - handle_width) * (value - range_start)
/ (range_end - range_start) / (range_end - range_start)
}; };
@ -417,7 +417,7 @@ pub fn draw<T, R>(
bounds: Rectangle { bounds: Rectangle {
x: bounds.x + offset + handle_width / 2.0, x: bounds.x + offset + handle_width / 2.0,
y: rail_y - style.rail.width / 2.0, y: rail_y - style.rail.width / 2.0,
width: bounds.width - offset, width: bounds.width - offset - handle_width / 2.0,
height: style.rail.width, height: style.rail.width,
}, },
border_radius: Default::default(), border_radius: Default::default(),

View file

@ -384,7 +384,7 @@ pub fn draw<T, R>(
let offset = if range_start >= range_end { let offset = if range_start >= range_end {
0.0 0.0
} else { } else {
(bounds.height - handle_width / 2.0) * (value - range_end) (bounds.height - handle_width) * (value - range_end)
/ (range_start - range_end) / (range_start - range_end)
}; };
@ -411,7 +411,7 @@ pub fn draw<T, R>(
x: rail_x - style.rail.width / 2.0, x: rail_x - style.rail.width / 2.0,
y: bounds.y + offset + handle_width / 2.0, y: bounds.y + offset + handle_width / 2.0,
width: style.rail.width, width: style.rail.width,
height: bounds.height - offset, height: bounds.height - offset - handle_width / 2.0,
}, },
border_radius: Default::default(), border_radius: Default::default(),
border_width: 0.0, border_width: 0.0,