Merge pull request #9268 from dotCooCoo/fix/recolor-empty-colors-table

Recolor Artwork: with every color preserved, the Colors table shows its empty-state note inside its body
This commit is contained in:
BFlat authored and GitHub committed 2026-11-25 15:58:55 +07:00
commit 01c602dc40
2 files changed
+20 -9

No files matched your search

+7 -9
View File
@@ -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<Vec<RowEdit>> = RefCell::new(Vec::new());
let shown_rows: &[Value] = rows;
let out = Table::<usize>::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::<usize>::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();
+13
View File
@@ -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()
}