mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 09:42:01 +00:00
🐛 Place the shapes of a copy group in its board when detaching
A detach advances the references of the nested copies and makes authored the place of a shape its new main would put elsewhere. It measured the shapes of a group or bool from the group, whose bounds differ from its main's when one of its shapes authors a move, so it authored places nothing had moved, and authored the group's own geometry for the same reason. The shapes of a group or bool are measured in the board around it, as a group takes its bounds from its shapes, and a group or bool never authors its geometry there. The harness model does the same. Test: detaching-keeps-a-shape-of-a-copy-bool-unauthored-where-its-main-places-it. Shape structure programs pass (seed 9001, 150). The benchmark of the commit before the previous one covers this one. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
97d0ed02c3
commit
c9683d7398
@ -2152,11 +2152,19 @@
|
||||
:include-deleted? true :with-context? true)
|
||||
main-objects (:objects (:container (meta main)))
|
||||
main-parent (get main-objects (:parent-id main))
|
||||
;; a group or bool takes its bounds from its children, so they are
|
||||
;; placed in the board around it
|
||||
board? (and (#{:group :bool} (:type parent)) (#{:group :bool} (:type main-parent))
|
||||
(not (ctsl/any-layout? (get objects (:frame-id shape)))))
|
||||
parent (if board? (get objects (:frame-id shape)) parent)
|
||||
main-parent (if board? (get main-objects (:frame-id main)) main-parent)
|
||||
;; a layout places the shape, so only its size and orientation can be its own
|
||||
layout-placed? (and (ctsl/any-layout-immediate-child? objects shape)
|
||||
(not (ctsl/position-absolute? shape)))]
|
||||
(if (and (some? main)
|
||||
(not (ctk/touched-group? shape :geometry-group))
|
||||
;; the bounds of a group or bool follow its children's places
|
||||
(not (#{:group :bool} (:type shape)))
|
||||
(if (and (some? (:shape-ref parent)) (not layout-placed?))
|
||||
(and (some? main-parent)
|
||||
(not (close-geometry? shape (get (placed-like main-objects main-parent parent
|
||||
|
||||
@ -389,12 +389,20 @@
|
||||
(let [parent (get after (:parent-id shape))
|
||||
main (get after (:shape-ref shape))
|
||||
main-parent (get after (:parent-id main))
|
||||
;; a group or bool takes its bounds from its children, so they
|
||||
;; measure from the board around it
|
||||
board? (and (#{:group :bool} (:type parent)) (#{:group :bool} (:type main-parent))
|
||||
(not (ctl/any-layout? (get after (:frame-id shape)))))
|
||||
parent (if board? (get after (:frame-id shape)) parent)
|
||||
main-parent (if board? (get after (:frame-id main)) main-parent)
|
||||
objects (cond-> after
|
||||
(and main (contains? groups :constraints-group))
|
||||
(update (:id main) merge
|
||||
(into {} (filter val) (select-keys shape [:constraints-h :constraints-v]))))]
|
||||
(cond
|
||||
(or (contains? groups :geometry-group) (contains? groups :swap-group) (nil? main))
|
||||
;; the bounds of a group or bool follow its children's places
|
||||
(or (contains? groups :geometry-group) (contains? groups :swap-group) (nil? main)
|
||||
(#{:group :bool} (:type shape)))
|
||||
groups
|
||||
|
||||
;; a layout places the shape, so only its size and orientation can be its own
|
||||
|
||||
@ -2508,6 +2508,12 @@
|
||||
:layout-copies true :text false}]
|
||||
:ops [[:grid-track 3 5 0 2] [:grid-track 0 3] [:grid-cell 3 0 0 1]]}))))
|
||||
|
||||
(t/deftest detaching-keeps-a-shape-of-a-copy-bool-unauthored-where-its-main-places-it
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :rich-variants true :text true :layout :flex
|
||||
:layout-copies false :layout-children false}]
|
||||
:ops [[:delete 11] [:detach 5] [:swap 10] [:add-child] [:structure 0 6 3] [:nest 11]
|
||||
[:transform 2 0 0 7] [:detach 13]]}))))
|
||||
|
||||
(t/deftest settling-a-bool-in-a-grid-copy-twice-keeps-its-shapes-in-place
|
||||
(t/is (map? (cg/run {:world [3 0 {:variants true :rich-variants true :text true :layout :grid
|
||||
:layout-copies true :layout-children true}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user