From 7afd0277022c25bbd5423317557740540154ca6c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 15:25:27 -0800 Subject: [PATCH] Document Info: a row wraps only when its label and value do not fit #9963 took wrapping off Document Info rows so each value stands at the panel's right edge. In a narrow panel in German the Flattener Preset row then ran past the panel, and main's gate failed on panels::tests_panel_rows::the_document_info_rows_wrap_in_a_narrow_panel_in_german. A row now measures its label and value: when both fit on one line it does not wrap, so the value stays at the right edge, and otherwise it wraps. --- crates/ui-egui/src/panels/doc_info.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/doc_info.rs b/crates/ui-egui/src/panels/doc_info.rs index ad8b8ce9f7..c94c3a5afb 100644 --- a/crates/ui-egui/src/panels/doc_info.rs +++ b/crates/ui-egui/src/panels/doc_info.rs @@ -35,8 +35,14 @@ pub struct DocInfoView { /// the second or third click of a double or triple click. pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool { let mut clicked = false; - // A wrapping row places its children as `Start` does, so the row does not wrap and the value stands at its end. - Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| { + // A row whose label and value fit on one line keeps the value at its end. A wrapping row places its children as + // `Start` does, so the row wraps only when the two do not fit, as in a narrow panel or a longer translation. + let width = |text: &str| { + let font = egui::TextStyle::Body.resolve(ui.style()); + ui.painter().layout_no_wrap(text.to_string(), font, egui::Color32::WHITE).size().x + }; + let fits = width(label) + width(value) + 2.0 * ui.spacing().item_spacing.x <= ui.available_width(); + Row::new().fill_width().align(RowAlign::SpaceBetween).wrap(!fits).show(ui, |ui, _| { Text::new(label.to_string()).shade(Shade::Muted).show(ui); // The value can be selected and copied, and a click copies all of it (#8432). A drag selects // and a Shift-click extends the selection, so neither copies.