diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 2233aa1f1..61a3df0b0 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -564,12 +564,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { } ui.data_mut(|d| d.insert_temp(key("seen-current"), current)); } - // With Locate Selected Objects on, an object selected anew outside the panel has the rows - // around it opened, and its row is revealed instead of the active layer's row (below). + // With Locate Selected Objects on, an object selected anew outside the panel (below). let located = newly_selected(app, ui).filter(|_| !highlighted); - if let Some(id) = located { - open_around(app, &doc, &[id]); - } // Search All, and the Filter button at its right. let query = ui .horizontal(|ui| { @@ -582,11 +578,18 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { .inner .trim() .to_lowercase(); + // The located object, when it has a row once the rows around it are open (Show Layers Only, a + // search or the filter can leave it out): those rows open, and its row is revealed instead of + // the row revealed above. Otherwise nothing opens. + let located = located.filter(|id| { + app.session.active().is_some_and(|st| listed_when_opened(&doc, &st.layers_open, &app.ui.layers_panel, &query, &app.ui.layers_filter, *id)) + }); + if let Some(id) = located { + open_around(app, &doc, &[id]); + } + let reveal = located.or(reveal); let Some(st) = app.session.active() else { return }; let list = rows_of_doc(ui, st, &app.ui.layers_panel, &query, &app.ui.layers_filter); - // The located object's row when it is listed (Show Layers Only, a search or the filter can - // leave it out), otherwise the row revealed above. - let reveal = located.filter(|id| list.iter().any(|r| r.node.id == *id)).or(reveal); let view = View { doc: &doc, thumbs: ThumbSource::of(app, st, &doc), @@ -710,6 +713,23 @@ fn open_around(app: &mut VectorcraftApp, doc: &Document, ids: &[NodeId]) { } } +/// Whether [`list_rows`] gives `id` a row once the layers and groups around it are open as well as +/// `open`. Only the rows of `id`'s top-level layer are listed. +fn listed_when_opened(doc: &Document, open: &OpenRows, opts: &PanelOptions, query: &str, filter: &Filter, id: NodeId) -> bool { + let Some(ancestry) = doc.ancestry(id) else { return false }; + let Some(layer) = doc.layers.iter().find(|l| ancestry.first() == Some(&l.id)) else { return false }; + if doc.mask_edit.is_some_and(|m| m.layer != layer.id) { + return false; + } + let mut open = open.clone(); + for a in ancestry.split_last().map(|(_, a)| a).unwrap_or_default() { + open.set(*a, true); + } + let mut rows = vec![]; + push_rows(layer, 0, false, (Color32::PLACEHOLDER, true), (&open, opts, query, filter, doc), &mut rows); + rows.iter().any(|r| r.node.id == id && r.guide.is_none()) +} + /// The active document's uid and its last selected object, the one Locate Object locates. fn last_selected(app: &VectorcraftApp) -> Option<(u64, Option)> { app.session.active().map(|st| (st.uid, st.selection.objects.last().copied())) @@ -3019,6 +3039,38 @@ mod tests { assert!((0..4).any(|_| tall_frame(&mut app, &ctx, &name).1), "the active layer's row is scrolled into view"); } + /// With Locate Selected Objects on, art selected outside the panel that Show Layers Only or the + /// filter leaves without a row opens nothing, so its group stays closed once the panel lists + /// every row again. Art the filter keeps has its group opened. + #[test] + fn with_the_option_art_the_panel_does_not_list_opens_nothing() { + let (mut app, _, paths) = groups_of_one(500); + app.ui.layers_panel.locate_selected = true; + let ctx = egui::Context::default(); + let open = |app: &VectorcraftApp, i: usize| { + let st = app.session.active().unwrap(); + st.layers_open.contains(st.doc.parent_of(paths[i]).unwrap()) + }; + let locate = |app: &mut VectorcraftApp, i: usize| { + app.session.execute("select.set", &json!({"ids": [paths[i].0]})).unwrap(); + for _ in 0..4 { + tall_frame(app, &ctx, ""); + } + }; + tall_frame(&mut app, &ctx, ""); + app.ui.layers_panel.layers_only = true; + locate(&mut app, 0); + app.ui.layers_panel.layers_only = false; + tall_frame(&mut app, &ctx, ""); + assert!(!open(&app, 0), "Show Layers Only: the group stays closed"); + app.ui.layers_filter = Filter { objects: vec![ObjectKind::Text], layers: vec![] }; + locate(&mut app, 1); + assert!(!open(&app, 1), "a filter that leaves the path out: the group stays closed"); + app.ui.layers_filter = Filter { objects: vec![ObjectKind::Paths], layers: vec![] }; + locate(&mut app, 2); + assert!(open(&app, 2), "a filter that keeps the path: the group opens"); + } + /// A layer of 2,000 groups of 10 paths with every row open: one frame lays out only the rows /// in view, and a row highlighted far below them is scrolled to. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index ce31bfbf4..cfeb2b33c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1700,8 +1700,9 @@ and `layerRows`, the rows highlighted in the panel. `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 or by a command, the panel opens the layers and groups around it and scrolls to its row, as after `layer.locate`, but - does not highlight the row. A change made with the panel's own rows, buttons or menu is not located, and a change - made during a drag is located when the drag ends. + does not highlight 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. A change made with the panel's own rows, buttons or menu is + not located, and a change made during a drag is located when the drag ends. A document opens with only its top-level layers open; the open rows are saved in the native file and reopen that way. - **Search and filter** (control channel and the app's MCP): the Search All field keeps the rows whose names hold the text typed, and `ui.layersFilter {objects?, layers?}` sets the choices of the Filter button beside it. `objects` (By diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0db5ea5aa..201c8f5f1 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -574,7 +574,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Ctrl/Cmd+Alt-clicking an eye switches the other layers to Outline and the row's layer to Preview, or switches all layers back to Preview when the others are in Outline (`layer.outlineOthers`, `layer.previewAll`). 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. - 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. + 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 or its centre is nearest a gridline on each axis, #740; 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. A bounding-box handle dragged with the Selection or Free Transform tool snaps what it moves as a dragged point snaps (#2054). With View › Snap to Grid on, it snaps to the nearest gridline, and with Snap to Pixel on, it snaps to whole pixels. With Smart Guides off and Snap to Point on, it snaps to the other objects' anchors and the ruler guides within the Snap to Point distance. With Smart Guides and Snap to Point both on, it lines up with the ruler guides as well as the other objects. Shift still keeps the proportions, and Alt still scales about the center.