Merge main into feat/scripts-api-d11-perspective-presets

This commit is contained in:
dotCooCoo committed 2026-12-04 08:02:00 -08:00
commit 8b394a116d
109 files changed
+8459 -450

No files matched your search

+16 -1
View File
@@ -853,9 +853,24 @@ fn art_remove_all(h: &Host, a: &[Data], kind: Kind) -> Answer {
let locks = d.locked_artboards();
let on_locked: Vec<u64> = ids.iter().filter(|i| locks.holds_id(**i)).map(|i| i.0).take(20).collect();
// A clipping path whose group or layer keeps other art would leave the next object clipping it.
let going: std::collections::HashSet<NodeId> = ids.iter().copied().collect();
// Deleting every path of a compound path would leave it empty, so a compound path that
// clips counts as deleted too.
let mut going: std::collections::HashSet<NodeId> = ids.iter().copied().collect();
let mut seen = std::collections::HashSet::new();
let mut emptied: Vec<NodeId> = Vec::new();
for p in ids.iter().filter_map(|i| d.parent_of(*i)) {
if going.contains(&p) || !seen.insert(p) {
continue;
}
let all_go = |n: &crate::doc::Node| n.children().is_some_and(|k| k.iter().all(|k| going.contains(&k.id)));
if d.node(p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. }) && all_go(n)) {
emptied.push(p);
}
}
going.extend(emptied.iter().copied());
let masks: Vec<u64> = ids
.iter()
.chain(&emptied)
.filter(|i| {
d.parent_of(**i).and_then(|p| d.node(p)).is_some_and(|p| {
let kids = p.children().map_or(&[][..], Vec::as_slice);
+15 -2
View File
@@ -394,6 +394,19 @@ fn paint_owner<'a>(d: &'a crate::Document, id: NodeId, n: &'a crate::doc::Node)
d.parent_of(id).and_then(|p| d.node(p)).filter(|p| matches!(p.kind, NodeKind::Compound { .. }) || p.is_compound_shape()).unwrap_or(n)
}
/// A script's new path goes on the active layer while it is shown and unlocked, or the topmost
/// shown, unlocked layer otherwise. While an opacity mask, pattern or symbol is being edited,
/// the path goes on the layer recorded by that edit mode. `create::on_layer` validates the layer.
fn new_path_layer(st: &crate::DocState) -> Option<NodeId> {
let d = &st.doc;
if let Some(layer) =
d.mask_edit.map(|e| e.layer).or_else(|| d.pattern_edit.as_ref().map(|e| e.layer)).or_else(|| d.symbol_edit.as_ref().map(|e| e.layer))
{
return Some(layer);
}
st.current_layer().filter(|l| d.is_editable(*l)).or_else(|| d.default_layer())
}
/// Runs a path creation command with its layer placement recorded.
fn drawing_normally(h: &super::Host, parent: Option<NodeId>, id: &str, params: &Value) -> std::result::Result<(Data, Value), HostError> {
let mut params = params.clone();
@@ -679,7 +692,7 @@ fn made_id(r: &(Data, Value)) -> std::result::Result<NodeId, HostError> {
fn make(h: &super::Host, doc: Doc, id: &str, params: &Value, reversed: bool) -> Answer {
let made = keeping_paint(h, || {
on_doc(h, doc.uid, true, |h| {
let parent = with_doc(h, doc, |_, st| st.current_layer().or_else(|| st.doc.default_layer()));
let parent = with_doc(h, doc, |_, st| new_path_layer(st));
let id = made_id(&drawing_normally(h, parent, id, params)?)?;
if reversed {
command(h, "path.reverse", &json!({"ids": [id.0]}))?;
@@ -845,7 +858,7 @@ fn items_add(h: &super::Host, a: &[Data]) -> Answer {
let ap = h.session.borrow().new_art();
ap.fill_paint().is_none() && ap.stroke_paint().is_none()
};
let parent = with_doc(h, doc, |_, st| st.current_layer().or_else(|| st.doc.default_layer()));
let parent = with_doc(h, doc, |_, st| new_path_layer(st));
let id = made_id(&drawing_normally(h, parent, "path.create", &json!({"d": ""}))?)?;
if unpainted {
command(h, "paint.setStroke", &json!({"none": true, "ids": [id.0], "objectOnly": true}))?;