mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 06:41:37 +02:00
🐛 Fix function signature
This commit is contained in:
parent
e7f05f2efc
commit
1378e88431
1 changed files with 65 additions and 62 deletions
|
@ -27,91 +27,94 @@
|
||||||
|
|
||||||
(defn child-layout-bound-points
|
(defn child-layout-bound-points
|
||||||
"Returns the bounds of the children as points"
|
"Returns the bounds of the children as points"
|
||||||
[parent child parent-bounds child-bounds correct-v bounds objects]
|
([parent child parent-bounds child-bounds bounds objects]
|
||||||
|
(child-layout-bound-points parent child parent-bounds child-bounds (gpt/point) bounds objects))
|
||||||
|
|
||||||
(let [row? (ctl/row? parent)
|
([parent child parent-bounds child-bounds correct-v bounds objects]
|
||||||
col? (ctl/col? parent)
|
|
||||||
|
|
||||||
hv (partial gpo/start-hv parent-bounds)
|
(let [row? (ctl/row? parent)
|
||||||
vv (partial gpo/start-vv parent-bounds)
|
col? (ctl/col? parent)
|
||||||
|
|
||||||
v-start? (ctl/v-start? parent)
|
hv (partial gpo/start-hv parent-bounds)
|
||||||
v-center? (ctl/v-center? parent)
|
vv (partial gpo/start-vv parent-bounds)
|
||||||
v-end? (ctl/v-end? parent)
|
|
||||||
h-start? (ctl/h-start? parent)
|
|
||||||
h-center? (ctl/h-center? parent)
|
|
||||||
h-end? (ctl/h-end? parent)
|
|
||||||
|
|
||||||
base-p (gpo/origin child-bounds)
|
v-start? (ctl/v-start? parent)
|
||||||
|
v-center? (ctl/v-center? parent)
|
||||||
|
v-end? (ctl/v-end? parent)
|
||||||
|
h-start? (ctl/h-start? parent)
|
||||||
|
h-center? (ctl/h-center? parent)
|
||||||
|
h-end? (ctl/h-end? parent)
|
||||||
|
|
||||||
width (gpo/width-points child-bounds)
|
base-p (gpo/origin child-bounds)
|
||||||
height (gpo/height-points child-bounds)
|
|
||||||
|
|
||||||
min-width (child-min-width child child-bounds bounds objects)
|
width (gpo/width-points child-bounds)
|
||||||
min-height (child-min-height child child-bounds bounds objects)
|
height (gpo/height-points child-bounds)
|
||||||
|
|
||||||
;; This is the leftmost (when row) or topmost (when col) point
|
min-width (child-min-width child child-bounds bounds objects)
|
||||||
;; Will be added always to the bounds and then calculated the other limits
|
min-height (child-min-height child child-bounds bounds objects)
|
||||||
;; from there
|
|
||||||
base-p (cond-> base-p
|
|
||||||
(and row? v-center?)
|
|
||||||
(gpt/add (vv (/ height 2)))
|
|
||||||
|
|
||||||
(and row? v-end?)
|
;; This is the leftmost (when row) or topmost (when col) point
|
||||||
(gpt/add (vv height))
|
;; Will be added always to the bounds and then calculated the other limits
|
||||||
|
;; from there
|
||||||
|
base-p (cond-> base-p
|
||||||
|
(and row? v-center?)
|
||||||
|
(gpt/add (vv (/ height 2)))
|
||||||
|
|
||||||
(and col? h-center?)
|
(and row? v-end?)
|
||||||
(gpt/add (hv (/ width 2)))
|
(gpt/add (vv height))
|
||||||
|
|
||||||
(and col? h-end?)
|
(and col? h-center?)
|
||||||
(gpt/add (hv width)))
|
(gpt/add (hv (/ width 2)))
|
||||||
|
|
||||||
;; We need some height/width to calculate the bounds. We stablish the minimum
|
(and col? h-end?)
|
||||||
min-width (max min-width 0.01)
|
(gpt/add (hv width)))
|
||||||
min-height (max min-height 0.01)
|
|
||||||
|
|
||||||
base-p (gpt/add base-p correct-v)
|
;; We need some height/width to calculate the bounds. We stablish the minimum
|
||||||
|
min-width (max min-width 0.01)
|
||||||
|
min-height (max min-height 0.01)
|
||||||
|
|
||||||
result
|
base-p (gpt/add base-p correct-v)
|
||||||
(cond-> [base-p
|
|
||||||
(gpt/add base-p (hv 0.01))
|
|
||||||
(gpt/add base-p (vv 0.01))]
|
|
||||||
|
|
||||||
col?
|
result
|
||||||
(conj (gpt/add base-p (vv min-height)))
|
(cond-> [base-p
|
||||||
|
(gpt/add base-p (hv 0.01))
|
||||||
|
(gpt/add base-p (vv 0.01))]
|
||||||
|
|
||||||
row?
|
col?
|
||||||
(conj (gpt/add base-p (hv min-width)))
|
(conj (gpt/add base-p (vv min-height)))
|
||||||
|
|
||||||
(and col? h-start?)
|
row?
|
||||||
(conj (gpt/add base-p (hv min-width)))
|
(conj (gpt/add base-p (hv min-width)))
|
||||||
|
|
||||||
(and col? h-center?)
|
(and col? h-start?)
|
||||||
(conj (gpt/add base-p (hv (/ min-width 2)))
|
(conj (gpt/add base-p (hv min-width)))
|
||||||
(gpt/subtract base-p (hv (/ min-width 2))))
|
|
||||||
|
|
||||||
(and col? h-end?)
|
(and col? h-center?)
|
||||||
(conj (gpt/subtract base-p (hv min-width)))
|
(conj (gpt/add base-p (hv (/ min-width 2)))
|
||||||
|
(gpt/subtract base-p (hv (/ min-width 2))))
|
||||||
|
|
||||||
(and row? v-start?)
|
(and col? h-end?)
|
||||||
(conj (gpt/add base-p (vv min-height)))
|
(conj (gpt/subtract base-p (hv min-width)))
|
||||||
|
|
||||||
(and row? v-center?)
|
(and row? v-start?)
|
||||||
(conj (gpt/add base-p (vv (/ min-height 2)))
|
(conj (gpt/add base-p (vv min-height)))
|
||||||
(gpt/subtract base-p (vv (/ min-height 2))))
|
|
||||||
|
|
||||||
(and row? v-end?)
|
(and row? v-center?)
|
||||||
(conj (gpt/subtract base-p (vv min-height))))
|
(conj (gpt/add base-p (vv (/ min-height 2)))
|
||||||
|
(gpt/subtract base-p (vv (/ min-height 2))))
|
||||||
|
|
||||||
correct-v
|
(and row? v-end?)
|
||||||
(cond-> correct-v
|
(conj (gpt/subtract base-p (vv min-height))))
|
||||||
(and row? (ctl/fill-width? child))
|
|
||||||
(gpt/subtract (hv (+ width min-width)))
|
|
||||||
|
|
||||||
(and col? (ctl/fill-height? child))
|
correct-v
|
||||||
(gpt/subtract (vv (+ height min-height)))
|
(cond-> correct-v
|
||||||
)]
|
(and row? (ctl/fill-width? child))
|
||||||
[result correct-v]))
|
(gpt/subtract (hv (+ width min-width)))
|
||||||
|
|
||||||
|
(and col? (ctl/fill-height? child))
|
||||||
|
(gpt/subtract (vv (+ height min-height)))
|
||||||
|
)]
|
||||||
|
[result correct-v])))
|
||||||
|
|
||||||
(defn layout-content-points
|
(defn layout-content-points
|
||||||
[bounds parent children objects]
|
[bounds parent children objects]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue