0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-16 01:31:22 -05:00

Expand mask when selected in workspace

This commit is contained in:
Andrés Moya 2020-10-21 09:01:12 +02:00 committed by Alonso Torres
parent 0ddf6d30b8
commit 823aa426ed
3 changed files with 23 additions and 13 deletions

View file

@ -159,7 +159,6 @@
(let [page-id (:current-page-id state)
objects (get-in state [:workspace-data :pages-index page-id :objects])
selected (get-in state [:workspace-local :selected])
shape (get objects id)
children (cph/get-children id objects)]
(some selected children)))]
(l/derived selector st/state)))

View file

@ -22,15 +22,16 @@
(mf/fnc group-shape
{::mf/wrap-props false}
[props]
(let [frame (unchecked-get props "frame")
shape (unchecked-get props "shape")
childs (unchecked-get props "childs")
mask (if (:masked-group? shape)
(first childs)
nil)
childs (if (:masked-group? shape)
(rest childs)
childs)
(let [frame (unchecked-get props "frame")
shape (unchecked-get props "shape")
childs (unchecked-get props "childs")
expand-mask (unchecked-get props "expand-mask")
mask (if (and (:masked-group? shape) (not expand-mask))
(first childs)
nil)
childs (if (and (:masked-group? shape) (not expand-mask))
(rest childs)
childs)
is-child-selected? (unchecked-get props "is-child-selected?")
{:keys [id x y width height]} shape
transform (geom/transform-matrix shape)]

View file

@ -46,8 +46,8 @@
on-context-menu
(mf/use-callback (mf/deps shape) #(common/on-context-menu % shape))
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
childs (mf/deref childs-ref)
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
childs (mf/deref childs-ref)
is-child-selected-ref
(mf/use-memo (mf/deps (:id shape)) #(refs/is-child-selected? (:id shape)))
@ -55,6 +55,15 @@
is-child-selected?
(mf/deref is-child-selected-ref)
mask-id (when (:masked-group? shape) (first (:shapes shape)))
is-mask-selected-ref
(mf/use-memo (mf/deps mask-id)
#(refs/make-selected-ref mask-id))
is-mask-selected?
(mf/deref is-mask-selected-ref)
on-double-click
(mf/use-callback
(mf/deps (:id shape))
@ -72,5 +81,6 @@
{:frame frame
:shape shape
:childs childs
:is-child-selected? is-child-selected?}]]))))
:is-child-selected? is-child-selected?
:expand-mask is-mask-selected?}]]))))