mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🐛 Add limit to growth fill shapes to the bounds of the layout
This commit is contained in:
parent
e7e80e99bd
commit
028c084b22
2 changed files with 37 additions and 6 deletions
|
@ -238,6 +238,30 @@
|
|||
(and col? (< total-min-width rest-layout-width total-max-width) (not (ctl/auto-width? parent)))
|
||||
(distribute-space :line-width :line-min-width :line-max-width total-min-width rest-layout-width))
|
||||
|
||||
;; Add information to limit the growth of width: 100% shapes to the bounds of the layout
|
||||
layout-lines
|
||||
(cond
|
||||
row?
|
||||
(->> layout-lines
|
||||
(reduce
|
||||
(fn [[result rest-layout-height] {:keys [line-height] :as line}]
|
||||
[(conj result (assoc line :to-bound-height rest-layout-height))
|
||||
(- rest-layout-height line-height layout-gap-row)])
|
||||
[[] layout-height])
|
||||
(first))
|
||||
|
||||
col?
|
||||
(->> layout-lines
|
||||
(reduce
|
||||
(fn [[result rest-layout-width] {:keys [line-width] :as line}]
|
||||
[(conj result (assoc line :to-bound-width rest-layout-width))
|
||||
(- rest-layout-width line-width layout-gap-col)])
|
||||
[[] layout-width])
|
||||
(first))
|
||||
|
||||
:else
|
||||
layout-lines)
|
||||
|
||||
[total-width total-height] (->> layout-lines (reduce add-lines [0 0]))
|
||||
|
||||
base-p (flp/get-base-line parent layout-bounds total-width total-height num-lines)]
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
transform-inverse
|
||||
child
|
||||
child-origin child-width
|
||||
{:keys [children-data line-width] :as layout-data}]
|
||||
{:keys [children-data line-width to-bound-width] :as layout-data}]
|
||||
|
||||
(cond
|
||||
(ctl/row? parent)
|
||||
|
@ -30,7 +30,8 @@
|
|||
:modifiers (ctm/resize-modifiers (gpt/point fill-scale 1) child-origin transform transform-inverse)})
|
||||
|
||||
(ctl/col? parent)
|
||||
(let [target-width (max (- line-width (ctl/child-width-margin child)) 0.01)
|
||||
(let [line-width (min line-width (or to-bound-width line-width))
|
||||
target-width (max (- line-width (ctl/child-width-margin child)) 0.01)
|
||||
max-width (ctl/child-max-width child)
|
||||
target-width (min max-width target-width)
|
||||
fill-scale (/ target-width child-width)]
|
||||
|
@ -43,7 +44,7 @@
|
|||
transform transform-inverse
|
||||
child
|
||||
child-origin child-height
|
||||
{:keys [children-data line-height] :as layout-data}]
|
||||
{:keys [children-data line-height to-bound-height] :as layout-data}]
|
||||
|
||||
(cond
|
||||
(ctl/col? parent)
|
||||
|
@ -53,7 +54,8 @@
|
|||
:modifiers (ctm/resize-modifiers (gpt/point 1 fill-scale) child-origin transform transform-inverse)})
|
||||
|
||||
(ctl/row? parent)
|
||||
(let [target-height (max (- line-height (ctl/child-height-margin child)) 0.01)
|
||||
(let [line-height (min line-height (or to-bound-height line-height))
|
||||
target-height (max (- line-height (ctl/child-height-margin child)) 0.01)
|
||||
max-height (ctl/child-max-height child)
|
||||
target-height (min max-height target-height)
|
||||
fill-scale (/ target-height child-height)]
|
||||
|
@ -71,8 +73,13 @@
|
|||
(when (or (ctl/fill-width? child) (ctl/fill-height? child))
|
||||
(gtr/calculate-geometry @parent-bounds))
|
||||
|
||||
fill-width (when (ctl/fill-width? child) (calc-fill-width-data parent transform transform-inverse child child-origin child-width layout-line))
|
||||
fill-height (when (ctl/fill-height? child) (calc-fill-height-data parent transform transform-inverse child child-origin child-height layout-line))
|
||||
fill-width
|
||||
(when (ctl/fill-width? child)
|
||||
(calc-fill-width-data parent transform transform-inverse child child-origin child-width layout-line))
|
||||
|
||||
fill-height
|
||||
(when (ctl/fill-height? child)
|
||||
(calc-fill-height-data parent transform transform-inverse child child-origin child-height layout-line))
|
||||
|
||||
child-width (or (:width fill-width) child-width)
|
||||
child-height (or (:height fill-height) child-height)
|
||||
|
|
Loading…
Add table
Reference in a new issue