diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index c6c9f72d3d..9d2ca82832 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -2092,9 +2092,6 @@ fn assign_tab( } }); } - if rows.is_empty() { - Text::new(tl!("No colors to recolor (preserved colors are left out).")).shade(Shade::Muted).show(ui); - } let columns = vec![ ColumnSpec::new( CURRENT, @@ -2122,10 +2119,12 @@ fn assign_tab( let source = keyed(&keys, |k| *k).with_text(|k| Cow::Owned(names.get(*k).cloned().unwrap_or_default())); let edits: RefCell> = RefCell::new(Vec::new()); let shown_rows: &[Value] = rows; - let out = Table::::new(tl!("Colors"), columns).min_rows(5).max_rows(8).selection(Bind::bound(&mut sel)).show_items( - ui, - &source, - &mut |key, icx| { + let out = Table::::new(tl!("Colors"), columns) + .min_rows(5) + .max_rows(8) + .empty(tl!("No colors to recolor (preserved colors are left out).")) + .selection(Bind::bound(&mut sel)) + .show_items(ui, &source, &mut |key, icx| { let i = *key; let edits = &edits; let row = shown_rows.get(i).cloned().unwrap_or_default(); @@ -2159,8 +2158,7 @@ fn assign_tab( edits.borrow_mut().push(RowEdit::Hex(i, *c)); } }) - }, - ); + }); let mut items = sel.items.clone(); items.sort_unstable(); items.dedup(); diff --git a/crates/ui-egui/src/tests/recolor.rs b/crates/ui-egui/src/tests/recolor.rs index 224bdc989c..6ab2abd049 100644 --- a/crates/ui-egui/src/tests/recolor.rs +++ b/crates/ui-egui/src/tests/recolor.rs @@ -677,6 +677,19 @@ fn the_preserve_checkboxes_open_as_they_were_last_confirmed() { assert_eq!(preserve(&r), [json!(false), json!(false), json!(true)], "Cancel keeps what OK left"); } +#[test] +fn with_every_color_preserved_the_colors_table_says_so_in_its_body() { + let mut app = app(); + art(&mut app, &["#ffffff", "#000000"]); + let mut r = assign(app, json!({})); + assert!(r.rows().is_empty(), "White and Black are preserved"); + let note = "No colors to recolor (preserved colors are left out)."; + let inside = |r: &Recolor| rect(r, "Colors").contains_rect(rect(r, note)); + assert!(inside(&r), "the note is drawn inside the Colors table, not above its empty rows"); + r.frame(); + assert!(inside(&r), "and stays there on the next frame"); +} + fn new_hsb(r: &Recolor) -> Vec<[f32; 3]> { field(r, "rows").as_array().unwrap().iter().map(|row| vectorcraft_engine::cmd::color_value(&row["to"]).unwrap().to_hsb()).collect() }