mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 22:53:02 +00:00
✨ Avoid setting touched flags in copies
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
(defn update-shapes
|
||||
([ids update-fn] (update-shapes ids update-fn nil))
|
||||
([ids update-fn {:keys [reg-objects? save-undo? attrs ignore-tree page-id]
|
||||
([ids update-fn {:keys [reg-objects? save-undo? attrs ignore-tree page-id ignore-touched-fn]
|
||||
:or {reg-objects? false save-undo? true}}]
|
||||
|
||||
(us/assert ::coll-of-uuid ids)
|
||||
@@ -52,7 +52,10 @@
|
||||
|
||||
changes (reduce
|
||||
(fn [changes id]
|
||||
(let [opts {:attrs attrs :ignore-geometry? (get ignore-tree id)}]
|
||||
(let [opts {:attrs attrs
|
||||
:ignore-geometry? (get ignore-tree id)
|
||||
:ignore-touched (when ignore-touched-fn
|
||||
(ignore-touched-fn id))}]
|
||||
(pcb/update-shapes changes [id] update-fn opts)))
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/set-save-undo? save-undo?)
|
||||
|
||||
@@ -78,7 +78,8 @@
|
||||
|
||||
(-> (ctm/empty)
|
||||
(ctm/move translation)
|
||||
(ctm/resize resize center)))))
|
||||
(ctm/resize resize center)
|
||||
(vary-meta assoc :copied-modifier? true)))))
|
||||
|
||||
(defn- process-text-modifiers
|
||||
"For texts we only use the displacement because resize
|
||||
@@ -379,7 +380,7 @@
|
||||
(ptk/reify ::set-rotation-modifiers
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
ids
|
||||
(->> shapes
|
||||
(remove #(get % :blocked false))
|
||||
@@ -416,25 +417,27 @@
|
||||
shapes (map (d/getf objects) ids)
|
||||
ignore-tree (->> (map #(get-ignore-tree object-modifiers objects %) shapes)
|
||||
(reduce merge {}))
|
||||
undo-id (uuid/next)]
|
||||
undo-id (uuid/next)
|
||||
|
||||
(rx/concat
|
||||
(if undo-transation?
|
||||
(rx/of (dwu/start-undo-transaction undo-id))
|
||||
(rx/empty))
|
||||
(rx/of (ptk/event ::dwg/move-frame-guides ids-with-children)
|
||||
(ptk/event ::dwcm/move-frame-comment-threads ids-with-children)
|
||||
(dch/update-shapes
|
||||
ids
|
||||
(fn [shape]
|
||||
(let [modif (get-in object-modifiers [(:id shape) :modifiers])
|
||||
text-shape? (cph/text-shape? shape)]
|
||||
(-> shape
|
||||
(gsh/transform-shape modif)
|
||||
(cond-> text-shape?
|
||||
(update-grow-type shape)))))
|
||||
{:reg-objects? true
|
||||
update-fn
|
||||
(fn [shape]
|
||||
(let [modif (get-in object-modifiers [(:id shape) :modifiers])
|
||||
text-shape? (cph/text-shape? shape)]
|
||||
(-> shape
|
||||
(gsh/transform-shape modif)
|
||||
(cond-> text-shape?
|
||||
(update-grow-type shape)))))
|
||||
|
||||
ignore-touched-fn
|
||||
(fn [shape-id]
|
||||
;; When a modifier comes from copying a main component to copies,
|
||||
;; do not set the touched flag, because this change is synced.
|
||||
(let [modif (get-in object-modifiers [shape-id :modifiers])]
|
||||
(:copied-modifier? (meta modif))))
|
||||
|
||||
opts {:reg-objects? true
|
||||
:ignore-tree ignore-tree
|
||||
:ignore-touched-fn ignore-touched-fn
|
||||
;; Attributes that can change in the transform. This way we don't have to check
|
||||
;; all the attributes
|
||||
:attrs [:selrect
|
||||
@@ -451,8 +454,15 @@
|
||||
:flip-y
|
||||
:grow-type
|
||||
:layout-item-h-sizing
|
||||
:layout-item-v-sizing
|
||||
]})
|
||||
:layout-item-v-sizing]}]
|
||||
|
||||
(rx/concat
|
||||
(if undo-transation?
|
||||
(rx/of (dwu/start-undo-transaction undo-id))
|
||||
(rx/empty))
|
||||
(rx/of (ptk/event ::dwg/move-frame-guides ids-with-children)
|
||||
(ptk/event ::dwcm/move-frame-comment-threads ids-with-children)
|
||||
(dch/update-shapes ids update-fn opts)
|
||||
(clear-local-transform))
|
||||
(if undo-transation?
|
||||
(rx/of (dwu/commit-undo-transaction undo-id))
|
||||
|
||||
@@ -683,7 +683,7 @@
|
||||
(rx/map
|
||||
(fn [[[pos mod?] shift?]]
|
||||
(let [delta-angle (calculate-angle pos mod? shift?)]
|
||||
(set-rotation-modifiers delta-angle shapes group-center))))
|
||||
(dwm/set-rotation-modifiers delta-angle shapes group-center))))
|
||||
(rx/take-until stoper))
|
||||
(rx/of (dwm/apply-modifiers)
|
||||
(finish-transform)))))))
|
||||
@@ -699,7 +699,7 @@
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
rotate-shape (fn [shape]
|
||||
(let [delta (- rotation (:rotation shape))]
|
||||
(set-rotation-modifiers delta [shape])))]
|
||||
(dwm/set-rotation-modifiers delta [shape])))]
|
||||
(rx/concat
|
||||
(rx/from (->> ids (map #(get objects %)) (map rotate-shape)))
|
||||
(rx/of (dwm/apply-modifiers)))))))
|
||||
|
||||
Reference in New Issue
Block a user