mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 04:25:52 -05:00
Merge main into feat/scripts-text-paint
This commit is contained in:
commit
429bab3afd
29 files changed
+964
-85
No files matched your search
@@ -24,7 +24,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"New…",
|
||||
["File"],
|
||||
None,
|
||||
"{preset?: a name from file.newPresets (start from it; the other params change it), name?|title?: document name (default Untitled-N), width?: pt=612|\"210 mm\", height?: pt=792 (each more than 0 and at most 3,999,856 pt, as artboard.new takes them), units?: \"Pixels\"|\"Points\"|\"Picas\"|\"Inches\"|\"Millimeters\"|\"Centimeters\"|\"Feet\"|\"Yards\"|\"Meters\"|\"Feet & Inches\" (default: prefs unitsGeneral, as print presets; screen presets: Pixels), orientation?: \"portrait\"|\"landscape\" (swaps width and height to match), artboards?: n (1–1000), artboardLayout?: {layout?: \"gridByRow\"|\"gridByColumn\"|\"row\"|\"column\", columns?: n (default: all in one row), rows?: n (gridByColumn only, an error with another layout: that many rows, in place of columns; a preset keeps them until columns without rows or another layout is given), spacing?: pt=20, rightToLeft?: bool}, bleed?: pt|[top, bottom, left, right]|{top?, …} (0–72 pt), backgroundContents?: \"transparent\"|\"white\" (a white artboard background, not an object), colorMode?: \"rgb\"|\"cmyk\" (a CMYK document starts with CMYK swatches and stores the colours applied to it as CMYK), rasterEffectsPpi?: 72|150|300 (1–2400), previewMode?: \"default\"|\"pixel\"|\"overprint\" (overprint turns Overprint Preview on, pixel Pixel Preview in the app; default leaves both), alignNewObjectsToPixelGrid?: bool (Advanced Options › Align New Objects to Pixel Grid: paths drawn in the document are pixel-aligned; default on for the Mobile and Web presets, else off; document.setup changes it later), profile?: a category of file.newPresets|null (the New Document profile the document starts from, see file.newProfiles; default: a built-in preset's category, kept by the saved and Recent presets made from it; null or no preset: the defaults), created?: Unix seconds|null (File Info's created date; default now, recorded in the journal so a replay matches), size?: a preset's size label (a preset file.newPresets lists can be passed back; ignored)} → {index, previewMode, profile?: the profile applied, warnings?: [text] (a color profile the profile's file carries that can't be used), profileError?: {profile, reason} (its file is a link or a folder, could not be read, was larger than 64 MiB or is not a native document, or the request may not read the profiles folder, a reason that leaves out the folder's path: the document has the defaults)}; the size is remembered in file.newPresets' Recent",
|
||||
"{preset?: a name from file.newPresets (start from it; the other params change it), name?|title?: document name (default Untitled-N), width?: pt=612|\"210 mm\", height?: pt=792 (each more than 0 and at most 3,999,856 pt, as artboard.new takes them), units?: \"Pixels\"|\"Points\"|\"Picas\"|\"Inches\"|\"Millimeters\"|\"Centimeters\"|\"Feet\"|\"Yards\"|\"Meters\"|\"Feet & Inches\" (default: prefs unitsGeneral, as print presets; screen presets: Pixels), orientation?: \"portrait\"|\"landscape\" (swaps width and height to match), artboards?: n (a whole number, 1–1000), artboardLayout?: {layout?: \"gridByRow\"|\"gridByColumn\"|\"row\"|\"column\", columns?: n (a whole number, 1–1000; default: all in one row), rows?: n (a whole number, 1–1000; gridByColumn only, an error with another layout: that many rows, in place of columns; a preset keeps them until columns without rows or another layout is given), spacing?: pt=20, rightToLeft?: bool}, bleed?: pt|[top, bottom, left, right]|{top?, …} (0–72 pt), backgroundContents?: \"transparent\"|\"white\" (a white artboard background, not an object), colorMode?: \"rgb\"|\"cmyk\" (a CMYK document starts with CMYK swatches and stores the colours applied to it as CMYK), rasterEffectsPpi?: 72|150|300 (1–2400), previewMode?: \"default\"|\"pixel\"|\"overprint\" (overprint turns Overprint Preview on, pixel Pixel Preview in the app; default leaves both), alignNewObjectsToPixelGrid?: bool (Advanced Options › Align New Objects to Pixel Grid: paths drawn in the document are pixel-aligned; default on for the Mobile and Web presets, else off; document.setup changes it later), profile?: a category of file.newPresets|null (the New Document profile the document starts from, see file.newProfiles; default: a built-in preset's category, kept by the saved and Recent presets made from it; null or no preset: the defaults), created?: Unix seconds|null (File Info's created date; default now, recorded in the journal so a replay matches), size?: a preset's size label (a preset file.newPresets lists can be passed back; ignored)} → {index, previewMode, profile?: the profile applied, warnings?: [text] (a color profile the profile's file carries that can't be used), profileError?: {profile, reason} (its file is a link or a folder, could not be read, was larger than 64 MiB or is not a native document, or the request may not read the profiles folder, a reason that leaves out the folder's path: the document has the defaults)}; the size is remembered in file.newPresets' Recent",
|
||||
always,
|
||||
super::newdoc::file_new
|
||||
),
|
||||
|
||||
@@ -135,7 +135,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Placement Options",
|
||||
[],
|
||||
None,
|
||||
"{ids?: [image or placed document ids] (default: the selected ones), preserve?: transforms|bounds (default)|fileDimensions|fit|fill, align?: topLeft|top|topRight|left|center (default)|right|bottomLeft|bottom|bottomRight (where the new art sits; not for bounds), clip?: false (clip it to the old bounds where it is larger)} how a file read again (links.relink, links.update) takes each image's place: transforms keeps its scale (relative to each file's 100% size), rotation and position; bounds stretches it into the old bounds; fileDimensions puts it at 100%, unrotated; fit and fill scale it proportionally to fit inside or cover the old bounds. Without options → {placement} of the first image; else one undo step → {ids, placement}",
|
||||
"{ids?: [image or placed document ids] (default: the selected ones), preserve?: transforms|bounds (default)|fileDimensions|fit|fill, align?: topLeft|top|topRight|left|center (default)|right|bottomLeft|bottom|bottomRight (where the new art sits; not for bounds), clip?: false (clip it to the old bounds where it is larger)} how a file read again (links.relink, links.update) takes each image's place: transforms keeps its scale (relative to each file's 100% size), rotation and position; bounds stretches it into the old bounds; fileDimensions puts it at 100%, unrotated; fit and fill scale it proportionally to fit inside or cover the old bounds. Without options → {ids, placement} (the images read, and the placement of the first); else one undo step → {ids, placement}",
|
||||
has_doc,
|
||||
placement_options
|
||||
),
|
||||
@@ -3230,7 +3230,7 @@ fn placement_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let first = ids.first().and_then(|id| placement_of(&doc, *id)).unwrap_or_default();
|
||||
drop(doc);
|
||||
if preserve.is_none() && align.is_none() && clip.is_none() {
|
||||
return Ok(json!({ "placement": placement_json(first) }));
|
||||
return Ok(json!({ "ids": ids_json(&ids), "placement": placement_json(first) }));
|
||||
}
|
||||
let set = |o: &mut PlacementOptions| {
|
||||
o.preserve = preserve.unwrap_or(o.preserve);
|
||||
|
||||
@@ -299,7 +299,11 @@ impl DocSettings {
|
||||
}
|
||||
|
||||
/// These settings with `p`'s changes (the params of `file.new`) → validated.
|
||||
pub fn with_params(mut self, p: &Value, cmd: &str) -> Result<Self> {
|
||||
pub fn with_params(self, p: &Value, cmd: &str) -> Result<Self> {
|
||||
self.with_params_inner(p, cmd, false)
|
||||
}
|
||||
|
||||
fn with_params_inner(mut self, p: &Value, cmd: &str, replaying: bool) -> Result<Self> {
|
||||
if let Some(u) = p.get("units").filter(|v| !v.is_null()) {
|
||||
let u = u.as_str().unwrap_or("");
|
||||
self.units = Unit::named(u).ok_or_else(|| bad(cmd, format!("unknown units `{u}`")))?;
|
||||
@@ -329,11 +333,11 @@ impl DocSettings {
|
||||
Some(o) => return Err(bad(cmd, format!("orientation must be portrait or landscape, not `{o}`"))),
|
||||
}
|
||||
if let Some(n) = p.get("artboards").filter(|v| !v.is_null()) {
|
||||
let n = n.as_f64().filter(|n| n.is_finite()).ok_or_else(|| bad(cmd, "artboards must be a number"))?;
|
||||
self.artboards = n.round().clamp(1.0, MAX_ARTBOARDS as f64) as u32;
|
||||
self.artboards = if replaying { n.as_f64().map(|n| n.round().clamp(1.0, f64::from(MAX_ARTBOARDS)) as u32) } else { count(n) }
|
||||
.ok_or_else(|| bad(cmd, format!("artboards must be a whole number from 1 to {MAX_ARTBOARDS}")))?;
|
||||
}
|
||||
if let Some(l) = p.get("artboardLayout").filter(|v| !v.is_null()) {
|
||||
self.layout_params(l, cmd)?;
|
||||
self.layout_params(l, cmd, replaying)?;
|
||||
}
|
||||
if let Some(b) = p.get("bleed").filter(|v| !v.is_null()) {
|
||||
self.bleed = super::docsetup::bleed_param(b, self.bleed, cmd)?;
|
||||
@@ -371,7 +375,7 @@ impl DocSettings {
|
||||
}
|
||||
|
||||
/// `artboardLayout: {layout?, columns?, rows?, spacing?, rightToLeft?}` or just a layout id.
|
||||
fn layout_params(&mut self, l: &Value, cmd: &str) -> Result<()> {
|
||||
fn layout_params(&mut self, l: &Value, cmd: &str, replaying: bool) -> Result<()> {
|
||||
let bad_layout = || bad(cmd, "artboardLayout.layout must be gridByRow, gridByColumn, row or column");
|
||||
if let Some(id) = l.as_str() {
|
||||
self.layout = ArtboardLayout::parse(id).ok_or_else(bad_layout)?;
|
||||
@@ -380,25 +384,22 @@ impl DocSettings {
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let o = l.as_object().ok_or_else(|| bad(cmd, "artboardLayout must be {layout?, columns?, spacing?, rightToLeft?}"))?;
|
||||
let o = l.as_object().ok_or_else(|| bad(cmd, "artboardLayout must be {layout?, columns?, rows?, spacing?, rightToLeft?}"))?;
|
||||
for (k, v) in o {
|
||||
match k.as_str() {
|
||||
"layout" => self.layout = v.as_str().and_then(ArtboardLayout::parse).ok_or_else(bad_layout)?,
|
||||
"columns" => {
|
||||
self.columns = v
|
||||
.as_f64()
|
||||
.filter(|c| c.is_finite() && *c >= 1.0)
|
||||
.ok_or_else(|| bad(cmd, "artboardLayout.columns must be 1 or more"))?
|
||||
.round()
|
||||
.min(MAX_ARTBOARDS as f64) as u32
|
||||
self.columns =
|
||||
if replaying { v.as_f64().filter(|n| *n >= 1.0).map(|n| n.round().min(f64::from(MAX_ARTBOARDS)) as u32) } else { count(v) }
|
||||
.ok_or_else(|| bad(cmd, format!("artboardLayout.columns must be a whole number from 1 to {MAX_ARTBOARDS}")))?
|
||||
}
|
||||
"rows" => {
|
||||
self.rows = v
|
||||
.as_f64()
|
||||
.map(f64::round)
|
||||
.filter(|r| (1.0..=MAX_ARTBOARDS as f64).contains(r))
|
||||
.map(|r| r as u32)
|
||||
.ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be from 1 to {MAX_ARTBOARDS}")))?
|
||||
self.rows = if replaying {
|
||||
v.as_f64().map(f64::round).filter(|n| (1.0..=f64::from(MAX_ARTBOARDS)).contains(n)).map(|n| n as u32)
|
||||
} else {
|
||||
count(v)
|
||||
}
|
||||
.ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be a whole number from 1 to {MAX_ARTBOARDS}")))?
|
||||
}
|
||||
"spacing" => {
|
||||
self.spacing = v
|
||||
@@ -407,7 +408,7 @@ impl DocSettings {
|
||||
.ok_or_else(|| bad(cmd, format!("artboardLayout.spacing must be 0–{MAX_SPACING} pt")))?
|
||||
}
|
||||
"rightToLeft" => self.right_to_left = v.as_bool().ok_or_else(|| bad(cmd, "artboardLayout.rightToLeft must be true or false"))?,
|
||||
_ => return Err(bad(cmd, format!("unknown artboardLayout key `{k}` (layout, columns, spacing, rightToLeft)"))),
|
||||
_ => return Err(bad(cmd, format!("unknown artboardLayout key `{k}` (layout, columns, rows, spacing, rightToLeft)"))),
|
||||
}
|
||||
}
|
||||
if o.contains_key("rows") && self.layout != ArtboardLayout::GridByColumn {
|
||||
@@ -610,6 +611,12 @@ fn de_rows<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<u32, D
|
||||
Ok(f64::deserialize(d)?.round().clamp(0.0, MAX_ARTBOARDS as f64) as u32)
|
||||
}
|
||||
|
||||
/// A count `file.new` takes (artboards, columns, rows): a whole number, written `4` or `4.0`, from 1
|
||||
/// to [`MAX_ARTBOARDS`]; anything else is `None`.
|
||||
fn count(v: &Value) -> Option<u32> {
|
||||
v.as_f64().filter(|n| n.fract() == 0.0 && (1.0..=f64::from(MAX_ARTBOARDS)).contains(n)).map(|n| n as u32)
|
||||
}
|
||||
|
||||
/// A saved or Recent preset's artboard spacing, kept to 0 to [`MAX_SPACING`] points.
|
||||
fn de_spacing<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<f64, D::Error> {
|
||||
Ok(f64::deserialize(d)?.clamp(0.0, MAX_SPACING))
|
||||
@@ -871,14 +878,7 @@ pub(crate) fn file_new(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// A preset keeps its name in Recent unless its size changed (turning it doesn't count).
|
||||
let sorted = |d: &DocSettings| (d.width.min(d.height), d.width.max(d.height), d.units);
|
||||
let size = str_param(p, "preset").map(|_| sorted(&base));
|
||||
let mut params = p.clone();
|
||||
if s.replaying()
|
||||
&& let Some(rows) = params.pointer_mut("/artboardLayout/rows")
|
||||
&& let Some(value) = rows.as_f64().filter(|r| r.is_finite() && *r >= 1.0)
|
||||
{
|
||||
*rows = json!(value.round().min(MAX_ARTBOARDS as f64) as u32);
|
||||
}
|
||||
let mut settings = base.with_params(¶ms, C)?;
|
||||
let mut settings = base.with_params_inner(p, C, s.replaying())?;
|
||||
if size != Some(sorted(&settings)) {
|
||||
settings.name = "Custom".into();
|
||||
}
|
||||
@@ -963,7 +963,7 @@ fn save(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(from) => find(s, from).ok_or_else(|| bad(C, format!("no preset called `{from}` (see file.newPresets)")))?,
|
||||
None => s.default_settings(),
|
||||
};
|
||||
let mut preset = base.with_params(p, C)?;
|
||||
let mut preset = base.with_params_inner(p, C, s.replaying())?;
|
||||
preset.name = name.to_string();
|
||||
let saved = &mut s.prefs.new_doc_presets;
|
||||
match saved.iter_mut().find(|q| q.name.eq_ignore_ascii_case(name)) {
|
||||
|
||||
@@ -578,7 +578,10 @@ fn placement_options_read_set_and_round_trip() {
|
||||
let mut s = session();
|
||||
let id = place(&mut s, &pic);
|
||||
run(&mut s, "select.set", json!({"ids": [id.0]}));
|
||||
assert_eq!(run(&mut s, "links.placementOptions", json!({})), json!({"placement": {"preserve": "bounds", "align": "center", "clip": false}}));
|
||||
assert_eq!(
|
||||
run(&mut s, "links.placementOptions", json!({})),
|
||||
json!({"ids": [id.0], "placement": {"preserve": "bounds", "align": "center", "clip": false}})
|
||||
);
|
||||
let r = run(&mut s, "links.placementOptions", json!({"preserve": "fill", "align": "topRight", "clip": true}));
|
||||
assert_eq!(r, json!({"ids": [id.0], "placement": {"preserve": "fill", "align": "topRight", "clip": true}}));
|
||||
assert!(s.execute("links.placementOptions", &json!({"preserve": "stretch"})).is_err());
|
||||
|
||||
@@ -173,6 +173,79 @@ fn ppi_overprint_preview_and_bad_params() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Artboard counts, columns and rows are whole numbers in range: a fraction or a count outside
|
||||
/// 1 to 1000 is an error, not rounded or clamped to one.
|
||||
#[test]
|
||||
fn counts_that_are_not_whole_or_out_of_range_are_errors() {
|
||||
for p in [
|
||||
json!({"artboards": 2.4}),
|
||||
json!({"artboards": 0}),
|
||||
json!({"artboards": -0.5}),
|
||||
json!({"artboards": 1001}),
|
||||
json!({"artboardLayout": {"columns": 2.4}}),
|
||||
json!({"artboardLayout": {"columns": 1001}}),
|
||||
json!({"artboardLayout": {"layout": "gridByColumn", "rows": 2.4}}),
|
||||
json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0.6}}),
|
||||
json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1000.4}}),
|
||||
] {
|
||||
let mut s = Session::new();
|
||||
assert!(s.execute("file.new", &p).is_err(), "{p}");
|
||||
assert!(s.active().is_none(), "{p}: no document on an error");
|
||||
}
|
||||
let s = new_doc(json!({"artboards": 6.0, "artboardLayout": {"layout": "gridByColumn", "rows": 2.0}}));
|
||||
assert_eq!(s.doc().unwrap().doc.artboards.len(), 6, "a whole number written 6.0 is a count");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replaying_a_journal_rounds_an_older_artboard_count() {
|
||||
let mut recorded = new_doc(json!({"artboards": 2}));
|
||||
recorded.journal.last_mut().unwrap().1["artboards"] = json!(2.4);
|
||||
let mut s = Session::new();
|
||||
for (id, p) in &recorded.journal {
|
||||
s.replay(id, p).unwrap();
|
||||
}
|
||||
assert_eq!(boards(&s), boards(&recorded));
|
||||
assert_eq!(boards(&s).len(), 2);
|
||||
assert!(s.execute("file.new", &json!({"artboards": 2.4})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replayed_counts_keep_their_rounding_and_range_rules() {
|
||||
for (key, value, expected) in [
|
||||
("artboards", 0.0, 1),
|
||||
("artboards", 1001.0, 1000),
|
||||
("columns", 2.4, 2),
|
||||
("columns", 1001.0, 1000),
|
||||
("rows", 2.4, 2),
|
||||
("rows", 0.6, 1),
|
||||
("rows", 1000.4, 1000),
|
||||
] {
|
||||
let mut p = json!({"width": 10, "height": 10, "artboards": 4,
|
||||
"artboardLayout": {"layout": "gridByColumn", "spacing": 0}});
|
||||
if key == "artboards" {
|
||||
p[key] = json!(value);
|
||||
} else {
|
||||
p["artboardLayout"][key] = json!(value);
|
||||
}
|
||||
let mut s = Session::new();
|
||||
s.replay("file.new", &p).unwrap();
|
||||
assert!(s.execute("file.new", &p).is_err(), "{p}");
|
||||
if key == "artboards" {
|
||||
p[key] = json!(expected);
|
||||
} else {
|
||||
p["artboardLayout"][key] = json!(expected);
|
||||
}
|
||||
assert_eq!(boards(&s), boards(&new_doc(p)));
|
||||
}
|
||||
for layout in [json!({"columns": 0.6}), json!({"rows": 0.4}), json!({"rows": 1000.6})] {
|
||||
let mut p = json!({"artboardLayout": layout});
|
||||
p["artboardLayout"]["layout"] = json!("gridByColumn");
|
||||
let mut s = Session::new();
|
||||
assert!(s.replay("file.new", &p).is_err(), "{p}");
|
||||
assert!(s.active().is_none(), "{p}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn categories_list_generated_presets_with_neutral_names() {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -1144,7 +1144,7 @@ fn file_new_takes_the_rows_of_a_grid_by_column() {
|
||||
let (plain, spaced) = (plain.with_params(&to_row, "file.new").unwrap(), spaced.with_params(&to_row, "file.new").unwrap());
|
||||
assert_eq!(plain.grid_columns(), spaced.grid_columns());
|
||||
let e = s.execute("file.new", &json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0}})).unwrap_err().to_string();
|
||||
assert!(e.contains("rows must be from 1 to 1000"), "{e}");
|
||||
assert!(e.contains("rows must be a whole number from 1 to 1000"), "{e}");
|
||||
for layout in ["gridByRow", "row", "column"] {
|
||||
let e = s.execute("file.new", &json!({"artboardLayout": {"layout": layout, "rows": 2}})).unwrap_err().to_string();
|
||||
assert!(e.contains("rows needs the gridByColumn layout"), "{layout}: {e}");
|
||||
@@ -1153,12 +1153,12 @@ fn file_new_takes_the_rows_of_a_grid_by_column() {
|
||||
|
||||
#[test]
|
||||
fn file_new_replays_legacy_fractional_and_large_rows() {
|
||||
for (rows, rounded) in [(3.6, 4), (1001.2, 1000)] {
|
||||
for (rows, rounded) in [(3.6, 4), (1000.4, 1000)] {
|
||||
let params = json!({"width": 100, "height": 100, "artboards": 5, "artboardLayout": {"layout": "gridByColumn", "rows": rows}});
|
||||
let mut s = Session::new();
|
||||
// A direct call rounds a fraction and refuses a count past 1000; a replay keeps it to 1000.
|
||||
// A direct call refuses a fraction; a replay rounds it to a count from 1 to 1000.
|
||||
let direct = Session::new().execute("file.new", ¶ms);
|
||||
assert_eq!(direct.is_err(), rows > 1000.0, "{rows}: {direct:?}");
|
||||
assert!(direct.is_err(), "{rows}: {direct:?}");
|
||||
s.replay("file.new", ¶ms).unwrap();
|
||||
let mut expected = Session::new();
|
||||
let mut params = params;
|
||||
|
||||
@@ -378,7 +378,7 @@ impl<'a> Reader<'a> {
|
||||
}
|
||||
}
|
||||
"Xw" => self.gs.hidden = Self::nums(&vals).last() == Some(&1.0),
|
||||
"A" => self.gs.locked = Self::nums(&vals).last() == Some(&1.0),
|
||||
"A" => self.gs.locked = Self::nums(&vals).last().is_some_and(|&v| v != 0.0),
|
||||
"XW" => self.state_marker(&vals, hidden),
|
||||
// Gradients.
|
||||
"Bd" => self.gradient_def = GradientDef::begin(&vals, &mut self.names),
|
||||
@@ -978,9 +978,14 @@ impl<'a> Reader<'a> {
|
||||
let Some(mut look) = f.children.pop() else { return };
|
||||
let state = (look.opacity, look.blend, look.isolate, look.knockout, look.knockout_shape);
|
||||
(look.opacity, look.blend, look.isolate, look.knockout, look.knockout_shape) = (1.0, BlendMode::Normal, false, Knockout::Neutral, false);
|
||||
let (visible, locked) = (object.visible, object.locked);
|
||||
(object.opacity, object.blend, object.isolate, object.knockout_shape) = (1.0, BlendMode::Normal, false, false);
|
||||
object.visible = true;
|
||||
object.locked = false;
|
||||
let mut group = Node::group(self.doc.alloc_id(), vec![Arc::new(look), Arc::new(object)]);
|
||||
(group.opacity, group.blend, group.isolate, group.knockout, group.knockout_shape) = state;
|
||||
group.visible = visible;
|
||||
group.locked = locked;
|
||||
self.text_looks.insert(group.id);
|
||||
if let Some(f) = self.frames.last_mut() {
|
||||
f.children.push(group);
|
||||
|
||||
@@ -12411,6 +12411,35 @@ fn type_with_an_art_brush_keeps_its_drawn_look() {
|
||||
assert_eq!(brushed, 0, "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// A hidden styled text wrapper group inherits hidden state while its inner text and look retain
|
||||
/// intrinsic visibility, so showing the group makes the inner artwork visible.
|
||||
#[test]
|
||||
fn hidden_styled_text_look_wrapper_group_showing_reveals_inner_text() {
|
||||
let own: String = "/AI11Text :\n0 /FreeUndo ,\n0 /FrameIndex ,\n7 /StoryIndex ,\n;\n".lines().map(|l| format!("%_{l}\n")).collect();
|
||||
let object = format!(
|
||||
"0 Ae\nu\n/AI11Text :\n1 /FreeUndo ,\n0 /FrameIndex ,\n0 /StoryIndex ,\n;\n{RED}{}f\nU\n0 0.5 0 0 0 Xy\n0 0 Xd\n6 () XW\n1 Xw\n1 A\n{own}1 (Inked) XW\n0 Xw\n0 A\n",
|
||||
rect_path(20.0, 18.0, 100.0, 62.0)
|
||||
);
|
||||
let def = format!("{}{}", lopsided_art("Ribbon art"), plugin_object(ART_BRUSH, "Ribbon", RIBBON));
|
||||
let r = read_ok(&format!("{def}{}{}", art_style("Ribbon", 1.0, &STRETCHED, ""), layer(&object)));
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "wrapper group created: {a:#?}");
|
||||
let group = &a[0];
|
||||
assert!(!group.visible, "wrapper group must inherit hidden state");
|
||||
assert!(group.locked, "wrapper group must inherit locked state");
|
||||
let children = group.children().expect("must be a group of look and text");
|
||||
assert_eq!(children.len(), 2);
|
||||
for child in children {
|
||||
assert!(child.visible, "inner child must retain intrinsic visibility");
|
||||
assert!(!child.locked, "inner child must not be locked");
|
||||
}
|
||||
let mut shown = (**group).clone();
|
||||
shown.visible = true;
|
||||
for child in shown.children().unwrap() {
|
||||
assert!(child.visible, "inner child remains visible when parent group is shown");
|
||||
}
|
||||
}
|
||||
|
||||
/// Each copy a Scatter brush places is its section's art turned over before the copy's rotation:
|
||||
/// the side of the section with y up goes down the page with the rotation at 0° to the page, and
|
||||
/// to the right of the path's direction when the rotation follows the path. A rotation turns the
|
||||
|
||||
@@ -43,7 +43,7 @@ use super::ate::{Story, Texts};
|
||||
|
||||
mod build;
|
||||
pub(super) mod compare;
|
||||
mod layers;
|
||||
pub(super) mod layers;
|
||||
mod plan;
|
||||
mod slots;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::compare::{
|
||||
};
|
||||
use super::plan::{made_only, make_slots, plan, readable_all};
|
||||
use super::slots::{
|
||||
ART_LEFT_OUT, Content, DREW_DIFFERENTLY, Filled, MAX_PAIRS, MAX_SLOTS, MAX_TEXT, OUTLINE_REACH, SlotInfo, TEXT_LEFT_OUT, TYPE_LEFT_OUT,
|
||||
collect_slots, extent, few, fill_slots, letters, text_objects, words,
|
||||
ART_LEFT_OUT, Content, DREW_DIFFERENTLY, Filled, MAX_PAIRS, MAX_PLACE_PAIRS, MAX_SLOTS, MAX_TEXT, OUTLINE_REACH, SlotInfo, TEXT_LEFT_OUT,
|
||||
TYPE_LEFT_OUT, collect_slots, extent, few, fill_slots, letters, text_objects, words,
|
||||
};
|
||||
use super::{
|
||||
Affine, Arc, BTreeSet, Document, Node, NodeId, NodeKind, PathData, Rect, Scaling, Story, Structure, Texts, Unit, VariableKind, Vec2, ai,
|
||||
@@ -1514,9 +1514,11 @@ fn slot_content(
|
||||
}
|
||||
// The page's type is matched with every text object whose type isn't made, and weighed against
|
||||
// where every made one draws: that has its limits (the slots of type that looks draw are within
|
||||
// them, see `build_from`).
|
||||
// them, see `build_from`). A file whose text document makes all but a few text objects is
|
||||
// matched only with those few (#9176).
|
||||
let open = infos.iter().zip(&made).filter(|(i, m)| i.look.is_none() && m.is_none()).count();
|
||||
if open > MAX_SLOTS || infos.len().saturating_mul(pages[0].len()) > MAX_PAIRS {
|
||||
let shown = pages[0].len();
|
||||
if open > MAX_SLOTS || open.saturating_mul(shown) > MAX_PAIRS || infos.len().saturating_mul(shown) > MAX_PLACE_PAIRS {
|
||||
return Err("it has too many text objects".into());
|
||||
}
|
||||
let mut content = plan(infos, stories, made, template, to_doc, pages, notes);
|
||||
|
||||
@@ -172,13 +172,19 @@ pub fn layered_ai_from(
|
||||
}
|
||||
// The PDF part, its pages placed and named as the editing data's artboards are, when the
|
||||
// layers can't be used (`why`).
|
||||
let from_pdf_part = |mut visible: Document, mut warnings: Vec<String>, why: &str| {
|
||||
let from_pdf_part = |mut visible: Document, mut warnings: Vec<String>, why: &str, layers_read: bool| {
|
||||
let mut read = ai::Names::new(names);
|
||||
let mut board_names = ai::Names::new(names);
|
||||
let (boards, active) = ai::artboards(&data, &mut board_names);
|
||||
if place_pages(&boards, active, &mut visible, unit) {
|
||||
read.absorb(board_names);
|
||||
}
|
||||
// The editing data's locks, read again only here (and only when its layers could be read):
|
||||
// the layers read below are spent on the editable document, which most files open as.
|
||||
if let Some(layers) = layers_read.then(|| ai::read_over_page(&data, false, names).ok()).flatten() {
|
||||
let private_layers: Vec<LockTree> = layers.doc.layers.iter().map(|l| LockTree::from_node(l)).collect();
|
||||
apply_private_layer_locks(&mut visible.layers, &private_layers);
|
||||
}
|
||||
let have = visible.patterns.len();
|
||||
let own_palette = use_palette(&data, &mut visible, &mut read);
|
||||
use_brushes(&data, &mut visible, have, &mut warnings, &mut read);
|
||||
@@ -199,7 +205,9 @@ pub fn layered_ai_from(
|
||||
// The envelopes of type the page doesn't hold against layers that don't draw as it, and how many
|
||||
// envelopes of type the layers had.
|
||||
let (mut free, mut count) = (None, 0);
|
||||
let built = structure.unwrap_or_else(|| read().map(Box::new)).and_then(|structure| {
|
||||
let structure = structure.unwrap_or_else(|| read().map(Box::new));
|
||||
let layers_read = structure.is_ok();
|
||||
let built = structure.and_then(|structure| {
|
||||
count = structure.warped_type.envelope_count();
|
||||
build_weighing(*structure, &data, Some(&visible), Page::Artboard, outlined, trust, unit, &mut free, &mut text)
|
||||
});
|
||||
@@ -230,7 +238,7 @@ pub fn layered_ai_from(
|
||||
all.extend(notes.into_iter().filter(|n| !all.contains(n)).collect::<Vec<_>>());
|
||||
(done, all, true)
|
||||
}
|
||||
Err(why) => from_pdf_part(visible, warnings, &why),
|
||||
Err(why) => from_pdf_part(visible, warnings, &why, layers_read),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +253,78 @@ fn holds_type_envelope(nodes: &[Arc<Node>]) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// Lightweight lock metadata snapshot of a node hierarchy, preserving names and lock states
|
||||
/// without holding `Arc<Node>` references to the artwork tree.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub(crate) struct LockTree {
|
||||
pub name: Option<String>,
|
||||
pub locked: bool,
|
||||
pub children: Vec<LockTree>,
|
||||
}
|
||||
|
||||
impl LockTree {
|
||||
pub fn from_node(node: &Node) -> Self {
|
||||
Self {
|
||||
name: node.name.clone(),
|
||||
locked: node.locked,
|
||||
children: node.children().map(|kids| kids.iter().map(|k| Self::from_node(k)).collect()).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Match unique names between visible nodes and private lock trees.
|
||||
fn unique_name_pairs<T: std::ops::Deref<Target = Node>>(vis_nodes: &[T], priv_nodes: &[LockTree]) -> Vec<(usize, usize)> {
|
||||
let mut priv_names: std::collections::HashMap<&str, (usize, usize)> = std::collections::HashMap::new();
|
||||
for (i, p) in priv_nodes.iter().enumerate() {
|
||||
if let Some(name) = p.name.as_deref() {
|
||||
let entry = priv_names.entry(name).or_insert((0, i));
|
||||
entry.0 += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let mut vis_names: std::collections::HashMap<&str, usize> = std::collections::HashMap::new();
|
||||
for v in vis_nodes.iter() {
|
||||
if let Some(name) = v.name.as_deref() {
|
||||
*vis_names.entry(name).or_insert(0) += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let mut pairs = Vec::new();
|
||||
for (v_idx, vis) in vis_nodes.iter().enumerate() {
|
||||
if let Some(name) = vis.name.as_deref()
|
||||
&& vis_names.get(name).copied() == Some(1)
|
||||
&& let Some(&(1, p_idx)) = priv_names.get(name)
|
||||
{
|
||||
pairs.push((v_idx, p_idx));
|
||||
}
|
||||
}
|
||||
pairs
|
||||
}
|
||||
|
||||
/// Apply lock states from private data layers to visible PDF layers.
|
||||
pub(crate) fn apply_private_layer_locks(visible_layers: &mut [Arc<Node>], private_layers: &[LockTree]) {
|
||||
// Only layers that are evidently the same one (a name unique on both sides) take its locks: one
|
||||
// layer each is no evidence, since a PDF part without layers comes in on a layer named for its
|
||||
// page, and the editing data it was set aside for may not be the art on it.
|
||||
for (v_idx, p_idx) in unique_name_pairs(visible_layers, private_layers) {
|
||||
apply_node_locks(Arc::make_mut(&mut visible_layers[v_idx]), &private_layers[p_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_node_locks(vis: &mut Node, priv_: &LockTree) {
|
||||
if priv_.locked {
|
||||
vis.locked = true;
|
||||
}
|
||||
let Some(vis_kids) = vis.children_mut() else { return };
|
||||
if vis_kids.is_empty() || priv_.children.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (v_idx, p_idx) in unique_name_pairs(vis_kids.as_slice(), &priv_.children) {
|
||||
apply_node_locks(Arc::make_mut(&mut vis_kids[v_idx]), &priv_.children[p_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/// The `.ai` whose editing copy is `private` (as [`layered_ai`] takes it) from its layers alone,
|
||||
/// without its PDF part, whose pages (each its trim box in points, width and height) are `pages`
|
||||
/// and are in units of `unit` points (its first page's `UserUnit`): the document and the notes of
|
||||
|
||||
@@ -50,6 +50,11 @@ pub(crate) const MAX_TEXT: usize = 16 << 20;
|
||||
/// kept as outlines and a node of the page's type.
|
||||
pub(super) const MAX_PAIRS: usize = 4_000_000;
|
||||
|
||||
/// Most pairs of a text object whose type is made and a piece of the page's type weighed only by
|
||||
/// where each lies (a box against a box, far cheaper than matching the page's type with a text
|
||||
/// object's words, which [`MAX_PAIRS`] limits).
|
||||
pub(super) const MAX_PLACE_PAIRS: usize = 4 * MAX_PAIRS;
|
||||
|
||||
/// `names` for a note: the first few, and how many more.
|
||||
pub(super) fn few(names: BTreeSet<String>) -> String {
|
||||
const SHOWN: usize = 5;
|
||||
@@ -307,12 +312,6 @@ pub(super) fn fill_slots(
|
||||
.iter()
|
||||
.map(|p| {
|
||||
let mut p = reid(doc, p);
|
||||
if !visible {
|
||||
Arc::make_mut(&mut p).visible = false;
|
||||
}
|
||||
if locked {
|
||||
Arc::make_mut(&mut p).locked = true;
|
||||
}
|
||||
if let Some(name) = name.filter(|_| matches!(p.kind, NodeKind::Text(_))) {
|
||||
Arc::make_mut(&mut p).name = Some(name.clone());
|
||||
}
|
||||
@@ -321,6 +320,7 @@ pub(super) fn fill_slots(
|
||||
.collect();
|
||||
let mut text = vec![];
|
||||
text_ids(&parts, &mut text);
|
||||
let mut wrapped = false;
|
||||
// When the page draws each of them with no transparency, the slot's, or the slot's
|
||||
// combined with that of the objects around it, the slot's takes its place: on the one
|
||||
// part, or on a group of several when the slot has transparency. Otherwise every part
|
||||
@@ -342,9 +342,12 @@ pub(super) fn fill_slots(
|
||||
(p.opacity, p.blend, p.isolate, p.knockout, p.knockout_shape) = (state.0, state.1, state.2, state.3, shape);
|
||||
} else if transparent {
|
||||
let mut group = Node::group(doc.alloc_id(), std::mem::take(&mut parts));
|
||||
group.visible = visible;
|
||||
group.locked = locked;
|
||||
(group.opacity, group.blend, group.isolate, group.knockout, group.knockout_shape) =
|
||||
(state.0, state.1, state.2, state.3, shape);
|
||||
parts.push(Arc::new(group));
|
||||
wrapped = true;
|
||||
}
|
||||
}
|
||||
// A wrap object stays one: the page's parts of it in a group, when there are several.
|
||||
@@ -352,12 +355,25 @@ pub(super) fn fill_slots(
|
||||
if parts.len() > 1 {
|
||||
let mut group = Node::group(doc.alloc_id(), std::mem::take(&mut parts));
|
||||
group.visible = visible;
|
||||
group.locked = locked;
|
||||
parts.push(Arc::new(group));
|
||||
wrapped = true;
|
||||
}
|
||||
for p in &mut parts {
|
||||
Arc::make_mut(p).extras_mut().wrap = wrap;
|
||||
}
|
||||
}
|
||||
if !wrapped {
|
||||
for p in &mut parts {
|
||||
let p = Arc::make_mut(p);
|
||||
if !visible {
|
||||
p.visible = false;
|
||||
}
|
||||
if locked {
|
||||
p.locked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// One text object with the slot's appearance and transparency keeps its graphic style.
|
||||
if let ([p], Some(a)) = (parts.as_mut_slice(), styled.as_ref())
|
||||
&& linked.is_some()
|
||||
@@ -751,4 +767,93 @@ mod tests {
|
||||
let inner = nodes[0].children().unwrap()[0].id;
|
||||
assert_eq!(filled.get(&slot), Some(&Filled { text: vec![inner], objects: vec![nodes[0].id, nodes[1].id] }));
|
||||
}
|
||||
|
||||
/// A transparent slot wrapper group inherits hidden state while its inner children retain
|
||||
/// their original visibility (both visible and intrinsically hidden), so showing the group
|
||||
/// reveals only the intrinsically visible artwork.
|
||||
#[test]
|
||||
fn transparent_slot_wrapper_group_showing_reveals_inner_art() {
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut slot = Node::group(doc.alloc_id(), vec![]);
|
||||
slot.name = Some("\u{0}text0:0".into());
|
||||
slot.visible = false;
|
||||
slot.locked = true;
|
||||
slot.opacity = 0.5; // see_through(n) == true -> transparent == true
|
||||
|
||||
let part = |doc: &mut Document, x: f64, visible: bool| {
|
||||
let t = vectorcraft_doc::TextObject::point(Point::new(x, 50.0), "Part", Default::default());
|
||||
let mut node = Node::new(doc.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
node.visible = visible;
|
||||
Arc::new(node)
|
||||
};
|
||||
// Page run contains both a visible child and an intrinsically hidden child:
|
||||
let parts = vec![part(&mut doc, 10.0, true), part(&mut doc, 60.0, false)];
|
||||
let mut nodes = vec![Arc::new(slot)];
|
||||
let mut content = vec![Content::Page(parts)].into_iter();
|
||||
let (mut empty, mut made, mut filled) = (0, vec![], std::collections::HashMap::new());
|
||||
fill_slots(&mut doc, &mut nodes, &mut content, &Default::default(), &mut empty, &mut made, &mut vec![], &mut filled);
|
||||
|
||||
assert_eq!(nodes.len(), 1);
|
||||
let group = &nodes[0];
|
||||
assert!(!group.visible, "wrapper group must inherit hidden state (visible = false)");
|
||||
assert!(group.locked, "wrapper group must inherit locked state");
|
||||
|
||||
let children = group.children().expect("must be a group of parts");
|
||||
assert_eq!(children.len(), 2);
|
||||
assert!(children[0].visible, "intrinsically visible child retains visible = true");
|
||||
assert!(!children[0].locked, "inner child must not be locked");
|
||||
assert!(!children[1].visible, "intrinsically hidden child retains visible = false");
|
||||
assert!(!children[1].locked, "inner child must not be locked");
|
||||
|
||||
// Showing the group updates only the group node's visible field:
|
||||
let mut shown = (**group).clone();
|
||||
shown.visible = true;
|
||||
assert!(shown.visible);
|
||||
let shown_children = shown.children().unwrap();
|
||||
assert!(shown_children[0].visible, "intrinsically visible child is visible when parent group is shown");
|
||||
assert!(!shown_children[1].visible, "intrinsically hidden child remains hidden when parent group is shown");
|
||||
}
|
||||
|
||||
/// A wrap slot wrapper group inherits hidden and locked states without overwriting children's
|
||||
/// original visibility flags when a page run contains both visible and intrinsically hidden children.
|
||||
#[test]
|
||||
fn wrap_slot_wrapper_group_preserves_child_visibility_and_showing_reveals_art() {
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut slot = Node::group(doc.alloc_id(), vec![]);
|
||||
slot.name = Some("\u{0}text0:0".into());
|
||||
slot.visible = false;
|
||||
slot.locked = true;
|
||||
let wrap = vectorcraft_doc::TextWrap { offset: 3.0, invert: true };
|
||||
slot.extras_mut().wrap = Some(wrap);
|
||||
|
||||
let part = |doc: &mut Document, x: f64, visible: bool| {
|
||||
let t = vectorcraft_doc::TextObject::point(Point::new(x, 50.0), "Part", Default::default());
|
||||
let mut node = Node::new(doc.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
node.visible = visible;
|
||||
Arc::new(node)
|
||||
};
|
||||
let parts = vec![part(&mut doc, 10.0, true), part(&mut doc, 60.0, false)];
|
||||
let mut nodes = vec![Arc::new(slot)];
|
||||
let mut content = vec![Content::Page(parts)].into_iter();
|
||||
let (mut empty, mut made, mut filled) = (0, vec![], std::collections::HashMap::new());
|
||||
fill_slots(&mut doc, &mut nodes, &mut content, &Default::default(), &mut empty, &mut made, &mut vec![], &mut filled);
|
||||
|
||||
assert_eq!(nodes.len(), 1);
|
||||
let group = &nodes[0];
|
||||
assert!(!group.visible, "wrap wrapper group must inherit hidden state");
|
||||
assert!(group.locked, "wrap wrapper group must inherit locked state");
|
||||
|
||||
let children = group.children().expect("must be a group of parts");
|
||||
assert_eq!(children.len(), 2);
|
||||
assert!(children[0].visible, "intrinsically visible child retains visible = true");
|
||||
assert!(!children[0].locked, "inner child must not be locked");
|
||||
assert!(!children[1].visible, "intrinsically hidden child retains visible = false");
|
||||
assert!(!children[1].locked, "inner child must not be locked");
|
||||
|
||||
let mut shown = (**group).clone();
|
||||
shown.visible = true;
|
||||
let shown_children = shown.children().unwrap();
|
||||
assert!(shown_children[0].visible, "intrinsically visible child is visible when parent group is shown");
|
||||
assert!(!shown_children[1].visible, "intrinsically hidden child remains hidden when parent group is shown");
|
||||
}
|
||||
}
|
||||
@@ -8664,6 +8664,361 @@ fn trusted_editing_data_keeps_an_artboard_taller_than_its_pdf_page() {
|
||||
assert!(!read, "the uncapped dimension must still match: {w:?}");
|
||||
}
|
||||
|
||||
/// A locked layer as the format writes it.
|
||||
fn locked_layer(name: &str, body: &str) -> String {
|
||||
format!("%AI5_BeginLayer\n1 1 0 1 0 0 1 0 79 128 255 0 50 0 Lb\n({name}) Ln\n{body}\nLB\n%AI5_EndLayer--\n")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_locked_layers_and_groups_preserve_locks() {
|
||||
let art_locked_group = format!("1 A\nu\n{}\nU\n0 A", square(10, 10));
|
||||
let plain_layer = layer("Unlocked Layer", true, &square(0, 0));
|
||||
let locked_l = locked_layer("Locked Layer", &art_locked_group);
|
||||
let n = native(&format!("{plain_layer}{locked_l}"));
|
||||
let file = private(&n);
|
||||
let (doc, notes, read) = crate::layered_ai(&file, pdf_part(10.0, 86.0), vec![], false, true, 1.0);
|
||||
assert!(read, "{notes:?}");
|
||||
let unlocked = doc.layers.iter().find(|l| l.name.as_deref() == Some("Unlocked Layer")).unwrap();
|
||||
let locked = doc.layers.iter().find(|l| l.name.as_deref() == Some("Locked Layer")).unwrap();
|
||||
assert!(!unlocked.locked, "Unlocked Layer is not locked");
|
||||
assert!(locked.locked, "Locked Layer retains locked == true");
|
||||
let group = locked.children().and_then(|c| c.iter().find(|n| matches!(n.kind, NodeKind::Group { .. })));
|
||||
assert!(group.is_some_and(|g| g.locked), "group with 1 A retains locked == true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_fallback_to_pdf_part_preserves_private_stream_layer_and_group_locks() {
|
||||
use std::sync::Arc;
|
||||
let art_locked_group = format!("1 A\nu\n{}\nU\n%_/ArtDictionary :\n%_(Locked Subgroup) /String (AIArtName) ,\n%_;\n0 A", square(10, 10));
|
||||
let locked_l = locked_layer("Map Layer", &art_locked_group);
|
||||
let n = native(&locked_l);
|
||||
let file = private(&n);
|
||||
let mut pdf = Document::new(100.0, 100.0);
|
||||
pdf.layers.clear();
|
||||
let mut vis_layer = Node::layer(pdf.alloc_id(), "Map Layer", LayerColor::Preset(0));
|
||||
vis_layer.locked = false;
|
||||
let mut vis_group = Node::group(pdf.alloc_id(), vec![]);
|
||||
vis_group.name = Some("Locked Subgroup".to_string());
|
||||
vis_group.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_group));
|
||||
}
|
||||
pdf.layers.push(Arc::new(vis_layer));
|
||||
|
||||
let layers = crate::AiLayers::decode(&file);
|
||||
let (doc, _notes, read) = crate::layered_ai_from(layers, pdf, vec![], false, false, 1.0, crate::NameEncoding::default());
|
||||
assert!(!read, "falls back to PDF part");
|
||||
let map_layer = doc.layers.iter().find(|l| l.name.as_deref() == Some("Map Layer")).unwrap();
|
||||
assert!(map_layer.locked, "Map Layer preserved locked == true from private stream metadata");
|
||||
let subgroup = map_layer.children().and_then(|c| c.iter().find(|n| n.name.as_deref() == Some("Locked Subgroup"))).unwrap();
|
||||
assert!(subgroup.locked, "Locked Subgroup preserved locked == true from private stream metadata");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_duplicate_group_names_under_different_layers_preserve_individual_lock_states() {
|
||||
use std::sync::Arc;
|
||||
let art_locked_group = format!("1 A\nu\n{}\nU\n%_/ArtDictionary :\n%_(SharedGroup) /String (AIArtName) ,\n%_;\n0 A", square(10, 10));
|
||||
let art_unlocked_group = format!("0 A\nu\n{}\nU\n%_/ArtDictionary :\n%_(SharedGroup) /String (AIArtName) ,\n%_;\n0 A", square(10, 10));
|
||||
let layer_a = layer("Layer A", true, &art_locked_group);
|
||||
let layer_b = layer("Layer B", true, &art_unlocked_group);
|
||||
let n = native(&format!("{layer_a}{layer_b}"));
|
||||
let file = private(&n);
|
||||
|
||||
let mut pdf = Document::new(100.0, 100.0);
|
||||
pdf.layers.clear();
|
||||
let mut vis_a = Node::layer(pdf.alloc_id(), "Layer A", LayerColor::Preset(0));
|
||||
let mut vis_grp_a = Node::group(pdf.alloc_id(), vec![]);
|
||||
vis_grp_a.name = Some("SharedGroup".to_string());
|
||||
vis_grp_a.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_a.kind {
|
||||
children.push(Arc::new(vis_grp_a));
|
||||
}
|
||||
|
||||
let mut vis_b = Node::layer(pdf.alloc_id(), "Layer B", LayerColor::Preset(1));
|
||||
let mut vis_grp_b = Node::group(pdf.alloc_id(), vec![]);
|
||||
vis_grp_b.name = Some("SharedGroup".to_string());
|
||||
vis_grp_b.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_b.kind {
|
||||
children.push(Arc::new(vis_grp_b));
|
||||
}
|
||||
pdf.layers.push(Arc::new(vis_a));
|
||||
pdf.layers.push(Arc::new(vis_b));
|
||||
|
||||
let layers = crate::AiLayers::decode(&file);
|
||||
let (doc, _notes, read) = crate::layered_ai_from(layers, pdf, vec![], false, false, 1.0, crate::NameEncoding::default());
|
||||
assert!(!read, "falls back to PDF part");
|
||||
|
||||
let l_a = doc.layers.iter().find(|l| l.name.as_deref() == Some("Layer A")).unwrap();
|
||||
let l_b = doc.layers.iter().find(|l| l.name.as_deref() == Some("Layer B")).unwrap();
|
||||
let grp_a = l_a.children().and_then(|c| c.iter().find(|n| n.name.as_deref() == Some("SharedGroup"))).unwrap();
|
||||
let grp_b = l_b.children().and_then(|c| c.iter().find(|n| n.name.as_deref() == Some("SharedGroup"))).unwrap();
|
||||
|
||||
assert!(grp_a.locked, "Layer A's SharedGroup is locked");
|
||||
assert!(!grp_b.locked, "Layer B's SharedGroup remains unlocked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_reordered_mixed_named_and_unnamed_children_preserve_locks() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut priv_layer = Node::layer(doc.alloc_id(), "Map", LayerColor::Preset(0));
|
||||
let mut priv_unnamed = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_unnamed.locked = false;
|
||||
let mut priv_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_roads.name = Some("Roads".to_string());
|
||||
priv_roads.locked = true;
|
||||
if let NodeKind::Layer { children, .. } = &mut priv_layer.kind {
|
||||
children.push(Arc::new(priv_unnamed));
|
||||
children.push(Arc::new(priv_roads));
|
||||
}
|
||||
|
||||
let mut vis_layer = Node::layer(doc.alloc_id(), "Map", LayerColor::Preset(0));
|
||||
let mut vis_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_roads.name = Some("Roads".to_string());
|
||||
vis_roads.locked = false;
|
||||
let mut vis_unnamed = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_unnamed.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_roads));
|
||||
children.push(Arc::new(vis_unnamed));
|
||||
}
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_layer)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_layer)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
let roads = visible_layers[0].children().unwrap()[0].clone();
|
||||
let unnamed = visible_layers[0].children().unwrap()[1].clone();
|
||||
assert_eq!(roads.name.as_deref(), Some("Roads"));
|
||||
assert!(roads.locked, "Roads matched by unique name and preserved locked == true");
|
||||
assert!(!unnamed.locked, "unnamed child matched to unlocked private child");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_reordered_three_children_roads_triangle_circle_preserve_locks() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
// Private children: [Roads (unlocked), locked triangle (unnamed), unlocked circle (unnamed)]
|
||||
let mut priv_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut priv_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_roads.name = Some("Roads".to_string());
|
||||
priv_roads.locked = false;
|
||||
let mut priv_triangle = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_triangle.locked = true;
|
||||
let mut priv_circle = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_circle.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut priv_layer.kind {
|
||||
children.push(Arc::new(priv_roads));
|
||||
children.push(Arc::new(priv_triangle));
|
||||
children.push(Arc::new(priv_circle));
|
||||
}
|
||||
|
||||
// Visible children: [triangle (unnamed), circle (unnamed), Roads]
|
||||
let mut vis_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut vis_triangle = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_triangle.locked = false;
|
||||
let mut vis_circle = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_circle.locked = false;
|
||||
let mut vis_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_roads.name = Some("Roads".to_string());
|
||||
vis_roads.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_triangle));
|
||||
children.push(Arc::new(vis_circle));
|
||||
children.push(Arc::new(vis_roads));
|
||||
}
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_layer)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_layer)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
let vis_tri = visible_layers[0].children().unwrap()[0].clone();
|
||||
let vis_circ = visible_layers[0].children().unwrap()[1].clone();
|
||||
let vis_rd = visible_layers[0].children().unwrap()[2].clone();
|
||||
|
||||
assert!(!vis_tri.locked, "unnamed triangle does not pair blindly with private triangle");
|
||||
assert!(!vis_circ.locked, "unnamed circle remains unlocked");
|
||||
assert!(!vis_rd.locked, "Roads matched to unlocked private Roads by unique name");
|
||||
}
|
||||
|
||||
/// The PDF part's one layer, named for its page because the PDF part has no layers, isn't the
|
||||
/// editing data's one layer: nothing says the art on it is that layer's, so the layer's lock and
|
||||
/// those of what it holds stay out of it.
|
||||
#[test]
|
||||
fn ai_fallback_with_generated_page_name_does_not_take_private_layer_lock() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut priv_layer = Node::layer(doc.alloc_id(), "Map", LayerColor::Preset(0));
|
||||
priv_layer.locked = true;
|
||||
let mut priv_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_roads.name = Some("Roads".to_string());
|
||||
priv_roads.locked = true;
|
||||
if let NodeKind::Layer { children, .. } = &mut priv_layer.kind {
|
||||
children.push(Arc::new(priv_roads));
|
||||
}
|
||||
let mut vis_layer = Node::layer(doc.alloc_id(), "Page 1", LayerColor::Preset(0));
|
||||
let mut vis_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_roads.name = Some("Roads".to_string());
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_roads));
|
||||
}
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_layer)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_layer)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
assert!(!visible_layers[0].locked, "the page's layer doesn't take the editing data's layer lock");
|
||||
assert!(!visible_layers[0].children().unwrap()[0].locked, "nor does what it holds");
|
||||
}
|
||||
|
||||
/// An editing copy that doesn't fit the PDF part (a stale copy of another page size) is set aside,
|
||||
/// and the PDF part without layers comes in on one layer named for its page: the editing copy's
|
||||
/// locked layer doesn't lock that art, which nothing ties to it.
|
||||
#[test]
|
||||
fn a_stale_editing_copy_does_not_lock_the_pdf_parts_page_layer() {
|
||||
let art = native(&locked_layer("Map", &square(10, 10)));
|
||||
let mut page = Document::new(300.0, 300.0);
|
||||
std::sync::Arc::make_mut(&mut page.layers[0]).name = Some("Page 1".into());
|
||||
let (d, w, read) = crate::layered_ai(&private(&art), page, vec![], false, false, 1.0);
|
||||
assert!(!read, "the editing copy of another page size is set aside: {w:?}");
|
||||
assert_eq!(names(&d), ["Page 1"], "{w:?}");
|
||||
assert!(!d.layers[0].locked, "the page's layer isn't locked: {w:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_unnamed_visible_child_does_not_pair_with_private_node() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut priv_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut priv_unnamed = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_unnamed.locked = false;
|
||||
let mut priv_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_roads.name = Some("Roads".to_string());
|
||||
priv_roads.locked = true;
|
||||
if let NodeKind::Layer { children, .. } = &mut priv_layer.kind {
|
||||
children.push(Arc::new(priv_unnamed));
|
||||
children.push(Arc::new(priv_roads));
|
||||
}
|
||||
|
||||
let mut vis_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut vis_first = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_first.locked = false;
|
||||
let mut vis_second = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_second.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_first));
|
||||
children.push(Arc::new(vis_second));
|
||||
}
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_layer)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_layer)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
let first = visible_layers[0].children().unwrap()[0].clone();
|
||||
let second = visible_layers[0].children().unwrap()[1].clone();
|
||||
assert!(!first.locked, "first unnamed visible group is unlocked");
|
||||
assert!(!second.locked, "second unnamed visible group does not pair positionally with locked Roads group");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_multi_page_unlayered_pdf_does_not_blindly_pair_with_private_layers() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut priv_1 = Node::layer(doc.alloc_id(), "Layer 1", LayerColor::Preset(0));
|
||||
priv_1.locked = true;
|
||||
let mut priv_2 = Node::layer(doc.alloc_id(), "Layer 2", LayerColor::Preset(0));
|
||||
priv_2.locked = false;
|
||||
|
||||
let vis_1 = Node::layer(doc.alloc_id(), "Page 1", LayerColor::Preset(0));
|
||||
let vis_2 = Node::layer(doc.alloc_id(), "Page 2", LayerColor::Preset(0));
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_1), Arc::new(vis_2)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_1), super::native::layers::LockTree::from_node(&priv_2)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
assert!(!visible_layers[0].locked, "Page 1 does not pair with private Layer 1");
|
||||
assert!(!visible_layers[1].locked, "Page 2 does not pair with private Layer 2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_duplicate_visible_name_does_not_lock_multiple_from_single_private_node() {
|
||||
use std::sync::Arc;
|
||||
let mut doc = Document::new(100.0, 100.0);
|
||||
let mut priv_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut priv_roads = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_roads.name = Some("Roads".to_string());
|
||||
priv_roads.locked = true;
|
||||
let mut priv_buildings = Node::group(doc.alloc_id(), vec![]);
|
||||
priv_buildings.name = Some("Buildings".to_string());
|
||||
priv_buildings.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut priv_layer.kind {
|
||||
children.push(Arc::new(priv_roads));
|
||||
children.push(Arc::new(priv_buildings));
|
||||
}
|
||||
|
||||
let mut vis_layer = Node::layer(doc.alloc_id(), "Layer", LayerColor::Preset(0));
|
||||
let mut vis_roads1 = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_roads1.name = Some("Roads".to_string());
|
||||
vis_roads1.locked = false;
|
||||
let mut vis_roads2 = Node::group(doc.alloc_id(), vec![]);
|
||||
vis_roads2.name = Some("Roads".to_string());
|
||||
vis_roads2.locked = false;
|
||||
if let NodeKind::Layer { children, .. } = &mut vis_layer.kind {
|
||||
children.push(Arc::new(vis_roads1));
|
||||
children.push(Arc::new(vis_roads2));
|
||||
}
|
||||
|
||||
let mut visible_layers = vec![Arc::new(vis_layer)];
|
||||
let private_layers = vec![super::native::layers::LockTree::from_node(&priv_layer)];
|
||||
super::native::layers::apply_private_layer_locks(&mut visible_layers, &private_layers);
|
||||
|
||||
let r1 = visible_layers[0].children().unwrap()[0].clone();
|
||||
let r2 = visible_layers[0].children().unwrap()[1].clone();
|
||||
assert!(!r1.locked, "ambiguous duplicate visible name does not receive private lock");
|
||||
assert!(!r2.locked, "second duplicate visible name remains unlocked");
|
||||
}
|
||||
|
||||
/// #9176: a file with more text objects than the page's type can be matched with each, all but one
|
||||
/// of them made from its text document, opens with its layers, and what is locked in it stays
|
||||
/// locked. Only the one text object whose type isn't made is matched with the page's type; the made
|
||||
/// ones are weighed by where they lie. (Our own minimized copy of the reported file's structure:
|
||||
/// about two thousand text objects whose type the text document makes, a few it can't, and as many
|
||||
/// pieces of type on the page, with locked groups.)
|
||||
#[test]
|
||||
fn a_file_with_many_made_text_objects_and_one_unread_keeps_its_layers_and_locks() {
|
||||
// Every text object against every piece of the page's type is past `MAX_PAIRS` (four million).
|
||||
let many = 2050;
|
||||
let doc =
|
||||
last_frame_unread(&text_document(&[("Hi there\r", 0, (8200.0, 8180.0), (0.0, 0.0), 0.0), ("Odd\r", 0, (8200.0, 8160.0), (0.0, 0.0), 0.0)]));
|
||||
let locked_group = format!("1 A\nu\n{}\nU\n0 A\n", square(10, 10));
|
||||
let art = native_with_text(&layer("Map", true, &(locked_group + &text_object(0).repeat(many) + &text_object(1))), &doc);
|
||||
// The PDF part: the square, the made type where the text document puts it, once per text object,
|
||||
// and as many small pieces of type apart from one another, which the one text object whose type
|
||||
// isn't made takes.
|
||||
let mut page = pdf_part(10.0, 86.0);
|
||||
let layer_id = page.layers[0].id;
|
||||
let put = |page: &mut Document, at: (f64, f64), text: &str, size: f64| {
|
||||
let style = vectorcraft_doc::CharStyle { size, ..Default::default() };
|
||||
let text = vectorcraft_doc::TextObject::point(vectorcraft_geom::Point::new(at.0, at.1), text, style);
|
||||
let id = page.alloc_id();
|
||||
let end = page.layers[0].children().map_or(0, |c| c.len());
|
||||
page.insert(Some(layer_id), end, Node::new(id, NodeKind::Text(Box::new(text)))).unwrap();
|
||||
};
|
||||
for _ in 0..many {
|
||||
put(&mut page, (58.5, 38.5), "Hi there", 14.0);
|
||||
}
|
||||
for k in 0..many {
|
||||
// Down each column, so that no two pieces painted one after the other are on one line.
|
||||
put(&mut page, (1.0 + (k / 46) as f64 * 2.1, 1.0 + (k % 46) as f64 * 2.1), "o", 1.0);
|
||||
}
|
||||
let (d, w, read) = crate::layered_ai(&private(&art), page, vec![], false, false, 1.0);
|
||||
assert!(read, "{w:?}");
|
||||
assert_eq!(names(&d), ["Map"], "{w:?}");
|
||||
let group = d.layers[0].children().and_then(|c| c.iter().find(|n| matches!(n.kind, NodeKind::Group { .. })));
|
||||
assert!(group.is_some_and(|g| g.locked), "the group locked in the file stays locked: {w:?}");
|
||||
assert!(all_texts(&d).iter().filter(|t| *t == "Hi there").count() >= many, "{w:?}");
|
||||
}
|
||||
|
||||
/// The page's "2014" drawn as one piece 20 points across the art, and two text objects "20" and
|
||||
/// "14" anchored at `twenty` and `fourteen`, set in the bundled Source Sans 3 at 14 points (a digit
|
||||
/// 6.958 points wide) so that where they draw doesn't hang on the fonts installed.
|
||||
|
||||
@@ -1274,7 +1274,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. Unchanged OK adds no undo step; edits run layer.setProps in one undo step. Existing names are preserved unless Name is edited or explicitly set; for several rows it sends only the fields set in the dialog",
|
||||
"{ids?|id?} open Layer Options for Layers panel rows (default: the highlighted rows, else the current layer), filled in from the first: dialog `ui.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. Unchanged OK adds no undo step; edits run layer.setProps in one undo step. Existing names are preserved unless Name is edited or explicitly set; for several rows it sends only the fields set in the dialog",
|
||||
),
|
||||
(
|
||||
"ui.layerDelete",
|
||||
@@ -1292,7 +1292,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.newLayer",
|
||||
"New Layer Options…",
|
||||
"Cmd+Alt+L",
|
||||
"{sublayer?: bool} open Layer Options for a new layer (or a sublayer of the current layer), named and coloured as it would be: dialog `layerOptions` with mode new|newSublayer; OK runs layer.new or layer.newSublayer with the fields. In isolation mode, a layer that would be outside the isolated art is an error and nothing opens; OK checks again, and with isolation mode started since, it returns the same error and makes no layer",
|
||||
"{sublayer?: bool} open Layer Options for a new layer (or a sublayer of the current layer), named and coloured as it would be: dialog `ui.layerOptions` with mode new|newSublayer; OK runs layer.new or layer.newSublayer with the fields. In isolation mode, a layer that would be outside the isolated art is an error and nothing opens; OK checks again, and with isolation mode started since, it returns the same error and makes no layer",
|
||||
),
|
||||
(
|
||||
"ui.newArtboard",
|
||||
@@ -1310,13 +1310,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.layersPanelOptions",
|
||||
"Panel Options…",
|
||||
"",
|
||||
"{} open the Layers panel's Panel Options: dialog `layersPanelOptions`, fields layersOnly, locateSelected (Locate Selected Objects, off by default: when the last selected object changes outside the panel, 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, 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; a change made during a drag is located when the drag ends), rowSize (small|medium|large|other), otherSize (12–100 pt), thumbLayers, thumbGroups, thumbObjects; OK applies them (kept with the UI state)",
|
||||
"{} open the Layers panel's Panel Options: dialog `ui.layersPanelOptions`, fields layersOnly, locateSelected (Locate Selected Objects, off by default: when the last selected object changes outside the panel, 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, 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; a change made during a drag is located when the drag ends), rowSize (small|medium|large|other), otherSize (12–100 pt), thumbLayers, thumbGroups, thumbObjects; OK applies them (kept with the UI state)",
|
||||
),
|
||||
(
|
||||
"ui.navigatorPanelOptions",
|
||||
"Panel Options…",
|
||||
"",
|
||||
"{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them), viewArtboardContentsOnly?: bool (View Artboard Contents Only in the panel menu, on by default and for UI state saved without it: the thumbnail fits the artboards and draws only the art inside them, cut at each artboard's edges; off, it also shows the art on the pasteboard)} set the Navigator panel's options, the color its view box is drawn in, solid dashes and artboard contents only (kept with the UI state) → {color, solidDashes, viewArtboardContentsOnly}; with none, open its Panel Options (dialog `navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing",
|
||||
"{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them), viewArtboardContentsOnly?: bool (View Artboard Contents Only in the panel menu, on by default and for UI state saved without it: the thumbnail fits the artboards and draws only the art inside them, cut at each artboard's edges; off, it also shows the art on the pasteboard)} set the Navigator panel's options, the color its view box is drawn in, solid dashes and artboard contents only (kept with the UI state) → {color, solidDashes, viewArtboardContentsOnly}; with none, open its Panel Options (dialog `ui.navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing",
|
||||
),
|
||||
(
|
||||
"ui.attributesPanelOptions",
|
||||
@@ -1645,7 +1645,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.rasterEffectsSettingsDialog",
|
||||
"Document Raster Effects Settings Dialog",
|
||||
"",
|
||||
"{} open Document Raster Effects Settings (dialog `rasterEffectsSettings`: the document.rasterEffectsSettings fields); OK runs it. The menu item opens it too",
|
||||
"{} open Document Raster Effects Settings (dialog `document.rasterEffectsSettings`: the document.rasterEffectsSettings fields); OK runs it. The menu item opens it too",
|
||||
),
|
||||
(
|
||||
"ui.effectGalleryDialog",
|
||||
@@ -1663,7 +1663,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.pdfPresetDialog",
|
||||
"PDF Preset",
|
||||
"",
|
||||
"{name?: a saved preset to edit | preset?: the preset a new one starts from (default VectorCraft Default)} open the preset editor (dialog `pdfPreset`: the Save PDF dialog's option fields plus `name` and `description`); OK runs pdf.preset.save and returns to PDF Presets",
|
||||
"{name?: a saved preset to edit | preset?: the preset a new one starts from (default VectorCraft Default)} open the preset editor (dialog `pdf-export`: the Save PDF dialog's option fields plus `name` and `description`); OK runs pdf.preset.save and returns to PDF Presets",
|
||||
),
|
||||
("file.openRecent11", "Open Recent File 11", "", "{}"),
|
||||
("file.openRecent12", "Open Recent File 12", "", "{}"),
|
||||
@@ -1918,7 +1918,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.actionSet.reset",
|
||||
"Reset Actions",
|
||||
"",
|
||||
"{mode?: \"replace\" | \"append\"} Reset Actions. replace (the default) replaces every set in the Actions panel with a new copy of the built-in Default Actions set, makes it current and selected, clears the panel's selected action and step and its expanded actions, and closes an open Set Options, New Action, Batch or step dialog that names a set; when the panel already shows only the built-in set as it comes in that state, nothing changes, the sets keep their ids and changed is false. append adds a new copy of the built-in set after the sets there are, with the next free number when its name is in use (Default Actions 2), and keeps the current set and the selection. Omitted params count as {}. Params of another type, another key, another mode, or a reset while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Reset Actions asks first (dialog `resetActions`): OK runs this with replace, Append with append → {changed, mode, set: the first built-in set's index}",
|
||||
"{mode?: \"replace\" | \"append\"} Reset Actions. replace (the default) replaces every set in the Actions panel with a new copy of the built-in Default Actions set, makes it current and selected, clears the panel's selected action and step and its expanded actions, and closes an open Set Options, New Action, Batch or step dialog that names a set; when the panel already shows only the built-in set as it comes in that state, nothing changes, the sets keep their ids and changed is false. append adds a new copy of the built-in set after the sets there are, with the next free number when its name is in use (Default Actions 2), and keeps the current set and the selection. Omitted params count as {}. Params of another type, another key, another mode, or a reset while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Reset Actions asks first (dialog `actionsQuestion`): OK runs this with replace, Append with append → {changed, mode, set: the first built-in set's index}",
|
||||
),
|
||||
(
|
||||
"ui.actionSet.clear",
|
||||
@@ -1949,7 +1949,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"file.saveForWeb",
|
||||
"Save for Web (Legacy)…",
|
||||
"Cmd+Alt+Shift+S",
|
||||
"{} open Save for Web (dialog `saveForWeb`: fields = the webExport.settings settings, `preset` loads a preset, __view: original|optimized|2up|4up, __zoom, __kbps; Save… remembers the settings and writes the files, Done only remembers them); with settings = document.exportForWeb, written to path, else a picked file (the web downloads the files) → {path, files, bytes}",
|
||||
"{} open Save for Web (dialog `save-for-web`: fields = the webExport.settings settings, `preset` loads a preset, __view: original|optimized|2up|4up, __zoom, __kbps; Save… remembers the settings and writes the files, Done only remembers them); with settings = document.exportForWeb, written to path, else a picked file (the web downloads the files) → {path, files, bytes}",
|
||||
),
|
||||
(
|
||||
"file.saveForWeb.browser",
|
||||
|
||||
@@ -1185,4 +1185,20 @@ mod tests {
|
||||
ok(&mut app);
|
||||
assert_eq!(app.session.active().unwrap().doc.node(layer).unwrap().display_name(), "Fresh Draft");
|
||||
}
|
||||
|
||||
/// `ui.layerOptions` and `ui.newLayer` open the dialog whose `key` their params text names, as `ui.inspect`
|
||||
/// lists it.
|
||||
#[test]
|
||||
fn layer_options_params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
for (command, arguments) in [("ui.layerOptions", json!({})), ("ui.newLayer", json!({})), ("ui.newLayer", json!({"sublayer": true}))] {
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == command).expect("registered").3;
|
||||
let mut app = app();
|
||||
app.run(command, arguments).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, KEY);
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{command} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,4 +127,17 @@ mod tests {
|
||||
let old: crate::UiState = serde_json::from_value(json!({"layers_panel": {"layersOnly": true}})).unwrap();
|
||||
assert!(old.layers_panel.layers_only && !old.layers_panel.locate_selected, "options saved without it");
|
||||
}
|
||||
|
||||
/// `ui.layersPanelOptions` opens the dialog whose `key` its params text names, as `ui.inspect` lists it.
|
||||
#[test]
|
||||
fn panel_options_params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == CMD).expect("registered").3;
|
||||
let mut app = app();
|
||||
app.run(CMD, json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, CMD);
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{CMD} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
}
|
||||
@@ -208,4 +208,18 @@ mod tests {
|
||||
let old: crate::UiState = serde_json::from_value(json!({})).unwrap();
|
||||
assert_eq!(old.navigator_panel, crate::panels::navigator::PanelOptions::default(), "UI state saved without them");
|
||||
}
|
||||
|
||||
/// `ui.navigatorPanelOptions` without options opens the dialog whose `key` its params text names, as `ui.inspect`
|
||||
/// lists it.
|
||||
#[test]
|
||||
fn panel_options_params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == KEY).expect("registered").3;
|
||||
let mut app = app();
|
||||
app.run(KEY, json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, KEY);
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{KEY} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
}
|
||||
@@ -1317,7 +1317,8 @@ mod tests {
|
||||
let mut app = app();
|
||||
open(&mut app);
|
||||
set(&app, "artboards", json!(5)).unwrap();
|
||||
set(&app, "artboardLayout", json!({"layout": "gridByColumn", "rows": 3.6, "spacing": 10})).unwrap();
|
||||
assert!(set(&app, "artboardLayout", json!({"layout": "gridByColumn", "rows": 3.6, "spacing": 10})).is_err(), "a fraction is refused");
|
||||
set(&app, "artboardLayout", json!({"layout": "gridByColumn", "rows": 4, "spacing": 10})).unwrap();
|
||||
assert_eq!(fields(&app)["artboardLayout"]["rows"], json!(4));
|
||||
create(&mut app);
|
||||
let st = app.session.active().unwrap();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//! clipped to them.
|
||||
//!
|
||||
//! Fields: `preserve` (transforms|bounds|fileDimensions|fit|fill), `align` (0-8, row by row from
|
||||
//! the top left) and `clip`. OK runs `links.placementOptions` with them and `ids` (null: the
|
||||
//! selected images): one undo step.
|
||||
//! the top left) and `clip`. OK runs `links.placementOptions` with them and the `ids` the dialog
|
||||
//! opened on (by default the images selected then): one undo step.
|
||||
|
||||
// PLAN: assumed craft_ui paths for ParamDialog, ParamKind, Param, DialogFields, FieldValue, HostedParamDialog and Label.
|
||||
use craft::ui::contract::Bind;
|
||||
@@ -48,6 +48,8 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
let source = (active.uid, active.reverts);
|
||||
let ids = p.get("ids").cloned().unwrap_or(Value::Null);
|
||||
let r = app.session.execute(CMD, &json!({ "ids": ids })).map_err(|e| e.to_string())?;
|
||||
// The images read: OK applies to these, whatever is selected by then.
|
||||
let ids = r["ids"].clone();
|
||||
let placement = &r["placement"];
|
||||
let align = ALIGN.iter().position(|a| Some(*a) == placement["align"].as_str()).unwrap_or(CENTRE);
|
||||
let mut fields = DialogFields::from_pairs([
|
||||
|
||||
@@ -217,4 +217,18 @@ mod tests {
|
||||
assert!(matches!(n.kind, vectorcraft_doc::NodeKind::Path { .. }), "the rectangle stays a path");
|
||||
assert_eq!(st.history.undo.len(), steps + 1);
|
||||
}
|
||||
|
||||
/// `ui.rasterEffectsSettingsDialog` opens the dialog whose `key` its params text names, as `ui.inspect` lists it.
|
||||
#[test]
|
||||
fn settings_dialog_params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
const COMMAND: &str = "ui.rasterEffectsSettingsDialog";
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == COMMAND).expect("registered").3;
|
||||
let mut app = app();
|
||||
app.run(COMMAND, json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, super::CMD);
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{COMMAND} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
}
|
||||
@@ -898,3 +898,18 @@ fn optimize_to_file_size_starts_at_the_size_of_the_art_as_it_is_now() {
|
||||
let bytes = fields(&app)["optimizeK"].as_f64().unwrap() * 1024.0;
|
||||
assert!(bytes >= after as f64 && bytes < after as f64 + 2.0, "{bytes} for {after}");
|
||||
}
|
||||
|
||||
/// `file.saveForWeb` without settings opens the dialog whose `key` its params text names, as `ui.inspect` lists it.
|
||||
#[test]
|
||||
fn params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
const COMMAND: &str = "file.saveForWeb";
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == COMMAND).expect("registered").3;
|
||||
let dir = vectorcraft_testkit::temp_dir("sfw-dialog-key");
|
||||
let (mut app, _) = app(&dir, false);
|
||||
app.run(COMMAND, json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, "save-for-web");
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{COMMAND} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
@@ -1175,3 +1175,17 @@ fn the_range_bleed_and_subset_fields_are_named() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `ui.pdfPresetDialog` opens the preset editor whose `key` its params text names, as `ui.inspect` lists it.
|
||||
#[test]
|
||||
fn preset_editor_params_text_names_the_dialog_key_ui_inspect_lists() {
|
||||
const COMMAND: &str = "ui.pdfPresetDialog";
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == COMMAND).expect("registered").3;
|
||||
let (mut app, _) = app();
|
||||
app.run(COMMAND, json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, PDF_KEY);
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "{COMMAND} opens `{key}`, which its params text does not name");
|
||||
}
|
||||
@@ -1275,7 +1275,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. Unchanged OK adds no undo step; edits run layer.setProps in one undo step. Existing names are preserved unless Name is edited or explicitly set; for several rows it sends only the fields set in the dialog",
|
||||
"{ids?|id?} open Layer Options for Layers panel rows (default: the highlighted rows, else the current layer), filled in from the first: dialog `ui.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. Unchanged OK adds no undo step; edits run layer.setProps in one undo step. Existing names are preserved unless Name is edited or explicitly set; for several rows it sends only the fields set in the dialog",
|
||||
),
|
||||
(
|
||||
"ui.layerDelete",
|
||||
@@ -1293,7 +1293,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.newLayer",
|
||||
"New Layer Options…",
|
||||
"Cmd+Alt+L",
|
||||
"{sublayer?: bool} open Layer Options for a new layer (or a sublayer of the current layer), named and coloured as it would be: dialog `layerOptions` with mode new|newSublayer; OK runs layer.new or layer.newSublayer with the fields. In isolation mode, a layer that would be outside the isolated art is an error and nothing opens; OK checks again, and with isolation mode started since, it returns the same error and makes no layer",
|
||||
"{sublayer?: bool} open Layer Options for a new layer (or a sublayer of the current layer), named and coloured as it would be: dialog `ui.layerOptions` with mode new|newSublayer; OK runs layer.new or layer.newSublayer with the fields. In isolation mode, a layer that would be outside the isolated art is an error and nothing opens; OK checks again, and with isolation mode started since, it returns the same error and makes no layer",
|
||||
),
|
||||
(
|
||||
"ui.newArtboard",
|
||||
@@ -1311,13 +1311,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.layersPanelOptions",
|
||||
"Panel Options…",
|
||||
"",
|
||||
"{} open the Layers panel's Panel Options: dialog `layersPanelOptions`, fields layersOnly, locateSelected (Locate Selected Objects, off by default: when the last selected object changes outside the panel, 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, 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; a change made during a drag is located when the drag ends), rowSize (small|medium|large|other), otherSize (12–100 pt), thumbLayers, thumbGroups, thumbObjects; OK applies them (kept with the UI state)",
|
||||
"{} open the Layers panel's Panel Options: dialog `ui.layersPanelOptions`, fields layersOnly, locateSelected (Locate Selected Objects, off by default: when the last selected object changes outside the panel, 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, 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; a change made during a drag is located when the drag ends), rowSize (small|medium|large|other), otherSize (12–100 pt), thumbLayers, thumbGroups, thumbObjects; OK applies them (kept with the UI state)",
|
||||
),
|
||||
(
|
||||
"ui.navigatorPanelOptions",
|
||||
"Panel Options…",
|
||||
"",
|
||||
"{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them), viewArtboardContentsOnly?: bool (View Artboard Contents Only in the panel menu, on by default and for UI state saved without it: the thumbnail fits the artboards and draws only the art inside them, cut at each artboard's edges; off, it also shows the art on the pasteboard)} set the Navigator panel's options, the color its view box is drawn in, solid dashes and artboard contents only (kept with the UI state) → {color, solidDashes, viewArtboardContentsOnly}; with none, open its Panel Options (dialog `navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing",
|
||||
"{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them), viewArtboardContentsOnly?: bool (View Artboard Contents Only in the panel menu, on by default and for UI state saved without it: the thumbnail fits the artboards and draws only the art inside them, cut at each artboard's edges; off, it also shows the art on the pasteboard)} set the Navigator panel's options, the color its view box is drawn in, solid dashes and artboard contents only (kept with the UI state) → {color, solidDashes, viewArtboardContentsOnly}; with none, open its Panel Options (dialog `ui.navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing",
|
||||
),
|
||||
(
|
||||
"ui.attributesPanelOptions",
|
||||
@@ -1646,7 +1646,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.rasterEffectsSettingsDialog",
|
||||
"Document Raster Effects Settings Dialog",
|
||||
"",
|
||||
"{} open Document Raster Effects Settings (dialog `rasterEffectsSettings`: the document.rasterEffectsSettings fields); OK runs it. The menu item opens it too",
|
||||
"{} open Document Raster Effects Settings (dialog `document.rasterEffectsSettings`: the document.rasterEffectsSettings fields); OK runs it. The menu item opens it too",
|
||||
),
|
||||
(
|
||||
"ui.effectGalleryDialog",
|
||||
@@ -1664,7 +1664,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.pdfPresetDialog",
|
||||
"PDF Preset",
|
||||
"",
|
||||
"{name?: a saved preset to edit | preset?: the preset a new one starts from (default VectorCraft Default)} open the preset editor (dialog `pdfPreset`: the Save PDF dialog's option fields plus `name` and `description`); OK runs pdf.preset.save and returns to PDF Presets",
|
||||
"{name?: a saved preset to edit | preset?: the preset a new one starts from (default VectorCraft Default)} open the preset editor (dialog `pdf-export`: the Save PDF dialog's option fields plus `name` and `description`); OK runs pdf.preset.save and returns to PDF Presets",
|
||||
),
|
||||
("file.openRecent11", "Open Recent File 11", "", "{}"),
|
||||
("file.openRecent12", "Open Recent File 12", "", "{}"),
|
||||
@@ -1919,7 +1919,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
crate::panels::actions::RESET,
|
||||
"Reset Actions",
|
||||
"",
|
||||
"{mode?: \"replace\" | \"append\"} Reset Actions. replace (the default) replaces every set in the Actions panel with a new copy of the built-in Default Actions set, makes it current and selected, clears the panel's selected action and step and its expanded actions, and closes an open Set Options, New Action, Batch or step dialog that names a set; when the panel already shows only the built-in set as it comes in that state, nothing changes, the sets keep their ids and changed is false. append adds a new copy of the built-in set after the sets there are, with the next free number when its name is in use (Default Actions 2), and keeps the current set and the selection. Omitted params count as {}. Params of another type, another key, another mode, or a reset while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Reset Actions asks first (dialog `resetActions`): OK runs this with replace, Append with append → {changed, mode, set: the first built-in set's index}",
|
||||
"{mode?: \"replace\" | \"append\"} Reset Actions. replace (the default) replaces every set in the Actions panel with a new copy of the built-in Default Actions set, makes it current and selected, clears the panel's selected action and step and its expanded actions, and closes an open Set Options, New Action, Batch or step dialog that names a set; when the panel already shows only the built-in set as it comes in that state, nothing changes, the sets keep their ids and changed is false. append adds a new copy of the built-in set after the sets there are, with the next free number when its name is in use (Default Actions 2), and keeps the current set and the selection. Omitted params count as {}. Params of another type, another key, another mode, or a reset while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Reset Actions asks first (dialog `actionsQuestion`): OK runs this with replace, Append with append → {changed, mode, set: the first built-in set's index}",
|
||||
),
|
||||
(
|
||||
crate::panels::actions::CLEAR,
|
||||
@@ -1950,7 +1950,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"file.saveForWeb",
|
||||
"Save for Web (Legacy)…",
|
||||
"Cmd+Alt+Shift+S",
|
||||
"{} open Save for Web (dialog `saveForWeb`: fields = the webExport.settings settings, `preset` loads a preset, __view: original|optimized|2up|4up, __zoom, __kbps; Save… remembers the settings and writes the files, Done only remembers them); with settings = document.exportForWeb, written to path, else a picked file (the web downloads the files) → {path, files, bytes}",
|
||||
"{} open Save for Web (dialog `save-for-web`: fields = the webExport.settings settings, `preset` loads a preset, __view: original|optimized|2up|4up, __zoom, __kbps; Save… remembers the settings and writes the files, Done only remembers them); with settings = document.exportForWeb, written to path, else a picked file (the web downloads the files) → {path, files, bytes}",
|
||||
),
|
||||
(
|
||||
"file.saveForWeb.browser",
|
||||
|
||||
@@ -1344,3 +1344,17 @@ fn insert_select_object_refuses_bad_params_and_changes_nothing() {
|
||||
}
|
||||
assert!(app.run(INSERT_SELECT_OBJECT, place(json!({"note": "x".repeat(1024)}))).is_ok(), "1,024 bytes goes in");
|
||||
}
|
||||
|
||||
/// The panel menu's Reset Actions asks in the dialog whose `key` the params text of [`RESET`] names, as `ui.inspect`
|
||||
/// lists it.
|
||||
#[test]
|
||||
fn reset_params_text_names_the_question_key_ui_inspect_lists() {
|
||||
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == RESET).expect("registered").3;
|
||||
let mut app = new_app();
|
||||
edits::ask_reset(&mut app);
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let ui = crate::control::inspect(&app, &ctx);
|
||||
let key = ui["dialogs"].as_array().and_then(|d| d.last()).and_then(|d| d["key"].as_str()).expect("a dialog with a key");
|
||||
assert_eq!(key, "actionsQuestion");
|
||||
assert!(doc.contains(&format!("dialog `{key}`")), "Reset Actions opens `{key}`, which the params text of {RESET} does not name");
|
||||
}
|
||||
@@ -535,7 +535,7 @@ const AT_START: usize = 4;
|
||||
/// A click makes a symbol current and a double click edits it; a symbol drags out to the canvas,
|
||||
/// onto New Symbol (duplicated) or onto Delete Symbol. Art dragged off the canvas and dropped on the
|
||||
/// list becomes a symbol (Shift at the release keeps the art as ordinary art); dropped on a symbol
|
||||
/// with Alt it redefines that symbol in one undo step.
|
||||
/// with Alt it redefines that symbol in one undo step, and Alt+Shift also keeps the art.
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let Some((doc, revision, uid, reverts, has_sel)) =
|
||||
app.session.active().map(|st| (st.doc.clone(), st.revision, st.uid, st.reverts, !st.selection.is_empty()))
|
||||
@@ -651,8 +651,13 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
&& redefines(&doc, ids)
|
||||
{
|
||||
// Redefine Symbol with the dropped art, which becomes an instance of it, in one
|
||||
// undo step. Alt art that cannot redefine changes nothing.
|
||||
run_reported(app, "symbol.update", json!({ "name": target.name, "ids": node_ids(ids) }));
|
||||
// undo step; Shift keeps the art as ordinary art, as the menu's Redefine Symbol
|
||||
// does. Alt art that cannot redefine changes nothing.
|
||||
let mut params = json!({ "name": target.name, "ids": node_ids(ids) });
|
||||
if mods.shift {
|
||||
params["keepArt"] = json!(true);
|
||||
}
|
||||
run_reported(app, "symbol.update", params);
|
||||
}
|
||||
}
|
||||
PresetEvent::Menu { target, command, .. } => item_command(app, &target.name, &command),
|
||||
|
||||
@@ -1638,6 +1638,31 @@ fn alt_art_drop_on_a_symbol_redefines_that_symbol_in_one_step() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Art released with Alt and Shift held on a symbol's tile or row, in each view, redefines that
|
||||
/// symbol and stays ordinary art in its place, as Redefine Symbol with Shift leaves it, in one
|
||||
/// undo step.
|
||||
#[test]
|
||||
fn alt_shift_art_drop_on_a_symbol_redefines_it_and_keeps_the_art() {
|
||||
for view in ["thumbnail", "smallList", "largeList"] {
|
||||
let (app, shape, placed) = alt_drop_doc(view);
|
||||
let leaf = symbol_art(&app, "Leaf");
|
||||
let undo = undo_len(&app);
|
||||
let mut p = harness(app, art_and_symbols);
|
||||
p.drag("Art", "Leaf", Modifiers::ALT | Modifiers::SHIFT);
|
||||
let mut app = p.app();
|
||||
assert_eq!(symbols(&mut app), ["Leaf", "Dot"], "{view}: no symbol added");
|
||||
assert_eq!(undo_len(&app), undo + 1, "{view}: one undo step");
|
||||
let doc = app.session.active().unwrap().doc.clone();
|
||||
let ratio = doc.node(placed).and_then(|n| n.geometric_bounds()).map(|b| b.width() / b.height());
|
||||
assert!(ratio.is_some_and(|r| (r - 2.0).abs() < 1e-6), "{view}: Leaf is the dropped art: {ratio:?}");
|
||||
assert!(doc.node(shape).is_some_and(|n| matches!(n.kind, NodeKind::Path { .. })), "{view}: the art keeps its id as a path");
|
||||
assert_eq!(art(&app, "Leaf"), (1, 1), "{view}: the art stays ordinary art, not a Leaf instance");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert!(Arc::ptr_eq(&leaf, &symbol_art(&app, "Leaf")), "{view}: undo restores Leaf");
|
||||
assert_eq!(art(&app, "Leaf"), (1, 1), "{view}: undo leaves the art");
|
||||
}
|
||||
}
|
||||
|
||||
/// An Alt drop that cannot redefine the symbol under the pointer changes nothing, makes no new
|
||||
/// symbol and adds no undo step: art holding an instance of the symbol, which the redefine
|
||||
/// refuses, a layer, and art released outside the list.
|
||||
|
||||
@@ -681,6 +681,94 @@ fn placement_options_dialog_sets_the_options() {
|
||||
assert_eq!(r["placement"], json!({"preserve": "fit", "align": "bottomRight", "clip": false}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_options_dialog_keeps_the_links_it_opened_on_when_the_selection_changes() {
|
||||
use crate::tests::picks::{answer_dialog, open_dialogs};
|
||||
let dir = Folder::new("dialog-selection");
|
||||
let (app, first, _) = app(&dir);
|
||||
let mut app = crate::testing::windowed(app);
|
||||
let c = dir.file("second.png", &png(60, 40));
|
||||
let second = app.run("file.place", json!({"path": c, "at": [200, 150]})).unwrap()["ids"][0].as_u64().unwrap();
|
||||
app.run("links.placementOptions", json!({"ids": [first], "preserve": "fill"})).unwrap();
|
||||
app.run("links.placementOptions", json!({"ids": [second], "preserve": "bounds"})).unwrap();
|
||||
let placement = |app: &mut VectorcraftApp, id: u64| app.run("links.placementOptions", json!({"ids": [id]})).unwrap()["placement"].clone();
|
||||
let second_before = placement(&mut app, second);
|
||||
|
||||
app.run("select.set", json!({"ids": [first]})).unwrap();
|
||||
app.run("ui.placementOptionsDialog", json!({})).unwrap();
|
||||
let open = open_dialogs(&app);
|
||||
assert_eq!(open.len(), 1, "the dialog is open");
|
||||
app.run("select.set", json!({"ids": [second]})).unwrap();
|
||||
answer_dialog(&mut app, open[0].id, &[("preserve", json!("fit"))], true);
|
||||
|
||||
assert_eq!(placement(&mut app, second), second_before, "the image selected after the dialog opened keeps its options");
|
||||
assert_eq!(placement(&mut app, first)["preserve"], json!("fit"), "OK applies to the image the dialog opened on");
|
||||
}
|
||||
|
||||
/// Two linked images, the first with preserve `fill` and the second with `bounds`, in a window.
|
||||
fn two_links(dir: &Folder) -> (VectorcraftApp, u64, u64) {
|
||||
let (app, first, _) = app(dir);
|
||||
let mut app = crate::testing::windowed(app);
|
||||
let c = dir.file("second.png", &png(60, 40));
|
||||
let second = app.run("file.place", json!({"path": c, "at": [200, 150]})).unwrap()["ids"][0].as_u64().unwrap();
|
||||
app.run("links.placementOptions", json!({"ids": [first], "preserve": "fill"})).unwrap();
|
||||
app.run("links.placementOptions", json!({"ids": [second], "preserve": "bounds"})).unwrap();
|
||||
(app, first, second)
|
||||
}
|
||||
|
||||
fn preserve_of(app: &mut VectorcraftApp, id: u64) -> serde_json::Value {
|
||||
app.run("links.placementOptions", json!({"ids": [id]})).unwrap()["placement"]["preserve"].clone()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_options_dialog_keeps_the_links_it_opened_on_when_the_selection_is_emptied() {
|
||||
use crate::tests::picks::{answer_dialog, open_dialogs};
|
||||
let dir = Folder::new("dialog-deselect");
|
||||
let (mut app, first, second) = two_links(&dir);
|
||||
app.run("select.set", json!({"ids": [first]})).unwrap();
|
||||
app.run("ui.placementOptionsDialog", json!({})).unwrap();
|
||||
let open = open_dialogs(&app);
|
||||
app.run("select.set", json!({"ids": []})).unwrap();
|
||||
answer_dialog(&mut app, open[0].id, &[("preserve", json!("fit"))], true);
|
||||
assert!(open_dialogs(&app).is_empty(), "OK closes the dialog");
|
||||
assert_eq!(preserve_of(&mut app, first), json!("fit"));
|
||||
assert_eq!(preserve_of(&mut app, second), json!("bounds"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_options_dialog_changes_nothing_when_a_link_it_opened_on_is_deleted() {
|
||||
use craft::ui::dialog::HeldOk;
|
||||
|
||||
use crate::tests::picks::{answer_dialog, open_dialogs};
|
||||
let dir = Folder::new("dialog-deleted");
|
||||
let (mut app, first, second) = two_links(&dir);
|
||||
app.run("select.set", json!({"ids": [first]})).unwrap();
|
||||
app.run("ui.placementOptionsDialog", json!({})).unwrap();
|
||||
let open = open_dialogs(&app);
|
||||
app.run("edit.clear", json!({})).unwrap();
|
||||
app.run("select.set", json!({"ids": [second]})).unwrap();
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
answer_dialog(&mut app, open[0].id, &[("preserve", json!("fit"))], true);
|
||||
let refused = app.dialogs().unwrap().with(|h| matches!(h.held_state(open[0].id), Some(HeldOk::Refused(_))));
|
||||
assert!(refused, "OK is refused and the dialog stays open");
|
||||
assert_eq!(preserve_of(&mut app, second), json!("bounds"), "the selected image keeps its options");
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "no undo step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_options_dialog_applies_to_the_ids_it_was_given() {
|
||||
use crate::tests::picks::{answer_dialog, open_dialogs};
|
||||
let dir = Folder::new("dialog-ids");
|
||||
let (mut app, first, second) = two_links(&dir);
|
||||
app.run("select.set", json!({"ids": [first]})).unwrap();
|
||||
app.run("ui.placementOptionsDialog", json!({"ids": [second]})).unwrap();
|
||||
let open = open_dialogs(&app);
|
||||
assert_eq!(open.len(), 1, "the dialog is open");
|
||||
answer_dialog(&mut app, open[0].id, &[("preserve", json!("fit"))], true);
|
||||
assert_eq!(preserve_of(&mut app, second), json!("fit"));
|
||||
assert_eq!(preserve_of(&mut app, first), json!("fill"), "the selected image keeps its options");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn properties_shows_the_selected_image_and_its_link_actions() {
|
||||
let dir = Folder::new("props");
|
||||
|
||||
@@ -600,7 +600,7 @@ keeps the dialog's options as a saved preset.
|
||||
|
||||
PDF presets: `ui.pdfPresetsDialog {selected?}` opens Edit → PDF Presets (dialog `pdfPresets`, field `selected`: a
|
||||
preset name). Built-in presets are read-only. New… and Edit… open the preset editor, which `ui.pdfPresetDialog {name?
|
||||
(a saved preset to edit) | preset? (the preset a new one starts from)}` opens too: dialog `pdfPreset`, the Save PDF
|
||||
(a saved preset to edit) | preset? (the preset a new one starts from)}` opens too: dialog `pdf-export`, the Save PDF
|
||||
dialog's option fields plus `name` and `description`; `ui.dialog.confirm` runs `pdf.preset.save` and returns to PDF
|
||||
Presets (a new preset can't take a name in use). Delete, Import… and Export… are `pdf.preset.delete`,
|
||||
`pdf.preset.import` and `pdf.preset.export`; `ui.dialog.confirm` closes. Opening a `.vcpdfpresets` file with `app.open`
|
||||
@@ -757,7 +757,7 @@ the dock's tab strip while Layers shows) lists the layer commands (New Layer…,
|
||||
Options for Selection…, clipping mask, isolation, Locate Object, Merge Selected, Flatten Artwork, Collect in New
|
||||
Layer, Release to Layers, Reverse Order, Template, Hide/Outline/Lock Others or Show/Preview/Unlock All Layers), Paste
|
||||
Remembers Layers (`layer.pasteRemembersLayers`, checked when on) and Panel Options…. Layer Options is the
|
||||
`layerOptions` dialog (`ui.layerOptions {ids?}`, `ui.newLayer {sublayer?}`), Panel Options the `layersPanelOptions`
|
||||
`ui.layerOptions` dialog (`ui.layerOptions {ids?}`, `ui.newLayer {sublayer?}`), Panel Options the `ui.layersPanelOptions`
|
||||
dialog (`ui.layersPanelOptions`), and `ui.layersExpand {ids?, open?}` opens or closes rows; see the Layers panel
|
||||
section of `docs/mcp.md` for the row commands (`layer.setCurrent`, `layer.highlight`, `layer.move`…).
|
||||
|
||||
@@ -769,7 +769,7 @@ File Info: File → File Info… (`file.info` from the menu or Cmd+Alt+Shift+I;
|
||||
stays open.
|
||||
|
||||
Document Raster Effects Settings: Effect → Document Raster Effects Settings… (`ui.rasterEffectsSettingsDialog` for
|
||||
agents) opens the `rasterEffectsSettings` dialog. Its fields are what `document.rasterEffectsSettings` reports
|
||||
agents) opens the `document.rasterEffectsSettings` dialog. Its fields are what `document.rasterEffectsSettings` reports
|
||||
(`resolution`, `colorModel`, `background`, `antiAlias`, `clippingMask`, `addAround` in pt, `preserveSpotColors`);
|
||||
`ui.dialog.confirm` runs it with them as one undo step; a bad value keeps the dialog open. Object → Rasterize… opens the
|
||||
`object.rasterize` dialog, whose fields (`ppi`, `colorModel`, `background`, `antiAlias`, `clippingMask`,
|
||||
@@ -884,7 +884,7 @@ art too large at that scale) keeps the dialog open.
|
||||
Placement Options: the Links panel's flyout (or `ui.placementOptionsDialog {ids?}` for agents) opens the
|
||||
`placementOptions` dialog for the selected images (fields `ids`, `preserve`: `transforms`/`bounds`/`fileDimensions`/
|
||||
`fit`/`fill`, `align`: `topLeft` … `bottomRight`, `clip`). `ui.dialog.confirm` runs `links.placementOptions` with them as
|
||||
one undo step.
|
||||
one undo step, on the images the dialog opened on even when the selection has changed since.
|
||||
|
||||
Relink: the Links panel's Relink… button and flyout item (or `ui.relinkDialog {ids?}` for agents) open the `relink`
|
||||
dialog for the selected images and placed documents (fields `ids`, `links`: `[{name, ids}]`, one row per linked file,
|
||||
@@ -997,7 +997,7 @@ the save dialog) opens `tiffOptions`, `bmpOptions` or `tgaOptions`: the raster r
|
||||
rows off; RLE turns flipped rows off). `ui.dialog.set` the fields and `ui.dialog.confirm` writes the file(s) with
|
||||
`document.export`.
|
||||
|
||||
Save for Web: File → Export → Save for Web (Legacy)… (`file.saveForWeb`, Ctrl/Cmd+Alt+Shift+S) opens the `saveForWeb`
|
||||
Save for Web: File → Export → Save for Web (Legacy)… (`file.saveForWeb`, Ctrl/Cmd+Alt+Shift+S) opens the `save-for-web`
|
||||
dialog on the remembered settings (`webExport.settings`). Its fields are the `document.exportForWeb` settings
|
||||
(`format`, `colors`, `reduction`, `dither`, `quality`, `colorTable`, `width`, `percent`, `output`…; set `preset` to load
|
||||
a preset) plus `__view` (`original`, `optimized`, `2up`, `4up`), `__zoom` (`fit` or a percentage), `__kbps` and
|
||||
|
||||
+13
-7
@@ -632,6 +632,11 @@ of `appearance.setItem`, `anchor` of `path.removeAnchor` and `addon.pen.removePo
|
||||
value such as `"3"`, `2.5`, `-1` or `true` with `` `index` must be a whole number ``, naming the key, and reports a key
|
||||
left out or null as missing (such as `` missing integer `index` ``). An optional one, such as `subpath`, keeps its default when
|
||||
left out or null; `appearance.setActiveItem` reads a null `index` as clearing the active item.
|
||||
`file.new` refuses a number given for `artboards`, `artboardLayout.columns` or `artboardLayout.rows` that is not a
|
||||
whole number from 1 to 1000, such as `2.4`, `0` or `1001`, and opens no document. A null `artboards` keeps the
|
||||
default or the preset's count; a null `columns` or `rows` is an error. A `file.new` step replayed from a journal or
|
||||
played from the Actions panel keeps the earlier rules: `artboards` is rounded and kept within 1 to 1000, a `columns` of
|
||||
1 or more is rounded and kept to at most 1000, and a `rows` is rounded and must then be from 1 to 1000.
|
||||
A command that leaves out an object selected inside a
|
||||
selected group also leaves it out when `ids` list it together with a group that holds it. Every command that takes
|
||||
`ids` (or `slices`, for the slice commands) refuses a list with an entry that is not a non-negative integer, or a value
|
||||
@@ -4824,7 +4829,7 @@ shows no notice.
|
||||
|
||||
## Navigator panel options
|
||||
|
||||
The Navigator panel menu's Panel Options… opens the `navigatorPanelOptions` dialog (fields `color`, `solidDashes`),
|
||||
The Navigator panel menu's Panel Options… opens the `ui.navigatorPanelOptions` dialog (fields `color`, `solidDashes`),
|
||||
and `ui.navigatorPanelOptions {color?, solidDashes?, viewArtboardContentsOnly?}` sets the options without it →
|
||||
`{color, solidDashes, viewArtboardContentsOnly}`; with none of the keys it opens the dialog. `color` is the color the
|
||||
panel's view box is drawn in: `#rrggbb` or a preset name.
|
||||
@@ -5217,8 +5222,9 @@ already walks Image Trace. Short agent entry points:
|
||||
of it in one undo step; with `keepArt: true` the art stays ordinary art in its place, with its ids, and stays selected
|
||||
unless it is hidden or locked, and the result's `id` is null; a `keepArt` other than true or false is an error; art that holds an instance of the symbol (opacity masks included), directly or through the art
|
||||
of the symbols it holds instances of, is refused and nothing changes; the Symbols panel menu's Redefine Symbol sends `keepArt: true` when it
|
||||
is chosen with Shift held, and the panel sends it with the dragged art's `ids` when art dragged
|
||||
off the canvas is released on a symbol's tile or row with Alt (Option on macOS) held),
|
||||
is chosen with Shift held, and the panel sends `symbol.update` with the dragged art's `ids` when art dragged
|
||||
off the canvas is released on a symbol's tile or row with Alt (Option on macOS) held, with `keepArt: true` when Shift
|
||||
is held too),
|
||||
`symbol.edit {id?, ids?, name?, x?, y?, artboard?, viewCenter?}` (symbol editing mode: the symbol's art on a temporary
|
||||
isolated layer, where the instance `id` shows it or centered on (x, y), by default on the center of artboard
|
||||
`artboard`, the active one the app passes, or in a document without artboards on `viewCenter`, the view's center the
|
||||
@@ -5999,7 +6005,7 @@ already walks Image Trace. Short agent entry points:
|
||||
next free number when its name is in use (`Default Actions 2`), and keeps the current set and the selection.
|
||||
Omitted params count as `{}`. Params of another type, another key, another `mode`, or a reset while an action
|
||||
records or plays (also while it waits at a stop) is an error and changes nothing. Reset records no undo step. The panel menu's Reset
|
||||
Actions is disabled while an action records or plays; it opens a `resetActions` question (fields `message`,
|
||||
Actions is disabled while an action records or plays; it opens an `actionsQuestion` question (fields `message`,
|
||||
`detail`, `append`): OK runs this with `replace`, Append with `append`, and `ui.dialog.cancel` changes nothing.
|
||||
`ui.actionSet.clear {ids?: [id]}` is Clear Actions, and returns `{cleared}`, the number of sets deleted. It deletes
|
||||
every set in the panel with its actions, the built-in Default Actions set included, so no set is current or
|
||||
@@ -7880,14 +7886,14 @@ and `layerRows`, the rows highlighted in the panel.
|
||||
`object.setProps` return an error when they would give either name to another path directly in the group, and a
|
||||
path pasted directly into the group under either name loses its name.
|
||||
- **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,
|
||||
{sublayer?}` open Layer Options (dialog `ui.layerOptions`: name, color, template, locked, visible, printable, preview,
|
||||
dimImages, dimPercent; for existing rows, unchanged approval adds no undo step; an edit is one undo step.
|
||||
Existing rows keep their stored names unless Name is edited or explicitly set through `ui.dialog.set`, so generated labels remain automatic.
|
||||
`ui.dialog.set` of `template` also sets `locked` and `dimImages`, as the
|
||||
checkbox does, except a Dim Images set before it; 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; in isolation mode `ui.newLayer` for a
|
||||
layer that would be outside the isolated art is an error, OK in the dialog checks again and returns the same error,
|
||||
and the Layers panel's New Layer and New Sublayer are off then), `ui.layersPanelOptions` opens Panel Options (`layersPanelOptions`:
|
||||
and the Layers panel's New Layer and New Sublayer are off then), `ui.layersPanelOptions` opens Panel Options (`ui.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
|
||||
@@ -10646,7 +10652,7 @@ and goes back to Document Setup, whose OK runs `document.setup`; its Cancel goes
|
||||
|
||||
`file.new` takes everything New Document sets: `preset` (a name from `file.newPresets`), `name`, `width`/`height`
|
||||
(points, or lengths such as `"210 mm"`), `units`, `orientation`, `artboards` with `artboardLayout {layout, columns,
|
||||
rows, spacing, rightToLeft}` (`rows`, 1 to 1000 and rounded to a whole number, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is
|
||||
rows, spacing, rightToLeft}` (`artboards`, `columns` and `rows` are whole numbers from 1 to 1000, and any other number is an error; `rows` gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is
|
||||
an error with another layout; a preset keeps the rows, and `file.newPresets` lists them as set even when there are
|
||||
fewer artboards, until `columns` without `rows`, or another layout, is given; New Document's Columns shows the columns
|
||||
the rows give the current number of artboards, and New Document drops the rows when Columns or the layout changes),
|
||||
|
||||
Reference in new issue
Block a user