mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 05:46:11 +02:00
🐛 Fix problem with hug layout
This commit is contained in:
parent
a439fb65ce
commit
be24989eab
1 changed files with 9 additions and 9 deletions
|
@ -244,13 +244,11 @@
|
||||||
modifiers (-> (dm/get-in modif-tree [parent-id :modifiers])
|
modifiers (-> (dm/get-in modif-tree [parent-id :modifiers])
|
||||||
(ctm/select-geometry))
|
(ctm/select-geometry))
|
||||||
has-modifiers? (ctm/child-modifiers? modifiers)
|
has-modifiers? (ctm/child-modifiers? modifiers)
|
||||||
layout? (ctl/layout? parent)
|
|
||||||
parent? (or (cph/group-like-shape? parent) (cph/frame-shape? parent))
|
parent? (or (cph/group-like-shape? parent) (cph/frame-shape? parent))
|
||||||
|
|
||||||
transformed-parent-bounds (delay (gtr/transform-bounds @(get bounds parent-id) modifiers))]
|
transformed-parent-bounds (delay (gtr/transform-bounds @(get bounds parent-id) modifiers))]
|
||||||
|
|
||||||
(cond-> modif-tree
|
(cond-> modif-tree
|
||||||
(and (not layout?) has-modifiers? parent? (not root?))
|
(and has-modifiers? parent? (not root?))
|
||||||
(set-children-modifiers objects bounds parent transformed-parent-bounds ignore-constraints))))
|
(set-children-modifiers objects bounds parent transformed-parent-bounds ignore-constraints))))
|
||||||
|
|
||||||
(defn- propagate-modifiers-layout
|
(defn- propagate-modifiers-layout
|
||||||
|
@ -312,7 +310,7 @@
|
||||||
"Recalculates the layouts to adjust the sizing: auto new sizes"
|
"Recalculates the layouts to adjust the sizing: auto new sizes"
|
||||||
[modif-tree sizing-auto-layouts objects bounds ignore-constraints]
|
[modif-tree sizing-auto-layouts objects bounds ignore-constraints]
|
||||||
(loop [modif-tree modif-tree
|
(loop [modif-tree modif-tree
|
||||||
bounds (transform-bounds bounds objects modif-tree)
|
bounds bounds
|
||||||
sizing-auto-layouts (reverse sizing-auto-layouts)]
|
sizing-auto-layouts (reverse sizing-auto-layouts)]
|
||||||
(if-let [current (first sizing-auto-layouts)]
|
(if-let [current (first sizing-auto-layouts)]
|
||||||
(let [parent-base (get objects current)
|
(let [parent-base (get objects current)
|
||||||
|
@ -325,7 +323,7 @@
|
||||||
[resize-modif-tree _]
|
[resize-modif-tree _]
|
||||||
(reduce #(propagate-modifiers-layout objects bounds ignore-constraints %1 %2) [resize-modif-tree #{}] tree-seq)
|
(reduce #(propagate-modifiers-layout objects bounds ignore-constraints %1 %2) [resize-modif-tree #{}] tree-seq)
|
||||||
|
|
||||||
bounds (transform-bounds bounds objects resize-modif-tree)
|
bounds (transform-bounds bounds objects resize-modif-tree tree-seq)
|
||||||
|
|
||||||
modif-tree (merge-modif-tree modif-tree resize-modif-tree)]
|
modif-tree (merge-modif-tree modif-tree resize-modif-tree)]
|
||||||
(recur modif-tree bounds (rest sizing-auto-layouts)))
|
(recur modif-tree bounds (rest sizing-auto-layouts)))
|
||||||
|
@ -340,15 +338,17 @@
|
||||||
shapes-tree (resolve-tree-sequence (-> modif-tree keys set) objects)
|
shapes-tree (resolve-tree-sequence (-> modif-tree keys set) objects)
|
||||||
|
|
||||||
;; Calculate the input transformation and constraints
|
;; Calculate the input transformation and constraints
|
||||||
modif-tree' (reduce #(propagate-modifiers-constraints objects bounds ignore-constraints %1 %2) modif-tree shapes-tree)
|
modif-tree (reduce #(propagate-modifiers-constraints objects bounds ignore-constraints %1 %2) modif-tree shapes-tree)
|
||||||
bounds (transform-bounds bounds objects modif-tree' shapes-tree)
|
bounds (transform-bounds bounds objects modif-tree shapes-tree)
|
||||||
|
|
||||||
[modif-tree-layout sizing-auto-layouts]
|
[modif-tree-layout sizing-auto-layouts]
|
||||||
(reduce #(propagate-modifiers-layout objects bounds ignore-constraints %1 %2) [{} #{}] shapes-tree)
|
(reduce #(propagate-modifiers-layout objects bounds ignore-constraints %1 %2) [{} #{}] shapes-tree)
|
||||||
|
|
||||||
modif-tree (merge-modif-tree modif-tree' modif-tree-layout)
|
modif-tree (merge-modif-tree modif-tree modif-tree-layout)
|
||||||
|
|
||||||
;; Calculate hug layouts positions
|
;; Calculate hug layouts positions
|
||||||
|
bounds (transform-bounds bounds objects modif-tree-layout shapes-tree)
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(-> modif-tree
|
(-> modif-tree
|
||||||
(sizing-auto-modifiers sizing-auto-layouts objects bounds ignore-constraints))
|
(sizing-auto-modifiers sizing-auto-layouts objects bounds ignore-constraints))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue