Repository navigation
Feat/vectorcraft placed documents - #564
Conversation
03c5e82 to
99d81b7
Compare
…t; output reads its file
99d81b7 to
5e7af3f
Compare
|
Merged, thank you @Haven-King! This is a big, carefully built feature. Placed VectorCraft documents stay linked and update when their file changes. They export as real vectors everywhere and fall back to previews with a warning. A save for an older version writes them as plain art, and the Links panel and its commands cover them. The engineering underneath is just as careful: bounds-checked v4 data after the JSON, the 8-level nesting stop, hash checks on re-read files, bounded LRU bitmap caches with poison-safe locks, and background renders left out of wasm. What I checked before merging:
Your rebases kept the code commits identical, which made re-checking easy. One follow-up we'll do separately: linked files (images on main too) are read with no size cap, so a document naming a huge file could exhaust memory. If you'd like to chat with us and other contributors, come join https://discord.gg/artcraft |
What and why
Place a VectorCraft document in another as a placed document: one locked object showing an artboard of the file, linked to it and updated when it changes. Until now, placing a document copied its art in as an editable group, which didn't follow the file and added every copy's paths and resources to the document.
Breaking change:
file.placeof a.vectorcraftfile from a path now links it by default. Passlink: false(Place's Link checkbox off) for the editable copy. Placing fromdataBase64still gives a copy. Files dropped on the canvas follow the same rule (Shift embeds).file.place'spageandcrop: "bounding"apply). The Link tooltip explains linking and embedding for the kind of file picked: images, VectorCraft documents, or both.links.embed). An image keeps its pixels; a placed document becomes the editable copy that placing it without Link gives, its symbols, patterns, swatches and images joining the document. Object › Expand does the same.check_tipputs a checkbox's tooltip where egui hit-tests it; a tooltip on a scope around the checkbox never shows.Each commit builds on the previous one and can be reviewed alone: widget -> format v4 -> model and exact drawing -> placing and output -> Links commands -> on-screen bitmaps -> UI.
Also as a note, this is an example of a behavior that all of the image-targeting ArtCraft projects would likely benefit from. I don't intend on porting it to the other two, I'm just pointing it out as a point of evidence towards rearchitecting the projects.
How it was tested
engine/src/tests_placed_document.rs(16 tests): placing linked or as a copy, output in every format, saved previews, nested documents, loops, errors and junk parameters, update, relink, Update Links on open, Break Link (compared with an unlinked placement), Expand, refresh on save, Link Info.render/src/tests_placed_document.rs: exact drawing, the placeholder then the bitmap, shared bitmaps, drawing from the preview, a document that places itself.docunit tests (resources, nesting, the cache, previews),format/tests/native_v4.rs(round trips, older versions inline, damaged offsets refused),ui-egui/src/tests_place.rs(Link on by default, the tooltip for each kind of file, Edit Original).One test fails, and it isn't this branch's:
cmd::typecmd::area_tests::leading_model_is_set_per_paragraph_and_saved_only_when_top_to_top(crates/engine/src/cmd/typecmd.rs).leadingModel: "emBoxTop"on the test's CJK text (一\n二) leaves the text's bounds unchanged.main(46dc8b1, "Type: Top-to-Top Leading"), and this branch touches neither the type code nor that test.CRAFT_FONTS_DIR, so there may be no CJK font with em-box metrics to move the line. I haven't checked whether it also fails onmain.The full suite was run with
--no-fail-fast, and that test is the only failure.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm). Everything passes except the one test above.unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md(there are none).