From 43a968d7513b09d8d7a516c6a8c8a291ef87e8da Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 00:03:58 -0800 Subject: [PATCH] Symbols: the options dialog skips locked or hidden symbol sets OK gave a new density only to symbol sets that can be edited, but a locked or hidden one in the selection made symbol.setDensity fail, so the brush options were not saved either. The dialog now leaves such sets out. --- .../ui-egui/src/dialogs/symbolism_options.rs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/symbolism_options.rs b/crates/ui-egui/src/dialogs/symbolism_options.rs index 969a625ee0..7a6fa2f29e 100644 --- a/crates/ui-egui/src/dialogs/symbolism_options.rs +++ b/crates/ui-egui/src/dialogs/symbolism_options.rs @@ -110,10 +110,16 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { false } -/// The selected symbol sets. +/// The selected symbol sets that can be edited (not locked or hidden). fn selected_sets(app: &VectorcraftApp) -> Vec { let Some(st) = app.session.active() else { return vec![] }; - st.selection.objects.iter().filter(|id| st.doc.node(**id).is_some_and(vectorcraft_engine::cmd::is_symbol_set)).map(|id| id.0).collect() + let editable = st.doc.editable(); + st.selection + .objects + .iter() + .filter(|id| st.doc.node(**id).is_some_and(vectorcraft_engine::cmd::is_symbol_set) && editable(**id)) + .map(|id| id.0) + .collect() } /// OK: set the brush the Symbolism tools share (the tool keeps it within its ranges), after giving @@ -319,4 +325,25 @@ mod tests { assert_eq!((width(&app), undo(&app)), (was, steps)); assert_eq!(app.session.tool_options_of("symbolSizer")["density"].as_f64(), Some(2.0)); } + + /// A locked symbol set in the selection keeps its spacing, and OK still sets the options. + #[test] + fn ok_sets_the_options_with_a_locked_symbol_set_selected() { + let mut app = app(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 10, "height": 10})).unwrap(); + app.run("symbol.new", json!({"name": "Dot"})).unwrap(); + app.run("select.set", json!({"ids": []})).unwrap(); + let set = app.run("symbol.spray", json!({"name": "Dot", "points": [[40, 150], [120, 150]], "radius": 4})).unwrap()["id"].as_u64().unwrap(); + app.run("object.lock", json!({})).unwrap(); + app.session.select(|_, sel| sel.set([vectorcraft_doc::NodeId(set)])).unwrap(); + let steps = app.session.active().unwrap().history.undo.len(); + app.run("tool.options", json!({"tool": "symbolSprayer"})).unwrap(); + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("density".into(), json!(9)); + d.fields.insert("diameter".into(), json!(30)); + super::super::confirm(&mut app).unwrap(); + assert_eq!(app.session.active().unwrap().history.undo.len(), steps); + let o = app.session.tool_options_of("symbolSizer"); + assert_eq!((o["density"].as_f64(), o["diameter"].as_f64()), (Some(9.0), Some(30.0))); + } }