mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 13:38:30 +02:00
Add missing event for select object matched by selrect.
This commit is contained in:
parent
ed99a28749
commit
fe6b93150b
1 changed files with 35 additions and 0 deletions
|
@ -84,6 +84,41 @@
|
||||||
(update-in state [:workspace :selected] disj id)
|
(update-in state [:workspace :selected] disj id)
|
||||||
(update-in state [:workspace :selected] conj id))))))
|
(update-in state [:workspace :selected] conj id))))))
|
||||||
|
|
||||||
|
(defn contained-in-selrect?
|
||||||
|
[shape selrect]
|
||||||
|
(let [sx1 (:x selrect)
|
||||||
|
sx2 (+ sx1 (:width selrect))
|
||||||
|
sy1 (:y selrect)
|
||||||
|
sy2 (+ sy1 (:height selrect))
|
||||||
|
rx1 (:x shape)
|
||||||
|
rx2 (+ rx1 (:width shape))
|
||||||
|
ry1 (:y shape)
|
||||||
|
ry2 (+ ry1 (:height shape))]
|
||||||
|
(and (neg? (- (:y selrect) (:y shape)))
|
||||||
|
(neg? (- (:x selrect) (:x shape)))
|
||||||
|
(pos? (- (+ (:y selrect)
|
||||||
|
(:height selrect))
|
||||||
|
(+ (:y shape)
|
||||||
|
(:height shape))))
|
||||||
|
(pos? (- (+ (:x selrect)
|
||||||
|
(:width selrect))
|
||||||
|
(+ (:x shape)
|
||||||
|
(:width shape)))))))
|
||||||
|
|
||||||
|
(defn select-shapes
|
||||||
|
"Select shapes that matches the select rect."
|
||||||
|
[selrect]
|
||||||
|
(reify
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(println "select-shapes" selrect)
|
||||||
|
(let [pid (get-in state [:workspace :page])
|
||||||
|
shapes (->> (vals (:shapes-by-id state))
|
||||||
|
(filter #(= (:page %) pid))
|
||||||
|
(filter #(contained-in-selrect? % selrect))
|
||||||
|
(map :id))]
|
||||||
|
(assoc-in state [:workspace :selected] (into #{} shapes))))))
|
||||||
|
|
||||||
(defn deselect-all
|
(defn deselect-all
|
||||||
"Mark a shape selected for drawing in the canvas."
|
"Mark a shape selected for drawing in the canvas."
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue