mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-31 05:07:51 -06:00
Print: Print, Print Preview and Print Setup take a print preset by name
file.print, print.preview and print.setup took print settings only as settings, so an agent had to read a preset with print.presets.list and copy its settings into the call. They now take preset, the name of [Default] or of a saved print preset in any case. The preset's settings are used instead of the document's, settings applies over them, and print.setup saves them with the document as one undo step. An unknown name is a parameter error that lists the presets. The app's file.print with params passes preset on to the engine. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
@@ -52,6 +52,20 @@ fn pages_place_the_artboard_on_the_trim_box() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_print_preset_lays_out_its_settings_with_settings_over_them() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 300, "height": 200, "artboards": 4})).unwrap();
|
||||
s.execute("print.setup", &json!({"settings": {"media": "a4"}})).unwrap();
|
||||
s.execute("print.presets.save", &json!({"name": "Sheet", "settings": {"artboards": "range", "range": "4"}})).unwrap();
|
||||
let v = s.execute("print.preview", &json!({"preset": "Sheet", "settings": {"artboards": "range", "range": "3"}})).unwrap();
|
||||
assert_eq!((v["pages"].clone(), v["sheets"][0]["artboard"].clone()), (json!(1), json!(2)), "{v}");
|
||||
assert_eq!(v["settings"]["media"], "letter", "the preset's paper, not the document's");
|
||||
let v = s.execute("print.preview", &json!({"preset": "Sheet"})).unwrap();
|
||||
assert_eq!((v["pages"].clone(), v["sheets"][0]["artboard"].clone()), (json!(1), json!(3)));
|
||||
assert_eq!(s.doc().unwrap().doc.print_setup.as_ref().unwrap()["media"], "a4", "the preview keeps nothing");
|
||||
}
|
||||
|
||||
/// Point type at (`x`, `y`) in `family` → its id.
|
||||
fn type_in(s: &mut Session, x: f64, y: f64, family: &str) -> u64 {
|
||||
s.execute("text.create", &json!({"x": x, "y": y, "text": "Ab", "font": family, "style": "Regular"})).unwrap()["id"].as_u64().unwrap()
|
||||
|
||||
Reference in New Issue
Block a user