mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Layers: Ctrl/Cmd+Alt-click on an eye switches the other layers between Outline and Preview
A Ctrl/Cmd+Alt-click on a row's eye in the Layers panel ran Hide Others or Show All Layers, as an Alt-click does. It now runs Outline Others for the row's layer (layer.outlineOthers), or Preview All Layers (layer.previewAll) when every other top-level layer is in Outline already. Each is one undo step. Alt-click and Ctrl/Cmd-click on an eye keep their actions. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
//! row it passes to the same state, in one undo step. Ctrl/Cmd-click an eye switches the layer
|
||||
//! between Preview and Outline. Alt-click an eye hides the other layers (`layer.hideOthers`), or
|
||||
//! shows every layer when they are hidden (`layer.showAll`); Alt-click a lock does the same with
|
||||
//! `layer.lockOthers` and `layer.unlockAll`.
|
||||
//! `layer.lockOthers` and `layer.unlockAll`. Ctrl/Cmd+Alt-click an eye switches the other layers
|
||||
//! to Outline and the row's layer to Preview (`layer.outlineOthers`), or switches every layer to
|
||||
//! Preview when the others are in Outline (`layer.previewAll`).
|
||||
//! - Dragging rows moves them above, below or into a layer or group (`layer.move`, a drop line or
|
||||
//! a box shows where); Alt copies them. A dimmed copy of the row follows the pointer. Dropped on
|
||||
//! the trash they are deleted, on New Layer duplicated.
|
||||
@@ -801,6 +803,19 @@ fn others_action(doc: &Document, n: &Node, eye: bool) -> (String, Value) {
|
||||
(cmd.into(), params)
|
||||
}
|
||||
|
||||
/// Ctrl/Cmd+Alt-clicking row `n`'s eye runs Outline Others, which puts every top-level layer but the
|
||||
/// one holding the row in Outline and puts that one in Preview. When all the other layers are in
|
||||
/// Outline already, it runs Preview All Layers. Each is one undo step.
|
||||
fn outline_others_action(doc: &Document, n: &Node) -> (String, Value) {
|
||||
let own = doc.layer_of(n.id);
|
||||
if doc.layers.iter().any(|l| Some(l.id) != own && !matches!(l.kind, NodeKind::Layer { preview: false, .. })) {
|
||||
("layer.outlineOthers".into(), json!({ "ids": [n.id.0] }))
|
||||
} else {
|
||||
// Preview All takes no rows.
|
||||
("layer.previewAll".into(), json!({}))
|
||||
}
|
||||
}
|
||||
|
||||
/// The eye and lock columns of row `n` at `r`.
|
||||
fn eye_and_lock(ui: &mut Ui, view: &View, n: &Node, r: egui::Rect, out: &mut Out) {
|
||||
let t = &view.t;
|
||||
@@ -832,7 +847,9 @@ fn eye_and_lock(ui: &mut Ui, view: &View, n: &Node, r: egui::Rect, out: &mut Out
|
||||
}
|
||||
let m = ui.input(|i| i.modifiers);
|
||||
if er.clicked() {
|
||||
if m.alt {
|
||||
if m.alt && m.command {
|
||||
out.actions.push(outline_others_action(view.doc, n));
|
||||
} else if m.alt {
|
||||
out.actions.push(others_action(view.doc, n, true));
|
||||
} else if m.command && n.is_layer() {
|
||||
// Ctrl/Cmd-click: Preview ↔ Outline for this layer.
|
||||
@@ -1486,6 +1503,44 @@ mod tests {
|
||||
assert!(doc.node(NodeId(sub["id"].as_u64().unwrap())).unwrap().visible);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_alt_clicking_an_eye_switches_the_other_layers_between_outline_and_preview() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap();
|
||||
run(&mut app, "file.new", json!({"width": 200, "height": 200}));
|
||||
run(&mut app, "layer.new", json!({}));
|
||||
run(&mut app, "layer.new", json!({}));
|
||||
let ctx = egui::Context::default();
|
||||
// Rows top first: Layers 3, 2, 1.
|
||||
let (circles, _) = frame(&mut app, &ctx, vec![], false);
|
||||
assert_eq!(circles.len(), 3);
|
||||
// Each layer bottom first: (visible, preview).
|
||||
let state = |app: &VectorcraftApp| -> Vec<(bool, bool)> {
|
||||
let doc = &app.session.active().unwrap().doc;
|
||||
doc.layers.iter().map(|l| (l.visible, !matches!(l.kind, NodeKind::Layer { preview: false, .. }))).collect()
|
||||
};
|
||||
let last = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.last().map(|u| u.label.clone());
|
||||
let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len();
|
||||
let eye = |i: usize| egui::pos2(12.0, circles[i].y);
|
||||
let ctrl_alt = egui::Modifiers { alt: true, command: true, ..Default::default() };
|
||||
let before = undo(&app);
|
||||
// Ctrl/Cmd+Alt-click Layer 1's eye: Layers 2 and 3 go to Outline in one step, and stay visible.
|
||||
click_with(&mut app, &ctx, eye(2), ctrl_alt);
|
||||
assert_eq!(state(&app), [(true, true), (true, false), (true, false)]);
|
||||
assert_eq!(undo(&app), before + 1);
|
||||
assert_eq!(last(&app).as_deref(), Some("Outline Others"));
|
||||
// Again: every layer previews, in one step.
|
||||
click_with(&mut app, &ctx, eye(2), ctrl_alt);
|
||||
assert_eq!(state(&app), [(true, true); 3]);
|
||||
assert_eq!(undo(&app), before + 2);
|
||||
assert_eq!(last(&app).as_deref(), Some("Preview All Layers"));
|
||||
// On a layer in Outline whose others preview: the others go to Outline and it previews.
|
||||
click_with(&mut app, &ctx, eye(0), egui::Modifiers::COMMAND);
|
||||
assert_eq!(state(&app), [(true, true), (true, true), (true, false)]);
|
||||
click_with(&mut app, &ctx, eye(0), ctrl_alt);
|
||||
assert_eq!(state(&app), [(true, false), (true, false), (true, true)]);
|
||||
}
|
||||
|
||||
/// A document with two rectangles on one layer → (app, layer, [bottom, top]).
|
||||
fn two_rects() -> (VectorcraftApp, NodeId, [NodeId; 2]) {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
|
||||
+2
-1
@@ -1352,7 +1352,8 @@ and `layerRows`, the rows highlighted in the panel.
|
||||
templates stay), `layer.collectInNew {ids?}`, `layer.releaseToLayers {id?, build?}` and
|
||||
`layer.releaseToLayersBuild` (each object of a layer or group in a sublayer of its own; Build adds up copies),
|
||||
`layer.reverse {ids?}`, `layer.template {ids?, on?}`, `layer.hideOthers` / `layer.showAll`,
|
||||
`layer.outlineOthers` / `layer.previewAll`, `layer.lockOthers` / `layer.unlockAll` (Alt-clicking an eye or a lock
|
||||
`layer.outlineOthers` / `layer.previewAll` (Ctrl/Cmd+Alt-clicking an eye runs Outline Others for the row's layer, or
|
||||
Preview All Layers when the others are in Outline already), `layer.lockOthers` / `layer.unlockAll` (Alt-clicking an eye or a lock
|
||||
runs Hide or Lock Others for the row's layer, or Show or Unlock All when the others already are), `layer.pasteRemembersLayers`,
|
||||
`object.isolate {id}` (a group, a layer or a single object; not type) / `object.exitIsolation`.
|
||||
- **Dialogs and panel state** (control channel and the app's MCP): `ui.layerOptions {ids?}` and `ui.newLayer
|
||||
|
||||
@@ -480,6 +480,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **Ruler guides as layer objects:** a guide goes on the current layer, shows, hides, locks and is deleted with it, is listed in the Layers panel (its row selects it) and moves to another layer (`guide.setLayer`, or its row dragged onto that layer's rows); guides on a hidden or locked layer can't be selected, moved or deleted, Duplicate copies a layer's guides and Merge Selected and Flatten Artwork keep them on the merged layer; guides from files saved before guides had layers go on the top visible, unlocked layer when the document opens. Not done: guides stacked among the art of their layer (they are listed above it), a guide row's own eye and lock. Lock Guides also locks the objects made into guides: they can't be selected, moved or deleted (#1543); they are drawn in the guide colour and style of Preferences, and a dragged selection snaps to ruler guides with Smart Guides on (#1583, fixes #1534). The Transform panel shows a selected ruler guide's X or Y, and typing a value moves it (#1659, part of #1597). This is not established by the documentation we could find: the public help pages on guides, rulers and the Transform, Control and Properties panels (read again on 2026-10-14) describe selecting and dragging unlocked guides and the panels' X and Y for a selection, not a guide's position in a panel, and the one public statement of it is a user's [community answer](https://community.adobe.com/questions-652/adding-a-new-custom-guide-785586), which is not documentation. It is kept as a convenience pending the owner's decision, with no parity claim and nothing counted towards a score.
|
||||
- **Layers panel:** every layer, sublayer, group and object is a clickable row at any depth: a click highlights it and makes its layer current (new art goes there), Shift-click a range, Ctrl/Cmd-click toggles. Sublayers are no longer treated as objects: clicks, marquees, Select All and the Select menu take the art inside them, and each sublayer selects in its own colour. Selection squares on rows with selected art (click selects a row's art, Shift adds or removes; dragging the square moves the selection to another row, Alt copies), the eye and lock on every row with drag-down-the-column (one undo step), Ctrl/Cmd-click an eye for per-layer Outline, Alt-click an eye or lock to hide or lock the other layers (again: show or unlock them all), triangles with Alt to open or close everything inside, drag and drop rows above, below or into layers and groups with a drop line (Alt copies) and a dimmed copy of the row under the pointer (dropped on the trash rows are deleted, on New Layer duplicated, as in Illustrator), inline rename, Delete key on highlighted rows. Buttons and the full panel menu: New Layer/Sublayer (Alt: options, Ctrl: on top), Duplicate, Delete, Options for Selection, clipping mask, isolation, Locate Object, Merge Selected, Flatten Artwork, Collect in New Layer, Release to Layers (Sequence and Build), Reverse Order, Template, Hide/Outline/Lock Others and Show/Preview/Unlock All, Paste Remembers Layers, Panel Options (row size, thumbnails per kind, Show Layers Only). Layer Options: name, colour (presets, each with a chip of its colour, or custom), Template, Lock, Show, Print, Preview (outline drawing and clicking) and Dim Images to %. Every operation is a command (`layer.move`, `layer.highlight`, `layer.merge`…) with validation against cycles and invalid nesting. A document opens with only its top-level layers open; the rows left open are saved in the native file (nothing is written for the default) and reopen that way. Only the rows scrolled into view are laid out, from a row list made once per change: a layer of 5,000 groups of 10 paths, all open, draws the panel in 0.4 ms a frame instead of about 29 s (#638).
|
||||
`object.setProps` with `visible: false` or `locked: true` deselects every selected object that is then hidden or locked, the key object included, as the eye and lock columns do.
|
||||
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.
|
||||
- **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).
|
||||
|
||||
Reference in New Issue
Block a user