🎉 Dynamic alignment brute-force method

This commit is contained in:
alonso.torres 2020-04-30 11:37:36 +02:00
parent 37d0f20b7e
commit ffd0c95760
11 changed files with 297 additions and 30 deletions

View file

@ -9,7 +9,8 @@
[uxbox.common.spec :as us]
[uxbox.common.uuid :as uuid]
[uxbox.main.worker :as uw]
[uxbox.util.geom.shapes :as geom]))
[uxbox.util.geom.shapes :as geom]
[uxbox.util.geom.snap :as snap]))
;; --- Protocols
@ -19,6 +20,7 @@
(declare setup-selection-index)
(declare update-selection-index)
(declare update-snap-data)
(declare reset-undo)
(declare append-undo)
@ -51,7 +53,8 @@
(let [page (:workspace-page state)
uidx (get-in state [:workspace-local :undo-index] ::not-found)]
(rx/concat
(rx/of (update-selection-index (:id page)))
(rx/of (update-selection-index (:id page))
(update-snap-data (:id page)))
(when (and save-undo? (not= uidx ::not-found))
(rx/of (reset-undo uidx)))
@ -138,6 +141,16 @@
:page-id page-id
:objects objects})))))
(defn update-snap-data
[page-id]
(ptk/reify ::update-snap-data
ptk/UpdateEvent
(update [_ state]
(let [page (get-in state [:workspace-pages page-id])
objects (get-in page [:data :objects])]
(println "Update snap data")
(-> state
(assoc :workspace-snap-data (snap/initialize-snap-data objects)))))))
;; --- Common Helpers & Events