mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 17:50:38 +00:00
🐛 Place a reset nested head as a resized copy around it places it
A copy taller than its main scales a nested head that is set to scale vertically. Resetting that head gave it the size of its main and kept its place, and the next sync scaled it again. Only a head with its own geometry took the placement a sync of the enclosing copy gives; a head under a copy with its own geometry, up to that enclosing copy, takes it too. Benchmark (scripts/bench-components, lower quantile in ms): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 19.071 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 40.616 | 0.59 | | library-update-into-copies | 83.083 | 46.556 | 0.56 | | main-edit-among-many-shapes | 4.837 | 2.149 | 0.44 | | main-edit-into-10-copies | 1.79 | 1.003 | 0.56 | | main-edit-into-100-copies | 15.415 | 9.518 | 0.62 | | main-edit-into-1000-copies | 153.086 | 94.056 | 0.61 | | variant-switch-into-copies | 32.052 | 20.334 | 0.63 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
c318971107
commit
c9316735a8
@ -2035,22 +2035,30 @@
|
||||
libraries current-file-id 1)))
|
||||
|
||||
(defn- settle-reset-placement
|
||||
"Place a reset nested head whose geometry was overridden as an ordinary
|
||||
copy of its position: its subtree takes the placement a sync of the head
|
||||
that owns its ref gives. Other heads keep the placement they have."
|
||||
"Place a reset nested head as an ordinary copy of its position when its
|
||||
geometry was overridden, or a copy between it and the head that owns its
|
||||
ref keeps its own: its subtree takes the placement a sync of that head
|
||||
gives. Other heads keep the placement they have."
|
||||
[changes file libraries container shape-id]
|
||||
(let [objects (pcb/get-objects changes)
|
||||
shape (get objects shape-id)
|
||||
parent (get objects (:parent-id shape))]
|
||||
parent (get objects (:parent-id shape))
|
||||
;; the head as it was before the reset cleared its overrides
|
||||
before (ctn/get-shape container shape-id)]
|
||||
(if (and (= :page (:type container))
|
||||
(:shape-ref parent)
|
||||
(not (ctk/swapped? shape))
|
||||
(ctk/touched-group? (ctn/get-shape container shape-id) :geometry-group))
|
||||
(not (ctk/swapped? shape)))
|
||||
(let [container (ctn/make-container (assoc container :objects objects) :page)
|
||||
component (ctf/find-ref-component file container libraries shape :include-deleted? true)
|
||||
head (d/seek #(= (:id component) (:component-id %))
|
||||
(ctn/get-parent-copy-heads objects parent))]
|
||||
(if head
|
||||
(ctn/get-parent-copy-heads objects parent))
|
||||
;; the copies from the parent up to that head
|
||||
between (when head
|
||||
(into [] (d/take-until #(= (:id head) (:id %)))
|
||||
(cfh/get-parents-with-self objects (:id parent))))]
|
||||
(if (and head
|
||||
(some #(ctk/touched-group? % :geometry-group)
|
||||
(cons before between)))
|
||||
(let [file (assoc-in file [:data :pages-index (:id container) :objects] objects)
|
||||
proposal (generate-sync-shape-direct (-> (pcb/empty-changes)
|
||||
(pcb/with-container container)
|
||||
|
||||
@ -980,3 +980,10 @@
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false
|
||||
:rich-variants true :grid-empty true :layout-copies true :text true}]
|
||||
:ops [[:style 1 35 1] [:style 0 29 1]]}))))
|
||||
|
||||
(t/deftest generated-reset-nested-head-keeps-the-size-its-resized-parent-gives
|
||||
;; a copy taller than its main scales a nested head set to scale
|
||||
;; vertically; resetting the head keeps the size that sync gives it
|
||||
(t/is (map? (cg/run {:world [2 0 {:text true :text-styles true :layout :grid :grid-empty true}]
|
||||
:ops [[:resize 0 0 0 0] [:nest 20 0 0 0] [:style 9 9 1] [:edit 20 1 1 :copy-head]
|
||||
[:reset 20]]}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user