mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 08:26:28 +00:00
Merge pull request #8074 from dotCooCoo/feat/intertwine-layers-drop
Layers: dragging objects into an Intertwine group adds them to it
This commit is contained in:
@@ -26,7 +26,9 @@ use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Document, Node, NodeId, NodeKind};
|
||||
use vectorcraft_geom::{FillRule, PathData, Point, SubPath};
|
||||
use vectorcraft_pathops as po;
|
||||
use vectorcraft_tools::intertwine::{Face, drawn_order, face_at, faces_in, faces_of, is_intertwine, nonempty, painted_areas};
|
||||
use vectorcraft_tools::intertwine::{
|
||||
Face, drawn_order, face_at, faces_in, faces_of, in_intertwine, is_intertwine, nonempty, painted_areas, refused_member,
|
||||
};
|
||||
|
||||
use super::edit::selected_roots;
|
||||
use super::pathops::Beside;
|
||||
@@ -106,17 +108,7 @@ fn refused(d: &Document, n: &Node) -> Option<&'static str> {
|
||||
if around.iter().filter(|a| **a != n.id).filter_map(|a| d.node(*a)).any(is_intertwine) {
|
||||
return Some("an object already in an Intertwine group");
|
||||
}
|
||||
let mut why = None;
|
||||
n.walk(&mut |c| {
|
||||
why = why.or(match &c.kind {
|
||||
NodeKind::Intertwine { .. } => Some("an Intertwine group"),
|
||||
NodeKind::Repeat(_) => Some("a Repeat"),
|
||||
NodeKind::Group { .. } if c.extras().graph.is_some() => Some("a graph"),
|
||||
NodeKind::Group { .. } if vectorcraft_tools::builder::is_live_paint(c) => Some("a Live Paint group"),
|
||||
_ => None,
|
||||
});
|
||||
});
|
||||
why
|
||||
refused_member(n)
|
||||
}
|
||||
|
||||
fn make(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
@@ -179,10 +171,7 @@ fn release(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
.flatten()
|
||||
.map(|c| {
|
||||
let mut c = (**c).clone();
|
||||
let mut e = c.extras_mut();
|
||||
e.intertwine = None;
|
||||
e.intertwine_tiers = Vec::new();
|
||||
drop(e);
|
||||
without_areas(&mut c);
|
||||
c
|
||||
})
|
||||
.collect();
|
||||
@@ -196,6 +185,92 @@ fn release(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
Ok(json!({ "ids": ids.iter().map(|i| i.0).collect::<Vec<_>>() }))
|
||||
}
|
||||
|
||||
// ---------- members that come and go ----------
|
||||
|
||||
/// Why `n` can't go into `parent`, an Intertwine group or a container inside one, if it can't
|
||||
/// ([`refused_member`]). Other containers take it as they did.
|
||||
pub(crate) fn refused_in(d: &Document, parent: Option<NodeId>, n: &Node) -> Option<&'static str> {
|
||||
parent.filter(|p| in_intertwine(d, *p)).and_then(|_| refused_member(n))
|
||||
}
|
||||
|
||||
/// The Intertwine groups that `ids` are members of, each once.
|
||||
pub(crate) fn groups_of(d: &Document, ids: &[NodeId]) -> Vec<NodeId> {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
ids.iter().filter_map(|i| d.parent_of(*i)).filter(|g| d.node(*g).is_some_and(is_intertwine) && seen.insert(*g)).collect()
|
||||
}
|
||||
|
||||
/// `n` without the areas it is drawn over other members in.
|
||||
fn without_areas(n: &mut Node) {
|
||||
if n.extras().intertwine.is_some() || !n.extras().intertwine_tiers.is_empty() {
|
||||
let mut e = n.extras_mut();
|
||||
e.intertwine = None;
|
||||
e.intertwine_tiers = Vec::new();
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether Intertwine group `g` has nothing of its own that changes how its members are drawn:
|
||||
/// it is visible and unlocked, with full opacity, normal blending, no appearance and no extras
|
||||
/// (an opacity mask among them).
|
||||
fn bare(g: &Node) -> bool {
|
||||
let plain = Node::new(g.id, NodeKind::Intertwine { children: vec![] });
|
||||
(g.visible, g.locked, g.opacity, g.blend, g.isolate, g.knockout, g.knockout_shape)
|
||||
== (plain.visible, plain.locked, plain.opacity, plain.blend, plain.isolate, plain.knockout, plain.knockout_shape)
|
||||
&& g.appearance == plain.appearance
|
||||
&& *g.extras() == *plain.extras()
|
||||
}
|
||||
|
||||
/// After objects moved in the Layers panel: each of `placed` (the objects now in place, each with
|
||||
/// the container it came from, None for a copy) that is not in the container it came from loses
|
||||
/// the areas it was drawn over other members in, so it joins an Intertwine group at no tier and
|
||||
/// leaves one as ordinary art. Then each of `left` (the Intertwine groups objects came from) that
|
||||
/// has fewer than two members is taken apart: its one member goes in its place without areas, and
|
||||
/// an empty one is removed. A group with one member and something of its own ([`bare`]) becomes a
|
||||
/// plain group of that member instead, keeping its id and all it has. The other members keep their
|
||||
/// areas.
|
||||
pub(crate) fn settle_members(d: &mut Document, placed: &[(NodeId, Option<NodeId>)], left: &[NodeId]) -> Result<()> {
|
||||
for (id, from) in placed {
|
||||
if d.node(*id).is_some_and(|n| n.extras().intertwine.is_some() || !n.extras().intertwine_tiers.is_empty())
|
||||
&& from.is_none_or(|f| d.parent_of(*id) != Some(f))
|
||||
{
|
||||
without_areas(d.node_mut(*id).ok_or(EngineError::NoNode(*id))?);
|
||||
}
|
||||
}
|
||||
let lone: Vec<NodeId> =
|
||||
left.iter().copied().filter(|g| d.node(*g).is_some_and(|n| is_intertwine(n) && n.children().is_none_or(|c| c.len() < 2))).collect();
|
||||
let (kept, lone): (Vec<NodeId>, Vec<NodeId>) =
|
||||
lone.into_iter().partition(|g| d.node(*g).is_some_and(|n| n.children().is_some_and(|c| c.len() == 1) && !bare(n)));
|
||||
for g in &kept {
|
||||
let n = d.node_mut(*g).ok_or(EngineError::NoNode(*g))?;
|
||||
if let NodeKind::Intertwine { children } = &mut n.kind {
|
||||
let children = std::mem::take(children)
|
||||
.into_iter()
|
||||
.map(|c| {
|
||||
let mut c = (*c).clone();
|
||||
without_areas(&mut c);
|
||||
Arc::new(c)
|
||||
})
|
||||
.collect();
|
||||
n.kind = NodeKind::Group { children, clip: false };
|
||||
}
|
||||
}
|
||||
let mut apart = Beside::replacing(d, &lone);
|
||||
for g in &lone {
|
||||
let Some(n) = d.node(*g) else { continue };
|
||||
let members: Vec<Node> = n
|
||||
.children()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|c| {
|
||||
let mut c = (**c).clone();
|
||||
without_areas(&mut c);
|
||||
c
|
||||
})
|
||||
.collect();
|
||||
apart.put(d, *g, members)?;
|
||||
}
|
||||
apart.finish(d)
|
||||
}
|
||||
|
||||
// ---------- Expand ----------
|
||||
|
||||
/// Replace Intertwine group `id` by a plain group of the art it draws
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Move Rows",
|
||||
[],
|
||||
None,
|
||||
"{ids|id, target, place?: \"above\"|\"below\"|\"inside\" (default inside), copy?: bool} drag rows in the Layers panel: above or below the target row (beside it, in its layer or group), or inside a layer or group (on top of its contents). Layers go only in layers or at the top level, objects in layers and groups; an object placed beside a top-level layer goes inside it. A row never goes into itself; a locked layer or group takes nothing. `copy` (Alt-drag) moves copies. Every selected object left hidden or locked, such as one moved into a hidden layer or group, is deselected (the key object too). One undo step → {ids}",
|
||||
"{ids|id, target, place?: \"above\"|\"below\"|\"inside\" (default inside), copy?: bool} drag rows in the Layers panel: above or below the target row (beside it, in its layer or group), or inside a layer, group or Intertwine group (on top of its contents). Layers go only in layers or at the top level, objects in layers, groups and Intertwine groups; an object placed beside a top-level layer goes inside it. An object placed in an Intertwine group becomes a member drawn in its row's order, with no arranged areas, and one placed in a group that is a member becomes part of that member; one that is or holds an Intertwine group, a Repeat, a graph or a Live Paint group is refused. A member moved out of its Intertwine group drops its arranged areas, and a group left with one member is replaced by that member, or becomes a plain group of it when the group has an opacity, blending, appearance, mask, lock or hidden state of its own (with no member, it is removed). A row never goes into itself; a locked layer or group takes nothing. `copy` (Alt-drag) moves copies. Every selected object left hidden or locked, such as one moved into a hidden layer or group, is deselected (the key object too). One undo step → {ids}",
|
||||
has_doc,
|
||||
move_rows
|
||||
),
|
||||
@@ -119,7 +119,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Reorder",
|
||||
[],
|
||||
None,
|
||||
"{id, parent?: id (null = top level), index} put a row at `index` (0 = bottom) of `parent` (layers only at the top level or in layers), deselecting every selected object left hidden or locked (the key object too)",
|
||||
"{id, parent?: id (null = top level), index} put a row at `index` (0 = bottom) of `parent` (layers only at the top level or in layers; an Intertwine group takes and gives up members as layer.move does), deselecting every selected object left hidden or locked (the key object too)",
|
||||
has_doc,
|
||||
move_node
|
||||
),
|
||||
@@ -242,14 +242,15 @@ pub(crate) fn row_roots(d: &Document, ids: &[NodeId]) -> Vec<NodeId> {
|
||||
}
|
||||
|
||||
/// Whether `parent` (None: the top level) can hold `n`: layers go at the top level or in layers,
|
||||
/// anything else in layers and groups.
|
||||
/// anything else in layers, groups and Intertwine groups (which also check what the object holds:
|
||||
/// [`super::intertwine::refused_in`]).
|
||||
pub(crate) fn accepts(d: &Document, parent: Option<NodeId>, n: &Node) -> bool {
|
||||
match parent {
|
||||
None => n.is_layer(),
|
||||
Some(p) => match d.node(p).map(|x| &x.kind) {
|
||||
Some(NodeKind::Layer { .. }) => true,
|
||||
// A ruler guide stays directly in a layer or sublayer.
|
||||
Some(NodeKind::Group { .. }) => !n.is_layer() && !n.is_ruler_guide(),
|
||||
Some(NodeKind::Group { .. } | NodeKind::Intertwine { .. }) => !n.is_layer() && !n.is_ruler_guide(),
|
||||
_ => false,
|
||||
},
|
||||
}
|
||||
@@ -791,10 +792,17 @@ fn move_rows(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let into = parent.and_then(|p| d.node(p)).map_or("the top level", |p| if p.is_layer() { "a layer" } else { p.kind_label() });
|
||||
return Err(bad(C, format!("{} can't go into {into}", n.display_name())));
|
||||
}
|
||||
if let Some(what) = nodes.iter().find_map(|n| super::intertwine::refused_in(d, parent, n)) {
|
||||
return Err(bad(C, format!("{what} can't be intertwined")));
|
||||
}
|
||||
if parent.is_some_and(|p| locked_within(d, p)) {
|
||||
return Err(EngineError::Other("the layer or group is locked".into()));
|
||||
}
|
||||
let label = if copy { "Duplicate Rows" } else { "Move Rows" };
|
||||
// Where each moved row comes from (a copy has a new id, so it comes from nowhere), and the
|
||||
// Intertwine groups it leaves.
|
||||
let from: std::collections::HashMap<NodeId, Option<NodeId>> = ids.iter().map(|i| (*i, d.parent_of(*i))).collect();
|
||||
let left = if copy { vec![] } else { super::intertwine::groups_of(d, &ids) };
|
||||
let moved = s.edit(label, |d, sel| {
|
||||
let nodes = if copy {
|
||||
let mut nodes = vec![];
|
||||
@@ -829,6 +837,8 @@ fn move_rows(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if copy {
|
||||
super::typecmd::refresh_bounds_of(d, &out);
|
||||
}
|
||||
let placed: Vec<(NodeId, Option<NodeId>)> = out.iter().map(|o| (*o, from.get(o).copied().flatten())).collect();
|
||||
super::intertwine::settle_members(d, &placed, &left)?;
|
||||
sel.prune(d);
|
||||
sel.deselect_uneditable(d);
|
||||
Ok(out)
|
||||
@@ -848,8 +858,15 @@ fn move_node(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !accepts(d, parent, n) {
|
||||
return Err(bad(C, "layers go only at the top level or in layers, objects in layers and groups"));
|
||||
}
|
||||
if let Some(what) = super::intertwine::refused_in(d, parent, n) {
|
||||
return Err(bad(C, format!("{what} can't be intertwined")));
|
||||
}
|
||||
let from = d.parent_of(id);
|
||||
let left = super::intertwine::groups_of(d, &[id]);
|
||||
s.edit("Reorder", |d, sel| {
|
||||
d.move_node(id, parent, index)?;
|
||||
super::intertwine::settle_members(d, &[(id, from)], &left)?;
|
||||
sel.prune(d);
|
||||
sel.deselect_uneditable(d);
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
@@ -80,11 +80,16 @@ pub(super) fn send_to_current_layer(s: &mut Session, _: &Value) -> Result<Value>
|
||||
if st.doc.children(Some(layer)).is_some_and(|c| c.iter().rev().filter(art).map(|n| n.id).take(ids.len()).eq(ids.iter().rev().copied())) {
|
||||
return ok();
|
||||
}
|
||||
s.edit("Send to Current Layer", |d, _| {
|
||||
let placed: Vec<(NodeId, Option<NodeId>)> = ids.iter().map(|i| (*i, st.doc.parent_of(*i))).collect();
|
||||
let left = crate::cmd::intertwine::groups_of(&st.doc, &ids);
|
||||
s.edit("Send to Current Layer", |d, sel| {
|
||||
let moved = d.remove_many(&ids)?;
|
||||
let ch = d.children_mut(Some(layer))?;
|
||||
let at = Node::guide_run_start(ch);
|
||||
ch.splice(at..at, moved);
|
||||
// Members sent out of an Intertwine group leave it as ordinary art.
|
||||
crate::cmd::intertwine::settle_members(d, &placed, &left)?;
|
||||
sel.prune(d);
|
||||
Ok(())
|
||||
})?;
|
||||
ok()
|
||||
|
||||
@@ -452,6 +452,237 @@ fn what_cannot_be_intertwined_is_refused_with_a_reason() {
|
||||
assert!(e.to_string().contains("not an Intertwine group"), "{e}");
|
||||
}
|
||||
|
||||
// ---------- members dragged in and out in the Layers panel ----------
|
||||
|
||||
/// A green rectangle (84..96 × 46..54) that crosses ring B's stroke at (90, 50) and no part of A.
|
||||
fn green_bar(s: &mut Session) -> NodeId {
|
||||
let id = id_of(&s.execute("shape.rectangle", &json!({"x": 84, "y": 46, "width": 12, "height": 8})).unwrap());
|
||||
s.execute("paint.setFill", &json!({"ids": [id.0], "color": "#00ff00"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"ids": [id.0], "none": true})).unwrap();
|
||||
id
|
||||
}
|
||||
|
||||
fn kids(s: &Session, g: NodeId) -> Vec<NodeId> {
|
||||
s.doc().unwrap().doc.node(g).and_then(vectorcraft_doc::Node::children).map(|c| c.iter().map(|n| n.id).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn rows(s: &mut Session, ids: &[NodeId], target: NodeId, place: &str, copy: bool) -> Result<Value> {
|
||||
s.execute("layer.move", &json!({"ids": ids.iter().map(|i| i.0).collect::<Vec<_>>(), "target": target.0, "place": place, "copy": copy}))
|
||||
}
|
||||
|
||||
fn undo_len(s: &Session) -> usize {
|
||||
s.doc().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn has_areas(s: &Session, id: NodeId) -> bool {
|
||||
let n = s.doc().unwrap().doc.node(id).unwrap();
|
||||
n.extras().intertwine.is_some() || !n.extras().intertwine_tiers.is_empty()
|
||||
}
|
||||
|
||||
fn parent(s: &Session, id: NodeId) -> Option<NodeId> {
|
||||
s.doc().unwrap().doc.parent_of(id)
|
||||
}
|
||||
|
||||
/// The help page: "You can drag additional objects into the group later."
|
||||
#[test]
|
||||
fn layer_move_adds_a_member_without_losing_existing_weave() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
let c = green_bar(&mut s);
|
||||
let undo = undo_len(&s);
|
||||
rows(&mut s, &[c], g, "inside", false).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, b, c], "on top of the group's objects");
|
||||
assert_eq!(undo_len(&s), undo + 1, "one undo step");
|
||||
assert!(area(&s, a).is_some(), "the arranged overlap is kept");
|
||||
let r = render(&s);
|
||||
assert!(red(&r, 50, 30) && blue(&r, 50, 70), "the rings are woven as before");
|
||||
assert!(green(&r, 90, 50), "the new member is drawn in its own order");
|
||||
// A live member: its overlap with B can be arranged.
|
||||
assert_eq!(arrange(&mut s, json!({"id": g.0, "at": [90, 50]}))["count"], 1);
|
||||
assert!(blue(&render(&s), 90, 50));
|
||||
for format in ["vectorcraft", "svg"] {
|
||||
let data = s.execute("document.export", &json!({"format": format})).unwrap()["dataBase64"].clone();
|
||||
let mut o = Session::new();
|
||||
o.execute("document.open", &json!({"name": format!("woven.{format}"), "dataBase64": data})).unwrap();
|
||||
let r = render(&o);
|
||||
assert!(red(&r, 50, 30) && blue(&r, 50, 70) && blue(&r, 90, 50), "{format}");
|
||||
}
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, b]);
|
||||
assert_eq!(parent(&s, c), parent(&s, g));
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, b, c]);
|
||||
}
|
||||
|
||||
/// An object that overlaps no member still joins the group, beside a member's row too; Alt-drag
|
||||
/// adds a copy, which starts drawn in its own order everywhere.
|
||||
#[test]
|
||||
fn layer_move_accepts_nonoverlapping_member() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
let c = id_of(&s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 5, "height": 5})).unwrap());
|
||||
rows(&mut s, &[c], a, "above", false).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, c, b], "above member A");
|
||||
let v = rows(&mut s, &[a], g, "inside", true).unwrap();
|
||||
let copy = NodeId(v["ids"][0].as_u64().unwrap());
|
||||
assert_eq!(kids(&s, g), [a, c, b, copy]);
|
||||
assert!(has_areas(&s, a) && !has_areas(&s, copy), "the copy has no arranged areas");
|
||||
let r = render(&s);
|
||||
assert!(red(&r, 50, 30) && red(&r, 50, 70), "the copy of A is drawn over B at both crossings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_move_rejects_unsupported_intertwine_members_atomically() {
|
||||
let mut s = session();
|
||||
let (a, b) = rings(&mut s);
|
||||
let p = id_of(&s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 5, "height": 5})).unwrap());
|
||||
select(&mut s, &[p]);
|
||||
let pg = id_of(&s.execute("object.group", &json!({})).unwrap());
|
||||
select(&mut s, &[a, b, pg]);
|
||||
let g = id_of(&s.execute("object.intertwine.make", &json!({})).unwrap());
|
||||
let d = id_of(&s.execute("shape.rectangle", &json!({"x": 150, "y": 150, "width": 10, "height": 10})).unwrap());
|
||||
let e = id_of(&s.execute("shape.rectangle", &json!({"x": 155, "y": 150, "width": 10, "height": 10})).unwrap());
|
||||
select(&mut s, &[d, e]);
|
||||
let g2 = id_of(&s.execute("object.intertwine.make", &json!({})).unwrap());
|
||||
let f = id_of(&s.execute("shape.rectangle", &json!({"x": 180, "y": 180, "width": 5, "height": 5})).unwrap());
|
||||
select(&mut s, &[g2, f]);
|
||||
let holder = id_of(&s.execute("object.group", &json!({})).unwrap());
|
||||
let layer = s.doc().unwrap().doc.layer_of(g).unwrap();
|
||||
let before = s.doc().unwrap().doc.clone();
|
||||
let undo = undo_len(&s);
|
||||
// No nested Intertwine groups: not as a member, inside a member's group, beside a member's
|
||||
// row, nor held in a group.
|
||||
for (ids, target, place) in [(g2, g, "inside"), (g2, pg, "inside"), (g2, a, "above"), (holder, g, "inside"), (holder, b, "below")] {
|
||||
let err = rows(&mut s, &[ids], target, place, false).unwrap_err();
|
||||
assert!(err.to_string().contains("an Intertwine group can't be intertwined"), "{place} {}: {err}", target.0);
|
||||
let err = rows(&mut s, &[ids], target, place, true).unwrap_err();
|
||||
assert!(err.to_string().contains("can't be intertwined"), "copy: {err}");
|
||||
}
|
||||
let err = s.execute("node.move", &json!({"id": holder.0, "parent": g.0, "index": 0})).unwrap_err();
|
||||
assert!(err.to_string().contains("an Intertwine group can't be intertwined"), "{err}");
|
||||
let err = rows(&mut s, &[layer], g, "inside", false).unwrap_err();
|
||||
assert!(err.to_string().contains("can't go into"), "{err}");
|
||||
assert_eq!(undo_len(&s), undo, "no undo step");
|
||||
assert!(s.doc().unwrap().doc == before, "the document is as it was");
|
||||
// A plain object goes into the group inside the Intertwine group.
|
||||
rows(&mut s, &[f], pg, "inside", false).unwrap();
|
||||
assert_eq!(kids(&s, pg), [p, f]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_move_clears_areas_when_member_leaves() {
|
||||
let mut s = session();
|
||||
let (a, b) = rings(&mut s);
|
||||
let c = green_bar(&mut s);
|
||||
select(&mut s, &[a, b, c]);
|
||||
let g = id_of(&s.execute("object.intertwine.make", &json!({})).unwrap());
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
assert!(has_areas(&s, a));
|
||||
rows(&mut s, &[a], g, "above", false).unwrap();
|
||||
assert_eq!(parent(&s, a), parent(&s, g));
|
||||
assert!(!has_areas(&s, a), "ordinary art again");
|
||||
assert_eq!(kids(&s, g), [b, c], "two members stay an Intertwine group");
|
||||
assert!(matches!(s.doc().unwrap().doc.node(g).unwrap().kind, NodeKind::Intertwine { .. }));
|
||||
let r = render(&s);
|
||||
assert!(red(&r, 50, 30) && red(&r, 50, 70) && green(&r, 90, 50), "A is above the group at both crossings");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, b, c]);
|
||||
assert!(has_areas(&s, a));
|
||||
assert!(red(&render(&s), 50, 30));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_move_between_intertwines_drops_old_areas() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
let d = id_of(&s.execute("shape.rectangle", &json!({"x": 150, "y": 150, "width": 10, "height": 10})).unwrap());
|
||||
let e = id_of(&s.execute("shape.rectangle", &json!({"x": 155, "y": 150, "width": 10, "height": 10})).unwrap());
|
||||
select(&mut s, &[d, e]);
|
||||
let g2 = id_of(&s.execute("object.intertwine.make", &json!({})).unwrap());
|
||||
rows(&mut s, &[a], g2, "inside", false).unwrap();
|
||||
assert_eq!(kids(&s, g2), [d, e, a]);
|
||||
assert!(!has_areas(&s, a), "the areas of the group it left do not come along");
|
||||
assert!(s.doc().unwrap().doc.node(g).is_none(), "the group A left has one member and is taken apart");
|
||||
assert_eq!(parent(&s, b), parent(&s, g2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_move_dissolves_a_group_left_with_one_member() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
let layer = parent(&s, g).unwrap();
|
||||
let top = id_of(&s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 5, "height": 5})).unwrap());
|
||||
select(&mut s, &[g]);
|
||||
let undo = undo_len(&s);
|
||||
rows(&mut s, &[b], top, "above", false).unwrap();
|
||||
assert_eq!(undo_len(&s), undo + 1, "one undo step");
|
||||
assert!(s.doc().unwrap().doc.node(g).is_none());
|
||||
assert_eq!(kids(&s, layer), [a, top, b], "the one member left is in the group's place");
|
||||
assert!(!has_areas(&s, a), "with no other member it has no areas");
|
||||
assert!(!s.doc().unwrap().selection.contains(g));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(kids(&s, layer), [g, top]);
|
||||
assert_eq!(kids(&s, g), [a, b]);
|
||||
let r = render(&s);
|
||||
assert!(red(&r, 50, 30) && blue(&r, 50, 70), "woven as before");
|
||||
// Both members out: the empty group is removed.
|
||||
rows(&mut s, &[a, b], g, "above", false).unwrap();
|
||||
assert!(s.doc().unwrap().doc.node(g).is_none());
|
||||
assert_eq!(kids(&s, layer), [a, b, top]);
|
||||
assert!(!has_areas(&s, a) && !has_areas(&s, b));
|
||||
}
|
||||
|
||||
/// A group left with one member that has an opacity of its own stays, as a plain group of that
|
||||
/// member, so the member is drawn as before.
|
||||
#[test]
|
||||
fn layer_move_keeps_a_lone_members_group_with_its_own_opacity() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
s.execute("object.setProps", &json!({"ids": [g.0], "opacity": 40})).unwrap();
|
||||
let layer = parent(&s, g).unwrap();
|
||||
rows(&mut s, &[b], g, "above", false).unwrap();
|
||||
assert_eq!(kids(&s, layer), [g, b]);
|
||||
assert_eq!(kids(&s, g), [a]);
|
||||
let n = s.doc().unwrap().doc.node(g).unwrap().clone();
|
||||
assert!(matches!(n.kind, NodeKind::Group { clip: false, .. }), "a plain group");
|
||||
assert!((n.opacity - 0.4).abs() < 1e-6, "{}", n.opacity);
|
||||
assert!(!has_areas(&s, a));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(matches!(s.doc().unwrap().doc.node(g).unwrap().kind, NodeKind::Intertwine { .. }));
|
||||
assert_eq!(kids(&s, g), [a, b]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn node_move_and_send_to_current_layer_clean_up_membership() {
|
||||
let mut s = session();
|
||||
let (g, a, b) = intertwined(&mut s);
|
||||
arrange(&mut s, json!({"at": [50, 30]}));
|
||||
let layer = parent(&s, g).unwrap();
|
||||
s.execute("node.move", &json!({"id": b.0, "parent": layer.0, "index": 0})).unwrap();
|
||||
assert!(s.doc().unwrap().doc.node(g).is_none());
|
||||
assert_eq!(kids(&s, layer), [b, a]);
|
||||
assert!(!has_areas(&s, a));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, b]);
|
||||
// A member sent to the current layer leaves the group the same way.
|
||||
select(&mut s, &[a]);
|
||||
s.execute("object.arrange.sendToCurrentLayer", &json!({})).unwrap();
|
||||
assert!(s.doc().unwrap().doc.node(g).is_none());
|
||||
assert_eq!(kids(&s, layer), [b, a]);
|
||||
assert!(!has_areas(&s, a));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
// node.move puts an object into an Intertwine group.
|
||||
let c = green_bar(&mut s);
|
||||
s.execute("node.move", &json!({"id": c.0, "parent": g.0, "index": 1})).unwrap();
|
||||
assert_eq!(kids(&s, g), [a, c, b]);
|
||||
}
|
||||
|
||||
// ---------- on the canvas ----------
|
||||
|
||||
fn press(s: &mut Session, pts: &[(f64, f64)], shift: bool) -> Vec<UiRequest> {
|
||||
|
||||
@@ -177,6 +177,27 @@ pub fn is_intertwine(n: &Node) -> bool {
|
||||
matches!(n.kind, NodeKind::Intertwine { .. })
|
||||
}
|
||||
|
||||
/// Why `n` can't be in an Intertwine group, if it can't: it is or holds an Intertwine group, a
|
||||
/// Repeat, a graph or a Live Paint group (the help page's limits).
|
||||
pub fn refused_member(n: &Node) -> Option<&'static str> {
|
||||
let mut why = None;
|
||||
n.walk(&mut |c| {
|
||||
why = why.or(match &c.kind {
|
||||
NodeKind::Intertwine { .. } => Some("an Intertwine group"),
|
||||
NodeKind::Repeat(_) => Some("a Repeat"),
|
||||
NodeKind::Group { .. } if c.extras().graph.is_some() => Some("a graph"),
|
||||
NodeKind::Group { .. } if crate::builder::is_live_paint(c) => Some("a Live Paint group"),
|
||||
_ => None,
|
||||
});
|
||||
});
|
||||
why
|
||||
}
|
||||
|
||||
/// Whether `id` is an Intertwine group or lies inside one.
|
||||
pub fn in_intertwine(doc: &Document, id: NodeId) -> bool {
|
||||
doc.ancestry(id).unwrap_or_default().iter().any(|a| doc.node(*a).is_some_and(is_intertwine))
|
||||
}
|
||||
|
||||
// ---------- the tool ----------
|
||||
|
||||
/// The overlap areas of an Intertwine group, kept for the document revision they were found in.
|
||||
|
||||
@@ -5,6 +5,7 @@ use super::{
|
||||
Arc, COLUMN, Color32, ColumnDrag, Document, INDENT, LayersDrag, Node, NodeId, NodeKind, Out, PanelDrag, ROW_KEYS, SQUARE_X, Sense, Stroke,
|
||||
StrokeKind, TARGET_X, Tokens, Ui, Value, View, icons, json, vec2, widgets,
|
||||
};
|
||||
use vectorcraft_tools::intertwine::{in_intertwine, refused_member};
|
||||
|
||||
/// Stable id for the layers panel's per-name UI state.
|
||||
pub(super) fn key(name: &str) -> egui::Id {
|
||||
@@ -109,15 +110,20 @@ pub(super) fn resolve_click(ui: &Ui, view: &View, list: &[Row], out: &mut Out) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Whether row `n` can take `drag` inside it.
|
||||
fn takes(n: &Node, drag: &LayersDrag, doc: &Document) -> bool {
|
||||
/// Whether row `n` can take `drag` (the rows or objects `moving`) inside it. A group or an
|
||||
/// Intertwine group takes objects; an Intertwine group, or a group in one, only objects that can
|
||||
/// be intertwined.
|
||||
fn takes(n: &Node, drag: &LayersDrag, moving: &[NodeId], doc: &Document) -> bool {
|
||||
match n.kind {
|
||||
NodeKind::Layer { .. } => true,
|
||||
NodeKind::Group { .. } => match drag {
|
||||
LayersDrag::Rows(ids) => !ids.iter().any(|i| doc.node(*i).is_some_and(Node::is_layer)),
|
||||
LayersDrag::Art => true,
|
||||
LayersDrag::Guides(_) => false,
|
||||
},
|
||||
NodeKind::Group { .. } | NodeKind::Intertwine { .. } => {
|
||||
let objects = match drag {
|
||||
LayersDrag::Rows(ids) => !ids.iter().any(|i| doc.node(*i).is_some_and(Node::is_layer)),
|
||||
LayersDrag::Art => true,
|
||||
LayersDrag::Guides(_) => false,
|
||||
};
|
||||
objects && (!in_intertwine(doc, n.id) || moving.iter().filter_map(|i| doc.node(*i)).all(|m| refused_member(m).is_none()))
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -677,7 +683,7 @@ fn drop_target(ui: &Ui, view: &View, n: &Node, r: egui::Rect, indent: f32, open:
|
||||
}
|
||||
let Some(p) = ui.input(|i| i.pointer.hover_pos()) else { return };
|
||||
let rel = (p.y - r.top()) / r.height().max(1.0);
|
||||
let inside = takes(n, &drag, doc);
|
||||
let inside = takes(n, &drag, &moving, doc);
|
||||
let place = match &*drag {
|
||||
LayersDrag::Art if inside => Place::Inside,
|
||||
LayersDrag::Art => Place::Above,
|
||||
@@ -685,6 +691,13 @@ fn drop_target(ui: &Ui, view: &View, n: &Node, r: egui::Rect, indent: f32, open:
|
||||
LayersDrag::Rows(_) if rel < 0.5 => Place::Above,
|
||||
LayersDrag::Rows(_) | LayersDrag::Guides(_) => Place::Below,
|
||||
};
|
||||
// Beside a member of an Intertwine group (or a row in one) only what can be intertwined goes.
|
||||
if place != Place::Inside
|
||||
&& doc.parent_of(n.id).is_some_and(|p| in_intertwine(doc, p))
|
||||
&& moving.iter().filter_map(|i| doc.node(*i)).any(|m| refused_member(m).is_some())
|
||||
{
|
||||
return;
|
||||
}
|
||||
let stroke = Stroke::new(2.0, view.t.accent);
|
||||
match place {
|
||||
Place::Above => {
|
||||
|
||||
@@ -1493,6 +1493,78 @@ fn dragging_rows_moves_them_into_other_layers_and_alt_copies() {
|
||||
let _ = (layer, c);
|
||||
}
|
||||
|
||||
/// An Intertwine group's row takes a dragged row inside it, as a group's does, and the object
|
||||
/// becomes a member; a row that can't be intertwined gets no inside box and goes beside it.
|
||||
#[test]
|
||||
fn dragging_a_row_into_an_intertwine_adds_a_member() {
|
||||
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();
|
||||
let rect = |app: &mut VectorcraftApp, x: f64| {
|
||||
NodeId(run(app, "shape.rectangle", json!({"x": x, "y": 0, "width": 20, "height": 20}))["id"].as_u64().unwrap())
|
||||
};
|
||||
run(&mut app, "file.new", json!({"width": 200, "height": 200}));
|
||||
let (a, b) = (rect(&mut app, 0.0), rect(&mut app, 10.0));
|
||||
run(&mut app, "select.set", json!({"ids": [a.0, b.0]}));
|
||||
let g = NodeId(run(&mut app, "object.intertwine.make", json!({}))["id"].as_u64().unwrap());
|
||||
let (d, e) = (rect(&mut app, 100.0), rect(&mut app, 110.0));
|
||||
run(&mut app, "select.set", json!({"ids": [d.0, e.0]}));
|
||||
let g2 = NodeId(run(&mut app, "object.intertwine.make", json!({}))["id"].as_u64().unwrap());
|
||||
let c = rect(&mut app, 50.0);
|
||||
run(&mut app, "select.none", json!({}));
|
||||
let doc = |app: &VectorcraftApp| app.session.active().unwrap().doc.clone();
|
||||
let ids = |nodes: Option<&Vec<Arc<Node>>>| nodes.map(|c| c.iter().map(|n| n.id).collect::<Vec<_>>()).unwrap_or_default();
|
||||
let layer = doc(&app).layers[0].id;
|
||||
let ctx = egui::Context::default();
|
||||
// Rows: Layer 1, c, the second Intertwine group, the first.
|
||||
let (circles, _) = frame(&mut app, &ctx, vec![], false);
|
||||
assert_eq!(circles.len(), 4);
|
||||
// c onto the middle of the first Intertwine group's row: into it, on top.
|
||||
drag(&mut app, &ctx, egui::pos2(150.0, circles[1].y), egui::pos2(150.0, circles[3].y + 3.0), false);
|
||||
assert_eq!(ids(doc(&app).node(g).and_then(Node::children)), [a, b, c]);
|
||||
// Rows: Layer 1, the second Intertwine group, the first (open on its moved row), c, b, a. The
|
||||
// second just below the middle of the first's row: no nested Intertwine groups, so the row has
|
||||
// no inside box and it goes below the group, beside it.
|
||||
let (circles, _) = frame(&mut app, &ctx, vec![], false);
|
||||
assert_eq!(circles.len(), 6);
|
||||
drag(&mut app, &ctx, egui::pos2(150.0, circles[1].y), egui::pos2(150.0, circles[2].y + 3.0), false);
|
||||
let now = doc(&app);
|
||||
assert_eq!(ids(now.node(layer).and_then(Node::children)), [g2, g]);
|
||||
assert_eq!(ids(now.node(g2).and_then(Node::children)), [d, e]);
|
||||
assert_eq!(ids(now.node(g).and_then(Node::children)), [a, b, c]);
|
||||
// Rows: Layer 1, the first (open), c, b, a, the second. Held over member b's row, the second
|
||||
// shows no line or box, as it can't go beside a member either; over the first's own row it
|
||||
// shows the line below it.
|
||||
let (circles, _) = frame(&mut app, &ctx, vec![], false);
|
||||
assert_eq!(circles.len(), 6);
|
||||
let accent = Tokens::get(&ctx).accent;
|
||||
let from = egui::pos2(150.0, circles[5].y);
|
||||
let marks_over = |app: &mut VectorcraftApp, to: egui::Pos2| {
|
||||
frame(app, &ctx, vec![egui::Event::PointerMoved(from)], false);
|
||||
frame(app, &ctx, vec![button(from, true)], false);
|
||||
frame(app, &ctx, vec![egui::Event::PointerMoved(from + vec2(0.0, 6.0))], false);
|
||||
frame(app, &ctx, vec![egui::Event::PointerMoved(to)], false);
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(app, ui));
|
||||
out.textures_delta.clear();
|
||||
let marks = out
|
||||
.shapes
|
||||
.iter()
|
||||
.filter(|c| match &c.shape {
|
||||
egui::Shape::LineSegment { stroke, .. } => stroke.color == accent,
|
||||
egui::Shape::Rect(r) => r.stroke.color == accent,
|
||||
_ => false,
|
||||
})
|
||||
.count();
|
||||
frame(app, &ctx, vec![egui::Event::PointerMoved(from)], false);
|
||||
frame(app, &ctx, vec![button(from, false)], false);
|
||||
frame(app, &ctx, vec![], false);
|
||||
marks
|
||||
};
|
||||
let beside_member = marks_over(&mut app, egui::pos2(150.0, circles[3].y + 3.0));
|
||||
let beside_group = marks_over(&mut app, egui::pos2(150.0, circles[1].y + 3.0));
|
||||
assert_eq!(beside_group, beside_member + 1);
|
||||
assert_eq!(ids(doc(&app).node(g).and_then(Node::children)), [a, b, c]);
|
||||
}
|
||||
|
||||
/// One headless frame of the panel on a short screen (300 × 260) with `events` (Alt held when
|
||||
/// `alt`): for every row name painted inside the list's view, its center, and the view.
|
||||
fn short_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>, alt: bool) -> (HashMap<String, egui::Pos2>, egui::Rect) {
|
||||
|
||||
+3
-2
@@ -557,8 +557,9 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
|
||||
(`object.intertwine.arrange` with `order` front, forward, backward or back;
|
||||
<https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/create-intertwined-objects.html>).
|
||||
The group renders, saves and exports through its live expansion; an object brought over another shows no hairline
|
||||
of the one below along that object's edges (#5337). Still missing: adding objects to the group by
|
||||
dragging them in the Layers panel is untested.
|
||||
of the one below along that object's edges (#5337). Objects dragged into the group in the Layers panel become
|
||||
members (`layer.move`), and a group left with one member by a drag out is replaced by that member (or a plain group
|
||||
of it, when the group has an appearance of its own).
|
||||
- **Done (from users' reports):** Object › Create Gradient Mesh on an embedded image turns it into a mesh over its
|
||||
rectangle, with the image's transform kept; each point takes the average colour and opacity of the picture around it
|
||||
(#1676). A linked image is refused, as the public documentation has it.
|
||||
|
||||
+11
-2
@@ -3053,6 +3053,14 @@ whose order changed and the id of the object now on top in each. A move that cha
|
||||
overlap offers Bring to Front, Bring Forward, Send Backward and Send to Back, which run this command for the object
|
||||
nearest to the pointer.
|
||||
|
||||
`layer.move` and `node.move` add objects to an Intertwine group: an object placed inside the group or beside one of its
|
||||
members becomes a member, drawn in its row's order, with no arranged areas; the other members keep theirs. An object
|
||||
placed in a group that is a member becomes part of that member and is drawn with it. An object that is or holds an Intertwine group, a Repeat, a graph or a Live Paint group is refused, as
|
||||
`object.intertwine.make` refuses it, in a group inside the group too, and nothing changes. A member moved out of the group (also by
|
||||
`object.arrange.sendToCurrentLayer`) drops its arranged areas. A group left with one member is replaced by that member, or
|
||||
becomes a plain group of that member when the group has an opacity, blending, appearance, opacity mask, lock or hidden
|
||||
state of its own. A group left with none is removed. Each of these happens in the move's undo step.
|
||||
|
||||
## Global Edit
|
||||
|
||||
Select › Start Global Edit is `select.globalEdit {appearance?, size?, artboards?, includeCanvas?}`. With one path,
|
||||
@@ -5370,8 +5378,9 @@ and `layerRows`, the rows highlighted in the panel.
|
||||
row highlighted, the trash button runs `edit.clear` on the selected guides and art, and guide rows dropped on the
|
||||
trash are deleted (`guide.remove {indexes}`).
|
||||
- **Dragging rows**: `layer.move {ids, target, place?: above|below|inside, copy?}` moves rows beside a row or into a
|
||||
layer or group (on top of its contents), keeping their stacking order; `copy` (Alt-drag) moves copies. Layers go
|
||||
only in layers or at the top level and objects in layers and groups (an object placed beside a top-level layer goes
|
||||
layer, group or Intertwine group (on top of its contents), keeping their stacking order; `copy` (Alt-drag) moves
|
||||
copies. Layers go only in layers or at the top level and objects in layers, groups and Intertwine groups (see
|
||||
Intertwine for the members an Intertwine group takes; an object placed beside a top-level layer goes
|
||||
inside it); a row never goes into itself or a row inside it, and a locked layer or group takes nothing. Dragging the
|
||||
selected-art square is `layer.move` with the selected objects. `node.move {id, parent?, index}` is the low-level
|
||||
form with the same nesting rules; unlike `layer.move`, it also moves a row into a locked layer or group.
|
||||
|
||||
@@ -1333,6 +1333,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
With Paste Remembers Layers on, art copied from a sublayer pastes back into that sublayer, as [the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=223) describes art going back to the layer it was copied from: in the same document while the sublayer is still there, two sublayers of the same name in different layers kept apart; in another document by the names of the sublayer and the layers around it. These rules are VectorCraft's own: a missing sublayer is made inside its layer (a missing layer on top, with the sublayer inside it), in the paste's one undo step; of layers with the same names, the topmost chain that matches the most names wins, a shown and unlocked one first; a matched layer that is hidden or locked, or inside one that is, refuses the paste, and nothing is pasted.
|
||||
The Filter button at the right of Search All keeps the rows that are of an object kind ticked under By Object (paths, shapes, text, images, effects, groups, linked files, guides) and in a state ticked under By Layer (locked, hidden), with the rows that hold them; a section with nothing ticked takes every row. The filter combines with the search, the button is lit while a filter is on, and Clear All in its popup turns the filter off (`ui.layersFilter`). The filter lasts the session.
|
||||
The panel menu's Save Selection submenu has Save Selection…, Update Selection and Edit Selection…, enabled and run as in the Select menu, and lists the document's saved selections: choosing one selects its objects again (`select.recall`).
|
||||
Objects dragged onto an Intertwine group's row, or beside one of its members' rows, become members of the group, as [the help page](https://helpx.adobe.com/illustrator/using/intertwine-objects.html) describes adding objects to the group later; Alt-drag adds copies, in one undo step either way (`layer.move`, `node.move`). An object that is or holds an Intertwine group, a Repeat, a graph or a Live Paint group gets no inside box on the group's row and no line beside a member's row, and is refused with the reason, as Make refuses it, and the document is left as it was. As VectorCraft's own rules, a new member has no arranged areas and is drawn in its row's order, the other members keep theirs, a member dragged or sent to the current layer out of the group drops its areas, and a group left with one member is replaced by that member, or becomes a plain group of it when the group has an opacity, blending, appearance, mask, lock or hidden state of its own. Tests: `layer_move_*`, `node_move_and_send_to_current_layer_clean_up_membership` (`crates/engine/src/tests/intertwine.rs`), `panels::layers::tests::dragging_a_row_into_an_intertwine_adds_a_member`.
|
||||
Deleting rows from the Layers panel (the trash button, rows dragged onto it, the panel menu's Delete Selection, and Delete or Backspace on highlighted rows) asks "Delete this layer and its artwork?" when a layer or sublayer among them holds art, hidden, locked and nested art included, and "Delete the selected items and their artwork?" when several rows are deleted; OK deletes the rows it asked about in one undo step, and Cancel keeps them (`ui.layerDelete`). The help page's shortcut list names the Layers panel as the place where deleting asks for confirmation ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). An empty layer, a layer with only guides, and groups or objects alone are deleted without a question, and `layer.delete` itself does not ask (`panels::layers` tests `deleting_a_layer_that_holds_art_asks_first`, `delete_selection_asks_only_for_layers_with_art`).
|
||||
The Command Palette lists Window › Layers › Delete Selection once, as the Layers panel's `ui.layerDelete`, so a pick asks the same question; it does not list `layer.delete`, which scripts run without a question. New Brush…, Brush Options…, Symbol Options…, Import SVG Filter… and Convert to Text are also listed once each, as the UI command that opens the dialog or file chooser (`palette` tests `a_wrapped_engine_command_is_listed_once_as_its_ui_command`, `a_pick_of_delete_selection_asks_before_deleting_a_layer_with_art`).
|
||||
No two Command Palette results for different commands, tools or plug-ins show the same name, in English or in any language with a complete menu catalog. Results that would share a name show the panel, menu or command they belong to (Export › Continue in Background and Open › Continue in Background, View › Rulers › Show Rulers and View › Perspective Grid › Show Rulers, Layers › Panel Options… and Navigator › Panel Options…, Tools › Knife and Path › Knife); results that still share one show their id after it (Ellipse (shape.ellipse) and Ellipse (addon.shapes.ellipse)), as two filter plug-ins with one name do. A query still finds a result by its name without the added path. Batch…, Flattener Preview and the four Other Library… commands are listed once each as their UI command, and Place… and Print… once each (`palette` tests `different_results_show_different_names`, `results_that_share_a_name_show_where_they_belong`, `filter_plugins_with_one_name_show_their_ids`, `each_id_is_one_result`, `a_pick_of_a_renamed_result_runs_its_own_command`).
|
||||
|
||||
Reference in New Issue
Block a user