mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 00:01:51 -05:00
♻️ Small refactor set modifiers
This commit is contained in:
parent
0ff0fd7ced
commit
741d3050ad
1 changed files with 40 additions and 48 deletions
|
@ -227,7 +227,7 @@
|
||||||
|
|
||||||
(declare start-move)
|
(declare start-move)
|
||||||
(declare start-move-duplicate)
|
(declare start-move-duplicate)
|
||||||
(declare start-local-displacement)
|
(declare set-local-displacement)
|
||||||
(declare clear-local-transform)
|
(declare clear-local-transform)
|
||||||
|
|
||||||
(defn start-move-selected
|
(defn start-move-selected
|
||||||
|
@ -342,9 +342,10 @@
|
||||||
(->> position
|
(->> position
|
||||||
(rx/with-latest vector snap-delta)
|
(rx/with-latest vector snap-delta)
|
||||||
(rx/map snap/correct-snap-point)
|
(rx/map snap/correct-snap-point)
|
||||||
(rx/map start-local-displacement))
|
(rx/map set-local-displacement))
|
||||||
|
|
||||||
(rx/of (apply-modifiers ids {:set-modifiers? true})
|
(rx/of (set-modifiers ids)
|
||||||
|
(apply-modifiers ids)
|
||||||
(calculate-frame-for-move ids)
|
(calculate-frame-for-move ids)
|
||||||
(finish-transform)))))))))
|
(finish-transform)))))))))
|
||||||
|
|
||||||
|
@ -396,10 +397,11 @@
|
||||||
(->> move-events
|
(->> move-events
|
||||||
(rx/take-until stopper)
|
(rx/take-until stopper)
|
||||||
(rx/scan #(gpt/add %1 mov-vec) (gpt/point 0 0))
|
(rx/scan #(gpt/add %1 mov-vec) (gpt/point 0 0))
|
||||||
(rx/map start-local-displacement))
|
(rx/map set-local-displacement))
|
||||||
(rx/of (move-selected direction shift?)))
|
(rx/of (move-selected direction shift?)))
|
||||||
|
|
||||||
(rx/of (apply-modifiers selected {:set-modifiers? true})
|
(rx/of (set-modifiers selected)
|
||||||
|
(apply-modifiers selected)
|
||||||
(finish-transform))))
|
(finish-transform))))
|
||||||
(rx/empty))))))
|
(rx/empty))))))
|
||||||
|
|
||||||
|
@ -537,11 +539,7 @@
|
||||||
(rx/of (apply-modifiers ids)))))))
|
(rx/of (apply-modifiers ids)))))))
|
||||||
|
|
||||||
(defn apply-modifiers
|
(defn apply-modifiers
|
||||||
([ids]
|
[ids]
|
||||||
(apply-modifiers ids nil))
|
|
||||||
|
|
||||||
([ids {:keys [set-modifiers?]
|
|
||||||
:or {set-modifiers? false}}]
|
|
||||||
(us/verify (s/coll-of uuid?) ids)
|
(us/verify (s/coll-of uuid?) ids)
|
||||||
(ptk/reify ::apply-modifiers
|
(ptk/reify ::apply-modifiers
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
@ -549,12 +547,7 @@
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
children-ids (->> ids (mapcat #(cp/get-children % objects)))
|
children-ids (->> ids (mapcat #(cp/get-children % objects)))
|
||||||
ids-with-children (d/concat [] children-ids ids)
|
ids-with-children (d/concat [] children-ids ids)
|
||||||
|
|
||||||
state (if set-modifiers?
|
|
||||||
(ptk/update (set-modifiers ids) state)
|
|
||||||
state)
|
|
||||||
object-modifiers (get state :workspace-modifiers)
|
object-modifiers (get state :workspace-modifiers)
|
||||||
|
|
||||||
ignore-tree (d/mapm #(get-in %2 [:modifiers :ignore-geometry?]) object-modifiers)]
|
ignore-tree (d/mapm #(get-in %2 [:modifiers :ignore-geometry?]) object-modifiers)]
|
||||||
|
|
||||||
(rx/of (dwu/start-undo-transaction)
|
(rx/of (dwu/start-undo-transaction)
|
||||||
|
@ -576,10 +569,9 @@
|
||||||
:transform-inverse
|
:transform-inverse
|
||||||
:rotation
|
:rotation
|
||||||
:flip-x
|
:flip-x
|
||||||
:flip-y]
|
:flip-y]})
|
||||||
})
|
|
||||||
(clear-local-transform)
|
(clear-local-transform)
|
||||||
(dwu/commit-undo-transaction)))))))
|
(dwu/commit-undo-transaction))))))
|
||||||
|
|
||||||
;; --- Update Dimensions
|
;; --- Update Dimensions
|
||||||
|
|
||||||
|
@ -649,7 +641,7 @@
|
||||||
:displacement (gmt/translate-matrix (gpt/point 0 (- (:height selrect))))})
|
:displacement (gmt/translate-matrix (gpt/point 0 (- (:height selrect))))})
|
||||||
(apply-modifiers selected))))))
|
(apply-modifiers selected))))))
|
||||||
|
|
||||||
(defn start-local-displacement [point]
|
(defn set-local-displacement [point]
|
||||||
(ptk/reify ::start-local-displacement
|
(ptk/reify ::start-local-displacement
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
|
Loading…
Add table
Reference in a new issue