diff --git a/common/src/app/common/test_helpers/composable/gen.cljc b/common/src/app/common/test_helpers/composable/gen.cljc index 5d1882e89f..6586642b36 100644 --- a/common/src/app/common/test_helpers/composable/gen.cljc +++ b/common/src/app/common/test_helpers/composable/gen.cljc @@ -815,6 +815,7 @@ model (-> model (shadow/parent-orientation (all-objects situation) (all-objects settled)) (shadow/layout-released (all-objects situation) (all-objects settled)) + (shadow/sync-scaled-heads (all-objects situation) (all-objects settled)) (settle-model settled true)) all (into (set (synchronizable-components situation)) (r/pending-components situation)) full-before (r/settle situation all) @@ -1079,7 +1080,8 @@ next-model (cond-> (or next-model model) (not (#{:undo :redo} kind)) (-> (shadow/parent-orientation (all-objects situation) (all-objects after)) - (shadow/layout-released (all-objects situation) (all-objects after)))) + (shadow/layout-released (all-objects situation) (all-objects after)) + (shadow/sync-scaled-heads (all-objects situation) (all-objects after)))) next-model (settle-model next-model after (empty? (r/pending-components after))) meaningful (not (oracle/equivalent? (oracle/design-snapshot situation {:free-head-placement false}) (oracle/design-snapshot after {:free-head-placement false}))) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index c5a88cb446..808060d7be 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -572,6 +572,30 @@ result))) model model)) +(defn sync-scaled-heads + "A copy parent that a sync resizes sizes its untouched swapped heads + through their constraints. A head it gives another size authors that + size, placed in the parent." + [model before after] + (let [sized-alike? #(and (mth/close? (:width %1) (:width %2)) + (mth/close? (:height %1) (:height %2)))] + (reduce-kv + (fn [result id groups] + (let [old (get before id) + shape (get after id) + old-parent (get before (:parent-id old)) + parent (get after (:parent-id shape))] + (if (and (contains? groups :swap-group) + (not (contains? groups :geometry-group)) + old shape old-parent parent + (= (:parent-id old) (:parent-id shape)) + (:shape-ref parent) + (not (sized-alike? old-parent parent)) + (not (sized-alike? old shape))) + (assoc-in result [id :geometry-group] (author-geometry shape parent)) + result))) + model model))) + (defn settle "A detached position turns its copies into ordinary shapes. Their former component choice stops applying; other authored groups stay in place. @@ -818,10 +842,10 @@ ;; a mirror stores its turn either way: the turns of two ;; mirrored mains agree where they point their axes alike (and (= attr :rotation) old-main old-parent new-parent) - (or (same? (get old-placed attr) (get placed attr)) - (and (mirrored? old-placed) (mirrored? placed) - (geom/same-placed-axes? old-main (get before (:parent-id old-main)) old-parent - main (get after (:parent-id main)) new-parent))) + (if (and (mirrored? old-placed) (mirrored? placed)) + (geom/same-placed-axes? old-main (get before (:parent-id old-main)) old-parent + main (get after (:parent-id main)) new-parent) + (same? (get old-placed attr) (get placed attr))) :else (same? (get old-placed attr) (get placed attr)))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index cc7e9b9e09..03b336725a 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2274,6 +2274,14 @@ [:update-main 22 21 23 7] [:text-style 18 0 25 10] [:variant-property 1 9 23 5] [:switch 20]]})))) +(t/deftest switching-a-copy-carries-no-mirrored-turn-its-mains-store-alike-but-point-apart + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles false :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies false :text true}] + :ops [[:swap] [:make-variant 12] [:rotate 0 0 1] [:delete 5] [:restore] [:transform 6 5] + [:transform 3 9 7 13] [:switch] [:undo] [:update-main 1] [:duplicate 2] + [:update-main 15] [:switch]]})))) + (t/deftest pushing-a-grid-direction-orders-the-copies-like-the-reflowed-main (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles false :layout :grid :variant-diff false :layout-item-margins false :grid-square true :rich-variants false