Repository navigation
Transform, Align, Object Properties and Live Shape Properties: a boolean given as text is refused - #3289
Open
dotCooCoo wants to merge 1 commit into
Conversation
…ean given as text is refused
The transform commands read their on/off options with bool_or, which
falls back to a default for a value that is not true or false. With
Scale Strokes & Effects on, object.scale {"strokes": "false"} scaled
the stroke as well, and object.move {"copy": "true"} moved the object
without a copy. Transform Again dropped such a value and used the one
the repeated transform had. Object Properties read visible, locked,
isolate and knockoutShape given as text as not given, and Live Shape
Properties read invertPie and makeSidesEqual given as text as false.
Each call reported success.
object.transform, move, nudge, rotate, scale, reflect, shear,
transformAgain and setBounds now fail with "`<key>` must be true or
false" for a copy, strokes, corners, patterns, objects or typeAreas
that is not true, false or null, with the message the grid and
overprint commands give. So do anchors in object.transform, big in
object.nudge, absolute in object.rotate, proportional in
object.setBounds, patterns in object.align, distribute and
distributeSpacing, visible, locked, isolate and knockoutShape in
object.setProps, and invertPie and makeSidesEqual in
object.setLiveShape. The document and its undo history stay as they
were. A null is read as a key left out.
Docs: docs/mcp.md, docs/target-app-parity.md.
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
On
main, the transform commands read their on/off options withbool_or, which falls back to a default for a value that is not true or false. With Scale Strokes & Effects on,object.scale {"sx": 200, "strokes": "false"}scales the stroke as well, andobject.move {"dx": 5, "copy": "true"}moves the object without a copy.object.transformAgaindrops such a value and uses the one the repeated transform had.object.setPropsreads{"visible": "false"}as a key left out, andobject.setLiveShapereads{"invertPie": "true"}as false. Each call reports success.object.transform,move,nudge,rotate,scale,reflect,shear,transformAgainandsetBoundsfail with "<key>must be true or false" for acopy,strokes,corners,patterns,objectsortypeAreasthat is not true, false or null, the message the grid and overprint commands give (crates/engine/src/cmd/create.rs:423,overprint.rs:124). So doanchorsinobject.transform,biginobject.nudge,absoluteinobject.rotateandproportionalinobject.setBounds.object.align,object.distributeandobject.distributeSpacingrefuse such apatterns.object.setPropsrefuses such avisible,locked,isolateorknockoutShape, andobject.setLiveShaperefuses such aninvertPieormakeSidesEqual.check_switches, which works ascheck_numbersdoes (crates/engine/src/cmd/mod.rs:323), before it changes anything;apply_transform,scaling,transform_patternsandtransforms_objectskeep their signatures.docs/mcp.mdlists the keys, anddocs/target-app-parity.mdhas one line for the change. The true-or-false message already has a row in every complete catalog. The change adds no new message text and no catalog rows.How it was tested
New tests in vectorcraft-engine, each failing on
main, where the first call succeeds:tests::a_boolean_given_as_text_for_a_transform_is_an_errormakes 13 calls across the nine transform commands, each giving one option as a string, a number or an array, with Scale Strokes & Effects on; the object keeps its bounds and stroke width, no copy is made and no undo step is added, andstrokes: falsewithcorners: nullthen scales the object and leaves its stroke width.tests::align_and_distribute_refuse_a_boolean_given_as_textgivespatternsas"true","false"and1; nothing moves and no undo step is added, and the three commands then run with null, false and true, the first aligning the objects.tests::object_properties_refuse_a_boolean_given_as_textgives each of the four keys as a string, a number or an array; the object and the undo history stay, and true, false and null then set or keep each value.tests_livecorners::invert_pie_and_make_sides_equal_refuse_a_boolean_given_as_textgives both keys as a string, a number or an array; the pie and the polygon stay, false and null leave them, and true inverts the pie and makes the sides equal.Targeted checks while building:
cargo clippy -p vectorcraft-engine --all-targets -- -D warnings; the new tests andcargo test -p vectorcraft-engine --lib;cargo fmt --all -- --check;cargo test -p vectorcraft-ui-egui --lib i18n;cargo xtask brands,layersandassets.On Windows 11 (x86-64) with rustc 1.99.1, on top of
mainatbc1ae08:CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask cipasses its 10 steps: 8,574 tests passed, 0 failed, 13 ignored.git merge-treereports no conflicts withmainatbc1ae08. #3262, #3206, #3204, #3181, #3091, #3014, #2841, #2671 and #2595 also changecrates/engine/src/cmd/object.rsortests.rsand merge with this branch. The branch merged with all of them but #3204 builds (cargo check -p vectorcraft-engine --tests), and so does the branch merged with #3204, which conflicts with #3206. The conflicts of #2734, #1987, #1906 and #1281 withmaininobject.rsare the same with or without this branch.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).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.Summary by CodeRabbit
Bug Fixes
nullis treated as omitted.Documentation