UI-1676: Ignore hidden symbol tint when expanding

This commit is contained in:
dotCooCoo
2026-11-05 05:54:43 +07:00
committed by bflatastic
parent 1fb0b4150d
commit 1968077984
2 changed files with 28 additions and 4 deletions
+2 -4
View File
@@ -347,10 +347,8 @@ fn expanded_instance(d: &mut Document, inst: &Node, own: bool) -> Option<Node> {
let NodeKind::SymbolInstance { symbol, xf } = &inst.kind else { return None };
let sym = d.symbols.iter().find(|s| &s.name == symbol)?;
let mut art = if own { vectorcraft_doc::symbol_overrides::dynamic_art(&sym.art, inst) } else { (*sym.art).clone() };
if let Some(f) = inst.appearance.fill()
&& let Some(c) = f.paint.color()
{
brush::tint_node(&mut art, &c, f.opacity);
if let Some((color, amount)) = brush::stain(inst) {
brush::tint_node(&mut art, &color, amount);
}
let art = d.place_symbol_art(symbol, &art, *xf)?;
let mut art = d.reid(&art);
+26
View File
@@ -1224,6 +1224,32 @@ fn place_and_break_link_round_trip_geometry() {
assert_eq!(n.appearance.stroke_width(), 1.0, "strokes are not scaled by normalisation");
}
#[test]
fn hidden_instance_fill_does_not_tint_expanded_symbol_art() {
for command in ["symbol.breakLink", "object.expand"] {
let mut s = session();
let source = rect(&mut s, 100.0, 50.0, 80.0, 40.0);
s.execute("paint.setFill", &json!({"ids": [source.0], "color": "#0000ff"})).unwrap();
let inst = NodeId(s.execute("symbol.new", &json!({"name": "Blue Box"})).unwrap()["id"].as_u64().unwrap());
s.execute("appearance.addFill", &json!({"ids": [inst.0]})).unwrap();
let fill = node(&s, inst).appearance.items.len() - 1;
s.execute("appearance.setItem", &json!({"ids": [inst.0], "index": fill, "color": "#ff0000"})).unwrap();
let center = |s: &Session| {
let doc = s.doc().unwrap().doc.clone();
vectorcraft_render::Renderer::new().render_region(&doc, Rect::new(0.0, 0.0, 400.0, 300.0), 1.0, true).pixel(140, 70)
};
let tinted = center(&s);
assert!(tinted[0] > tinted[2], "the visible instance fill tints the symbol: {tinted:?}");
s.execute("appearance.setItem", &json!({"ids": [inst.0], "index": fill, "visible": false})).unwrap();
let original = center(&s);
assert!(original[2] > original[0], "hiding the fill restores the blue symbol: {original:?}");
let params = if command == "symbol.breakLink" { json!({"ids": [inst.0]}) } else { json!({"object": true, "fill": false, "stroke": false}) };
s.execute(command, &params).unwrap();
assert_eq!(center(&s), original, "{command} must keep the untinted colors");
}
}
#[test]
fn break_link_then_update_redefines_all_instances() {
let mut s = session();