mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 02:56:12 +02:00
🐛 Fix problem when moving shapes inside nested frames
This commit is contained in:
parent
9cb6e71258
commit
ddf8aaf68f
10 changed files with 43 additions and 21 deletions
|
@ -1344,7 +1344,7 @@
|
|||
[frame-id frame-id delta])
|
||||
|
||||
(empty? page-selected)
|
||||
(let [frame-id (cph/frame-id-by-position page-objects mouse-pos)
|
||||
(let [frame-id (cph/top-nested-frame page-objects mouse-pos)
|
||||
delta (gpt/subtract mouse-pos orig-pos)]
|
||||
[frame-id frame-id delta])
|
||||
|
||||
|
@ -1456,7 +1456,7 @@
|
|||
height 16
|
||||
page-id (:current-page-id state)
|
||||
frame-id (-> (wsh/lookup-page-objects state page-id)
|
||||
(cph/frame-id-by-position @ms/mouse-position))
|
||||
(cph/top-nested-frame @ms/mouse-position))
|
||||
shape (cp/setup-rect-selrect
|
||||
{:id id
|
||||
:type :text
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
focus (:workspace-focus-selected state)
|
||||
zoom (get-in state [:workspace-local :zoom] 1)
|
||||
|
||||
fid (cph/frame-id-by-position objects initial)
|
||||
fid (cph/top-nested-frame objects initial)
|
||||
|
||||
shape (get-in state [:workspace-drawing :object])
|
||||
shape (-> shape
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
content (get-in state [:workspace-drawing :object :content] [])
|
||||
position (get-in content [0 :params] nil)
|
||||
frame-id (cph/frame-id-by-position objects position)]
|
||||
frame-id (cph/top-nested-frame objects position)]
|
||||
(-> state
|
||||
(assoc-in [:workspace-drawing :object :frame-id] frame-id))))))
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
objects (:objects page)
|
||||
unames (volatile! (un/retrieve-used-names objects))
|
||||
|
||||
frame-id (cph/frame-id-by-position objects (gpt/add orig-pos delta))
|
||||
frame-id (cph/top-nested-frame objects (gpt/add orig-pos delta))
|
||||
|
||||
update-new-shape
|
||||
(fn [new-shape original-shape]
|
||||
|
|
|
@ -258,7 +258,7 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
content (get-in state [:workspace-drawing :object :content] [])
|
||||
position (get-in content [0 :params] nil)
|
||||
frame-id (cph/frame-id-by-position objects position)]
|
||||
frame-id (cph/top-nested-frame objects position)]
|
||||
(-> state
|
||||
(assoc-in [:workspace-drawing :object :frame-id] frame-id))))))
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
;; Calculate the frame over which we're drawing
|
||||
(let [position @ms/mouse-position
|
||||
frame-id (:frame-id attrs (cph/frame-id-by-position objects position))
|
||||
frame-id (:frame-id attrs (cph/top-nested-frame objects position))
|
||||
shape (when-not (empty? selected)
|
||||
(cph/get-base-shape objects selected))]
|
||||
|
||||
|
@ -252,7 +252,6 @@
|
|||
(ptk/reify ::create-and-add-shape
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(prn ">>>create-")
|
||||
(let [{:keys [width height]} data
|
||||
|
||||
[vbc-x vbc-y] (viewport-center state)
|
||||
|
@ -260,7 +259,7 @@
|
|||
y (:y data (- vbc-y (/ height 2)))
|
||||
page-id (:current-page-id state)
|
||||
frame-id (-> (wsh/lookup-page-objects state page-id)
|
||||
(cph/frame-id-by-position {:x frame-x :y frame-y}))
|
||||
(cph/top-nested-frame {:x frame-x :y frame-y}))
|
||||
shape (-> (cp/make-minimal-shape type)
|
||||
(merge data)
|
||||
(merge {:x x :y y})
|
||||
|
|
|
@ -437,7 +437,7 @@
|
|||
(try
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
frame-id (cph/frame-id-by-position objects position)
|
||||
frame-id (cph/top-nested-frame objects position)
|
||||
selected (wsh/lookup-selected state)
|
||||
|
||||
[vb-x vb-y vb-width vb-height] (svg-dimensions svg-data)
|
||||
|
|
|
@ -864,7 +864,7 @@
|
|||
(let [position @ms/mouse-position
|
||||
page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
frame-id (cph/frame-id-by-position objects position)
|
||||
frame-id (cph/top-nested-frame objects position)
|
||||
|
||||
moving-shapes
|
||||
(->> ids
|
||||
|
@ -878,15 +878,17 @@
|
|||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/update-shapes moving-frames (fn [shape]
|
||||
;; Hide in viwer must be enabled just when a board is moved inside another artboard an nested to it, we have to avoid situations like:
|
||||
;; - Moving inside the same frame
|
||||
;; - Moving outside the frame
|
||||
(cond-> shape
|
||||
(and (not= frame-id (:id shape))
|
||||
(not= frame-id (:frame-id shape))
|
||||
(not= frame-id uuid/zero))
|
||||
(assoc :hide-in-viewer true))))
|
||||
(pcb/update-shapes
|
||||
moving-frames
|
||||
(fn [shape]
|
||||
;; Hide in viwer must be enabled just when a board is moved inside another artboard an nested to it, we have to avoid situations like:
|
||||
;; - Moving inside the same frame
|
||||
;; - Moving outside the frame
|
||||
(cond-> shape
|
||||
(and (not= frame-id (:id shape))
|
||||
(not= frame-id (:frame-id shape))
|
||||
(not= frame-id uuid/zero))
|
||||
(assoc :hide-in-viewer true))))
|
||||
(pcb/change-parent frame-id moving-shapes))]
|
||||
|
||||
(when-not (empty? changes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue