mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Fix problem with auto layout an absolute positioning
This commit is contained in:
parent
c6d1f80af2
commit
8b5a36a49f
4 changed files with 31 additions and 23 deletions
|
@ -117,7 +117,9 @@
|
||||||
|
|
||||||
child-bounds))]
|
child-bounds))]
|
||||||
|
|
||||||
(->> children (map get-child-bounds))))
|
(->> children
|
||||||
|
(remove ctl/layout-absolute?)
|
||||||
|
(map get-child-bounds))))
|
||||||
|
|
||||||
(defn layout-content-bounds
|
(defn layout-content-bounds
|
||||||
[bounds {:keys [layout-padding] :as parent} children]
|
[bounds {:keys [layout-padding] :as parent} children]
|
||||||
|
|
|
@ -96,7 +96,6 @@
|
||||||
"Propagates the modifiers from a parent too its children applying constraints if necesary"
|
"Propagates the modifiers from a parent too its children applying constraints if necesary"
|
||||||
[modif-tree children objects bounds parent transformed-parent-bounds ignore-constraints]
|
[modif-tree children objects bounds parent transformed-parent-bounds ignore-constraints]
|
||||||
(let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])]
|
(let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])]
|
||||||
|
|
||||||
;; Move modifiers don't need to calculate constraints
|
;; Move modifiers don't need to calculate constraints
|
||||||
(if (ctm/only-move? modifiers)
|
(if (ctm/only-move? modifiers)
|
||||||
(loop [modif-tree modif-tree
|
(loop [modif-tree modif-tree
|
||||||
|
@ -205,14 +204,14 @@
|
||||||
(let [origin (gpo/origin @parent-bounds)
|
(let [origin (gpo/origin @parent-bounds)
|
||||||
scale-width (/ auto-width (gpo/width-points @parent-bounds))]
|
scale-width (/ auto-width (gpo/width-points @parent-bounds))]
|
||||||
(-> modifiers
|
(-> 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
|
set-parent-auto-height
|
||||||
(fn [modifiers auto-height]
|
(fn [modifiers auto-height]
|
||||||
(let [origin (gpo/origin @parent-bounds)
|
(let [origin (gpo/origin @parent-bounds)
|
||||||
scale-height (/ auto-height (gpo/height-points @parent-bounds))]
|
scale-height (/ auto-height (gpo/height-points @parent-bounds))]
|
||||||
(-> modifiers
|
(-> 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)
|
children (->> (cph/get-immediate-children objects parent-id)
|
||||||
(remove :hidden))
|
(remove :hidden))
|
||||||
|
|
|
@ -346,24 +346,6 @@
|
||||||
(defn align-self-stretch? [{:keys [layout-item-align-self]}]
|
(defn align-self-stretch? [{:keys [layout-item-align-self]}]
|
||||||
(= :stretch 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?
|
(defn layout-absolute?
|
||||||
([objects id]
|
([objects id]
|
||||||
(layout-absolute? (get objects id)))
|
(layout-absolute? (get objects id)))
|
||||||
|
@ -376,6 +358,28 @@
|
||||||
([shape]
|
([shape]
|
||||||
(or (:layout-item-z-index shape) 0)))
|
(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
|
(defn remove-layout-container-data
|
||||||
[shape]
|
[shape]
|
||||||
(dissoc shape
|
(dissoc shape
|
||||||
|
|
|
@ -349,7 +349,10 @@
|
||||||
col? (ctl/col? parent)
|
col? (ctl/col? parent)
|
||||||
row? (ctl/row? 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
|
(cond-> shape
|
||||||
;; If the parent is hug width and the direction column
|
;; If the parent is hug width and the direction column
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue