diff --git a/frontend/src/arthur/ui/timeline.cljs b/frontend/src/arthur/ui/timeline.cljs index 0d055e1..cd54589 100644 --- a/frontend/src/arthur/ui/timeline.cljs +++ b/frontend/src/arthur/ui/timeline.cljs @@ -79,6 +79,20 @@ (+ at (/ (or (clip/frames clip (node/source n)) 0) rate)) (clip/frames clip sid))) +(defn- shows + "Where on the ruler `n` has something to show, as `[from to)`, given `->open` + from its own frames to the ruler's; nil where it places nothing or shows + something across all of its span. + + A SPAN IS NOT CONTENT. Lengthening a placement past the end of the symbol it + plays leaves the bar longer and the picture empty — `node/placed-frame` runs + out — so the row has to say where the symbol does. A held or looping + placement always has a frame to show, so only a playing one answers." + [clip n ->open] + (when-let [t (and (node/source n) (node/source-time n))] + (mapv (comp ->open (time->parent t)) + [0 (or (clip/frames clip (node/source n)) 0)]))) + (defn- node-label "What to call a node in the label column. @@ -194,6 +208,7 @@ :expandable? true :expanded? open? :span cspan + :shows (shows clip child cself) :key-items (key-items child sid cself) :keys (into [] (comp (mapcat keyed-frames) (map cself) @@ -242,6 +257,7 @@ (node-label clip (:id child) child)) :source (node/source child) :span (mapv ->open (node/placed-span child)) + :shows (shows clip child (comp ->open (local->parent child))) :key-items (key-items child sid (comp ->open (local->parent child))) :keys (into [] (comp (mapcat keyed-frames) @@ -306,6 +322,7 @@ :expandable? true :expanded? open? :span span + :shows (shows clip n self) :key-items (key-items n sid self) :keys (into [] (comp (mapcat keyed-frames) (map self) @@ -328,6 +345,7 @@ (some-> (node/source child) name)) :source (node/source child) :span (mapv source-self (node/placed-span child)) + :shows (shows clip child (comp source-self (local->parent child))) ;; The clip's own keys, on the ;; block, so a collapsed lane ;; still says where it changes. @@ -1046,12 +1064,24 @@ (reset! gesture nil) (when @preview (reset! preview nil))) :on-pointer-cancel (fn [e] (.stopPropagation e) (reset! gesture nil) (reset! preview nil))}]))) +(defn- runout + "The stretches of a bar drawn from `in` to `out` where what it places has + nothing to show — see `shows` — as Flash draws empty frames: unfilled, inside + the outline of a clip that still lasts there." + [in out shows] + (when-let [[from to] shows] + (for [[a b] [[in (min out from)] [(max in to) out]] + :when (< a b)] + ^{:key a} + [:span.tl-runout {:style {:left (str (* 100 (/ (- a in) (- out in))) "%") + :width (str (* 100 (/ (- b a) (- out in))) "%")}}]))) + (defn- track-cell "`sliding` is the gesture in flight: `{:row :path :kind :from :df}`, where `:from` is the frame the press was on and `:df` how many frames the pointer has moved since. What it looks like mid-drag is `[:ui :sliding]`, which the clip every row and the stage are drawn from already has in it." - [{:keys [path span keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]} + [{:keys [path span shows keys key-items gaps dense? kind node-kind select slides cels lane? of unmapped? owner]} frames sliding hint {:keys [clip store open selection selections target-path key-selection key-preview key-anchor key-state key-elements choose-row!]}] (let [selected-set (set selections) active-row (:row @sliding) @@ -1313,6 +1343,7 @@ :on-pointer-down (when (and select (not unmapped?)) #(begin! % (or slides path) :slide select nil nil))} + (runout in out shows) (when (and select (not unmapped?)) [:span.tl-edge.in {:title "Drag start" :on-pointer-down #(begin! % path :in select nil nil)}]) @@ -1320,7 +1351,7 @@ [:span.tl-edge.out {:title "Drag endpoint · Shift-drag ripples later clips" :on-pointer-down #(begin! % path :out select nil nil)}])])) (doall - (for [[i {:keys [id label source span select ghost?]}] + (for [[i {:keys [id label source span shows select ghost?]}] (map-indexed vector (cond-> (vec cels) (= select (:target-lane @sliding)) @@ -1377,6 +1408,7 @@ {:selection select :label label :in (js/Math.floor in) :duration (- out in)}))} + (runout in out shows) [:span.tl-cel-label label] (when select (if joined? diff --git a/frontend/test/arthur/events/lane_test.cljs b/frontend/test/arthur/events/lane_test.cljs index fcadbea..beaafc3 100644 --- a/frontend/test/arthur/events/lane_test.cljs +++ b/frontend/test/arthur/events/lane_test.cljs @@ -225,6 +225,28 @@ (is (= [[2 3]] (mapv :span (:cels lane))) "a lane placed at twice the speed draws its frames 4–6 on ruler frames 2–3"))) +(deftest a-bar-says-where-what-it-plays-runs-out + (let [placed {:id :short :kind :instance :z "a" :span [0 10] + :time {:at 6 :rate 1} + :source {:symbol :short} + :playback {:in 0 :speed 1 :end :stop}} + doc (-> (clip/blank) + (assoc-in [:symbols :main :frames] 24) + (assoc-in [:symbols :main :nodes] {:short placed}) + (assoc-in [:symbols :short] {:id :short :frames 4 :nodes {}})) + row #(first (timeline/rows % :main #{}))] + (is (= [6 16] (:span (row doc)))) + (is (= [6 10] (:shows (row doc))) + "four frames of symbol, stretched to ten, show from 6 to 10 only") + (is (nil? (:shows (row (assoc-in doc [:symbols :main :nodes :short :playback :speed] 0)))) + "a held placement shows its frame across the whole span") + (let [lane (-> (assoc-in doc [:symbols :main :display] :lane) + (assoc-in [:symbols :main :nodes :short :playback :speed] 2) + (timeline/rows :main #{}) + first)] + (is (= [[6 8]] (mapv :shows (:cels lane))) + "a clip in a lane says it too, at its own speed")))) + (deftest an-ordinary-symbol-keeps-a-row-per-node (let [doc (update-in (fixture/document) [:symbols :main] dissoc :display) rows (timeline/rows doc :main #{})] diff --git a/static/arthur/app.css b/static/arthur/app.css index 71420ad..deeffa2 100644 --- a/static/arthur/app.css +++ b/static/arthur/app.css @@ -1372,6 +1372,16 @@ button.followable svg { width: 12px; height: 12px; display: block; } text-overflow: ellipsis; pointer-events: none; } +/* Frames of a clip past the end of what it plays: still the clip's — the outline + and the handles go on — but empty, as Flash leaves an empty frame unfilled. */ +.tl-runout { + position: absolute; + top: 0; + bottom: 0; + background: repeating-linear-gradient(135deg, var(--pane) 0 3px, var(--sunk) 3px 6px); + pointer-events: none; +} +.tl-cel-label { position: relative; } .tl-span.ghost { background: transparent; border: 1px dashed var(--sel);