0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 00:01:51 -05:00

🐛 Fix problems with nested groups

This commit is contained in:
alonso.torres 2022-07-05 13:15:20 +02:00 committed by Andrey Antukh
parent 51e8eea795
commit 84c0825893
2 changed files with 20 additions and 22 deletions

View file

@ -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

View file

@ -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))))