mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Mark a pushed swap's geometry only when its axes differ from its main
When update-main pushes a swap into the main as a plain nested copy, the copy authors its geometry when its orientation differs from its main's in the parent's orientation. A mirrored shape can store rotation 90 or 270 for the same axes, so comparing the stored rotations found a turn where the transforms matched, and marked a geometry override for no visible difference. The override now follows the axes, mirror included. Test: updating-a-main-from-a-mirrored-copy-pushes-its-swap-without-a- geometry-override, the variant gate program of round 11 (seed 164135730). Common suite: 2420 tests, 0 failures. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+--------+--------+--------| | deepest-edit-through-three-levels | 35.215 | 19.46 | 20.414 | 0.55 | | edit-through-a-chain-of-dependents | 68.931 | 38.28 | 40.467 | 0.56 | | library-update-into-copies | 83.083 | 52.248 | 53.668 | 0.63 | | main-edit-among-many-shapes | 4.837 | 2.193 | 2.315 | 0.45 | | main-edit-into-10-copies | 1.79 | 1.06 | 1.077 | 0.59 | | main-edit-into-100-copies | 15.415 | 9.551 | 10.18 | 0.62 | | main-edit-into-1000-copies | 153.086 | 96.62 | 99.326 | 0.63 | | variant-switch-into-copies | 32.052 | 22.138 | 22.88 | 0.69 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
6970d5c935
commit
e8ab93d6fb
@ -1213,9 +1213,13 @@
|
||||
main-container (when main
|
||||
(main-in-parent-orientation (:container (meta main)) main
|
||||
container shape false))
|
||||
expected (get-in main-container [:objects (:id main)])]
|
||||
expected (get-in main-container [:objects (:id main)])
|
||||
;; a mirrored shape can store another rotation for the same axes
|
||||
turned? (and expected
|
||||
(not (gmt/unit? (gmt/multiply (axes-matrix expected)
|
||||
(gmt/inverse (axes-matrix shape))))))]
|
||||
(cond-> shape
|
||||
(and expected (orient-like shape expected (gsh/shape->center shape)))
|
||||
turned?
|
||||
(update :touched ctk/set-touched-group :geometry-group)
|
||||
|
||||
(and main (some #(not= (get shape %) (get main %)) [:constraints-h :constraints-v :fixed-scroll]))
|
||||
|
||||
@ -2116,6 +2116,15 @@
|
||||
:ops [[:variant-property] [:switch 3] [:combine 11] [:combine 12] [:resize 10]
|
||||
[:variant-property 8 9] [:add-variant] [:switch 2] [:update-main]]}))))
|
||||
|
||||
(t/deftest updating-a-main-from-a-mirrored-copy-pushes-its-swap-without-a-geometry-override
|
||||
(t/is (map? (cg/run {:world [3 2 {:variants true :text-styles true :layout nil :variant-diff false
|
||||
:layout-item-margins false :grid-square true :rich-variants true
|
||||
:layout-children true :grid-empty false :layout-copies true :text false}]
|
||||
:ops [[:swap 6 5 0] [:add-variant 4 5 3] [:make-variant 4] [:make-variant 0 1 5]
|
||||
[:make-variant 1] [:switch 2] [:detach 0 2 6] [:combine] [:swap 2 2 0] [:switch]
|
||||
[:nest 6 3 3] [:add-variant 1 5 5] [:rotate 0 4 5] [:nest 3 3 4] [:switch]
|
||||
[:switch] [:transform 0 4 0 2] [:update-main]]}))))
|
||||
|
||||
(t/deftest moving-a-flex-copy-child-after-a-switch-resized-its-sibling-authors-no-geometry
|
||||
(t/is (map? (cg/run {:world [1 2 {:variants true :text-styles false :layout :flex :variant-diff false
|
||||
:layout-item-margins false :grid-square false :rich-variants true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user