mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
✨ Review changes
This commit is contained in:
parent
6e35b5c6b6
commit
4c5e8f42ce
7 changed files with 245 additions and 209 deletions
|
@ -105,9 +105,8 @@
|
||||||
(child-layout-bound-points parent child)
|
(child-layout-bound-points parent child)
|
||||||
points))]
|
points))]
|
||||||
|
|
||||||
(as-> children $
|
(-> (mapcat child-bounds children)
|
||||||
(mapcat child-bounds $)
|
(gco/transform-points (gco/center-shape parent) (:transform-inverse parent))
|
||||||
(gco/transform-points $ (gco/center-shape parent) (:transform-inverse parent))
|
(gre/squared-points)
|
||||||
(gre/squared-points $)
|
(gpo/pad-points (- pad-top) (- pad-right) (- pad-bottom) (- pad-left))
|
||||||
(gpo/pad-points $ (- pad-top) (- pad-right) (- pad-bottom) (- pad-left))
|
(gre/points->rect))))
|
||||||
(gre/points->rect $))))
|
|
||||||
|
|
|
@ -8,41 +8,22 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.shapes.common :as gco]
|
[app.common.geom.shapes.common :as gco]
|
||||||
[app.common.geom.shapes.flex-layout.lines :as fli]
|
[app.common.geom.shapes.flex-layout.lines :as fli]
|
||||||
[app.common.geom.shapes.rect :as gsr]
|
[app.common.geom.shapes.rect :as gsr]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.shape.layout :as ctl]))
|
[app.common.types.shape.layout :as ctl]))
|
||||||
|
|
||||||
(defn layout-drop-areas
|
(defn drop-child-areas
|
||||||
"Retrieve the layout drop areas to move shapes inside layouts"
|
[{:keys [transform-inverse] :as frame} parent-rect child index reverse? prev-x prev-y last?]
|
||||||
[{:keys [margin-x margin-y] :as frame} layout-data children]
|
|
||||||
|
|
||||||
(let [col? (ctl/col? frame)
|
(let [col? (ctl/col? frame)
|
||||||
row? (ctl/row? frame)
|
row? (ctl/row? frame)
|
||||||
h-center? (and row? (ctl/h-center? frame))
|
|
||||||
h-end? (and row? (ctl/h-end? frame))
|
|
||||||
v-center? (and col? (ctl/v-center? frame))
|
|
||||||
v-end? (and row? (ctl/v-end? frame))
|
|
||||||
reverse? (:reverse? layout-data)
|
|
||||||
|
|
||||||
[layout-gap-row layout-gap-col] (ctl/gaps frame)
|
[layout-gap-row layout-gap-col] (ctl/gaps frame)
|
||||||
|
|
||||||
children (vec (cond->> (d/enumerate children)
|
start-p (-> child :points first)
|
||||||
reverse? reverse))
|
center (gco/center-shape frame)
|
||||||
|
start-p (gmt/transform-point-center start-p center transform-inverse)
|
||||||
redfn-child
|
|
||||||
(fn [[result parent-rect prev-x prev-y] [[index child] next]]
|
|
||||||
(let [prev-x (or prev-x (:x parent-rect))
|
|
||||||
prev-y (or prev-y (:y parent-rect))
|
|
||||||
|
|
||||||
last? (nil? next)
|
|
||||||
|
|
||||||
start-p (gpt/point (:selrect child))
|
|
||||||
start-p (-> start-p
|
|
||||||
(gmt/transform-point-center (gco/center-shape child) (:transform frame))
|
|
||||||
(gmt/transform-point-center (gco/center-shape frame) (:transform-inverse frame)))
|
|
||||||
|
|
||||||
box-x (:x start-p)
|
box-x (:x start-p)
|
||||||
box-y (:y start-p)
|
box-y (:y start-p)
|
||||||
|
@ -52,7 +33,8 @@
|
||||||
x (if col? (:x parent-rect) prev-x)
|
x (if col? (:x parent-rect) prev-x)
|
||||||
y (if row? (:y parent-rect) prev-y)
|
y (if row? (:y parent-rect) prev-y)
|
||||||
|
|
||||||
width (cond
|
width
|
||||||
|
(cond
|
||||||
(and row? last?)
|
(and row? last?)
|
||||||
(- (+ (:x parent-rect) (:width parent-rect)) x)
|
(- (+ (:x parent-rect) (:width parent-rect)) x)
|
||||||
|
|
||||||
|
@ -62,7 +44,8 @@
|
||||||
:else
|
:else
|
||||||
(+ box-width (- box-x prev-x) (/ layout-gap-row 2)))
|
(+ box-width (- box-x prev-x) (/ layout-gap-row 2)))
|
||||||
|
|
||||||
height (cond
|
height
|
||||||
|
(cond
|
||||||
(and col? last?)
|
(and col? last?)
|
||||||
(- (+ (:y parent-rect) (:height parent-rect)) y)
|
(- (+ (:y parent-rect) (:height parent-rect)) y)
|
||||||
|
|
||||||
|
@ -70,32 +53,36 @@
|
||||||
(:height parent-rect)
|
(:height parent-rect)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(+ box-height (- box-y prev-y) (/ layout-gap-col 2)))
|
(+ box-height (- box-y prev-y) (/ layout-gap-col 2)))]
|
||||||
|
|
||||||
[line-area-1 line-area-2]
|
|
||||||
(if row?
|
(if row?
|
||||||
(let [half-point-width (+ (- box-x x) (/ box-width 2))]
|
(let [half-point-width (+ (- box-x x) (/ box-width 2))]
|
||||||
[(-> (gsr/make-rect x y half-point-width height)
|
[(gsr/make-rect x y width height)
|
||||||
|
(-> (gsr/make-rect x y half-point-width height)
|
||||||
(assoc :index (if reverse? (inc index) index)))
|
(assoc :index (if reverse? (inc index) index)))
|
||||||
(-> (gsr/make-rect (+ x half-point-width) y (- width half-point-width) height)
|
(-> (gsr/make-rect (+ x half-point-width) y (- width half-point-width) height)
|
||||||
(assoc :index (if reverse? index (inc index))))])
|
(assoc :index (if reverse? index (inc index))))])
|
||||||
(let [half-point-height (+ (- box-y y) (/ box-height 2))]
|
(let [half-point-height (+ (- box-y y) (/ box-height 2))]
|
||||||
[(-> (gsr/make-rect x y width half-point-height)
|
[(gsr/make-rect x y width height)
|
||||||
|
(-> (gsr/make-rect x y width half-point-height)
|
||||||
(assoc :index (if reverse? (inc index) index)))
|
(assoc :index (if reverse? (inc index) index)))
|
||||||
(-> (gsr/make-rect x (+ y half-point-height) width (- height half-point-height))
|
(-> (gsr/make-rect x (+ y half-point-height) width (- height half-point-height))
|
||||||
(assoc :index (if reverse? index (inc index))))]))
|
(assoc :index (if reverse? index (inc index))))]))))
|
||||||
|
|
||||||
result (conj result line-area-1 line-area-2)]
|
(defn drop-line-area
|
||||||
|
[{:keys [transform-inverse margin-x margin-y] :as frame}
|
||||||
|
{:keys [start-p layout-gap-row layout-gap-col num-children line-width line-height] :as line-data}
|
||||||
|
prev-x prev-y last?]
|
||||||
|
|
||||||
[result parent-rect (+ x width) (+ y height)]))
|
(let [col? (ctl/col? frame)
|
||||||
|
row? (ctl/row? frame)
|
||||||
|
h-center? (and row? (ctl/h-center? frame))
|
||||||
|
h-end? (and row? (ctl/h-end? frame))
|
||||||
|
v-center? (and col? (ctl/v-center? frame))
|
||||||
|
v-end? (and row? (ctl/v-end? frame))
|
||||||
|
|
||||||
redfn-lines
|
center (gco/center-shape frame)
|
||||||
(fn [[result from-idx prev-x prev-y] [{:keys [start-p layout-gap-row layout-gap-col num-children line-width line-height]} next]]
|
start-p (gmt/transform-point-center start-p center transform-inverse)
|
||||||
(let [start-p (gmt/transform-point-center start-p (gco/center-shape frame) (:transform-inverse frame))
|
|
||||||
|
|
||||||
prev-x (or prev-x (:x frame))
|
|
||||||
prev-y (or prev-y (:y frame))
|
|
||||||
last? (nil? next)
|
|
||||||
|
|
||||||
line-width
|
line-width
|
||||||
(if row?
|
(if row?
|
||||||
|
@ -146,17 +133,55 @@
|
||||||
(:height frame)
|
(:height frame)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(+ line-height (- box-y prev-y) (/ layout-gap-col 2)))
|
(+ line-height (- box-y prev-y) (/ layout-gap-col 2)))]
|
||||||
|
(gsr/make-rect x y width height)))
|
||||||
|
|
||||||
line-area (gsr/make-rect x y width height)
|
(defn layout-drop-areas
|
||||||
|
"Retrieve the layout drop areas to move shapes inside layouts"
|
||||||
|
[frame layout-data children]
|
||||||
|
|
||||||
children (subvec children from-idx (+ from-idx num-children))
|
(let [reverse? (:reverse? layout-data)
|
||||||
|
children (vec (cond->> (d/enumerate children) reverse? reverse))
|
||||||
|
lines (:layout-lines layout-data)]
|
||||||
|
|
||||||
result (first (reduce redfn-child [result line-area] (d/with-next children)))]
|
(loop [areas []
|
||||||
|
from-idx 0
|
||||||
|
prev-line-x (:x frame)
|
||||||
|
prev-line-y (:y frame)
|
||||||
|
|
||||||
[result (+ from-idx num-children) (+ x width) (+ y height)]))]
|
current-line (first lines)
|
||||||
|
lines (rest lines)]
|
||||||
|
|
||||||
(first (reduce redfn-lines [[] 0] (d/with-next (:layout-lines layout-data))))))
|
(if (nil? current-line)
|
||||||
|
areas
|
||||||
|
|
||||||
|
(let [line-area (drop-line-area frame current-line prev-line-x prev-line-y (nil? (first lines)))
|
||||||
|
children (subvec children from-idx (+ from-idx (:num-children current-line)))
|
||||||
|
|
||||||
|
next-areas
|
||||||
|
(loop [areas areas
|
||||||
|
prev-child-x (:x line-area)
|
||||||
|
prev-child-y (:y line-area)
|
||||||
|
[index child] (first children)
|
||||||
|
children (rest children)]
|
||||||
|
|
||||||
|
(if (nil? child)
|
||||||
|
areas
|
||||||
|
|
||||||
|
(let [[child-area child-area-start child-area-end]
|
||||||
|
(drop-child-areas frame line-area child index reverse? prev-child-x prev-child-y (nil? (first children)))]
|
||||||
|
(recur (conj areas child-area-start child-area-end)
|
||||||
|
(+ (:x child-area) (:width child-area))
|
||||||
|
(+ (:y child-area) (:height child-area))
|
||||||
|
(first children)
|
||||||
|
(rest children)))))]
|
||||||
|
|
||||||
|
(recur next-areas
|
||||||
|
(+ from-idx (:num-children current-line))
|
||||||
|
(+ (:x line-area) (:width line-area))
|
||||||
|
(+ (:y line-area) (:height line-area))
|
||||||
|
(first lines)
|
||||||
|
(rest lines)))))))
|
||||||
|
|
||||||
(defn get-drop-index
|
(defn get-drop-index
|
||||||
[frame-id objects position]
|
[frame-id objects position]
|
||||||
|
|
|
@ -37,16 +37,24 @@
|
||||||
(or row? (not (ctl/auto-height? shape))))
|
(or row? (not (ctl/auto-height? shape))))
|
||||||
|
|
||||||
[layout-gap-row layout-gap-col] (ctl/gaps shape)
|
[layout-gap-row layout-gap-col] (ctl/gaps shape)
|
||||||
layout-width (gpo/width-points layout-bounds)
|
|
||||||
layout-height (gpo/height-points layout-bounds)
|
|
||||||
|
|
||||||
calculate-line-data
|
layout-width (gpo/width-points layout-bounds)
|
||||||
(fn [[{:keys [line-min-width line-min-height
|
layout-height (gpo/height-points layout-bounds)]
|
||||||
|
|
||||||
|
(loop [line-data nil
|
||||||
|
result []
|
||||||
|
child (first children)
|
||||||
|
children (rest children)]
|
||||||
|
|
||||||
|
(if (nil? child)
|
||||||
|
(cond-> result (some? line-data) (conj line-data))
|
||||||
|
|
||||||
|
(let [{:keys [line-min-width line-min-height
|
||||||
line-max-width line-max-height
|
line-max-width line-max-height
|
||||||
num-children
|
num-children
|
||||||
children-data] :as line-data} result] child]
|
children-data]} line-data
|
||||||
|
|
||||||
(let [child-bounds (gst/parent-coords-points child shape)
|
child-bounds (gst/parent-coords-points child shape)
|
||||||
child-width (gpo/width-points child-bounds)
|
child-width (gpo/width-points child-bounds)
|
||||||
child-height (gpo/height-points child-bounds)
|
child-height (gpo/height-points child-bounds)
|
||||||
child-min-width (ctl/child-min-width child)
|
child-min-width (ctl/child-min-width child)
|
||||||
|
@ -77,31 +85,31 @@
|
||||||
|
|
||||||
next-line-min-width (+ line-min-width next-min-width (* layout-gap-row num-children))
|
next-line-min-width (+ line-min-width next-min-width (* layout-gap-row num-children))
|
||||||
next-line-min-height (+ line-min-height next-min-height (* layout-gap-col num-children))]
|
next-line-min-height (+ line-min-height next-min-height (* layout-gap-col num-children))]
|
||||||
|
|
||||||
(if (and (some? line-data)
|
(if (and (some? line-data)
|
||||||
(or (not wrap?)
|
(or (not wrap?)
|
||||||
(and row? (<= next-line-min-width layout-width))
|
(and row? (<= next-line-min-width layout-width))
|
||||||
(and col? (<= next-line-min-height layout-height))))
|
(and col? (<= next-line-min-height layout-height))))
|
||||||
|
|
||||||
[{:line-min-width (if row? (+ line-min-width next-min-width) (max line-min-width next-min-width))
|
(recur {:line-min-width (if row? (+ line-min-width next-min-width) (max line-min-width next-min-width))
|
||||||
:line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width))
|
:line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width))
|
||||||
:line-min-height (if col? (+ line-min-height next-min-height) (max line-min-height next-min-height))
|
:line-min-height (if col? (+ line-min-height next-min-height) (max line-min-height next-min-height))
|
||||||
:line-max-height (if col? (+ line-max-height next-max-height) (max line-max-height next-max-height))
|
:line-max-height (if col? (+ line-max-height next-max-height) (max line-max-height next-max-height))
|
||||||
:num-children (inc num-children)
|
:num-children (inc num-children)
|
||||||
:children-data (conjv children-data child-data)}
|
:children-data (conjv children-data child-data)}
|
||||||
result]
|
result
|
||||||
|
(first children)
|
||||||
|
(rest children))
|
||||||
|
|
||||||
[{:line-min-width next-min-width
|
(recur {:line-min-width next-min-width
|
||||||
:line-min-height next-min-height
|
:line-min-height next-min-height
|
||||||
:line-max-width next-max-width
|
:line-max-width next-max-width
|
||||||
:line-max-height next-max-height
|
:line-max-height next-max-height
|
||||||
:num-children 1
|
:num-children 1
|
||||||
:children-data [child-data]}
|
:children-data [child-data]}
|
||||||
(cond-> result (some? line-data) (conj line-data))])))
|
(cond-> result (some? line-data) (conj line-data))
|
||||||
|
(first children)
|
||||||
[line-data layout-lines] (reduce calculate-line-data [nil []] children)]
|
(rest children))))))))
|
||||||
|
|
||||||
(cond-> layout-lines (some? line-data) (conj line-data))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn add-space-to-items
|
(defn add-space-to-items
|
||||||
;; Distributes the remainder space between the lines
|
;; Distributes the remainder space between the lines
|
||||||
|
@ -162,8 +170,7 @@
|
||||||
(let [start-p (flp/get-start-line parent layout-bounds layout-line base-p total-width total-height num-lines)
|
(let [start-p (flp/get-start-line parent layout-bounds layout-line base-p total-width total-height num-lines)
|
||||||
next-p (flp/get-next-line parent layout-bounds layout-line base-p total-width total-height num-lines)]
|
next-p (flp/get-next-line parent layout-bounds layout-line base-p total-width total-height num-lines)]
|
||||||
|
|
||||||
[(conj result
|
[(conj result (assoc layout-line :start-p start-p))
|
||||||
(assoc layout-line :start-p start-p))
|
|
||||||
next-p]))]
|
next-p]))]
|
||||||
|
|
||||||
(let [[total-min-width total-min-height total-max-width total-max-height]
|
(let [[total-min-width total-min-height total-max-width total-max-height]
|
||||||
|
@ -303,10 +310,10 @@
|
||||||
layout-lines
|
layout-lines
|
||||||
(->> (init-layout-lines shape children layout-bounds)
|
(->> (init-layout-lines shape children layout-bounds)
|
||||||
(add-lines-positions shape layout-bounds)
|
(add-lines-positions shape layout-bounds)
|
||||||
(mapv (partial add-line-spacing shape layout-bounds))
|
(into []
|
||||||
(mapv (partial add-children-resizes shape)))]
|
(comp (map (partial add-line-spacing shape layout-bounds))
|
||||||
|
(map (partial add-children-resizes shape)))))]
|
||||||
|
|
||||||
{:layout-lines layout-lines
|
{:layout-lines layout-lines
|
||||||
:layout-bounds layout-bounds
|
:layout-bounds layout-bounds
|
||||||
:reverse? reverse?}))
|
:reverse? reverse?}))
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,6 @@
|
||||||
(let [layout-width (gpo/width-points layout-bounds)
|
(let [layout-width (gpo/width-points layout-bounds)
|
||||||
layout-height (gpo/height-points layout-bounds)
|
layout-height (gpo/height-points layout-bounds)
|
||||||
[layout-gap-row layout-gap-col] (ctl/gaps parent)
|
[layout-gap-row layout-gap-col] (ctl/gaps parent)
|
||||||
|
|
||||||
row? (ctl/row? parent)
|
row? (ctl/row? parent)
|
||||||
col? (ctl/col? parent)
|
col? (ctl/col? parent)
|
||||||
space-between? (ctl/space-between? parent)
|
space-between? (ctl/space-between? parent)
|
||||||
|
@ -127,10 +126,8 @@
|
||||||
v-center? (ctl/v-center? parent)
|
v-center? (ctl/v-center? parent)
|
||||||
v-end? (ctl/v-end? parent)
|
v-end? (ctl/v-end? parent)
|
||||||
content-stretch? (ctl/content-stretch? parent)
|
content-stretch? (ctl/content-stretch? parent)
|
||||||
|
hv (partial gpo/start-hv layout-bounds)
|
||||||
hv #(gpo/start-hv layout-bounds %)
|
vv (partial gpo/start-vv layout-bounds)
|
||||||
vv #(gpo/start-vv layout-bounds %)
|
|
||||||
|
|
||||||
children-gap-width (* layout-gap-row (dec num-children))
|
children-gap-width (* layout-gap-row (dec num-children))
|
||||||
children-gap-height (* layout-gap-col (dec num-children))
|
children-gap-height (* layout-gap-col (dec num-children))
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[app.common.geom.shapes.pixel-precision :as gpp]
|
[app.common.geom.shapes.pixel-precision :as gpp]
|
||||||
[app.common.geom.shapes.transforms :as gtr]
|
[app.common.geom.shapes.transforms :as gtr]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
|
[app.common.spec :as us]
|
||||||
[app.common.types.modifiers :as ctm]
|
[app.common.types.modifiers :as ctm]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.common.uuid :as uuid]))
|
[app.common.uuid :as uuid]))
|
||||||
|
@ -30,7 +31,9 @@
|
||||||
"Given the ids that have changed search for layout roots to recalculate"
|
"Given the ids that have changed search for layout roots to recalculate"
|
||||||
[ids objects]
|
[ids objects]
|
||||||
|
|
||||||
(assert (or (nil? ids) (set? ids)) (dm/str "tree sequence from not set: " ids))
|
(us/assert!
|
||||||
|
:expr (or (nil? ids) (set? ids))
|
||||||
|
:hint (dm/str "tree sequence from not set: " ids))
|
||||||
|
|
||||||
(letfn [(get-tree-root ;; Finds the tree root for the current id
|
(letfn [(get-tree-root ;; Finds the tree root for the current id
|
||||||
[id]
|
[id]
|
||||||
|
@ -76,8 +79,8 @@
|
||||||
(generate-tree ;; Generate a tree sequence from a given root id
|
(generate-tree ;; Generate a tree sequence from a given root id
|
||||||
[id]
|
[id]
|
||||||
(->> (tree-seq
|
(->> (tree-seq
|
||||||
#(d/not-empty? (get-in objects [% :shapes]))
|
#(d/not-empty? (dm/get-in objects [% :shapes]))
|
||||||
#(get-in objects [% :shapes])
|
#(dm/get-in objects [% :shapes])
|
||||||
id)
|
id)
|
||||||
(map #(get objects %))))]
|
(map #(get objects %))))]
|
||||||
|
|
||||||
|
@ -90,7 +93,7 @@
|
||||||
"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 objects parent transformed-parent ignore-constraints snap-pixel?]
|
[modif-tree objects parent transformed-parent ignore-constraints snap-pixel?]
|
||||||
(let [children (map (d/getf objects) (:shapes parent))
|
(let [children (map (d/getf objects) (:shapes parent))
|
||||||
modifiers (get-in modif-tree [(:id parent) :modifiers])
|
modifiers (dm/get-in modif-tree [(:id parent) :modifiers])
|
||||||
parent (gtr/transform-shape parent (ctm/select-parent-modifiers modifiers))
|
parent (gtr/transform-shape parent (ctm/select-parent-modifiers modifiers))
|
||||||
|
|
||||||
set-child
|
set-child
|
||||||
|
@ -106,7 +109,7 @@
|
||||||
(defn- process-layout-children
|
(defn- process-layout-children
|
||||||
[modif-tree objects parent transformed-parent]
|
[modif-tree objects parent transformed-parent]
|
||||||
(letfn [(process-child [modif-tree child]
|
(letfn [(process-child [modif-tree child]
|
||||||
(let [modifiers (get-in modif-tree [(:id parent) :modifiers])
|
(let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])
|
||||||
child-modifiers (-> modifiers
|
child-modifiers (-> modifiers
|
||||||
(ctm/select-child-geometry-modifiers)
|
(ctm/select-child-geometry-modifiers)
|
||||||
(gcl/normalize-child-modifiers parent child transformed-parent))]
|
(gcl/normalize-child-modifiers parent child transformed-parent))]
|
||||||
|
@ -120,7 +123,7 @@
|
||||||
[modif-tree objects parent]
|
[modif-tree objects parent]
|
||||||
|
|
||||||
(letfn [(apply-modifiers [modif-tree child]
|
(letfn [(apply-modifiers [modif-tree child]
|
||||||
(let [modifiers (get-in modif-tree [(:id child) :modifiers])]
|
(let [modifiers (dm/get-in modif-tree [(:id child) :modifiers])]
|
||||||
(cond-> child
|
(cond-> child
|
||||||
(some? modifiers)
|
(some? modifiers)
|
||||||
(gtr/transform-shape modifiers)
|
(gtr/transform-shape modifiers)
|
||||||
|
@ -165,7 +168,7 @@
|
||||||
[modif-tree objects parent]
|
[modif-tree objects parent]
|
||||||
(letfn [(apply-modifiers
|
(letfn [(apply-modifiers
|
||||||
[child]
|
[child]
|
||||||
(let [modifiers (get-in modif-tree [(:id child) :modifiers])]
|
(let [modifiers (dm/get-in modif-tree [(:id child) :modifiers])]
|
||||||
(cond-> child
|
(cond-> child
|
||||||
(some? modifiers)
|
(some? modifiers)
|
||||||
(gtr/transform-shape modifiers)
|
(gtr/transform-shape modifiers)
|
||||||
|
@ -187,7 +190,7 @@
|
||||||
(-> modifiers
|
(-> modifiers
|
||||||
(ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent)))))]
|
(ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent)))))]
|
||||||
|
|
||||||
(let [modifiers (get-in modif-tree [(:id parent) :modifiers])
|
(let [modifiers (dm/get-in modif-tree [(:id parent) :modifiers])
|
||||||
children (->> parent
|
children (->> parent
|
||||||
:shapes
|
:shapes
|
||||||
(map (comp apply-modifiers (d/getf objects))))
|
(map (comp apply-modifiers (d/getf objects))))
|
||||||
|
@ -210,7 +213,7 @@
|
||||||
[objects snap-pixel? ignore-constraints [modif-tree recalculate] parent]
|
[objects snap-pixel? ignore-constraints [modif-tree recalculate] parent]
|
||||||
(let [parent-id (:id parent)
|
(let [parent-id (:id parent)
|
||||||
root? (= uuid/zero parent-id)
|
root? (= uuid/zero parent-id)
|
||||||
modifiers (get-in modif-tree [parent-id :modifiers])
|
modifiers (dm/get-in modif-tree [parent-id :modifiers])
|
||||||
|
|
||||||
modifiers (cond-> modifiers
|
modifiers (cond-> modifiers
|
||||||
(and (not root?) (ctm/has-geometry? modifiers) snap-pixel?)
|
(and (not root?) (ctm/has-geometry? modifiers) snap-pixel?)
|
||||||
|
@ -248,7 +251,7 @@
|
||||||
[objects modif-tree parent]
|
[objects modif-tree parent]
|
||||||
(let [is-layout? (ctl/layout? parent)
|
(let [is-layout? (ctl/layout? parent)
|
||||||
is-auto? (or (ctl/auto-height? parent) (ctl/auto-width? parent))
|
is-auto? (or (ctl/auto-height? parent) (ctl/auto-width? parent))
|
||||||
modifiers (get-in modif-tree [(:id parent) :modifiers])
|
modifiers (dm/get-in modif-tree [(:id parent) :modifiers])
|
||||||
transformed-parent (gtr/transform-shape parent modifiers)]
|
transformed-parent (gtr/transform-shape parent modifiers)]
|
||||||
(cond-> modif-tree
|
(cond-> modif-tree
|
||||||
is-layout?
|
is-layout?
|
||||||
|
|
|
@ -12,10 +12,14 @@
|
||||||
|
|
||||||
(defn make-rect
|
(defn make-rect
|
||||||
([p1 p2]
|
([p1 p2]
|
||||||
(let [x1 (min (:x p1) (:x p2))
|
(let [xp1 (:x p1)
|
||||||
y1 (min (:y p1) (:y p2))
|
yp1 (:y p1)
|
||||||
x2 (max (:x p1) (:x p2))
|
xp2 (:x p2)
|
||||||
y2 (max (:y p1) (:y p2))]
|
yp2 (:y p2)
|
||||||
|
x1 (min xp1 xp2)
|
||||||
|
y1 (min yp1 yp2)
|
||||||
|
x2 (max xp1 xp2)
|
||||||
|
y2 (max yp1 yp2)]
|
||||||
(make-rect x1 y1 (- x2 x1) (- y2 y1))))
|
(make-rect x1 y1 (- x2 x1) (- y2 y1))))
|
||||||
|
|
||||||
([x y width height]
|
([x y width height]
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[app.common.geom.shapes.path :as gpa]
|
[app.common.geom.shapes.path :as gpa]
|
||||||
[app.common.geom.shapes.rect :as gpr]
|
[app.common.geom.shapes.rect :as gpr]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.modifiers :as ctm]
|
[app.common.types.modifiers :as ctm]
|
||||||
[app.common.uuid :as uuid]))
|
[app.common.uuid :as uuid]))
|
||||||
|
|
||||||
|
@ -452,7 +453,7 @@
|
||||||
(map (d/getf objects))
|
(map (d/getf objects))
|
||||||
(apply-children-modifiers objects modif-tree))]
|
(apply-children-modifiers objects modif-tree))]
|
||||||
(cond-> parent
|
(cond-> parent
|
||||||
(= :group (:type parent))
|
(cph/group-shape? parent)
|
||||||
(update-group-selrect children))))
|
(update-group-selrect children))))
|
||||||
|
|
||||||
(defn get-children-bounds
|
(defn get-children-bounds
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue