Improve consistency of Padding API

This commit is contained in:
Héctor Ramón Jiménez 2025-11-18 21:33:13 +01:00
parent 53110f0ede
commit 5b029ae61c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
6 changed files with 48 additions and 29 deletions

View file

@ -383,7 +383,7 @@ where
let size = {
let intrinsic = Size::new(
0.0,
(f32::from(text_line_height) + self.padding.vertical())
(f32::from(text_line_height) + self.padding.y())
* self.options.len() as f32,
);
@ -424,7 +424,7 @@ where
let option_height =
f32::from(self.text_line_height.to_absolute(text_size))
+ self.padding.vertical();
+ self.padding.y();
let new_hovered_option =
(cursor_position.y / option_height) as usize;
@ -454,7 +454,7 @@ where
let option_height =
f32::from(self.text_line_height.to_absolute(text_size))
+ self.padding.vertical();
+ self.padding.y();
*self.hovered_option =
Some((cursor_position.y / option_height) as usize);
@ -515,7 +515,7 @@ where
self.text_size.unwrap_or_else(|| renderer.default_size());
let option_height =
f32::from(self.text_line_height.to_absolute(text_size))
+ self.padding.vertical();
+ self.padding.y();
let offset = viewport.y - bounds.y;
let start = (offset / option_height) as usize;

View file

@ -665,7 +665,7 @@ where
line_height: self.text_line_height,
font,
bounds: Size::new(
bounds.width - self.padding.horizontal(),
bounds.width - self.padding.x(),
f32::from(self.text_line_height.to_absolute(text_size)),
),
align_x: text::Alignment::Default,

View file

@ -287,10 +287,7 @@ where
span.padding.top,
),
bounds.size()
+ Size::new(
span.padding.horizontal(),
span.padding.vertical(),
),
+ Size::new(span.padding.x(), span.padding.y()),
);
renderer.fill_quad(

View file

@ -654,7 +654,7 @@ where
limits
.height(min_bounds.height)
.max()
.expand(Size::new(0.0, self.padding.vertical())),
.expand(Size::new(0.0, self.padding.y())),
)
}
}