Use Padding::horizontal and Padding::vertical helpers

This commit is contained in:
Héctor Ramón 2021-06-01 19:21:43 +07:00
parent 2e17d7860b
commit b94cd7a2a8
5 changed files with 10 additions and 14 deletions

View file

@ -119,8 +119,8 @@ impl Limits {
/// Shrinks the current [`Limits`] to account for the given padding.
pub fn pad(&self, padding: Padding) -> Limits {
self.shrink(Size::new(
(padding.left + padding.right) as f32,
(padding.top + padding.bottom) as f32,
padding.horizontal() as f32,
padding.vertical() as f32,
))
}

View file

@ -299,7 +299,7 @@ where
let size = {
let intrinsic = Size::new(
0.0,
f32::from(text_size + self.padding.top + self.padding.bottom)
f32::from(text_size + self.padding.vertical())
* self.options.len() as f32,
);
@ -364,11 +364,8 @@ where
*self.hovered_option = Some(
((cursor_position.y - bounds.y)
/ f32::from(
text_size
+ self.padding.top
+ self.padding.bottom,
)) as usize,
/ f32::from(text_size + self.padding.vertical()))
as usize,
);
if let Some(index) = *self.hovered_option {