diff --git a/frontend/src/arthur/ui/timeline.cljs b/frontend/src/arthur/ui/timeline.cljs index 8d6a833..76c3f11 100644 --- a/frontend/src/arthur/ui/timeline.cljs +++ b/frontend/src/arthur/ui/timeline.cljs @@ -365,26 +365,39 @@ (walk sid [] 0 identity) []))))) -(defn palette-track-row - "`sid`'s palette row: ONE LANE ROW WHETHER OR NOT THE LANE EXISTS YET, because +(defn palette-track-rows + "`sid`'s palette rows. Its row: ONE LANE ROW WHETHER OR NOT THE LANE EXISTS YET, because a person putting a palette transition somewhere is doing the same thing in either case. Empty, it names the symbol whose palette it would be; filled, it - is the lane symbol's own row under this pane's name for it." + is the lane symbol's own row under this pane's name for it, and opens as any + lane does: onto the selected transition, its keys and channels." [clip sid frames expanded chosen] (let [track-id (get-in clip [:symbols sid :palette-track]) track (get-in clip [:symbols track-id])] (if (= :palette-track (:type track)) - ;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection and all: it is - ;; the row `rows` already draws for a lane symbol, wearing this pane's - ;; name for it. Only the row of a track that does not exist yet has to say - ;; whose palette it would be, which is what creating in it needs. - (-> (first (rows clip track-id expanded chosen)) - (assoc :path [::palette-track] :owner track-id - :label "palette" :kind :palette - :expandable? false :expanded? false)) - {:path [::palette-track] :depth 0 :label "palette" :kind :palette - :lane? true :owner nil :select [::palette-track sid] - :span [0 frames] :keys [] :cels []}))) + ;; A MATERIALIZED TRACK IS AN ORDINARY LANE ROW, selection, portal and + ;; all: it is what `rows` already draws for a lane symbol, wearing this + ;; pane's name for it. Only the row of a track that does not exist yet has + ;; to say whose palette it would be, which is what creating in it needs. + ;; + ;; `rows` calls a lane's own row `[::lane]`, which is also the open + ;; symbol's when that is a lane, so this row goes by `[::palette-track]` + ;; and is translated on the way in. The portal's rows keep their authored + ;; paths -- the clip ids are the track's own -- and carry the track as + ;; their `:owner`, so dragging them slides the clip in the track. + (let [expanded (cond-> (disj (set expanded) [::lane]) + (contains? (set expanded) [::palette-track]) (conj [::lane])) + [lane & more] (rows clip track-id expanded chosen)] + (into [(assoc lane :path [::palette-track] :owner track-id + :label "palette" :kind :palette)] + (comp (take-while #(pos? (:depth %))) + (map #(cond-> (assoc % :owner track-id) + (= ::lane (first (:path %))) + (assoc :path (into [::palette-track] (rest (:path %))))))) + more)) + [{:path [::palette-track] :depth 0 :label "palette" :kind :palette + :lane? true :owner nil :select [::palette-track sid] + :span [0 frames] :keys [] :cels []}]))) (defn sound-rows "Audio rows use the same flattened intervals as the mixer, including source @@ -1395,7 +1408,7 @@ {:id ::drop :label (str "+ " (:label drop)) :ghost? true :span drop-span}) chosen (when (= :node (first selection)) (nth selection 3)) - picture (cond-> (cond->> (into [(palette-track-row clip open frames expanded chosen)] + picture (cond-> (cond->> (into (palette-track-rows clip open frames expanded chosen) (rows clip open expanded chosen)) lane-ghost (mapv (fn [row] diff --git a/frontend/test/arthur/events/lane_test.cljs b/frontend/test/arthur/events/lane_test.cljs index 4dac1fa..aefaa67 100644 --- a/frontend/test/arthur/events/lane_test.cljs +++ b/frontend/test/arthur/events/lane_test.cljs @@ -98,19 +98,42 @@ "creating in a lane does not move the playhead")))) (deftest the-palette-row-is-a-lane-row-whether-or-not-its-track-exists - (let [empty-row (timeline/palette-track-row (clip/blank) :main 120 #{} nil) + (let [empty-row (first (timeline/palette-track-rows (clip/blank) :main 120 #{} nil)) filled (-> (clip/blank) (assoc-in [:symbols :main :palette-track] :track) (assoc-in [:symbols :track] {:id :track :type :palette-track :display :lane :frames 120 :nodes {}})) - filled-row (timeline/palette-track-row filled :main 120 #{} nil)] + filled-row (first (timeline/palette-track-rows filled :main 120 #{} nil))] ;; The double-click that creates in a lane asks nothing else of a row. (is (:lane? empty-row)) (is (:lane? filled-row)) (is (= [:node :track nil []] (:select filled-row)) "a track that exists is addressed as the lane it is"))) +(deftest the-palette-row-opens-onto-the-selected-transition-like-any-lane + (let [doc (-> (clip/blank) + (assoc-in [:symbols :main :palette-track] :track) + (assoc-in [:symbols :night] {:id :night :type :palette :frames 1 :nodes {}}) + (assoc-in [:symbols :track] + {:id :track :type :palette-track :display :lane :frames 120 + :nodes {:p {:id :p :kind :instance :source :night :span [10 40] + :time {:mode :map :at 10 :rate 1} + :channels {[:pos] {:keys {0 [0 0] 12 [5 0]}}}}}})) + closed (timeline/palette-track-rows doc :main 120 #{} [:p]) + [lane portal & channels] (timeline/palette-track-rows + doc :main 120 #{[:arthur.ui.timeline/palette-track] [:p]} [:p])] + (is (= 1 (count closed))) + (is (:expandable? (first closed)) "the palette lane has a disclosure like any lane") + (is (:expanded? lane)) + (is (= [:p] (:path portal)) "the portal is the selected transition, by its own path") + (is (= [:node :track :p [:p]] (:select portal))) + (is (= :track (:owner portal)) "dragging its bar slides it in the track") + (is (= [10 22] (:keys portal)) "its keys are on this ruler") + (is (= [:p [:pos]] (:path (first channels))) "and it opens onto its channels") + (is (not (contains? #{[:arthur.ui.timeline/lane]} (:path lane))) + "the palette lane never shares the open lane's expansion"))) + (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")]