Use top alignment instead of new layer

This commit is contained in:
Cory Forsstrom 2022-04-27 08:49:55 -07:00
parent 6e70d9ad83
commit 4329f0480b

View file

@ -402,23 +402,20 @@ 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)
{ {
renderer.with_layer(bounds, |layer| { renderer.fill_text(Text {
layer.fill_text(Text { content: label,
content: label, size: f32::from(text_size.unwrap_or(renderer.default_size())),
size: f32::from(text_size.unwrap_or(layer.default_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(), ..bounds
width: f32::INFINITY, },
..bounds horizontal_alignment: alignment::Horizontal::Left,
}, vertical_alignment: alignment::Vertical::Top,
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Center,
})
}); });
} }
} }