Add multi-object stage selection and transforms
This commit is contained in:
parent
b41180db08
commit
dff23d7994
10 changed files with 315 additions and 44 deletions
|
|
@ -274,6 +274,22 @@
|
|||
(is (string? (gesture/refusal {:channels {[:xform :pos] {:animated? true :dense {:stride 2}}}})))
|
||||
(is (nil? (gesture/refusal {:channels {[:xform :pos] (ch/keyed {0 [1 1]} :hold)}}))))
|
||||
|
||||
(deftest moving-a-measured-part-adds-an-authored-offset
|
||||
(let [key "measured-position"
|
||||
st {key {:data (js/Float32Array. #js [1 2 2 3])}}
|
||||
measured {:animated? true :dense {:store key :offset 0 :stride 2 :frames 2}}
|
||||
c (-> (clip/blank)
|
||||
(paint/new-shape :main :brow 0 [0 0 10 0 5 3] :brow)
|
||||
(assoc-in [:symbols :main :nodes :brow :channels [:xform :pos]] measured))
|
||||
once (gesture/apply-values c :main :brow 0 {[:xform :pos] [4 6]} false st)
|
||||
twice (gesture/apply-values once :main :brow 0 {[:xform :pos] [5 8]} false st)
|
||||
pos #(get-in % [:symbols :main :nodes :brow :channels [:xform :pos]])]
|
||||
(is (= (:dense measured) (:dense (pos twice))) "the measured base survives")
|
||||
(is (= [5 8] (ch/value-at (pos twice) 0 st)) "the brow lands under the pointer")
|
||||
(is (= [6 9] (ch/value-at (pos twice) 1 st))
|
||||
"its measured motion continues underneath the authored offset")
|
||||
(is (= 1 (count (:over (pos twice)))) "repeated drags update one correction layer")))
|
||||
|
||||
(deftest a-click-selects-the-level-figma-would
|
||||
(let [hit [:a :b :c :shape]]
|
||||
(testing "choose"
|
||||
|
|
@ -297,6 +313,18 @@
|
|||
(is (= [:dot] (pick/hit ops [52.5 50])) "a few-pixel shape can be missed by a little")
|
||||
(is (nil? (pick/hit ops [30 30])))))
|
||||
|
||||
(deftest a-marquee-selects-visible-objects-at-one-depth
|
||||
(let [sq (fn [path x0] {:kind :poly :node path :n 4
|
||||
:pts (js/Float64Array.
|
||||
#js [x0 0 (+ x0 10) 0 (+ x0 10) 10 x0 10])})
|
||||
ops [(sq [:left :inside] 0) (sq [:right :inside] 20) (sq [:away] 80)]]
|
||||
(is (= [[:left] [:right]] (pick/in-rect ops [-2 -2 35 12] 1))
|
||||
"a fresh marquee chooses objects in the open symbol")
|
||||
(is (= [[:left :inside] [:right :inside]] (pick/in-rect ops [-2 -2 35 12] 2))
|
||||
"an existing deep selection keeps the marquee at that depth")
|
||||
(is (= [[:left]] (pick/in-rect ops [5 5 6 6] 1))
|
||||
"intersection, rather than full containment, makes small objects selectable")))
|
||||
|
||||
(deftest an-instances-box-is-what-its-symbol-draws
|
||||
(let [c (two-down)
|
||||
{:keys [frame]} (nest/placement c nil :main [u v] 16)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue