Add line_height to pick_list::Icon
This commit is contained in:
parent
9a8b30d7e9
commit
f0c87375d5
1 changed files with 16 additions and 5 deletions
|
|
@ -360,6 +360,8 @@ pub struct Icon<Font> {
|
||||||
pub code_point: char,
|
pub code_point: char,
|
||||||
/// Font size of the content.
|
/// Font size of the content.
|
||||||
pub size: Option<f32>,
|
pub size: Option<f32>,
|
||||||
|
/// Line height of the content.
|
||||||
|
pub line_height: text::LineHeight,
|
||||||
/// The shaping strategy of the icon.
|
/// The shaping strategy of the icon.
|
||||||
pub shaping: text::Shaping,
|
pub shaping: text::Shaping,
|
||||||
}
|
}
|
||||||
|
|
@ -632,22 +634,31 @@ pub fn draw<'a, T, Renderer>(
|
||||||
Renderer::ICON_FONT,
|
Renderer::ICON_FONT,
|
||||||
Renderer::ARROW_DOWN_ICON,
|
Renderer::ARROW_DOWN_ICON,
|
||||||
*size,
|
*size,
|
||||||
|
text::LineHeight::default(),
|
||||||
text::Shaping::Basic,
|
text::Shaping::Basic,
|
||||||
)),
|
)),
|
||||||
Handle::Static(Icon {
|
Handle::Static(Icon {
|
||||||
font,
|
font,
|
||||||
code_point,
|
code_point,
|
||||||
size,
|
size,
|
||||||
|
line_height,
|
||||||
shaping,
|
shaping,
|
||||||
}) => Some((*font, *code_point, *size, *shaping)),
|
}) => Some((*font, *code_point, *size, *line_height, *shaping)),
|
||||||
Handle::Dynamic { open, closed } => {
|
Handle::Dynamic { open, closed } => {
|
||||||
if state().is_open {
|
if state().is_open {
|
||||||
Some((open.font, open.code_point, open.size, open.shaping))
|
Some((
|
||||||
|
open.font,
|
||||||
|
open.code_point,
|
||||||
|
open.size,
|
||||||
|
open.line_height,
|
||||||
|
open.shaping,
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
Some((
|
Some((
|
||||||
closed.font,
|
closed.font,
|
||||||
closed.code_point,
|
closed.code_point,
|
||||||
closed.size,
|
closed.size,
|
||||||
|
closed.line_height,
|
||||||
closed.shaping,
|
closed.shaping,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -655,19 +666,19 @@ pub fn draw<'a, T, Renderer>(
|
||||||
Handle::None => None,
|
Handle::None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((font, code_point, size, shaping)) = handle {
|
if let Some((font, code_point, size, line_height, shaping)) = handle {
|
||||||
let size = size.unwrap_or_else(|| renderer.default_size());
|
let size = size.unwrap_or_else(|| renderer.default_size());
|
||||||
|
|
||||||
renderer.fill_text(Text {
|
renderer.fill_text(Text {
|
||||||
content: &code_point.to_string(),
|
content: &code_point.to_string(),
|
||||||
size,
|
size,
|
||||||
line_height: text::LineHeight::default(),
|
line_height,
|
||||||
font,
|
font,
|
||||||
color: style.handle_color,
|
color: style.handle_color,
|
||||||
bounds: Rectangle {
|
bounds: Rectangle {
|
||||||
x: bounds.x + bounds.width - padding.horizontal(),
|
x: bounds.x + bounds.width - padding.horizontal(),
|
||||||
y: bounds.center_y(),
|
y: bounds.center_y(),
|
||||||
height: size * 1.2,
|
height: f32::from(line_height.to_absolute(Pixels(size))),
|
||||||
..bounds
|
..bounds
|
||||||
},
|
},
|
||||||
horizontal_alignment: alignment::Horizontal::Right,
|
horizontal_alignment: alignment::Horizontal::Right,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue