mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
wip roto
This commit is contained in:
parent
3112d04a99
commit
de4c7762ad
2 changed files with 32 additions and 12 deletions
|
@ -142,6 +142,13 @@
|
|||
|
||||
(update state :workspace-modifiers merge modif-tree))))))
|
||||
|
||||
(defn set-modifiers-raw
|
||||
[modifiers]
|
||||
(ptk/reify ::set-modifiers-raw
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update state :workspace-modifiers merge modifiers))))
|
||||
|
||||
;; Rotation use different algorithm to calculate children modifiers (and do not use child constraints).
|
||||
(defn- set-rotation-modifiers
|
||||
([angle shapes]
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
[app.common.pages.helpers :as cph] ; TODO: move this to ctst
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.main.data.workspace.transforms :as dwt]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.workspace.viewport.utils :as vwu]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.timers :as tm]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn- transform-no-resize
|
||||
|
@ -344,7 +346,7 @@
|
|||
[copies objects modifiers]
|
||||
;; (js/console.log "copies" (clj->js copies))
|
||||
(letfn [(add-copy-modifiers-one [modifiers copy-shape copy-root main-root main-shapes main-shapes-modif]
|
||||
(assert (not (contains? modifiers (:id copy-shape))) "Si peta esto, we have a problem")
|
||||
;; (assert (not (contains? modifiers (:id copy-shape))) "Si peta esto, we have a problem")
|
||||
(let [main-shape-modif (d/seek #(ctk/is-main-of? % copy-shape) main-shapes-modif)
|
||||
;; copy-shape (cond-> copy-shape
|
||||
;; (some? (:transform-inverse copy-shape))
|
||||
|
@ -444,30 +446,41 @@
|
|||
(let [prev-shapes (mf/use-var nil)
|
||||
prev-modifiers (mf/use-var nil)
|
||||
prev-transforms (mf/use-var nil)
|
||||
unflag (mf/use-var false)
|
||||
|
||||
copies
|
||||
(mf/use-memo ; TODO: ojo estas deps hay que revisarlas
|
||||
(mf/deps modifiers (and (d/not-empty? @prev-modifiers) (d/not-empty? modifiers)))
|
||||
(mf/deps modifiers (and (d/not-empty? @prev-modifiers) (d/not-empty? modifiers)) @unflag)
|
||||
(fn []
|
||||
(let [shapes (->> (keys modifiers)
|
||||
(mapv (d/getf objects)))]
|
||||
(get-copies shapes objects modifiers))))
|
||||
(when-not @unflag
|
||||
(let [shapes (->> (keys modifiers)
|
||||
(mapv (d/getf objects)))]
|
||||
(get-copies shapes objects modifiers)))))
|
||||
|
||||
modifiers
|
||||
(mf/use-memo
|
||||
(mf/deps objects modifiers copies)
|
||||
(mf/deps objects modifiers copies @unflag)
|
||||
(fn []
|
||||
(js/console.log "==================")
|
||||
(js/console.log "modifiers (antes)" (clj->js modifiers))
|
||||
(js/console.log "copies" (clj->js copies))
|
||||
(add-copies-modifiers copies objects modifiers)))
|
||||
(if @unflag
|
||||
(do
|
||||
(reset! unflag false)
|
||||
modifiers)
|
||||
(let [new-modifiers (add-copies-modifiers copies objects modifiers)]
|
||||
(js/console.log "==================")
|
||||
(js/console.log "modifiers (antes)" (clj->js modifiers))
|
||||
(js/console.log "copies" (clj->js copies))
|
||||
(js/console.log "modifiers (después)" (clj->js new-modifiers))
|
||||
(reset! unflag true)
|
||||
(when (seq new-modifiers)
|
||||
(tm/schedule #(st/emit! (dwt/set-modifiers-raw new-modifiers))))
|
||||
new-modifiers))))
|
||||
|
||||
transforms
|
||||
(mf/use-memo
|
||||
(mf/deps modifiers)
|
||||
(fn []
|
||||
(when (some? modifiers)
|
||||
(js/console.log "modifiers (después)" (clj->js modifiers))
|
||||
(js/console.log "****modifiers" (clj->js modifiers))
|
||||
(when (seq modifiers)
|
||||
(d/mapm (fn [id {modifiers :modifiers}]
|
||||
(let [shape (get objects id)
|
||||
center (gsh/center-shape shape)
|
||||
|
|
Loading…
Add table
Reference in a new issue