mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
Document Info: a value wider than the panel wraps inside it
A row moves its value under the label when the two do not fit on one line, but a value wider than the whole panel, such as a long document name, still ran past the panel's edge. The value now shows as multiline selectable text, so it wraps inside the panel. Short values still stand at the row end.
This commit is contained in:
1 parent
e23c4d7624
commit
97ee32bcf7
2 files changed
+22
-2
No files matched your search
@@ -39,8 +39,10 @@ pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool {
|
||||
Row::new().fill_width().align(RowAlign::SpaceBetween).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.
|
||||
clicked = copy_value(ui, label, value, false);
|
||||
// and a Shift-click extends the selection, so neither copies. A value too long to fit beside
|
||||
// its label wraps inside the panel.
|
||||
let shown = SelectableText::new(label.to_string(), value).multiline().show(ui);
|
||||
clicked = copy_shown(ui, &shown, value);
|
||||
});
|
||||
clicked
|
||||
}
|
||||
|
||||
@@ -33,6 +33,24 @@ fn document_info_values_end_at_one_edge() {
|
||||
assert!(value.left() > label.right() + label.width(), "the value {value:?} sits against its label {label:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_long_document_info_value_wraps_inside_a_narrow_panel() {
|
||||
let name = "A document name long enough to run past a narrow panel";
|
||||
let mut app = crate::testing::windowed(VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()));
|
||||
run(&mut app, "file.new", json!({"width": 200, "height": 200, "name": name}));
|
||||
let mut panel = Panel::new(app, doc_info::show);
|
||||
let width = 160.0;
|
||||
panel.room(egui::vec2(width, ROOM.y));
|
||||
panel.frame();
|
||||
panel.frame();
|
||||
let texts = panel.texts();
|
||||
let runs: Vec<Rect> = texts.iter().filter(|(t, _)| t.starts_with("A document")).map(|(_, r)| *r).collect();
|
||||
assert!(!runs.is_empty(), "no run of the name in {texts:?}");
|
||||
for r in &runs {
|
||||
assert!(r.right() <= width + 0.5, "the name ends at {}, past the panel's {width}: {texts:?}", r.right());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn info_paints_stand_a_section_apart_from_the_numbers() {
|
||||
let mut app = app_with_rect();
|
||||
|
||||
Reference in new issue
Block a user