summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-04-30 13:22:39 +0200
committerLibravatar GitHub <noreply@github.com>2022-04-30 13:22:39 +0200
commitabc993103fa59da6ad2b7ba5a40fd5aa59952ee5 (patch)
treeb77b038da9fe1df4449e03b470c96f1d417f8c45 /native
parent521be3603c0dd7319bec4a391359e79c7d89e5a6 (diff)
parentd562c27e8ce10ecf4aed4d5fc4c64a737391c2c9 (diff)
downloadiced-abc993103fa59da6ad2b7ba5a40fd5aa59952ee5.tar.gz
iced-abc993103fa59da6ad2b7ba5a40fd5aa59952ee5.tar.bz2
iced-abc993103fa59da6ad2b7ba5a40fd5aa59952ee5.zip
Merge pull request #1318 from tarkah/fix/picklist-text-wrapping
Fix `PickList` text wrapping
Diffstat (limited to '')
-rw-r--r--native/src/widget/pick_list.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs
index e050ada5..0374aef7 100644
--- a/native/src/widget/pick_list.rs
+++ b/native/src/widget/pick_list.rs
@@ -402,21 +402,24 @@ pub fn draw<T, Renderer>(
if let Some(label) =
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 {
content: label,
- size: f32::from(text_size.unwrap_or(renderer.default_size())),
+ size: text_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(),
- ..bounds
+ y: bounds.center_y() - text_size / 2.0,
+ width: bounds.width - f32::from(padding.horizontal()),
+ height: text_size,
},
horizontal_alignment: alignment::Horizontal::Left,
- vertical_alignment: alignment::Vertical::Center,
- })
+ vertical_alignment: alignment::Vertical::Top,
+ });
}
}