diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 09c4b8c4e..67219de40 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -453,7 +453,9 @@ pub fn accepts_field(d: &Dialog, field: &str) -> bool { /// Set `field` of `d` to `value` for `ui.dialog.set`, as the dialog's own control for it does: a /// Pattern Brush Options corner tile set this way is saved by OK, as one chosen from its menu is, -/// and an Edit Data Set field set this way is no longer the row's empty text value. +/// an Edit Data Set field set this way is no longer the row's empty text value, and a Layer +/// Options setting set this way for several rows is sent to every row (Template also sets Lock +/// and Dim Images, as its checkbox does). pub fn set_field(d: &mut Dialog, field: String, value: Value) { if d.kind == brush_options::KIND { brush_art_options::note_set(d, &field); @@ -461,6 +463,9 @@ pub fn set_field(d: &mut Dialog, field: String, value: Value) { if d.kind == variables::KIND { variables::note_set(d, &field); } + if d.kind == layer_options::KIND { + layer_options::note_set(d, &field, &value); + } d.fields.insert(field, value); } diff --git a/crates/ui-egui/src/dialogs/layer_options.rs b/crates/ui-egui/src/dialogs/layer_options.rs index d33941dc6..6b3d29408 100644 --- a/crates/ui-egui/src/dialogs/layer_options.rs +++ b/crates/ui-egui/src/dialogs/layer_options.rs @@ -5,7 +5,8 @@ //! Fields: `ids` (the rows edited; none for a new layer), `mode` (`edit`, `new` or `newSublayer`), //! `layer` (the rows are layers), `name`, `color` (a preset's name such as "Light Blue", or //! `#rrggbb`), `template`, `locked`, `visible`, `printable`, `preview`, `dimImages` and -//! `dimPercent`. OK runs `layer.setProps`, `layer.new` or `layer.newSublayer`. +//! `dimPercent`. OK runs `layer.setProps`, `layer.new` or `layer.newSublayer`. For several rows +//! the dialog shows the first row's settings, and OK sends only the ones set in the dialog. use serde_json::{Value, json}; use vectorcraft_doc::{LAYER_COLORS, LayerColor, Node, NodeId, NodeKind}; @@ -18,6 +19,75 @@ use crate::{VectorcraftApp, widgets}; /// The dialog kind of Layer Options. pub const KIND: &str = "layerOptions"; +/// The field listing the fields set in the dialog, by its controls or `ui.dialog.set`. +const SET: &str = "__set"; + +/// The field holding, for several rows, the first row's Template, Lock, Dim Images and its +/// percentage as the dialog opened. +const OPENED: &str = "__opened"; + +/// Records that `field` was set. +fn mark(d: &mut Dialog, field: &str) { + match d.fields.get_mut(SET) { + Some(Value::Array(a)) => { + if !a.iter().any(|k| k == field) { + a.push(json!(field)); + } + } + _ => { + d.fields.insert(SET.into(), json!([field])); + } + } +} + +/// Records that `ui.dialog.set` sets `field` to `value`. Template also sets Lock and Dim Images, +/// as its checkbox does. +pub(super) fn note_set(d: &mut Dialog, field: &str, value: &Value) { + if field.starts_with("__") { + return; + } + match value.as_bool() { + Some(on) if field == "template" && on != d.bool("template") => set_template(d, on), + _ => mark(d, field), + } +} + +/// Turns Template on or off. A template is locked and dims its images, and turning Template off +/// unlocks it and turns Dim Images off. For several rows, OK sends Lock and Dim Images only when +/// they are set in the dialog. `layer.setProps` then locks each row that becomes a template and +/// dims it to 50%, unless a percentage is set in the dialog, so the dialog shows 50%; it unlocks +/// each row that stops being a template and stops dimming it. +/// When Template is set back to the first row's value, Lock and Dim Images that were not set in +/// the dialog show the first row's values again. +fn set_template(d: &mut Dialog, on: bool) { + choose(d, "template", json!(on)); + d.fields.insert("locked".into(), json!(on)); + d.fields.insert("dimImages".into(), json!(on)); + let Some(opened) = d.fields.get(OPENED).cloned() else { + return; + }; + if opened.get("template") == Some(&json!(on)) { + for key in ["locked", "dimImages", "dimPercent"] { + if let Some(v) = opened.get(key).filter(|_| !is_set(d, key)) { + d.fields.insert(key.into(), v.clone()); + } + } + } else if on && !is_set(d, "dimPercent") { + d.fields.insert("dimPercent".into(), json!(50)); + } +} + +/// Whether `field` was set in the dialog. +fn is_set(d: &Dialog, field: &str) -> bool { + d.fields.get(SET).and_then(Value::as_array).is_some_and(|a| a.iter().any(|k| k == field)) +} + +/// Sets `key` to `value` from one of the dialog's controls. +fn choose(d: &mut Dialog, key: &str, value: Value) { + d.fields.insert(key.into(), value); + mark(d, key); +} + pub(super) const SPEC: DialogSpec = DialogSpec { heading, body, confirm, min_width: 320.0, ..DialogSpec::FORM }; fn heading(d: &Dialog) -> String { @@ -73,6 +143,11 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { let first = ids.first().and_then(|id| st.doc.node(*id)).ok_or("no such layer or object")?; let xml_id = app.session.prefs.identify_objects_by == "xmlId"; let mut f = fields_of(first, xml_id); + if ids.len() > 1 { + let opened: serde_json::Map<_, _> = + ["template", "locked", "dimImages", "dimPercent"].iter().filter_map(|k| Some((k.to_string(), f.get(*k)?.clone()))).collect(); + f.insert(OPENED.into(), Value::Object(opened)); + } f.insert("ids".into(), json!(ids.iter().map(|i| i.0).collect::>())); f.insert("mode".into(), json!("edit")); app.ui.dialog = Some(Dialog { kind: KIND.into(), fields: f }); @@ -109,7 +184,7 @@ fn toggle(ui: &mut egui::Ui, d: &mut Dialog, key: &str, text: &str, enabled: boo let v = d.bool(key); let changed = widgets::check(ui, text, v, enabled); if changed { - d.fields.insert(key.into(), json!(!v)); + choose(d, key, json!(!v)); } changed } @@ -154,7 +229,7 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { let cur = d.str("color"); let shown = LAYER_COLORS.iter().map(|(n, _)| *n).find(|n| n.eq_ignore_ascii_case(&cur)).unwrap_or("Custom"); if let Some((n, _)) = color_dropdown(ui, shown).and_then(|i| LAYER_COLORS.get(i)) { - d.fields.insert("color".into(), json!(n)); + choose(d, "color", json!(n)); } let [r, g, b] = LAYER_COLORS .iter() @@ -169,7 +244,7 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { .unwrap_or(LAYER_COLORS[0].1); let mut rgb = [r, g, b]; if ui.color_edit_button_srgb(&mut rgb).changed() { - d.fields.insert("color".into(), json!(format!("#{:02x}{:02x}{:02x}", rgb[0], rgb[1], rgb[2]))); + choose(d, "color", json!(format!("#{:02x}{:02x}{:02x}", rgb[0], rgb[1], rgb[2]))); } }); ui.end_row(); @@ -179,11 +254,9 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { if layer { ui.horizontal(|ui| { ui.vertical(|ui| { - // A template is locked and dims its images; turning it off frees both. - if toggle(ui, d, "template", tl!("Template"), true) { - let on = d.bool("template"); - d.fields.insert("locked".into(), json!(on)); - d.fields.insert("dimImages".into(), json!(on)); + let template = d.bool("template"); + if widgets::check(ui, tl!("Template"), template, true) { + set_template(d, !template); } toggle(ui, d, "visible", tl!("Show"), true); toggle(ui, d, "preview", tl!("Preview"), true); @@ -191,8 +264,13 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { toggle(ui, d, "dimImages", tl!("Dim Images to:"), true); let v = d.f64("dimPercent", 50.0); let dim = d.bool("dimImages"); - if let Some(v) = ui.add_enabled_ui(dim, |ui| crate::widgets::range_field(ui, "dimPercent", v, 0.0..=100.0, "%", 0, 52.0)).inner { - d.fields.insert("dimPercent".into(), json!(v)); + if let Some(v) = ui + .add_enabled_ui(dim, |ui| { + crate::widgets::range_field_named(ui, "dimPercent", Some(tl!("Dim Images to:")), v, 0.0..=100.0, "%", 0, 52.0) + }) + .inner + { + choose(d, "dimPercent", json!(v)); } }); }); @@ -210,7 +288,8 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { false } -/// The command and params OK runs. +/// The command and params OK runs. For several rows only the settings set in the dialog are sent, +/// so each row keeps its own values for the rest. pub(crate) fn params(d: &Dialog) -> (&'static str, Value) { let mut p = serde_json::Map::new(); let many = d.fields.get("ids").and_then(Value::as_array).is_some_and(|a| a.len() > 1); @@ -226,6 +305,12 @@ pub(crate) fn params(d: &Dialog) -> (&'static str, Value) { p.insert("preview".into(), json!(d.bool("preview"))); p.insert("dimImages".into(), if d.bool("dimImages") { json!(d.f64("dimPercent", 50.0).clamp(0.0, 100.0)) } else { json!(false) }); } + if many { + // A percentage set in the dialog is sent whenever Dim Images is on, also when Dim Images + // was turned on by Template. + let percent = d.bool("dimImages") && is_set(d, "dimPercent"); + p.retain(|k, _| is_set(d, k) || (k == "dimImages" && percent)); + } match d.str("mode").as_str() { "new" => ("layer.new", Value::Object(p)), "newSublayer" => ("layer.newSublayer", Value::Object(p)), @@ -259,8 +344,9 @@ mod tests { out.textures_delta.clear(); } + /// Sets a field as `ui.dialog.set` does. fn set(app: &mut VectorcraftApp, k: &str, v: Value) { - app.ui.dialog.as_mut().unwrap().fields.insert(k.into(), v); + super::super::set_field(app.ui.dialog.as_mut().unwrap(), k.into(), v); } /// Explicit object ids must not silently disappear or fall back to the highlighted row. @@ -300,6 +386,204 @@ mod tests { assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1); } + /// Two layers with different options, the first plain and the second green, locked, in + /// outline view and dimmed to 30%. + fn two_layers(app: &mut VectorcraftApp) -> (NodeId, NodeId) { + let first = app.session.doc().unwrap().doc.layers[0].id; + let p = json!({"color": "#00ff00", "locked": true, "preview": false, "dimImages": 30}); + let second = NodeId(app.session.execute("layer.new", &p).unwrap()["id"].as_u64().unwrap()); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + draw(app); + (first, second) + } + + fn layer(app: &VectorcraftApp, id: NodeId) -> Node { + app.session.doc().unwrap().doc.node(id).unwrap().clone() + } + + /// A setting set to the first layer's own value still goes to every layer. + #[test] + fn layer_options_for_several_layers_send_only_the_settings_set() { + let mut app = app(); + let (first, second) = two_layers(&mut app); + set(&mut app, "printable", json!(false)); + set(&mut app, "color", json!("Light Blue")); + let (_, p) = params(app.ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"printable": false, "color": "Light Blue", "ids": [first.0, second.0]})); + super::super::confirm(&mut app).unwrap(); + let (a, b) = (layer(&app, first), layer(&app, second)); + assert!(matches!(a.kind, NodeKind::Layer { color: LayerColor::Preset(0), printable: false, preview: true, dim_images: None, .. })); + assert!(!a.locked); + let NodeKind::Layer { color, printable, preview, dim_images, .. } = b.kind else { panic!("not a layer") }; + assert_eq!((color, printable, preview, dim_images, b.locked), (LayerColor::Preset(0), false, false, Some(30), true)); + } + + /// Template locks and dims to 50% each layer whose Template it changes; a Dim Images + /// percentage set as well goes to every layer. + #[test] + fn template_for_several_layers_leaves_lock_and_dimming_to_each_layer() { + let mut app = app(); + let (first, second) = two_layers(&mut app); + app.run("layer.setProps", json!({"ids": [second.0], "template": true, "dimImages": 30})).unwrap(); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "template", json!(true)); + let (_, p) = params(app.ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"template": true, "ids": [first.0, second.0]})); + super::super::confirm(&mut app).unwrap(); + let (a, b) = (layer(&app, first), layer(&app, second)); + assert!(a.is_template() && a.locked && matches!(a.kind, NodeKind::Layer { dim_images: Some(50), .. })); + assert!(b.is_template() && b.locked && matches!(b.kind, NodeKind::Layer { dim_images: Some(30), .. })); + // The first layer is dimmed to 50% now; 50% set again goes to both. + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "dimPercent", json!(50)); + let (_, p) = params(app.ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"dimImages": 50.0, "ids": [first.0, second.0]})); + super::super::confirm(&mut app).unwrap(); + assert!(matches!(layer(&app, second).kind, NodeKind::Layer { dim_images: Some(50), .. })); + // A percentage set while Dim Images is off is sent once Dim Images is on. + app.run("layer.setProps", json!({"ids": [first.0], "template": false, "dimImages": false})).unwrap(); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "dimPercent", json!(20)); + assert_eq!(params(app.ui.dialog.as_ref().unwrap()).1, json!({"ids": [first.0, second.0]})); + set(&mut app, "dimImages", json!(true)); + assert_eq!(params(app.ui.dialog.as_ref().unwrap()).1, json!({"dimImages": 20.0, "ids": [first.0, second.0]})); + } + + /// A percentage set while Dim Images is off is sent when Template turns Dim Images on. + #[test] + fn a_percentage_set_before_template_turns_dimming_on_goes_to_every_layer() { + let mut app = app(); + let (first, second) = two_layers(&mut app); + set(&mut app, "dimPercent", json!(20)); + set(&mut app, "template", json!(true)); + let (_, p) = params(app.ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"template": true, "dimImages": 20.0, "ids": [first.0, second.0]})); + super::super::confirm(&mut app).unwrap(); + for id in [first, second] { + assert!(matches!(layer(&app, id).kind, NodeKind::Layer { template: true, dim_images: Some(20), .. })); + } + } + + /// The open dialog of `app` in a test harness, drawn and ready for clicks. + fn harness(app: VectorcraftApp) -> egui_kittest::Harness<'static, VectorcraftApp> { + let mut fonts = false; + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(900.0, 700.0)).build_ui_state( + move |ui, app: &mut VectorcraftApp| { + if !std::mem::replace(&mut fonts, true) { + crate::theme::install_fonts(ui.ctx()); + return; + } + super::super::show(app, ui.ctx()); + }, + app, + ); + h.run_steps(4); + h + } + + /// Clicking Template ticks Lock and Dim Images and leaves them to each layer; clicking Dim + /// Images off afterwards sends that to every layer. + #[test] + fn dim_images_clicked_after_template_goes_to_every_layer() { + use egui_kittest::kittest::Queryable; + let mut app = app(); + let (first, second) = two_layers(&mut app); + let mut h = harness(app); + h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Template").click(); + h.run_steps(3); + let d = h.state().ui.dialog.as_ref().unwrap(); + assert!(d.bool("template") && d.bool("locked") && d.bool("dimImages")); + assert_eq!(params(d).1, json!({"template": true, "ids": [first.0, second.0]})); + h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Dim Images to:").click(); + h.run_steps(3); + let (_, p) = params(h.state().ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"template": true, "dimImages": false, "ids": [first.0, second.0]})); + let app = h.state_mut(); + super::super::confirm(app).unwrap(); + for id in [first, second] { + let n = layer(app, id); + assert!(n.locked && matches!(n.kind, NodeKind::Layer { template: true, dim_images: None, .. })); + } + } + + /// Template set through `ui.dialog.set` locks and dims as its checkbox does, and set back it + /// shows the first layer's Lock and Dim Images again and sends neither. + #[test] + fn template_set_and_set_back_leaves_lock_and_dimming_alone() { + let mut app = app(); + let (first, second) = two_layers(&mut app); + app.run("layer.setProps", json!({"ids": [first.0], "locked": true})).unwrap(); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "template", json!(true)); + let d = app.ui.dialog.as_ref().unwrap(); + assert!(d.bool("locked") && d.bool("dimImages")); + assert_eq!(params(d).1, json!({"template": true, "ids": [first.0, second.0]})); + set(&mut app, "template", json!(false)); + let d = app.ui.dialog.as_ref().unwrap(); + assert!(d.bool("locked") && !d.bool("dimImages")); + assert_eq!(params(d).1, json!({"template": false, "ids": [first.0, second.0]})); + super::super::confirm(&mut app).unwrap(); + assert!(layer(&app, first).locked && layer(&app, second).locked); + assert!(matches!(layer(&app, second).kind, NodeKind::Layer { dim_images: Some(30), .. })); + } + + /// Template turned on shows the 50% that `layer.setProps` dims each new template to, and + /// turned back off shows the first layer's own percentage again. + #[test] + fn template_shows_the_percentage_it_dims_to() { + let mut app = app(); + let (first, second) = two_layers(&mut app); + app.run("layer.setProps", json!({"ids": [first.0], "dimImages": 30})).unwrap(); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "template", json!(true)); + let d = app.ui.dialog.as_ref().unwrap(); + assert_eq!(d.f64("dimPercent", 0.0), 50.0); + set(&mut app, "template", json!(false)); + let d = app.ui.dialog.as_ref().unwrap(); + assert!(d.bool("dimImages")); + assert_eq!(d.f64("dimPercent", 0.0), 30.0); + assert_eq!(params(d).1, json!({"template": false, "ids": [first.0, second.0]})); + set(&mut app, "template", json!(true)); + super::super::confirm(&mut app).unwrap(); + assert!(matches!(layer(&app, first).kind, NodeKind::Layer { template: true, dim_images: Some(50), .. })); + } + + /// Template set through `ui.dialog.set` for one layer locks it and dims its images, as the + /// checkbox does. + #[test] + fn template_set_for_one_layer_locks_and_dims_it() { + let mut app = app(); + let id = app.session.doc().unwrap().doc.layers[0].id; + app.run("ui.layerOptions", json!({"ids": [id.0]})).unwrap(); + set(&mut app, "template", json!(true)); + super::super::confirm(&mut app).unwrap(); + let n = layer(&app, id); + assert!(n.locked && matches!(n.kind, NodeKind::Layer { template: true, dim_images: Some(50), .. })); + } + + /// A percentage typed in while Dim Images is on stays set when Template is then clicked on, + /// since Template leaves Dim Images on. + #[test] + fn a_percentage_typed_before_template_goes_to_every_layer() { + use egui_kittest::kittest::Queryable; + let mut app = app(); + let (first, second) = two_layers(&mut app); + app.run("layer.setProps", json!({"ids": [first.0], "dimImages": 30})).unwrap(); + app.run("ui.layerOptions", json!({"ids": [first.0, second.0]})).unwrap(); + set(&mut app, "dimPercent", json!(40)); + let mut h = harness(app); + h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Template").click(); + h.run_steps(3); + let (_, p) = params(h.state().ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"template": true, "dimImages": 40.0, "ids": [first.0, second.0]})); + // Template off again shows the first layer's Dim Images, on, and the percentage still + // goes to every layer. + h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Template").click(); + h.run_steps(3); + let (_, p) = params(h.state().ui.dialog.as_ref().unwrap()); + assert_eq!(p, json!({"template": false, "dimImages": 40.0, "ids": [first.0, second.0]})); + } + #[test] fn new_layer_options_make_a_layer_and_objects_get_name_show_and_lock() { let mut app = app(); diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 46748f5db..92bd0ed74 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -847,7 +847,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.layerOptions", "Options for Selection…", "", - "{ids?|id?} open Layer Options for Layers panel rows (default: the highlighted rows, else the current layer), filled in from the first: dialog `layerOptions`, fields name, color (a preset name such as \"Light Blue\" or #rrggbb), template, locked, visible, printable, preview, dimImages (bool), dimPercent (0–100); an object's row has name, visible and locked. OK runs layer.setProps (one undo step)", + "{ids?|id?} open Layer Options for Layers panel rows (default: the highlighted rows, else the current layer), filled in from the first: dialog `layerOptions`, fields name, color (a preset name such as \"Light Blue\" or #rrggbb), template, locked, visible, printable, preview, dimImages (bool), dimPercent (0–100); an object's row has name, visible and locked. OK runs layer.setProps (one undo step); for several rows it sends only the fields set in the dialog", ), ( "ui.newLayer", diff --git a/docs/mcp.md b/docs/mcp.md index af2adefa7..1c6f26069 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2578,7 +2578,9 @@ and `layerRows`, the rows highlighted in the panel. while a symbol is edited only the editing layer or art on it) / `object.exitIsolation`. - **Dialogs and panel state** (control channel and the app's MCP): `ui.layerOptions {ids?}` and `ui.newLayer {sublayer?}` open Layer Options (dialog `layerOptions`: name, color, template, locked, visible, printable, preview, - dimImages, dimPercent; OK is one undo step; Cmd/Ctrl+Alt+L runs `ui.newLayer` for a new layer), `ui.layersPanelOptions` opens Panel Options (`layersPanelOptions`: + dimImages, dimPercent; OK is one undo step; `ui.dialog.set` of `template` also sets `locked` and `dimImages`, as the + checkbox does; for several `ids` the dialog shows the first row's settings, and OK sends only the fields set with a + control or `ui.dialog.set`; Cmd/Ctrl+Alt+L runs `ui.newLayer` for a new layer), `ui.layersPanelOptions` opens Panel Options (`layersPanelOptions`: layersOnly, locateSelected, rowSize small|medium|large|other, otherSize, thumbLayers, thumbGroups, thumbObjects), and `ui.layersExpand {ids?, open?}` opens or closes rows as their triangles do (Alt-click: everything inside). With `locateSelected` on (Locate Selected Objects, off by default), when the last selected object changes on the canvas diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 1ad03aa3d..539a213f8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -825,6 +825,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Alt-clicking a layer's or sublayer's name makes it the current layer, as a click does, and selects its visible, unlocked art, as its selection square does (`layer.selectAll`, then `layer.setCurrent`); on a hidden or locked layer it clears the selection. The reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists Alt-click on the layer name for selecting all objects on the layer. Object › Arrange › Send to Current Layer returns the error "the target layer is locked or hidden" and leaves the selected objects where they are when the current layer is hidden or locked, or is inside a hidden or locked layer. Selected objects are deselected, the key object included, when a row drag moves them into a hidden layer or group, when `node.move` moves them into a hidden or locked layer or group, when Merge Selected moves them into a hidden or locked layer, when Collect in New Layer moves them into a new layer inside a hidden or locked layer, when Flatten Artwork moves them into a locked layer, and when applying a data set hides them. + Layer Options for several highlighted rows shows the first row's settings, and OK changes only the settings set in the dialog: each row keeps its own color, Template, Lock, Show, Print, Preview and Dim Images otherwise (`crates/ui-egui/src/dialogs/layer_options.rs` tests). Panel Options › Locate Selected Objects (beyond Illustrator, off by default): when the last selected object changes on the canvas or by a command, the panel opens the layers and groups around it and scrolls to its row, as Locate Object does, without highlighting the row; when Show Layers Only, a search or the filter leaves the object without a row, the panel opens no rows for it and scrolls as with the option off. - **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't). A move that Shift keeps level, upright or diagonal stays on that line when it snaps, with the Selection, Group Selection or Direct Selection tool. It slides along the line until the selection lands on the grid or on whole pixels, lines up with the other objects or is spaced evenly with them, or until the line passes an anchor or crosses a ruler guide near the point the selection was grabbed by. A level or upright move snaps along its own axis only.