mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 18:48:37 -05:00
✨ Allows selection of inside items with double click
This commit is contained in:
parent
f99b3bfdb8
commit
185b1f9ee1
3 changed files with 36 additions and 4 deletions
|
@ -1203,6 +1203,19 @@
|
|||
(->> (impl-match-by-selrect state selrect)
|
||||
(assoc-in state [:workspace-local :selected]))))))
|
||||
|
||||
(defn select-inside-group
|
||||
[group-id position]
|
||||
(ptk/reify ::select-inside-group
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [page-id (::page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
group (get objects group-id)
|
||||
children (map #(get objects %) (:shapes group))
|
||||
selected (->> children (filter #(geom/has-point? % position)) first)]
|
||||
(cond-> state
|
||||
selected (assoc-in [:workspace-local :selected] #{(:id selected)}))))))
|
||||
|
||||
;; --- Update Shape Attrs
|
||||
|
||||
(defn update-shape
|
||||
|
|
|
@ -587,6 +587,20 @@
|
|||
(< ry1 sy2)
|
||||
(> ry2 sy1))))
|
||||
|
||||
(defn has-point?
|
||||
[shape position]
|
||||
(let [{:keys [x y]} position
|
||||
selrect {:x1 (- x 5)
|
||||
:y1 (- y 5)
|
||||
:x2 (+ x 5)
|
||||
:y2 (+ y 5)
|
||||
:x (- x 5)
|
||||
:y (- y 5)
|
||||
:width 10
|
||||
:height 10
|
||||
:type :rect}]
|
||||
(overlaps? shape selrect)))
|
||||
|
||||
(defn transform-shape
|
||||
([shape] (transform-shape nil shape))
|
||||
([frame shape]
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.interop :as itr]
|
||||
[uxbox.main.ui.shapes.common :as common]
|
||||
[uxbox.main.ui.shapes.attrs :as attrs]))
|
||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||
[uxbox.main.data.workspace :as dw]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.main.streams :as ms]))
|
||||
|
||||
(defonce ^:dynamic *debug* (atom true))
|
||||
(defonce ^:dynamic *debug* (atom false))
|
||||
|
||||
(declare translate-to-frame)
|
||||
(declare group-shape)
|
||||
|
@ -34,7 +37,9 @@
|
|||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(dom/prevent-default event)
|
||||
#_(st/emit! (dw/select-inside-group)))]
|
||||
(st/emit! (dw/select-inside-group
|
||||
(:id shape)
|
||||
@ms/mouse-position)))]
|
||||
|
||||
[:g.shape {:on-mouse-down on-mouse-down
|
||||
:on-context-menu on-context-menu
|
||||
|
@ -73,7 +78,7 @@
|
|||
[:rect {:x x
|
||||
:y y
|
||||
:fill (if (deref *debug*) "red" "transparent")
|
||||
:opacity 0.8
|
||||
:opacity 0.5
|
||||
:id (str "group-" id)
|
||||
:width width
|
||||
:height height}])])))
|
||||
|
|
Loading…
Add table
Reference in a new issue