0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-26 16:56:11 -05:00

Code cleaing on draw area.

This commit is contained in:
Andrey Antukh 2016-08-12 20:50:16 +03:00
parent 5e8a3f2bfc
commit 6b8b6ac5b9
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -63,9 +63,6 @@
(declare on-init-draw-icon) (declare on-init-draw-icon)
(declare on-init-draw-path) (declare on-init-draw-path)
(declare on-init-draw-generic) (declare on-init-draw-generic)
(declare on-draw-start)
(declare on-draw)
(declare on-draw-complete)
(defn- watch-draw-actions (defn- watch-draw-actions
[] []
@ -162,7 +159,6 @@
(on-end [] (on-end []
(let [shape (normalize-shape @drawing-shape)] (let [shape (normalize-shape @drawing-shape)]
(println "on-end" shape)
(rs/emit! (uds/add-shape shape) (rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil) (udw/select-for-drawing nil)
(uds/select-first-shape)) (uds/select-first-shape))
@ -192,30 +188,22 @@
(rx/skip-while #(nil? @drawing-shape)) (rx/skip-while #(nil? @drawing-shape))
(rx/with-latest-from vector wb/mouse-ctrl-s))] (rx/with-latest-from vector wb/mouse-ctrl-s))]
(rx/subscribe firstpos (fn [{:keys [x y] :as pt}] (letfn [(on-start [{:keys [x y] :as pt}]
(let [shape (geom/setup shape {:x1 x :y1 y (let [shape (geom/setup shape {:x1 x :y1 y :x2 x :y2 y})]
:x2 x :y2 y})] (reset! drawing-shape shape)))
(reset! drawing-shape shape))))
(rx/subscribe stream on-draw nil on-draw-complete)))
;; (defn- on-draw-start (on-draw [[pt ctrl?]]
;; [shape {:keys [x y] :as pt}] (let [pt (gpt/divide pt @wb/zoom-ref)]
;; (let [shape (geom/setup shape {:x1 x :y1 y :x2 x :y2 y})] (reset! drawing-position (assoc pt :lock ctrl?))))
;; (reset! drawing-shape shape))) (on-end []
(let [shape @drawing-shape
(defn- on-draw shpos @drawing-position
[[pt ctrl?]] shape (geom/resize shape shpos)]
(let [pt (gpt/divide pt @wb/zoom-ref)] (rs/emit! (uds/add-shape shape)
(reset! drawing-position (assoc pt :lock ctrl?)))) (udw/select-for-drawing nil)
(uds/select-first-shape))
(defn- on-draw-complete (reset! drawing-position nil)
[] (reset! drawing-shape nil)
(let [shape @drawing-shape (rlocks/release! :ui/draw)))]
shpos @drawing-position (rx/subscribe firstpos on-start)
shape (geom/resize shape shpos)] (rx/subscribe stream on-draw nil on-end))))
(rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil)
(uds/select-first-shape))
(reset! drawing-position nil)
(reset! drawing-shape nil)
(rlocks/release! :ui/draw)))