Merge remote-tracking branch 'origin/main' into staging

This commit is contained in:
Alejandro Alonso 2022-06-09 08:55:05 +02:00
commit 801cdd940a
11 changed files with 73 additions and 15 deletions

View file

@ -166,6 +166,7 @@
(dm/export gtr/update-group-selrect)
(dm/export gtr/update-mask-selrect)
(dm/export gtr/resize-modifiers)
(dm/export gtr/change-orientation-modifiers)
(dm/export gtr/rotation-modifiers)
(dm/export gtr/merge-modifiers)
(dm/export gtr/transform-shape)

View file

@ -426,6 +426,31 @@
:resize-transform shape-transform
:resize-transform-inverse shape-transform-inv}))
(defn change-orientation-modifiers
[shape orientation]
(us/assert map? shape)
(us/verify #{:horiz :vert} orientation)
(let [width (:width shape)
height (:height shape)
new-width (if (= orientation :horiz) (max width height) (min width height))
new-height (if (= orientation :horiz) (min width height) (max width height))
shape-transform (:transform shape)
shape-transform-inv (:transform-inverse shape)
shape-center (gco/center-shape shape)
{sr-width :width sr-height :height} (:selrect shape)
origin (cond-> (gpt/point (:selrect shape))
(some? shape-transform)
(transform-point-center shape-center shape-transform))
scalev (gpt/divide (gpt/point new-width new-height)
(gpt/point sr-width sr-height))]
{:resize-vector scalev
:resize-origin origin
:resize-transform shape-transform
:resize-transform-inverse shape-transform-inv}))
(defn rotation-modifiers
[shape center angle]
(let [displacement (let [shape-center (gco/center-shape shape)]

View file

@ -372,8 +372,8 @@
(assert-page-id changes)
(assert-objects changes)
(let [page-id (::page-id (meta changes))
objects (lookup-objects changes)
objects (lookup-objects changes)
xform (comp
(mapcat #(cons % (cph/get-parent-ids objects %)))
(map (d/getf objects))
@ -409,7 +409,8 @@
resize-parent
(fn [changes parent]
(let [children (->> parent :shapes (map (d/getf objects)))
(let [objects (lookup-objects changes)
children (->> parent :shapes (map (d/getf objects)))
resized-parent (cond
(empty? children) ;; a parent with no children will be deleted,
nil ;; so it does not need resize
@ -434,12 +435,12 @@
(if (seq rops)
(-> changes
(update :redo-changes conj (assoc change :operations rops))
(update :undo-changes d/preconj (assoc change :operations uops)))
(update :undo-changes d/preconj (assoc change :operations uops))
(apply-changes-local))
changes))
changes)))]
(-> (reduce resize-parent changes all-parents)
(apply-changes-local))))
(reduce resize-parent changes all-parents)))
;; Library changes