From 84c082589365c395031275968fd0817eb4e3b0dc Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 5 Jul 2022 13:15:20 +0200 Subject: [PATCH] :bug: Fix problems with nested groups --- common/src/app/common/geom/shapes/layout.cljc | 32 +++++++++---------- .../src/app/common/geom/shapes/modifiers.cljc | 10 +++--- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/common/src/app/common/geom/shapes/layout.cljc b/common/src/app/common/geom/shapes/layout.cljc index 969526c86f..d369514b75 100644 --- a/common/src/app/common/geom/shapes/layout.cljc +++ b/common/src/app/common/geom/shapes/layout.cljc @@ -30,28 +30,28 @@ (or (= :top layout-dir) (= :bottom layout-dir))) (defn h-start? - [{:keys [layout-v-orientation]}] - (= layout-v-orientation :left)) + [{:keys [layout-h-orientation]}] + (= layout-h-orientation :left)) (defn h-center? - [{:keys [layout-v-orientation]}] - (= layout-v-orientation :center)) - -(defn h-end? - [{:keys [layout-v-orientation]}] - (= layout-v-orientation :right)) - -(defn v-start? - [{:keys [layout-h-orientation]}] - (= layout-h-orientation :top)) - -(defn v-center? [{:keys [layout-h-orientation]}] (= layout-h-orientation :center)) -(defn v-end? +(defn h-end? [{:keys [layout-h-orientation]}] - (= layout-h-orientation :bottom)) + (= layout-h-orientation :right)) + +(defn v-start? + [{:keys [layout-v-orientation]}] + (= layout-v-orientation :top)) + +(defn v-center? + [{:keys [layout-v-orientation]}] + (= layout-v-orientation :center)) + +(defn v-end? + [{:keys [layout-v-orientation]}] + (= layout-v-orientation :bottom)) (defn add-padding [transformed-rect {:keys [layout-padding-type layout-padding]}] (let [{:keys [p1 p2 p3 p4]} layout-padding diff --git a/common/src/app/common/geom/shapes/modifiers.cljc b/common/src/app/common/geom/shapes/modifiers.cljc index 7b6325da00..a548c85ce1 100644 --- a/common/src/app/common/geom/shapes/modifiers.cljc +++ b/common/src/app/common/geom/shapes/modifiers.cljc @@ -109,11 +109,10 @@ (letfn [(set-child [transformed-rect snap-pixel? modif-tree child] (let [modifiers (get-in modif-tree [(:id shape) :modifiers]) child-modifiers (gct/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect) - child-modifiers (cond-> child-modifiers snap-pixel? (set-pixel-precision child)) - ] + child-modifiers (cond-> child-modifiers snap-pixel? (set-pixel-precision child))] (cond-> modif-tree (not (gtr/empty-modifiers? child-modifiers)) - (assoc (:id child) {:modifiers child-modifiers}))))] + (update-in [(:id child) :modifiers] #(merge % child-modifiers)))))] (let [children (map (d/getf objects) (:shapes shape)) modifiers (get-in modif-tree [(:id shape) :modifiers]) transformed-rect (gtr/transform-selrect (:selrect shape) modifiers) @@ -148,7 +147,6 @@ [_ modif-tree] (reduce (partial set-layout-modifiers shape) [layout-data modif-tree] children)] - ;;(.log js/console "modif-tree" modif-tree) modif-tree))) (defn get-first-layout @@ -170,7 +168,7 @@ ;; Layout found. We continue upward but we mark this layout (and (= :frame (:type parent)) (:layout parent)) - (recur (:id parent) (:id parent)) + (:id parent) ;; If group or boolean or other type of group we continue with the last result :else @@ -208,6 +206,6 @@ (cond-> (:layout shape) (set-layout-modifiers objects current)))] - (recur (first pending) (rest pending) modif-tree #_touched-layouts)) + (recur (first pending) (rest pending) modif-tree)) modif-tree))))