Fix wrongly sized multiline TextEdit
in justified layouts
This commit is contained in:
parent
d9fd806e94
commit
36cffd7b84
1 changed files with 5 additions and 7 deletions
|
@ -468,7 +468,11 @@ impl<'t, S: TextBuffer> TextEdit<'t, S> {
|
|||
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 mut wrap_width = desired_width.min(available_width);
|
||||
let wrap_width = if ui.layout().horizontal_justify() {
|
||||
available_width
|
||||
} else {
|
||||
desired_width.min(available_width)
|
||||
};
|
||||
|
||||
let make_galley = |ui: &Ui, wrap_width: f32, text: &str| {
|
||||
let text = mask_if_password(text);
|
||||
|
@ -491,12 +495,6 @@ impl<'t, S: TextBuffer> TextEdit<'t, S> {
|
|||
let desired_size = vec2(wrap_width, galley.size.y.max(desired_height));
|
||||
let (auto_id, rect) = ui.allocate_space(desired_size);
|
||||
|
||||
if (rect.width() - desired_size.x).abs() > 0.5 {
|
||||
// We didn't get what we asked for. Likely we are in a justified layout, and got enlarged.
|
||||
wrap_width = rect.width();
|
||||
galley = make_galley(ui, wrap_width, text.as_ref())
|
||||
}
|
||||
|
||||
let id = id.unwrap_or_else(|| {
|
||||
if let Some(id_source) = id_source {
|
||||
ui.make_persistent_id(id_source)
|
||||
|
|
Loading…
Reference in a new issue