diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 3816496173..87f6720669 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -673,7 +673,19 @@ (not= (boolean (:flip-x before)) (boolean (:flip-x after))) (not= (boolean (:flip-y before)) (boolean (:flip-y after))))) ids (when changed? (cfh/get-children-ids (:objects container) (:id before)))] - (if (seq ids) + (cond + ;; 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))) + (let [refit {:type :reg-objects :shapes [(:id before)]}] + (pcb/add-changes changes container [refit] [refit])) + + (seq ids) (let [orientation (fn [shape] (let [matrix (axes-matrix shape)] (assoc shape :transform matrix :transform-inverse (gmt/inverse matrix)))) @@ -704,6 +716,8 @@ (update :touched ctk/set-touched-group :geometry-group)) #(cond-> % (some? turn) turn :always (gsh/move delta))) {:ignore-touched true})) + + :else changes))) (defn- constraint-sized-main diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 8c4022dd28..dc362184b2 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2477,6 +2477,21 @@ :layout-copies false :layout-children true}] :ops [[:add-child 5] [:structure 12] [:transform 12 10 0 12]]})))) +(t/deftest syncing-a-copy-group-keeps-the-place-its-shape-authors + (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants false :text false :layout :grid + :layout-copies false :layout-children false}] + :ops [[:add-child 1] [:structure 2] [:transform 2 0 0 2]]})))) + +(t/deftest syncing-a-copy-group-keeps-the-size-its-shape-authors + (t/is (map? (cg/run {:world [1 0 {:variants true :rich-variants false :text false :layout :grid + :layout-copies false :layout-children false}] + :ops [[:add-child 1] [:structure 2] [:transform 2 2 0 2]]})))) + +(t/deftest undoing-a-turn-of-a-copy-group-gives-the-groups-of-its-copies-their-bounds-back + (t/is (map? (cg/run {:world [2 2 {:variants true :rich-variants true :text true :layout nil + :layout-copies false :layout-children false}] + :ops [[:add-child 7] [:add-child 7] [:structure 13] [:transform 10 15 0 12]]})))) + (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}]