mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
Merge pull request #10007 from dotCooCoo/fix/doc-info-long-values-wrap
Document Info: a value wider than the panel wraps inside it
This commit is contained in:
2 files changed
+22
-2
No files matched your search
@@ -45,8 +45,10 @@ pub(crate) fn row(ui: &mut Ui, label: &str, value: &str) -> bool {
|
||||
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.
|
||||
clicked = copy_value(ui, label, value, false);
|
||||
// and a Shift-click extends the selection, so neither copies. A value wider than the panel
|
||||
// wraps inside it.
|
||||
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