fixed creating in

This commit is contained in:
Your Name 2026-10-03 02:15:27 -04:00
parent 2697401aad
commit a90e0cfb61
5 changed files with 99 additions and 17 deletions

View file

@ -72,26 +72,30 @@
(vals (get-in saved [:symbols :main :nodes]))))
"claiming the frame leaves no overlapping cel"))))
(deftest double-click-creation-uses-the-lane-and-pointer-frame
(deftest double-click-creation-uses-the-lane-and-playhead
(let [doc (fixture/document)
id (store/install! {:clip doc :store {}} "double-click-new-symbol")]
(reset! rf-db/app-db {:clip/current id :paint/revision 0
:ui {:open :main} :playback {:frame 0}})
:ui {:open :main} :playback {:frame 5}})
(rf/dispatch-sync [::ui/new-symbol-at 5 [:node :main nil []]])
(let [saved (:clip (store/entry id))
[_ sid instance-id] (get-in @rf-db/app-db [:ui :selection])
selection (get-in @rf-db/app-db [:ui :selection])
instance (get-in saved [:symbols sid :nodes instance-id])]
(is (= :main sid))
(is (= [5 6] (node/placed-span instance)))
(is (= 1 (clip/frames saved (node/source instance))))
(is (zero? (get-in @rf-db/app-db [:playback :frame]))
"the pointer frame, not the playhead, chooses the new cel's time"))))
(is (= (node/source instance)
(:sid (creation/target saved {} :main selection 5)))
"the new cel can immediately be selected as the creation target")
(is (= 5 (get-in @rf-db/app-db [:playback :frame]))
"the playhead chooses the new cel's time"))))
(deftest the-same-double-click-command-creates-a-palette-symbol-on-the-palette-row
(let [doc (clip/blank)
id (store/install! {:clip doc :store {}} "double-click-palette-symbol")]
(reset! rf-db/app-db {:clip/current id :paint/revision 0
:ui {:open :main} :playback {:frame 0}})
:ui {:open :main} :playback {:frame 5}})
(rf/dispatch-sync [::ui/new-symbol-at 5
[:arthur.ui.timeline/palette-track :main]])
(let [saved (:clip (store/entry id))
@ -213,6 +217,36 @@
(at 25))
"a lane behind an inactive parent occurrence is not valid")))
(deftest creation-uses-the-occurrence-path-at-arbitrary-depth
(let [instance (fn [id source span]
{:id id :kind :instance :z "a" :span span
:time {:mode :map :at 0 :rate 1}
:source {:symbol source}
:playback {:in 0 :speed 1 :end :stop}})
doc {:fps 24 :width 20 :height 20
:symbols
{:main {:id :main :frames 20
:nodes {:outer (instance :outer :ordinary [0 20])}}
:ordinary {:id :ordinary :frames 20
:nodes {:lane (instance :lane :symbol-7 [0 20])}}
:symbol-7 {:id :symbol-7 :name "symbol-7" :display :lane :frames 20
:nodes {:cel (instance :cel :symbol-8 [4 10])}}
:symbol-8 {:id :symbol-8 :name "symbol-8" :frames 6 :nodes {}}}}
lane-selection [:node :ordinary :lane [:outer :lane]]
;; The path, rather than these redundant owner fields, is authoritative
;; for creation. A row address may name the occurrence from an outer
;; view; resolution must still enter the terminal cel.
cel-selection [:node :ordinary :lane [:outer :lane :cel]]
pick #(select-keys (creation/target doc nil :main % 5)
[:kind :sid :path :frame])]
(is (= {:kind :lane :sid :symbol-7 :path [:outer :lane] :frame 5}
(pick lane-selection))
"the nested lane header remains the lane insertion surface")
(is (= {:kind :symbol :sid :symbol-8
:path [:outer :lane :cel] :frame 5}
(pick cel-selection))
"the cel enters its symbol no matter how deeply the lane is nested")))
(deftest creation-walks-out-of-an-instance-past-its-window
(let [doc {:fps 24 :width 20 :height 20
:symbols
@ -360,6 +394,16 @@
(is (= #{[:already-open]} (get-in after [:ui :expanded]))
"disclosure is changed only by the twist control")))
(deftest disclosure-sets-the-state-painted-by-the-button
;; A move can reveal a destination after the old, closed button has already
;; received pointer-down. Its eventual click must keep the row open instead
;; of toggling the newer state closed again.
(reset! rf-db/app-db {:ui {:expanded #{[:destination]}}})
(rf/dispatch-sync [::ui/set-row-expanded [:destination] true])
(is (= #{[:destination]} (get-in @rf-db/app-db [:ui :expanded])))
(rf/dispatch-sync [::ui/set-row-expanded [:destination] false])
(is (empty? (get-in @rf-db/app-db [:ui :expanded]))))
(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