🐛 Fit a copy's masked group to its mask whenever sync changes it

A masked group takes all its geometry from its mask. When the mask of a
group in a copy authors a flip, the untouched group follows it; a later
sync gave the group its main's unflipped geometry, apart from its mask.

A masked group whose geometry sync changes in any way carries nothing
and takes its mask's geometry again, as a group a sync moves or resizes
fits its shapes again.

Test: flipping-the-mask-of-a-copy-group-flips-the-group-for-good.

The benchmark of the previous commit covers this one.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-13 02:05:30 +01:00
parent fb24f8c19e
commit 8c2ef98bb2
2 changed files with 14 additions and 5 deletions

View File

@ -683,11 +683,14 @@
;; a group or bool takes its bounds from its children, which sync places
;; one by one: a move or resize of its bounds carries nothing, and it
;; fits them again
(and (seq ids) (or moved? resized?)
(mth/close? (or (:rotation before) 0) (or (:rotation after) 0) 1e-10)
(= (boolean (:flip-x before)) (boolean (:flip-x after)))
(= (boolean (:flip-y before)) (boolean (:flip-y after)))
(#{:group :bool} (:type before)))
(and (seq ids)
(#{:group :bool} (:type before))
(or (and (or moved? resized?)
(mth/close? (or (:rotation before) 0) (or (:rotation after) 0) 1e-10)
(= (boolean (:flip-x before)) (boolean (:flip-x after)))
(= (boolean (:flip-y before)) (boolean (:flip-y after))))
;; a masked group takes all its geometry from its mask
(:masked-group before)))
(let [refit {:type :reg-objects :shapes [(:id before)]}]
(pcb/add-changes changes container [refit] [refit]))

View File

@ -2524,6 +2524,12 @@
:layout-copies false :layout-children false}]
:ops [[:structure 0 4] [:transform 0 4 0 2]]}))))
(t/deftest flipping-the-mask-of-a-copy-group-flips-the-group-for-good
(t/is (map? (cg/run {:world [3 1 {:variants true :rich-variants true :text true :layout :grid
:layout-copies false :layout-children false}]
:ops [[:remove-child 9] [:add-child 7] [:delete 7] [:add-child] [:undo]
[:structure 10 1] [:transform 10 5 0 2]]}))))
(t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place
(t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid
:layout-copies true :layout-children true}]