mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 19:08:31 +02:00
Merge remote-tracking branch 'origin/main' into staging
This commit is contained in:
commit
801cdd940a
11 changed files with 73 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue