mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 23:57:36 +02:00
✨ Minor improvements on shape selection.
This commit is contained in:
parent
78509f3a06
commit
f906945101
4 changed files with 27 additions and 20 deletions
|
@ -573,6 +573,7 @@
|
||||||
(assoc-in $ [:workspace-data :shapes-by-id id] shape))))
|
(assoc-in $ [:workspace-data :shapes-by-id id] shape))))
|
||||||
|
|
||||||
(declare commit-shapes-changes)
|
(declare commit-shapes-changes)
|
||||||
|
(declare select-shape)
|
||||||
(declare recalculate-shape-canvas-relation)
|
(declare recalculate-shape-canvas-relation)
|
||||||
|
|
||||||
(defn add-shape
|
(defn add-shape
|
||||||
|
@ -589,7 +590,8 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [shape (get-in state [:workspace-data :shapes-by-id id])]
|
(let [shape (get-in state [:workspace-data :shapes-by-id id])]
|
||||||
(rx/of (commit-shapes-changes [[:add-shape id shape]])))))))
|
(rx/of (commit-shapes-changes [[:add-shape id shape]])
|
||||||
|
(select-shape id)))))))
|
||||||
|
|
||||||
;; --- Duplicate Selected
|
;; --- Duplicate Selected
|
||||||
|
|
||||||
|
@ -612,7 +614,6 @@
|
||||||
;; --- Toggle shape's selection status (selected or deselected)
|
;; --- Toggle shape's selection status (selected or deselected)
|
||||||
|
|
||||||
(defn select-shape
|
(defn select-shape
|
||||||
"Mark a shape selected for drawing."
|
|
||||||
[id]
|
[id]
|
||||||
(s/assert ::us/uuid id)
|
(s/assert ::us/uuid id)
|
||||||
(ptk/reify ::select-shape
|
(ptk/reify ::select-shape
|
||||||
|
@ -638,18 +639,6 @@
|
||||||
(assoc :selected #{})
|
(assoc :selected #{})
|
||||||
(dissoc :selected-canvas))))))
|
(dissoc :selected-canvas))))))
|
||||||
|
|
||||||
;; --- Select First Shape
|
|
||||||
|
|
||||||
;; TODO: first???
|
|
||||||
|
|
||||||
(def select-first-shape
|
|
||||||
(ptk/reify ::select-first-shape
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(let [pid (get-in state [:workspace-local :id])
|
|
||||||
sid (first (get-in state [:workspace-data :shapes]))]
|
|
||||||
(assoc-in state [:workspace-local :selected] #{sid})))))
|
|
||||||
|
|
||||||
;; --- Select Shapes (By selrect)
|
;; --- Select Shapes (By selrect)
|
||||||
|
|
||||||
(defn- impl-try-match-shape
|
(defn- impl-try-match-shape
|
||||||
|
@ -1034,10 +1023,29 @@
|
||||||
(ptk/reify ::select-for-drawing
|
(ptk/reify ::select-for-drawing
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update state :workspace-local assoc :drawing-tool tool :drawing data)))))
|
(update state :workspace-local assoc :drawing-tool tool :drawing data))
|
||||||
|
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [cancel-event? (fn [event]
|
||||||
|
(interrupt? event))
|
||||||
|
stoper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
||||||
|
(->> (rx/filter cancel-event? stream)
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/map (constantly clear-drawing))
|
||||||
|
(rx/take-until stoper)))))))
|
||||||
|
|
||||||
;; --- Shape Proportions
|
;; --- Shape Proportions
|
||||||
|
|
||||||
|
;; (defn toggle-shape-proportion-lock
|
||||||
|
;; [id]
|
||||||
|
;; (ptk/reify ::toggle-shape-proportion-lock
|
||||||
|
;; ptk/UpdateEvent
|
||||||
|
;; (update [_ state]
|
||||||
|
;; (let [shape (-> (get-in state [:workspace-data :shapes-by-id id])
|
||||||
|
;; (geom/size)
|
||||||
|
|
||||||
|
|
||||||
;; TODO: revisit
|
;; TODO: revisit
|
||||||
|
|
||||||
(deftype LockShapeProportions [id]
|
(deftype LockShapeProportions [id]
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
[:& messages-widget]
|
[:& messages-widget]
|
||||||
[:& header {:page page :layout layout :flags flags}]
|
[:& header {:page page :layout layout :flags flags}]
|
||||||
|
|
||||||
(when (:colorpalette flags)
|
(when (:colorpalette layout)
|
||||||
[:& colorpalette])
|
[:& colorpalette])
|
||||||
|
|
||||||
(when (and layout page)
|
(when (and layout page)
|
||||||
|
|
|
@ -280,9 +280,8 @@
|
||||||
(geom/transform shape modifier-mtx)
|
(geom/transform shape modifier-mtx)
|
||||||
shape)
|
shape)
|
||||||
shape (dissoc shape ::initialized? :modifier-mtx)]
|
shape (dissoc shape ::initialized? :modifier-mtx)]
|
||||||
;; Add & select the cred shape to the workspace
|
;; Add & select the created shape to the workspace
|
||||||
(rx/of (dw/add-shape shape)
|
(rx/of (dw/add-shape shape)))))))))
|
||||||
dw/select-first-shape))))))))
|
|
||||||
|
|
||||||
(def close-drawing-path
|
(def close-drawing-path
|
||||||
(ptk/reify ::close-drawing-path
|
(ptk/reify ::close-drawing-path
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
:ctrl+b #(st/emit! (dw/select-for-drawing :rect))
|
:ctrl+b #(st/emit! (dw/select-for-drawing :rect))
|
||||||
:ctrl+e #(st/emit! (dw/select-for-drawing :circle))
|
:ctrl+e #(st/emit! (dw/select-for-drawing :circle))
|
||||||
:ctrl+t #(st/emit! (dw/select-for-drawing :text))
|
:ctrl+t #(st/emit! (dw/select-for-drawing :text))
|
||||||
:esc #(st/emit! dw/deselect-all)
|
:esc #(st/emit! :interrupt dw/deselect-all)
|
||||||
:delete #(st/emit! dw/delete-selected)
|
:delete #(st/emit! dw/delete-selected)
|
||||||
:ctrl+up #(st/emit! (dw/order-selected-shapes :up))
|
:ctrl+up #(st/emit! (dw/order-selected-shapes :up))
|
||||||
:ctrl+down #(st/emit! (dw/order-selected-shapes :down))
|
:ctrl+down #(st/emit! (dw/order-selected-shapes :down))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue