Use f32 for Padding

This commit is contained in:
Héctor Ramón Jiménez 2023-02-17 16:09:49 +01:00
parent 0872d078e2
commit 3320ac1126
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
12 changed files with 98 additions and 79 deletions

View file

@ -344,9 +344,7 @@ where
let size = {
let intrinsic = Size::new(
0.0,
text_size
+ f32::from(self.padding.vertical())
* self.options.len() as f32,
text_size + self.padding.vertical() * self.options.len() as f32,
);
limits.resolve(intrinsic)
@ -387,7 +385,7 @@ where
*self.hovered_option = Some(
((cursor_position.y - bounds.y)
/ (text_size + f32::from(self.padding.vertical())))
/ (text_size + self.padding.vertical()))
as usize,
);
}
@ -402,7 +400,7 @@ where
*self.hovered_option = Some(
((cursor_position.y - bounds.y)
/ (text_size + f32::from(self.padding.vertical())))
/ (text_size + self.padding.vertical()))
as usize,
);
@ -451,8 +449,7 @@ where
let text_size =
self.text_size.unwrap_or_else(|| renderer.default_size());
let option_height =
(text_size + f32::from(self.padding.vertical())) as usize;
let option_height = (text_size + self.padding.vertical()) as usize;
let offset = viewport.y - bounds.y;
let start = (offset / option_height as f32) as usize;
@ -469,7 +466,7 @@ where
x: bounds.x,
y: bounds.y + (option_height * i) as f32,
width: bounds.width,
height: text_size + f32::from(self.padding.vertical()),
height: text_size + self.padding.vertical(),
};
if is_selected {
@ -487,12 +484,12 @@ where
renderer.fill_text(Text {
content: &option.to_string(),
bounds: Rectangle {
x: bounds.x + self.padding.left as f32,
x: bounds.x + self.padding.left,
y: bounds.center_y(),
width: f32::INFINITY,
..bounds
},
size: f32::from(text_size),
size: text_size,
font: self.font.clone(),
color: if is_selected {
appearance.selected_text_color