mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 20:31:38 +02:00
🐛 Fix problem with space-around and auto-width/height
This commit is contained in:
parent
e041f93680
commit
9f9d9277a6
2 changed files with 55 additions and 20 deletions
|
@ -87,11 +87,24 @@
|
||||||
(let [parent-id (:id parent)
|
(let [parent-id (:id parent)
|
||||||
parent-bounds @(get bounds parent-id)
|
parent-bounds @(get bounds parent-id)
|
||||||
|
|
||||||
|
row? (ctl/row? parent)
|
||||||
|
col? (ctl/col? parent)
|
||||||
|
space-around? (ctl/space-around? parent)
|
||||||
|
[layout-gap-row layout-gap-col] (ctl/gaps parent)
|
||||||
|
|
||||||
|
row-pad (if (and col? space-around?)
|
||||||
|
layout-gap-row
|
||||||
|
0)
|
||||||
|
|
||||||
|
col-pad (if (and row? space-around?)
|
||||||
|
layout-gap-col
|
||||||
|
0)
|
||||||
|
|
||||||
{pad-top :p1 pad-right :p2 pad-bottom :p3 pad-left :p4} layout-padding
|
{pad-top :p1 pad-right :p2 pad-bottom :p3 pad-left :p4} layout-padding
|
||||||
pad-top (or pad-top 0)
|
pad-top (+ (or pad-top 0) row-pad)
|
||||||
pad-right (or pad-right 0)
|
pad-right (+ (or pad-right 0) col-pad)
|
||||||
pad-bottom (or pad-bottom 0)
|
pad-bottom (+ (or pad-bottom 0) row-pad)
|
||||||
pad-left (or pad-left 0)
|
pad-left (+ (or pad-left 0) col-pad)
|
||||||
|
|
||||||
child-bounds
|
child-bounds
|
||||||
(fn [child]
|
(fn [child]
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
(let [col? (ctl/col? shape)
|
(let [col? (ctl/col? shape)
|
||||||
row? (ctl/row? shape)
|
row? (ctl/row? shape)
|
||||||
|
space-around? (ctl/space-around? shape)
|
||||||
|
|
||||||
wrap? (and (ctl/wrap? shape)
|
wrap? (and (ctl/wrap? shape)
|
||||||
(or col? (not (ctl/auto-width? shape)))
|
(or col? (not (ctl/auto-width? shape)))
|
||||||
|
@ -77,8 +78,18 @@
|
||||||
next-max-width (+ child-margin-width (if fill-width? child-max-width child-width))
|
next-max-width (+ child-margin-width (if fill-width? child-max-width child-width))
|
||||||
next-max-height (+ child-margin-height (if fill-height? child-max-height child-height))
|
next-max-height (+ child-margin-height (if fill-height? child-max-height child-height))
|
||||||
|
|
||||||
next-line-min-width (+ line-min-width next-min-width (* layout-gap-col num-children))
|
total-gap-col (if space-around?
|
||||||
next-line-min-height (+ line-min-height next-min-height (* layout-gap-row num-children))]
|
(* layout-gap-col (+ num-children 2))
|
||||||
|
(* layout-gap-col num-children))
|
||||||
|
|
||||||
|
total-gap-row (if space-around?
|
||||||
|
(* layout-gap-row (+ num-children 2))
|
||||||
|
(* layout-gap-row num-children))
|
||||||
|
|
||||||
|
next-line-min-width (+ line-min-width next-min-width total-gap-col)
|
||||||
|
next-line-min-height (+ line-min-height next-min-height total-gap-row)
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
(if (and (some? line-data)
|
(if (and (some? line-data)
|
||||||
(or (not wrap?)
|
(or (not wrap?)
|
||||||
|
@ -226,16 +237,38 @@
|
||||||
|
|
||||||
row? (ctl/row? shape)
|
row? (ctl/row? shape)
|
||||||
col? (ctl/col? shape)
|
col? (ctl/col? shape)
|
||||||
|
auto-height? (ctl/auto-height? shape)
|
||||||
|
auto-width? (ctl/auto-width? shape)
|
||||||
space-between? (ctl/space-between? shape)
|
space-between? (ctl/space-between? shape)
|
||||||
space-around? (ctl/space-around? shape)
|
space-around? (ctl/space-around? shape)
|
||||||
|
|
||||||
[layout-gap-row layout-gap-col] (ctl/gaps shape)
|
[layout-gap-row layout-gap-col] (ctl/gaps shape)
|
||||||
|
|
||||||
|
margin-x
|
||||||
|
(cond (and row? space-around? (not auto-width?))
|
||||||
|
(max layout-gap-col (/ (- width line-width) (inc num-children)))
|
||||||
|
|
||||||
|
(and row? space-around? auto-width?)
|
||||||
|
layout-gap-col
|
||||||
|
|
||||||
|
:else
|
||||||
|
0)
|
||||||
|
|
||||||
|
margin-y
|
||||||
|
(cond (and col? space-around? (not auto-height?))
|
||||||
|
(max layout-gap-row (/ (- height line-height) (inc num-children)))
|
||||||
|
|
||||||
|
(and col? space-around? auto-height?)
|
||||||
|
layout-gap-row
|
||||||
|
|
||||||
|
:else
|
||||||
|
0)
|
||||||
|
|
||||||
layout-gap-col
|
layout-gap-col
|
||||||
(cond (and row? space-around?)
|
(cond (and row? space-around?)
|
||||||
0
|
0
|
||||||
|
|
||||||
(and row? space-between?)
|
(and row? space-between? (not auto-width?))
|
||||||
(max layout-gap-col (/ (- width line-width) (dec num-children)))
|
(max layout-gap-col (/ (- width line-width) (dec num-children)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
@ -245,21 +278,11 @@
|
||||||
(cond (and col? space-around?)
|
(cond (and col? space-around?)
|
||||||
0
|
0
|
||||||
|
|
||||||
(and col? space-between?)
|
(and col? space-between? (not auto-height?))
|
||||||
(max layout-gap-row (/ (- height line-height) (dec num-children)))
|
(max layout-gap-row (/ (- height line-height) (dec num-children)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
layout-gap-row)
|
layout-gap-row)]
|
||||||
|
|
||||||
margin-x
|
|
||||||
(if (and row? space-around?)
|
|
||||||
(/ (- width line-width) (inc num-children))
|
|
||||||
0)
|
|
||||||
|
|
||||||
margin-y
|
|
||||||
(if (and col? space-around?)
|
|
||||||
(/ (- height line-height) (inc num-children))
|
|
||||||
0)]
|
|
||||||
(assoc line-data
|
(assoc line-data
|
||||||
:layout-bounds layout-bounds
|
:layout-bounds layout-bounds
|
||||||
:layout-gap-row layout-gap-row
|
:layout-gap-row layout-gap-row
|
||||||
|
@ -308,4 +331,3 @@
|
||||||
{:layout-lines layout-lines
|
{:layout-lines layout-lines
|
||||||
:layout-bounds layout-bounds
|
:layout-bounds layout-bounds
|
||||||
:reverse? reverse?}))
|
:reverse? reverse?}))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue