diff --git a/common/src/app/common/geom/modifiers.cljc b/common/src/app/common/geom/modifiers.cljc index ec4646f66..bd6253e46 100644 --- a/common/src/app/common/geom/modifiers.cljc +++ b/common/src/app/common/geom/modifiers.cljc @@ -308,6 +308,17 @@ (reduce calculate-modifiers [modif-tree bounds]) (first)))) +(defn filter-layouts-ids + "Returns a list of ids without the root-frames with only move" + [objects modif-tree] + (->> modif-tree + (remove (fn [[id {:keys [modifiers]}]] + (or (ctm/empty? modifiers) + (and (cfh/root-frame? objects id) + (ctm/only-move? modifiers))))) + (map first) + (set))) + (defn set-objects-modifiers "Applies recursively the modifiers and calculate the layouts and constraints for all the items to be placed correctly" ([modif-tree objects] @@ -331,9 +342,13 @@ (cgt/apply-structure-modifiers modif-tree)) ;; Creates the sequence of shapes with the shapes that are modified - shapes-tree + shapes-tree-all (cgst/resolve-tree (-> modif-tree keys set) objects) + ;; This second sequence is used to recalculate layouts (we remove moved root-frames) + shapes-tree-layout + (cgst/resolve-tree (filter-layouts-ids objects modif-tree) objects) + bounds-map (cond-> (cgb/objects->bounds-map objects) (some? old-modif-tree) @@ -347,13 +362,13 @@ ;; Propagates the modifiers to the normal shapes with constraints modif-tree - (propagate-modifiers-constraints objects bounds-map ignore-constraints modif-tree shapes-tree) + (propagate-modifiers-constraints objects bounds-map ignore-constraints modif-tree shapes-tree-all) bounds-map (cgb/transform-bounds-map bounds-map objects modif-tree) modif-tree-layout - (propagate-modifiers-layouts objects bounds-map ignore-constraints shapes-tree) + (propagate-modifiers-layouts objects bounds-map ignore-constraints shapes-tree-layout) modif-tree (cgt/merge-modif-tree modif-tree modif-tree-layout) @@ -363,7 +378,7 @@ (cgb/transform-bounds-map bounds-map objects modif-tree-layout) ;; Find layouts with auto width/height - sizing-auto-layouts (find-auto-layouts objects shapes-tree) + sizing-auto-layouts (find-auto-layouts objects shapes-tree-layout) modif-tree (sizing-auto-modifiers modif-tree sizing-auto-layouts objects bounds-map ignore-constraints)