Unify clip placement across symbol modes
This commit is contained in:
parent
e459307a4a
commit
93f5112bb3
5 changed files with 136 additions and 117 deletions
|
|
@ -394,6 +394,53 @@
|
|||
(mapv node/placed-span (symbol/children (get-in after [:symbols :main :nodes]))))
|
||||
"it is simply placed, on screen with what was already there"))))
|
||||
|
||||
(deftest repeated-symbol-drops-keep-the-symbols-natural-duration
|
||||
(let [empty-lane (assoc-in (document) [:symbols :main]
|
||||
{:id :main :frames 40 :display :lane :nodes {}})
|
||||
once (:clip (span/place-symbol empty-lane nil :main :one :wave 0
|
||||
{:extent :grow-symbol :remainder-id :r1}))
|
||||
twice (:clip (span/place-symbol once nil :main :two :wave 10
|
||||
{:extent :grow-symbol :remainder-id :r2}))
|
||||
thrice (:clip (span/place-symbol twice nil :main :three :wave 20
|
||||
{:extent :grow-symbol :remainder-id :r3}))]
|
||||
(is (= [[:one [0 10]] [:two [10 20]] [:three [20 30]]]
|
||||
(mapv (juxt :id node/placed-span)
|
||||
(symbol/children (get-in thrice [:symbols :main :nodes]))))
|
||||
"materializing the same source repeatedly does not collapse later instances")
|
||||
(is (every? #(= [0 10] (:span %))
|
||||
(symbol/children (get-in thrice [:symbols :main :nodes]))))
|
||||
(let [resolve (clip/resolver thrice :main nil pal/index-of nil)]
|
||||
(doseq [[id at] [[:one 0] [:two 10] [:three 20]]]
|
||||
(is (= [0 300 600 900]
|
||||
(mapv (fn [f]
|
||||
(let [op (first (filter #(= [id :mark] (:node %))
|
||||
(resolve (+ at f))))]
|
||||
(js/Math.round (:cx op))))
|
||||
[0 3 6 9]))
|
||||
(str id " gets its own complete source clock"))))
|
||||
(is (empty? (clip/problems thrice)))))
|
||||
|
||||
(deftest transfer-is-one-placement-rule-with-two-destination-modes
|
||||
(let [doc (document)
|
||||
moved (:clip (span/transfer doc :main :insert :main 2
|
||||
{:extent :grow-symbol :remainder-id :rest}))
|
||||
clips (symbol/children (get-in moved [:symbols :main :nodes]))]
|
||||
(is (= [[0 2] [2 6] [6 8]] (mapv node/placed-span clips))
|
||||
"moving within a lane claims the landing interval from both neighbours")
|
||||
(is (= :insert (:id (second clips))))
|
||||
(is (empty? (symbol/overlaps (get-in moved [:symbols :main]))))
|
||||
;; The identical transfer into an ordinary symbol simply composites.
|
||||
(let [ordinary (assoc-in doc [:symbols :other]
|
||||
{:id :other :frames 12
|
||||
:nodes {:existing (cel :existing :drawing-a 0 4 0)}})
|
||||
free (:clip (span/transfer ordinary :main :b :other 1
|
||||
{:extent :grow-symbol :remainder-id :rest}))]
|
||||
(is (= #{:existing :b} (set (keys (get-in free [:symbols :other :nodes])))))
|
||||
(is (= 1 (count (symbol/overlaps (get-in free [:symbols :other]))))
|
||||
"overlap is ordinary composition outside lane mode")
|
||||
(is (nil? (get-in free [:symbols :main :nodes :b])))
|
||||
(is (empty? (clip/problems free))))))
|
||||
|
||||
(deftest an-existing-clip-can-be-moved-and-claim-where-it-lands
|
||||
(let [doc (assoc-in (document) [:symbols :main :nodes :badge]
|
||||
{:id :badge :kind :instance :z "z"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue