mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 14:30:37 +00:00
🐛 Keep parent orientation when resetting a nested copy
Resetting a selected nested copy must compose its parent placement even when that parent remains a component copy. Red regression reproduced; reset suite passes 16 tests / 63 assertions. Benchmark vs Phase 1e: main 10/100/1000 0.51/0.64/0.65; levels 0.50; chain 0.57; library 0.53; many shapes 0.47; switch 0.59. No flags. AI-assisted-by: GPT-6
This commit is contained in:
parent
8e18c62860
commit
a8f20d40b6
@ -263,12 +263,12 @@
|
||||
(defn- main-in-parent-orientation
|
||||
"Place a main in the orientation of an ordinary instance parent. Such a
|
||||
parent can survive detach, while the nested copy stays untouched."
|
||||
[main-container shape-main container shape-inst]
|
||||
[main-container shape-main container shape-inst reset?]
|
||||
(let [parent (ctn/get-shape container (:parent-id shape-inst))
|
||||
main-parent (get-in main-container [:objects (:parent-id shape-main)])
|
||||
relative (gmt/multiply (or (:transform parent) (gmt/matrix))
|
||||
(or (:transform-inverse main-parent) (gmt/matrix)))]
|
||||
(if (or (nil? parent) (:shape-ref parent) (gmt/unit? relative))
|
||||
(if (or (nil? parent) (and (:shape-ref parent) (not reset?)) (gmt/unit? relative))
|
||||
main-container
|
||||
(let [transform (gmt/transform-in (gsh/shape->center shape-main) relative)
|
||||
angle (- (or (:rotation parent) 0) (or (:rotation main-parent) 0))
|
||||
@ -299,7 +299,7 @@
|
||||
(ctf/get-content-ref-shape library component shape-inst))
|
||||
main-container (find-main-container container shape-inst shape-main
|
||||
library file libraries component)
|
||||
main-container (main-in-parent-orientation main-container shape-main container shape-inst)
|
||||
main-container (main-in-parent-orientation main-container shape-main container shape-inst reset?)
|
||||
shape-main (ctn/get-shape main-container (:id shape-main))]
|
||||
(sync-copy-recursive changes
|
||||
{:container container
|
||||
|
||||
@ -639,3 +639,14 @@
|
||||
(t/is (= 0 (:rotation (ths/get-shape reset :copy-child))))
|
||||
(t/is (nil? (:touched (ths/get-shape reset :copy-root))))
|
||||
(t/is (= (thn/normalize-file rotated) (thn/normalize-file undone)))))
|
||||
|
||||
(t/deftest reset-a-nested-copy-keeps-its-rotated-parent-placement
|
||||
(let [initial (-> (setup/nested-component-with-copy)
|
||||
(r/step (n/rotate :copy-root 45)) r/settle)
|
||||
head (tm/role-shape initial :copy-instance)
|
||||
child (tm/shape-by-id initial (first (:shapes head)))
|
||||
reset (-> initial (r/step (n/reset :copy-instance)) r/settle)
|
||||
after (tm/shape-by-id reset (:id child))]
|
||||
(t/is (gsh/close-attrs? :points (:points child) (:points after) 0.001))
|
||||
(t/is (= (:rotation child) (:rotation after)))
|
||||
(t/is (nil? (:touched (tm/role-shape reset :copy-instance))))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user