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

@ -1698,6 +1698,7 @@
(dm/export dwt/start-resize)
(dm/export dwt/update-dimensions)
(dm/export dwt/change-orientation)
(dm/export dwt/start-rotate)
(dm/export dwt/increase-rotation)
(dm/export dwt/start-move-selected)

View file

@ -556,6 +556,32 @@
(watch [_ _ _]
(rx/of (apply-modifiers ids)))))
(defn change-orientation
"Change orientation of shapes, from the sidebar options form.
Will ignore pixel snap used in the options side panel"
[ids orientation]
(us/verify (s/coll-of ::us/uuid) ids)
(us/verify #{:horiz :vert} orientation)
(ptk/reify ::change-orientation
ptk/UpdateEvent
(update [_ state]
(let [objects (wsh/lookup-page-objects state)
layout (get state :workspace-layout)
snap-pixel? (contains? layout :snap-pixel-grid)
update-modifiers
(fn [state id]
(let [shape (get objects id)
modifiers (gsh/change-orientation-modifiers shape orientation)]
(-> state
(update :workspace-modifiers
#(set-objects-modifiers % objects shape modifiers false snap-pixel?)))))]
(reduce update-modifiers state ids)))
ptk/WatchEvent
(watch [_ _ _]
(rx/of (apply-modifiers ids)))))
;; -- Rotate --------------------------------------------------------
(defn start-rotate
@ -786,7 +812,7 @@
(rx/of (apply-modifiers selected)
(finish-transform))))
(rx/empty))))))
(rx/empty))))))
(s/def ::x number?)
(s/def ::y number?)

View file

@ -110,12 +110,7 @@
on-orientation-clicked
(fn [orientation]
(let [width (:width values)
height (:height values)
new-width (if (= orientation :horiz) (max width height) (min width height))
new-height (if (= orientation :horiz) (min width height) (max width height))]
(st/emit! (udw/update-dimensions ids :width new-width)
(udw/update-dimensions ids :height new-height))))
(st/emit! (udw/change-orientation ids orientation)))
on-size-change
(mf/use-callback