Merge pull request #10003 from dotCooCoo/fix/main-doc-info-row-wrap

Main: a Document Info row wraps only when its label and value do not fit
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 15:25:30 -08:00
commit 9d6438931f
1 file changed
+8 -2
+8 -2
View File
@@ -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.