mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Settle the descendants of a reflected copy child as sync does
Reflecting a shape can leave a turned descendant's flip flags in another decomposition of the same transform (rotation 270 with a vertical flip for rotation 90 with a horizontal one), and a later sync of the copy rewrites them. The transform settles the descendants of a reflected copy head from its copy root so both agree. A plain copy shape with children, such as the nested head a main detached, was left out. Any reflected copy shape with children settles from its copy root. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 19.748 | 0.56 | | edit-through-a-chain-of-dependents | 68.931 | 42.466 | 0.62 | | library-update-into-copies | 83.083 | 51.313 | 0.62 | | main-edit-among-many-shapes | 4.837 | 2.445 | 0.51 | | main-edit-into-10-copies | 1.79 | 0.988 | 0.55 | | main-edit-into-100-copies | 15.415 | 9.629 | 0.62 | | main-edit-into-1000-copies | 153.086 | 100.363 | 0.66 | | variant-switch-into-copies | 32.052 | 21.275 | 0.66 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
a737c17788
commit
5077c22ab9
@ -463,19 +463,21 @@
|
||||
(d/ordered-map)
|
||||
(keep (fn [id]
|
||||
(let [shape (get objects id)
|
||||
root (when (:component-id shape) (ctn/get-component-shape objects shape))
|
||||
root (when (:shape-ref shape) (ctn/get-component-shape objects shape))
|
||||
old (get before id)
|
||||
reflected-head? (and (:component-id shape)
|
||||
(:shape-ref shape)
|
||||
(or (not= (boolean (:flip-x old)) (boolean (:flip-x shape)))
|
||||
(not= (boolean (:flip-y old)) (boolean (:flip-y shape)))))]
|
||||
;; a copy head, or a plain copy shape with children
|
||||
reflected? (and (some? root)
|
||||
(or (:component-id shape) (seq (:shapes shape)))
|
||||
(or (not= (boolean (:flip-x old)) (boolean (:flip-x shape)))
|
||||
(not= (boolean (:flip-y old)) (boolean (:flip-y shape)))))]
|
||||
(cond
|
||||
(and (ctk/swapped? shape)
|
||||
(and (some? root)
|
||||
(ctk/swapped? shape)
|
||||
(not (ctk/touched-group? shape :geometry-group))
|
||||
(not= (orientation old) (orientation shape)))
|
||||
[(:id root) true]
|
||||
|
||||
reflected-head?
|
||||
reflected?
|
||||
[(:id root) false])))
|
||||
ids))]
|
||||
(reduce (fn [changes [id resize?]]
|
||||
|
||||
@ -312,6 +312,14 @@
|
||||
(t/is (map? (cg/run {:world [2 1 {:text true :layout :grid}]
|
||||
:ops [[:rotate 1] [:transform 2 16 0 9]]}))))
|
||||
|
||||
(t/deftest reflecting-a-plain-copy-child-settles-descendant-flips
|
||||
;; the main detaches its nested copy, so the copy's nested head is a plain
|
||||
;; copy child; reflecting it leaves its turned child as a full sync does
|
||||
(t/is (map? (cg/run {:world [3 1 {:text true :text-styles true :layout nil :layout-children false
|
||||
:layout-item-margins false :grid-square false :grid-empty false}]
|
||||
:ops [[:transform 3 9 1 7] [:remove-child 0 0 0 0] [:detach 4 0 0 0]
|
||||
[:transform 0 4 0 7]]}))))
|
||||
|
||||
(t/deftest swapping-after-a-resized-variant-keeps-child-placement
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false :rich-variants true
|
||||
:text true :layout nil :layout-copies true}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user