mirror of
https://github.com/penpot/penpot.git
synced 2025-06-21 00:37:00 +02:00
Move some functions from data.workspace to shapes ns.
This commit is contained in:
parent
8284f0141c
commit
a2da98f7ab
2 changed files with 31 additions and 21 deletions
|
@ -106,27 +106,6 @@
|
||||||
(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
|
(defn select-shapes
|
||||||
"Select shapes that matches the select rect."
|
"Select shapes that matches the select rect."
|
||||||
[selrect]
|
[selrect]
|
||||||
|
|
|
@ -164,3 +164,34 @@
|
||||||
:y (:y result)))
|
:y (:y result)))
|
||||||
shape))
|
shape))
|
||||||
|
|
||||||
|
(defn resolve-parent
|
||||||
|
"Recursively resolve the real shape parent."
|
||||||
|
[{:keys [group] :as shape}]
|
||||||
|
(if group
|
||||||
|
(resolve-parent (get-in @st/state [:shapes-by-id group]))
|
||||||
|
shape))
|
||||||
|
|
||||||
|
(defn contained-in?
|
||||||
|
"Check if a shape is contained in the
|
||||||
|
provided selection rect."
|
||||||
|
[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)))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue