Add a minimum width to TextEdit to prevent them from being tiny

This commit is contained in:
Emil Ernerfeldt 2021-08-24 15:59:31 +02:00
parent f940ae9edf
commit d865852d24

View file

@ -458,7 +458,8 @@ impl<'t, S: TextBuffer> TextEdit<'t, S> {
.or(ui.style().override_text_style) .or(ui.style().override_text_style)
.unwrap_or_else(|| ui.style().body_text_style); .unwrap_or_else(|| ui.style().body_text_style);
let line_spacing = ui.fonts().row_height(text_style); let line_spacing = ui.fonts().row_height(text_style);
let available_width = ui.available_width(); const MIN_WIDTH: f32 = 24.0; // Never make a `TextEdit` more narrow than this.
let available_width = ui.available_width().at_least(MIN_WIDTH);
let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width); let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width);
let make_galley = |ui: &Ui, text: &str| { let make_galley = |ui: &Ui, text: &str| {