mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 09:08:31 -05:00
♻️ Refactor resize shapes from the sidebar measures form
This commit is contained in:
parent
be387ad892
commit
ca9edf2bc9
1 changed files with 15 additions and 13 deletions
|
@ -445,7 +445,8 @@
|
||||||
"Apply the modifiers to one shape, and the corresponding ones to all children,
|
"Apply the modifiers to one shape, and the corresponding ones to all children,
|
||||||
depending on the child constraints. The modifiers are not directly applied to
|
depending on the child constraints. The modifiers are not directly applied to
|
||||||
the objects tree, but to a separated structure (modif-tree), that may be
|
the objects tree, but to a separated structure (modif-tree), that may be
|
||||||
merged later with the real objects."
|
merged later with the real objects. This way, the objects are changed only
|
||||||
|
once, avoiding unnecesary redrawings."
|
||||||
[modif-tree objects shape modifiers root transformed-root]
|
[modif-tree objects shape modifiers root transformed-root]
|
||||||
(let [children (->> (get shape :shapes [])
|
(let [children (->> (get shape :shapes [])
|
||||||
(map #(get objects %)))
|
(map #(get objects %)))
|
||||||
|
@ -594,20 +595,21 @@
|
||||||
(ptk/reify ::update-dimensions
|
(ptk/reify ::update-dimensions
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
|
objects (get-in state [:workspace-data :pages-index page-id :objects])]
|
||||||
|
|
||||||
;; For each shape updates the modifiers given as arguments
|
(reduce (fn [state id]
|
||||||
update-shape
|
(let [shape (get objects id)
|
||||||
(fn [objects shape-id]
|
modifiers (gsh/resize-modifiers shape attr value)]
|
||||||
(let [shape (get objects shape-id)
|
(update state :workspace-modifiers
|
||||||
modifier (gsh/resize-modifiers shape attr value)]
|
#(set-modifiers-recursive %
|
||||||
(set-modifiers-recursive objects objects shape modifier nil nil)))]
|
objects
|
||||||
|
shape
|
||||||
(d/update-in-when
|
modifiers
|
||||||
state
|
nil
|
||||||
[:workspace-data :pages-index page-id :objects]
|
nil))))
|
||||||
#(reduce update-shape % ids))))
|
state
|
||||||
|
ids)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
|
Loading…
Add table
Reference in a new issue