0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-05 03:21:26 -05:00

🐛 Fix problem with auto layout an absolute positioning

This commit is contained in:
alonso.torres 2023-02-28 13:15:48 +01:00
parent c6d1f80af2
commit 8b5a36a49f
4 changed files with 31 additions and 23 deletions

View file

@ -117,7 +117,9 @@
child-bounds))]
(->> children (map get-child-bounds))))
(->> children
(remove ctl/layout-absolute?)
(map get-child-bounds))))
(defn layout-content-bounds
[bounds {:keys [layout-padding] :as parent} children]

View file

@ -96,7 +96,6 @@
"Propagates the modifiers from a parent too its children applying constraints if necesary"
[modif-tree children objects bounds parent transformed-parent-bounds ignore-constraints]
(let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])]
;; Move modifiers don't need to calculate constraints
(if (ctm/only-move? modifiers)
(loop [modif-tree modif-tree
@ -205,14 +204,14 @@
(let [origin (gpo/origin @parent-bounds)
scale-width (/ auto-width (gpo/width-points @parent-bounds))]
(-> modifiers
(ctm/resize-parent (gpt/point scale-width 1) origin (:transform parent) (:transform-inverse parent)))))
(ctm/resize (gpt/point scale-width 1) origin (:transform parent) (:transform-inverse parent)))))
set-parent-auto-height
(fn [modifiers auto-height]
(let [origin (gpo/origin @parent-bounds)
scale-height (/ auto-height (gpo/height-points @parent-bounds))]
(-> modifiers
(ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent)))))
(ctm/resize (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent)))))
children (->> (cph/get-immediate-children objects parent-id)
(remove :hidden))

View file

@ -346,24 +346,6 @@
(defn align-self-stretch? [{:keys [layout-item-align-self]}]
(= :stretch layout-item-align-self))
(defn change-h-sizing?
[frame-id objects children-ids]
(and (layout? objects frame-id)
(auto-width? objects frame-id)
(or (and (col? objects frame-id)
(every? (partial fill-width? objects) children-ids))
(and (row? objects frame-id)
(some (partial fill-width? objects) children-ids)))))
(defn change-v-sizing?
[frame-id objects children-ids]
(and (layout? objects frame-id)
(auto-height? objects frame-id)
(or (and (col? objects frame-id)
(some (partial fill-height? objects) children-ids))
(and (row? objects frame-id)
(every? (partial fill-height? objects) children-ids)))))
(defn layout-absolute?
([objects id]
(layout-absolute? (get objects id)))
@ -376,6 +358,28 @@
([shape]
(or (:layout-item-z-index shape) 0)))
(defn change-h-sizing?
[frame-id objects children-ids]
(and (layout? objects frame-id)
(auto-width? objects frame-id)
(or (and (col? objects frame-id)
(->> children-ids
(remove (partial layout-absolute? objects))
(every? (partial fill-width? objects))))
(and (row? objects frame-id)
(->> children-ids
(remove (partial layout-absolute? objects))
(some (partial fill-width? objects)))))))
(defn change-v-sizing?
[frame-id objects children-ids]
(and (layout? objects frame-id)
(auto-height? objects frame-id)
(or (and (col? objects frame-id)
(some (partial fill-height? objects) children-ids))
(and (row? objects frame-id)
(every? (partial fill-height? objects) children-ids)))))
(defn remove-layout-container-data
[shape]
(dissoc shape

View file

@ -349,7 +349,10 @@
col? (ctl/col? parent)
row? (ctl/row? parent)
all-children (->> parent :shapes (map (d/getf objects)))]
all-children (->> parent
:shapes
(map (d/getf objects))
(remove ctl/layout-absolute?))]
(cond-> shape
;; If the parent is hug width and the direction column