0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

Select on insert shape

This commit is contained in:
Jesús Espino 2016-04-17 13:18:36 +02:00
parent 8d2767999b
commit 33e13362fd
2 changed files with 16 additions and 2 deletions

View file

@ -284,6 +284,16 @@
(-apply-update [_ state]
(stsh/drop-shape state sid tid loc))))
(defn select-first-shape
"Mark a shape selected for drawing in the canvas."
[]
(reify
rs/UpdateEvent
(-apply-update [_ state]
(let [page (get-in state [:workspace :page])
id (first (get-in state [:pages-by-id page :shapes]))]
(assoc-in state [:workspace :selected] #{id})))))
(defn select-shape
"Mark a shape selected for drawing in the canvas."
[id]

View file

@ -89,7 +89,9 @@
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l)
props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)}
shape (ush/initialize shape props)]
(rs/emit! (uds/add-shape shape))))
(rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil)
(uds/select-first-shape))))
(defn- initialize-shape-drawing
"A drawing handler for generic shapes such as rect, circle, text, etc."
@ -102,7 +104,9 @@
(let [shape @drawing-shape
shpos @drawing-position
shape (ush/resize shape shpos)]
(rs/emit! (uds/add-shape shape))
(rs/emit! (uds/add-shape shape)
(udw/select-for-drawing nil)
(uds/select-first-shape))
(reset! drawing-position nil)
(reset! drawing-shape nil)))]