Review changes

This commit is contained in:
alonso.torres 2022-11-10 14:55:13 +01:00
parent 6e35b5c6b6
commit 4c5e8f42ce
7 changed files with 245 additions and 209 deletions

View file

@ -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 $))))

View file

@ -8,16 +8,71 @@
(: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)
row? (ctl/row? frame)
[layout-gap-row layout-gap-col] (ctl/gaps frame)
start-p (-> child :points first)
center (gco/center-shape frame)
start-p (gmt/transform-point-center start-p center transform-inverse)
box-x (:x start-p)
box-y (:y start-p)
box-width (-> child :selrect :width)
box-height (-> child :selrect :height)
x (if col? (:x parent-rect) prev-x)
y (if row? (:y parent-rect) prev-y)
width
(cond
(and row? last?)
(- (+ (:x parent-rect) (:width parent-rect)) x)
col?
(:width parent-rect)
:else
(+ box-width (- box-x prev-x) (/ layout-gap-row 2)))
height
(cond
(and col? last?)
(- (+ (:y parent-rect) (:height parent-rect)) y)
row?
(:height parent-rect)
:else
(+ box-height (- box-y prev-y) (/ layout-gap-col 2)))]
(if row?
(let [half-point-width (+ (- box-x x) (/ box-width 2))]
[(gsr/make-rect x y width height)
(-> (gsr/make-rect x y half-point-width height)
(assoc :index (if reverse? (inc index) index)))
(-> (gsr/make-rect (+ x half-point-width) y (- width half-point-width) height)
(assoc :index (if reverse? index (inc index))))])
(let [half-point-height (+ (- box-y y) (/ box-height 2))]
[(gsr/make-rect x y width height)
(-> (gsr/make-rect x y width half-point-height)
(assoc :index (if reverse? (inc index) index)))
(-> (gsr/make-rect x (+ y half-point-height) width (- height half-point-height))
(assoc :index (if reverse? index (inc index))))]))))
(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?]
(let [col? (ctl/col? frame) (let [col? (ctl/col? frame)
row? (ctl/row? frame) row? (ctl/row? frame)
@ -25,138 +80,108 @@
h-end? (and row? (ctl/h-end? frame)) h-end? (and row? (ctl/h-end? frame))
v-center? (and col? (ctl/v-center? frame)) v-center? (and col? (ctl/v-center? frame))
v-end? (and row? (ctl/v-end? frame)) v-end? (and row? (ctl/v-end? frame))
reverse? (:reverse? layout-data)
[layout-gap-row layout-gap-col] (ctl/gaps frame) center (gco/center-shape frame)
start-p (gmt/transform-point-center start-p center transform-inverse)
children (vec (cond->> (d/enumerate children) line-width
reverse? reverse)) (if row?
(:width frame)
(+ line-width margin-x
(if row? (* layout-gap-row (dec num-children)) 0)))
redfn-child line-height
(fn [[result parent-rect prev-x prev-y] [[index child] next]] (if col?
(let [prev-x (or prev-x (:x parent-rect)) (:height frame)
prev-y (or prev-y (:y parent-rect)) (+ line-height margin-y
(if col?
(* layout-gap-col (dec num-children))
0)))
last? (nil? next) box-x
(- (:x start-p)
(cond
h-center? (/ line-width 2)
h-end? line-width
:else 0))
start-p (gpt/point (:selrect child)) box-y
start-p (-> start-p (- (:y start-p)
(gmt/transform-point-center (gco/center-shape child) (:transform frame)) (cond
(gmt/transform-point-center (gco/center-shape frame) (:transform-inverse frame))) v-center? (/ line-height 2)
v-end? line-height
:else 0))
box-x (:x start-p) x (if row? (:x frame) prev-x)
box-y (:y start-p) y (if col? (:y frame) prev-y)
box-width (-> child :selrect :width)
box-height (-> child :selrect :height)
x (if col? (:x parent-rect) prev-x) width (cond
y (if row? (:y parent-rect) prev-y) (and col? last?)
(- (+ (:x frame) (:width frame)) x)
width (cond row?
(and row? last?) (:width frame)
(- (+ (:x parent-rect) (:width parent-rect)) x)
col? :else
(:width parent-rect) (+ line-width (- box-x prev-x) (/ layout-gap-row 2)))
:else height (cond
(+ box-width (- box-x prev-x) (/ layout-gap-row 2))) (and row? last?)
(- (+ (:y frame) (:height frame)) y)
height (cond col?
(and col? last?) (:height frame)
(- (+ (:y parent-rect) (:height parent-rect)) y)
row? :else
(:height parent-rect) (+ line-height (- box-y prev-y) (/ layout-gap-col 2)))]
(gsr/make-rect x y width height)))
:else (defn layout-drop-areas
(+ box-height (- box-y prev-y) (/ layout-gap-col 2))) "Retrieve the layout drop areas to move shapes inside layouts"
[frame layout-data children]
[line-area-1 line-area-2] (let [reverse? (:reverse? layout-data)
(if row? children (vec (cond->> (d/enumerate children) reverse? reverse))
(let [half-point-width (+ (- box-x x) (/ box-width 2))] lines (:layout-lines layout-data)]
[(-> (gsr/make-rect x y half-point-width height)
(assoc :index (if reverse? (inc index) index)))
(-> (gsr/make-rect (+ x half-point-width) y (- width half-point-width) height)
(assoc :index (if reverse? index (inc index))))])
(let [half-point-height (+ (- box-y y) (/ box-height 2))]
[(-> (gsr/make-rect x y width half-point-height)
(assoc :index (if reverse? (inc index) index)))
(-> (gsr/make-rect x (+ y half-point-height) width (- height half-point-height))
(assoc :index (if reverse? index (inc index))))]))
result (conj result line-area-1 line-area-2)] (loop [areas []
from-idx 0
prev-line-x (:x frame)
prev-line-y (:y frame)
[result parent-rect (+ x width) (+ y height)])) current-line (first lines)
lines (rest lines)]
redfn-lines (if (nil? current-line)
(fn [[result from-idx prev-x prev-y] [{:keys [start-p layout-gap-row layout-gap-col num-children line-width line-height]} next]] areas
(let [start-p (gmt/transform-point-center start-p (gco/center-shape frame) (:transform-inverse frame))
prev-x (or prev-x (:x frame)) (let [line-area (drop-line-area frame current-line prev-line-x prev-line-y (nil? (first lines)))
prev-y (or prev-y (:y frame)) children (subvec children from-idx (+ from-idx (:num-children current-line)))
last? (nil? next)
line-width next-areas
(if row? (loop [areas areas
(:width frame) prev-child-x (:x line-area)
(+ line-width margin-x prev-child-y (:y line-area)
(if row? (* layout-gap-row (dec num-children)) 0))) [index child] (first children)
children (rest children)]
line-height (if (nil? child)
(if col? areas
(:height frame)
(+ line-height margin-y
(if col?
(* layout-gap-col (dec num-children))
0)))
box-x (let [[child-area child-area-start child-area-end]
(- (:x start-p) (drop-child-areas frame line-area child index reverse? prev-child-x prev-child-y (nil? (first children)))]
(cond (recur (conj areas child-area-start child-area-end)
h-center? (/ line-width 2) (+ (:x child-area) (:width child-area))
h-end? line-width (+ (:y child-area) (:height child-area))
:else 0)) (first children)
(rest children)))))]
box-y (recur next-areas
(- (:y start-p) (+ from-idx (:num-children current-line))
(cond (+ (:x line-area) (:width line-area))
v-center? (/ line-height 2) (+ (:y line-area) (:height line-area))
v-end? line-height (first lines)
:else 0)) (rest lines)))))))
x (if row? (:x frame) prev-x)
y (if col? (:y frame) prev-y)
width (cond
(and col? last?)
(- (+ (:x frame) (:width frame)) x)
row?
(:width frame)
:else
(+ line-width (- box-x prev-x) (/ layout-gap-row 2)))
height (cond
(and row? last?)
(- (+ (:y frame) (:height frame)) y)
col?
(:height frame)
:else
(+ line-height (- box-y prev-y) (/ layout-gap-col 2)))
line-area (gsr/make-rect x y width height)
children (subvec children from-idx (+ from-idx num-children))
result (first (reduce redfn-child [result line-area] (d/with-next children)))]
[result (+ from-idx num-children) (+ x width) (+ y height)]))]
(first (reduce redfn-lines [[] 0] (d/with-next (:layout-lines layout-data))))))
(defn get-drop-index (defn get-drop-index
[frame-id objects position] [frame-id objects position]

View file

@ -37,71 +37,79 @@
(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)
child-min-height (ctl/child-min-height child) child-min-height (ctl/child-min-height child)
child-max-width (ctl/child-max-width child) child-max-width (ctl/child-max-width child)
child-max-height (ctl/child-max-height child) child-max-height (ctl/child-max-height child)
[child-margin-top child-margin-right child-margin-bottom child-margin-left] [child-margin-top child-margin-right child-margin-bottom child-margin-left]
(ctl/child-margins child) (ctl/child-margins child)
child-margin-width (+ child-margin-left child-margin-right) child-margin-width (+ child-margin-left child-margin-right)
child-margin-height (+ child-margin-top child-margin-bottom) child-margin-height (+ child-margin-top child-margin-bottom)
fill-width? (ctl/fill-width? child) fill-width? (ctl/fill-width? child)
fill-height? (ctl/fill-height? child) fill-height? (ctl/fill-height? child)
;; We need this info later to calculate the child resizes when fill ;; We need this info later to calculate the child resizes when fill
child-data {:id (:id child) child-data {:id (:id child)
:child-min-width (if fill-width? child-min-width child-width) :child-min-width (if fill-width? child-min-width child-width)
:child-min-height (if fill-height? child-min-height child-height) :child-min-height (if fill-height? child-min-height child-height)
:child-max-width (if fill-width? child-max-width child-width) :child-max-width (if fill-width? child-max-width child-width)
:child-max-height (if fill-height? child-max-height child-height)} :child-max-height (if fill-height? child-max-height child-height)}
next-min-width (+ child-margin-width (if fill-width? child-min-width child-width)) next-min-width (+ child-margin-width (if fill-width? child-min-width child-width))
next-min-height (+ child-margin-height (if fill-height? child-min-height child-height)) next-min-height (+ child-margin-height (if fill-height? child-min-height child-height))
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-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)
(or (not wrap?)
(and row? (<= next-line-min-width layout-width))
(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)) (if (and (some? line-data)
:line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width)) (or (not wrap?)
:line-min-height (if col? (+ line-min-height next-min-height) (max line-min-height next-min-height)) (and row? (<= next-line-min-width layout-width))
:line-max-height (if col? (+ line-max-height next-max-height) (max line-max-height next-max-height)) (and col? (<= next-line-min-height layout-height))))
:num-children (inc num-children)
:children-data (conjv children-data child-data)}
result]
[{: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-min-height next-min-height :line-max-width (if row? (+ line-max-width next-max-width) (max line-max-width next-max-width))
: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-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 1 :num-children (inc num-children)
:children-data [child-data]} :children-data (conjv children-data child-data)}
(cond-> result (some? line-data) (conj line-data))]))) result
(first children)
[line-data layout-lines] (reduce calculate-line-data [nil []] children)] (rest children))
(cond-> layout-lines (some? line-data) (conj line-data))))
(recur {:line-min-width next-min-width
:line-min-height next-min-height
:line-max-width next-max-width
:line-max-height next-max-height
:num-children 1
:children-data [child-data]}
(cond-> result (some? line-data) (conj line-data))
(first children)
(rest children))))))))
(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?}))

View file

@ -114,24 +114,21 @@
"Cross axis line. It's position is fixed along the different lines" "Cross axis line. It's position is fixed along the different lines"
[parent layout-bounds {:keys [line-width line-height num-children]} base-p total-width total-height num-lines] [parent layout-bounds {:keys [line-width line-height num-children]} base-p total-width total-height num-lines]
(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) space-around? (ctl/space-around? parent)
space-around? (ctl/space-around? parent) h-center? (ctl/h-center? parent)
h-center? (ctl/h-center? parent) h-end? (ctl/h-end? parent)
h-end? (ctl/h-end? parent) 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)
vv (partial gpo/start-vv layout-bounds)
hv #(gpo/start-hv layout-bounds %) children-gap-width (* layout-gap-row (dec num-children))
vv #(gpo/start-vv layout-bounds %)
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))
line-height line-height

View file

@ -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?

View file

@ -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]

View file

@ -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