mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
📎 Model an authored size through its parent's later resizes
A nested copy in a main that authors its height and scales vertically has its height scaled when an update main resizes that main. The model kept only the size as authored, as the copy's place in a plain main is not an override, and compared it raw. An authored size now follows its parent's later resizes through its constraints, though its place stays unauthored. Test: an-authored-size-follows-a-resize-of-its-main-through-its-constraint. Structure, swap and scale programs pass (seed 9006, 150 each). Harness only; the benchmark is not run. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
782623c935
commit
6f7a77504f
@ -190,6 +190,10 @@
|
||||
parent)
|
||||
placed (when (and objects (not (:sized? (::position (meta expected)))))
|
||||
(authored-placement expected parent shape))
|
||||
;; an authored size follows its parent's later resizes through its
|
||||
;; constraints too, though its place is not authored
|
||||
sized-placed (when (and objects (:sized? (::position (meta expected))))
|
||||
(authored-placement expected parent shape))
|
||||
;; a group or bool takes its corners from its children: at its
|
||||
;; expected corners, its turn and flips say nothing more
|
||||
derived (and (#{:group :bool} (:type shape))
|
||||
@ -241,6 +245,8 @@
|
||||
;; a recorded place sizes it through its constraints as its parent resizes
|
||||
(and (#{:width :height} key) placed (number? actual))
|
||||
(mth/close? (get placed key) actual 0.01)
|
||||
(and (#{:width :height} key) sized-placed (number? actual))
|
||||
(mth/close? (get sized-placed key) actual 0.01)
|
||||
(#{:flip-x :flip-y} key) (= (boolean value) (boolean actual))
|
||||
;; under one flip, either order of turn and flip stores the opposite turn
|
||||
(and (= :rotation key) (number? value) (number? actual)
|
||||
|
||||
@ -2598,6 +2598,12 @@
|
||||
:layout-copies false :text true}]
|
||||
:ops [[:grid-cell 13] [:grid-track 0 0 11] [:grid-track 0 3] [:add-child 8] [:grid-track 0 2]]}))))
|
||||
|
||||
(t/deftest an-authored-size-follows-a-resize-of-its-main-through-its-constraint
|
||||
(t/is (map? (cg/run {:world [1 0 {:variants true :layout :grid :layout-item-margins false :grid-square false
|
||||
:rich-variants false :layout-children false :grid-empty false
|
||||
:layout-copies false :text false}]
|
||||
:ops [[:duplicate] [:swap] [:resize] [:resize 2] [:style 0 9 1] [:edit 2 0 0 1] [:update-main 2]]}))))
|
||||
|
||||
(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