mirror of
https://github.com/penpot/penpot.git
synced 2025-03-14 08:41:48 -05:00
🐛 Fix problems with nested groups
This commit is contained in:
parent
51e8eea795
commit
84c0825893
2 changed files with 20 additions and 22 deletions
|
@ -30,28 +30,28 @@
|
||||||
(or (= :top layout-dir) (= :bottom layout-dir)))
|
(or (= :top layout-dir) (= :bottom layout-dir)))
|
||||||
|
|
||||||
(defn h-start?
|
(defn h-start?
|
||||||
[{:keys [layout-v-orientation]}]
|
[{:keys [layout-h-orientation]}]
|
||||||
(= layout-v-orientation :left))
|
(= layout-h-orientation :left))
|
||||||
|
|
||||||
(defn h-center?
|
(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]}]
|
[{:keys [layout-h-orientation]}]
|
||||||
(= layout-h-orientation :center))
|
(= layout-h-orientation :center))
|
||||||
|
|
||||||
(defn v-end?
|
(defn h-end?
|
||||||
[{:keys [layout-h-orientation]}]
|
[{: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]}]
|
(defn add-padding [transformed-rect {:keys [layout-padding-type layout-padding]}]
|
||||||
(let [{:keys [p1 p2 p3 p4]} layout-padding
|
(let [{:keys [p1 p2 p3 p4]} layout-padding
|
||||||
|
|
|
@ -109,11 +109,10 @@
|
||||||
(letfn [(set-child [transformed-rect snap-pixel? modif-tree child]
|
(letfn [(set-child [transformed-rect snap-pixel? modif-tree child]
|
||||||
(let [modifiers (get-in modif-tree [(:id shape) :modifiers])
|
(let [modifiers (get-in modif-tree [(:id shape) :modifiers])
|
||||||
child-modifiers (gct/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)
|
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
|
(cond-> modif-tree
|
||||||
(not (gtr/empty-modifiers? child-modifiers))
|
(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))
|
(let [children (map (d/getf objects) (:shapes shape))
|
||||||
modifiers (get-in modif-tree [(:id shape) :modifiers])
|
modifiers (get-in modif-tree [(:id shape) :modifiers])
|
||||||
transformed-rect (gtr/transform-selrect (:selrect shape) modifiers)
|
transformed-rect (gtr/transform-selrect (:selrect shape) modifiers)
|
||||||
|
@ -148,7 +147,6 @@
|
||||||
[_ modif-tree]
|
[_ modif-tree]
|
||||||
(reduce (partial set-layout-modifiers shape) [layout-data modif-tree] children)]
|
(reduce (partial set-layout-modifiers shape) [layout-data modif-tree] children)]
|
||||||
|
|
||||||
;;(.log js/console "modif-tree" modif-tree)
|
|
||||||
modif-tree)))
|
modif-tree)))
|
||||||
|
|
||||||
(defn get-first-layout
|
(defn get-first-layout
|
||||||
|
@ -170,7 +168,7 @@
|
||||||
;; Layout found. We continue upward but we mark this layout
|
;; Layout found. We continue upward but we mark this layout
|
||||||
(and (= :frame (:type parent))
|
(and (= :frame (:type parent))
|
||||||
(:layout 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
|
;; If group or boolean or other type of group we continue with the last result
|
||||||
:else
|
:else
|
||||||
|
@ -208,6 +206,6 @@
|
||||||
(cond-> (:layout shape)
|
(cond-> (:layout shape)
|
||||||
(set-layout-modifiers objects current)))]
|
(set-layout-modifiers objects current)))]
|
||||||
|
|
||||||
(recur (first pending) (rest pending) modif-tree #_touched-layouts))
|
(recur (first pending) (rest pending) modif-tree))
|
||||||
|
|
||||||
modif-tree))))
|
modif-tree))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue