Merge pull request #1318 from tarkah/fix/picklist-text-wrapping

Fix `PickList` text wrapping
This commit is contained in:
Héctor Ramón 2022-04-30 13:22:39 +02:00 committed by GitHub
commit abc993103f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -402,21 +402,24 @@ pub fn draw<T, Renderer>(
if let Some(label) = if let Some(label) =
label.as_ref().map(String::as_str).or_else(|| placeholder) label.as_ref().map(String::as_str).or_else(|| placeholder)
{ {
let text_size = f32::from(text_size.unwrap_or(renderer.default_size()));
renderer.fill_text(Text { renderer.fill_text(Text {
content: label, content: label,
size: f32::from(text_size.unwrap_or(renderer.default_size())), size: text_size,
font: font.clone(), font: font.clone(),
color: is_selected color: is_selected
.then(|| style.text_color) .then(|| style.text_color)
.unwrap_or(style.placeholder_color), .unwrap_or(style.placeholder_color),
bounds: Rectangle { bounds: Rectangle {
x: bounds.x + f32::from(padding.left), x: bounds.x + f32::from(padding.left),
y: bounds.center_y(), y: bounds.center_y() - text_size / 2.0,
..bounds width: bounds.width - f32::from(padding.horizontal()),
height: text_size,
}, },
horizontal_alignment: alignment::Horizontal::Left, horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center, vertical_alignment: alignment::Vertical::Top,
}) });
} }
} }