mirror of
https://github.com/penpot/penpot.git
synced 2025-01-27 00:49:28 -05:00
✨ Improve & simplify the drawing end event.
This commit is contained in:
parent
363b2db695
commit
20364f47b4
1 changed files with 11 additions and 16 deletions
|
@ -22,6 +22,7 @@
|
||||||
[uxbox.util.math :as mth]
|
[uxbox.util.math :as mth]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.data :refer [seek]]
|
[uxbox.util.data :refer [seek]]
|
||||||
|
[uxbox.util.geom.matrix :as gmt]
|
||||||
[uxbox.util.geom.path :as path]
|
[uxbox.util.geom.path :as path]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]
|
||||||
[uxbox.util.uuid :as uuid]))
|
[uxbox.util.uuid :as uuid]))
|
||||||
|
@ -289,23 +290,17 @@
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [pid (get-in state [:workspace :current])
|
(let [pid (get-in state [:workspace :current])
|
||||||
shape (get-in state [:workspace pid :drawing])]
|
shape (get-in state [:workspace pid :drawing])]
|
||||||
(if (::initialized? shape)
|
(rx/concat
|
||||||
(let [resize-mtx (get-in state [:workspace pid :modifiers (:id shape) :resize])
|
(rx/of dw/clear-drawing)
|
||||||
shape (cond-> shape
|
(when (::initialized? shape)
|
||||||
resize-mtx (geom/transform resize-mtx))]
|
(let [modifier-mtx (:modifier-mtx shape)
|
||||||
(rx/of
|
shape (if (gmt/matrix? modifier-mtx)
|
||||||
;; Remove the stalled modifiers
|
(geom/transform shape modifier-mtx)
|
||||||
;; TODO: maybe a specific event for "clear modifiers"
|
shape)
|
||||||
#(update-in % [:workspace pid :modifiers] dissoc (:id shape))
|
shape (dissoc shape ::initialized? :modifier-mtx)]
|
||||||
|
|
||||||
;; Unselect the drawing tool
|
|
||||||
;; TODO; maybe a specific event for clear draw-tool
|
|
||||||
dw/clear-drawing
|
|
||||||
|
|
||||||
;; Add & select the cred shape to the workspace
|
;; Add & select the cred shape to the workspace
|
||||||
(dw/add-shape (dissoc shape ::initialized?))
|
(rx/of (dw/add-shape shape)
|
||||||
(dw/select-first-shape)))
|
(dw/select-first-shape)))))))))
|
||||||
(rx/of #(update-in % [:workspace pid] dissoc :drawing :drawing-tool)))))))
|
|
||||||
|
|
||||||
(def close-drawing-path
|
(def close-drawing-path
|
||||||
(reify
|
(reify
|
||||||
|
|
Loading…
Add table
Reference in a new issue