Clip bounds to prevent text overflow
This commit is contained in:
parent
83171f05d0
commit
6e70d9ad83
1 changed files with 18 additions and 16 deletions
|
|
@ -402,9 +402,10 @@ 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.fill_text(Text {
|
renderer.with_layer(bounds, |layer| {
|
||||||
|
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)
|
||||||
|
|
@ -418,6 +419,7 @@ pub fn draw<T, Renderer>(
|
||||||
horizontal_alignment: alignment::Horizontal::Left,
|
horizontal_alignment: alignment::Horizontal::Left,
|
||||||
vertical_alignment: alignment::Vertical::Center,
|
vertical_alignment: alignment::Vertical::Center,
|
||||||
})
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue