Unify timeline placement and gesture geometry

This commit is contained in:
Your Name 2026-10-01 23:35:22 -04:00
parent 4e5e02c856
commit 0cb9d0ebf6
16 changed files with 702 additions and 121 deletions

View file

@ -115,3 +115,73 @@
lane (first (filter :lane? (timeline/rows doc :main #{} nil)))]
(is (= [:vo] (mapv :id (:cels lane))))
(is (empty? (timeline/sound-rows doc :main #{})))))
(deftest aiming-the-open-lanes-own-row-is-a-selection-and-not-a-crash
;; `rows` names the open symbol's own lane row `[:node sid nil []]`, and
;; `selected` used to open the rows above a selection with `(pop path)` —
;; which THROWS on `[]`, aborting the whole event. Nothing was selected,
;; nothing was aimed, and the next polygon went wherever the stale target
;; still pointed, which is most of what made aiming a lane feel random.
(let [doc (fixture/document)
id (store/install! {:clip doc :store {}} "aim-the-open-lane")
db {:clip/current id :paint/revision 0
:ui {:open :main :target {:sid :main :id :a :path [:a]}}
:playback {:frame 0}}
lane (first (filter :lane? (timeline/rows doc :main #{})))
after (ui/aimed db (:select lane))]
(is (= [:node :main nil []] (:select lane)))
(is (= [:node :main nil []] (get-in after [:ui :selection])))
(is (nil? (get-in after [:ui :target]))
"the open symbol IS the place, so aiming its own row clears the target")
(is (= [] (ui/where-new-goes doc after)))
(is (empty? (get-in after [:ui :expanded]))
"and there are no rows above the top to open")))
(deftest finishing-a-polygon-opens-no-rows
;; Expansion is the twist triangle's business. Finishing a shape used to open
;; every row down to it, which inside a lane meant tearing its one row into a
;; portal, that clip's channels and every shape already in the drawing.
(let [doc (fixture/document)
id (store/install! {:clip doc :store {}} "finish-opens-nothing")
db {:clip/current id :paint/revision 0
:ui {:open :main :tool :polygon
:target {:sid :main :id :a :path [:a]}
:draft [10 10 40 10 40 40]}
:playback {:frame 1}}]
(reset! rf-db/app-db db)
(rf/dispatch-sync [::ui/finish-polygon])
(let [after @rf-db/app-db
[kind sid shape-id path] (get-in after [:ui :selection])]
(is (= :node kind))
(is (= :drawing-a sid) "the shape went into the drawing the aimed clip places")
(is (= [:a shape-id] path))
(is (empty? (get-in after [:ui :expanded])))
(is (nil? (get-in after [:ui :tool]))))))
(deftest a-clip-made-for-a-drawing-is-selected-in-the-symbol-it-lives-in
;; The clip `beginning-polygon` materializes lives in the symbol the LANE
;; draws. Naming the open one instead left a selection that looked up to
;; nothing, so the inspector, the breadcrumb and every span command went blank
;; on a drawing that had just been created.
(let [doc (-> (fixture/document)
;; The last of the lane's three clips taken out, so frames 8
;; to 12 are a gap and drawing there makes the held clip that
;; was missing rather than landing in one that is there.
(update-in [:symbols :main :nodes] dissoc :insert)
(assoc-in [:symbols :shot]
{:id :shot :fps 24 :frames 12
:nodes {:girl {:id :girl :kind :instance :z "b" :span [0 12]
:time {:mode :map :at 0 :rate 1}
:source {:symbol :main}
:playback {:in 0 :speed 1 :end :stop}}}}))
id (store/install! {:clip doc :store {}} "clip-selected-where-it-lives")
db {:clip/current id :paint/revision 0
:ui {:open :shot :target {:sid :shot :id :girl :path [:girl]}}
:playback {:frame 9}}
after (ui/beginning-polygon db)
[_ sid clip-id path] (get-in after [:ui :selection])
saved (:clip (store/entry id))]
(is (= :main sid) "the lane's symbol, not the open one")
(is (= [:girl clip-id] path))
(is (some? (get-in saved [:symbols :main :nodes clip-id]))
"and that is where the node actually is")))