summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2022-04-25 09:01:04 -0700
committerLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2022-04-25 09:01:04 -0700
commit6e70d9ad83432b45e6bcfd022ba31e192ad99669 (patch)
tree29b5cefdbeb55dfbf514ab643cecd062a077c925 /native
parent83171f05d0111808ebafda309222e45062d3a0b0 (diff)
downloadiced-6e70d9ad83432b45e6bcfd022ba31e192ad99669.tar.gz
iced-6e70d9ad83432b45e6bcfd022ba31e192ad99669.tar.bz2
iced-6e70d9ad83432b45e6bcfd022ba31e192ad99669.zip
Clip bounds to prevent text overflow
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/pick_list.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs
index 998b9b3c..4f00c96e 100644
--- a/native/src/widget/pick_list.rs
+++ b/native/src/widget/pick_list.rs
@@ -402,22 +402,24 @@ pub fn draw<T, Renderer>(
if let Some(label) =
label.as_ref().map(String::as_str).or_else(|| placeholder)
{
- renderer.fill_text(Text {
- content: label,
- size: f32::from(text_size.unwrap_or(renderer.default_size())),
- font: font.clone(),
- color: is_selected
- .then(|| style.text_color)
- .unwrap_or(style.placeholder_color),
- bounds: Rectangle {
- x: bounds.x + f32::from(padding.left),
- y: bounds.center_y(),
- width: f32::INFINITY,
- ..bounds
- },
- horizontal_alignment: alignment::Horizontal::Left,
- vertical_alignment: alignment::Vertical::Center,
- })
+ renderer.with_layer(bounds, |layer| {
+ layer.fill_text(Text {
+ content: label,
+ size: f32::from(text_size.unwrap_or(layer.default_size())),
+ font: font.clone(),
+ color: is_selected
+ .then(|| style.text_color)
+ .unwrap_or(style.placeholder_color),
+ bounds: Rectangle {
+ x: bounds.x + f32::from(padding.left),
+ y: bounds.center_y(),
+ width: f32::INFINITY,
+ ..bounds
+ },
+ horizontal_alignment: alignment::Horizontal::Left,
+ vertical_alignment: alignment::Vertical::Center,
+ })
+ });
}
}