Use f32 for Icon::size and remove unnecessary conversions
This commit is contained in:
parent
898307e9ac
commit
0e2fc99eb8
2 changed files with 7 additions and 7 deletions
|
|
@ -583,7 +583,7 @@ impl<'a> Step {
|
|||
text_input = text_input.icon(text_input::Icon {
|
||||
font: ICON_FONT,
|
||||
code_point: '\u{e900}',
|
||||
size: Some(35),
|
||||
size: Some(35.0),
|
||||
position: text_input::IconPosition::Right,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ pub struct Icon<Font> {
|
|||
/// The unicode code point that will be used as the icon.
|
||||
pub code_point: char,
|
||||
/// Font size of the content.
|
||||
pub size: Option<u16>,
|
||||
pub size: Option<f32>,
|
||||
/// Position of the icon.
|
||||
pub position: IconPosition,
|
||||
}
|
||||
|
|
@ -886,7 +886,7 @@ pub fn draw<Renderer>(
|
|||
position,
|
||||
} = icon;
|
||||
|
||||
let padding = f32::from(padding.horizontal());
|
||||
let padding = padding.horizontal();
|
||||
let size = size.unwrap_or_else(|| renderer.default_size());
|
||||
let width = renderer.measure_width(
|
||||
&code_point.to_string(),
|
||||
|
|
@ -939,14 +939,14 @@ pub fn draw<Renderer>(
|
|||
position,
|
||||
} = icon;
|
||||
|
||||
let padding = f32::from(padding.horizontal());
|
||||
let padding = padding.horizontal();
|
||||
let size = size.unwrap_or_else(|| renderer.default_size());
|
||||
let width =
|
||||
renderer.measure_width(&code_point.to_string(), size, font.clone());
|
||||
|
||||
renderer.fill_text(Text {
|
||||
content: &code_point.to_string(),
|
||||
size: f32::from(size),
|
||||
size,
|
||||
font: font.clone(),
|
||||
color: appearance.icon_color,
|
||||
bounds: Rectangle {
|
||||
|
|
@ -954,8 +954,8 @@ pub fn draw<Renderer>(
|
|||
IconPosition::Left => bounds.x + width + padding,
|
||||
IconPosition::Right => bounds.x + bounds.width - padding,
|
||||
},
|
||||
y: bounds.center_y() - f32::from(size) / 2.0,
|
||||
height: f32::from(size),
|
||||
y: bounds.center_y() - size / 2.0,
|
||||
height: size,
|
||||
..bounds
|
||||
},
|
||||
horizontal_alignment: alignment::Horizontal::Right,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue