mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
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:
1 file changed
+8
-2
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user