mirror of
https://github.com/penpot/penpot.git
synced 2025-02-26 08:45:34 -05:00
Enable path edition with grid alignment.
This commit is contained in:
parent
df10586e3f
commit
1693d172bd
2 changed files with 20 additions and 3 deletions
|
@ -376,7 +376,6 @@
|
|||
[shape interaction]
|
||||
(UpdateInteraction. shape interaction))
|
||||
|
||||
|
||||
;; --- Delete Interaction
|
||||
|
||||
(defrecord DeleteInteracton [shape id]
|
||||
|
@ -403,6 +402,25 @@
|
|||
{:pre [(uuid? id) (number? index) (gpt/point? delta)]}
|
||||
(UpdatePath. id index delta))
|
||||
|
||||
(defrecord InitialPathPointAlign [id index]
|
||||
rs/WatchEvent
|
||||
(-apply-watch [_ state s]
|
||||
(let [shape (get-in state [:shapes-by-id id])
|
||||
point (get-in shape [:points index])
|
||||
point (gpt/add point canvas-coords)]
|
||||
(->> (align-point point)
|
||||
(rx/map #(gpt/subtract % point))
|
||||
(rx/map #(update-path id index %))))))
|
||||
|
||||
(defn initial-path-point-align
|
||||
"Event responsible of align a specified point of the
|
||||
shape by `index` with the grid."
|
||||
[id index]
|
||||
{:pre [(uuid? id)
|
||||
(number? index)
|
||||
(not (neg? index))]}
|
||||
(InitialPathPointAlign. id index))
|
||||
|
||||
;; --- Start shape "edition mode"
|
||||
|
||||
(defrecord StartEditionMode [id]
|
||||
|
|
|
@ -145,7 +145,6 @@
|
|||
(defn start-path-edition
|
||||
[shape-id index]
|
||||
(letfn [(on-move [delta]
|
||||
(println "on-move" delta)
|
||||
(rs/emit! (uds/update-path shape-id index delta)))
|
||||
(on-end []
|
||||
(rlocks/release! :shape/resize))]
|
||||
|
@ -156,7 +155,7 @@
|
|||
stream (rx/take-until stoper wb/mouse-delta-s)]
|
||||
(rlocks/acquire! :shape/resize)
|
||||
(when @wb/alignment-ref
|
||||
(rs/emit! (uds/initial-vertext-align shape-id index)))
|
||||
(rs/emit! (uds/initial-path-point-align shape-id index)))
|
||||
(rx/subscribe stream on-move nil on-end))))
|
||||
|
||||
(mx/defc path-edition-selection-handlers
|
||||
|
|
Loading…
Add table
Reference in a new issue