Frames are cells: a grid through the rows, and a playhead a frame wide

As in Flash, a hairline at every frame over the rows and through the cels,
stronger at every second; too narrow to see, it steps by the fewest frames
that divide a second, and goes when even that is too dense. The playhead is
the frame it is on: a tinted cell with its line on the frame's left edge,
where the ruler's number is, and a head carrying the frame number. Too
narrow to tint, it is the line alone, as in Resolve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Olive Vaughn 2026-10-10 20:36:51 -04:00
parent b45f7307a3
commit e72d63214c
2 changed files with 69 additions and 17 deletions

View file

@ -1316,7 +1316,9 @@
to move two elements' `left`. That cost more than painting the frame did and
starved the rAF loop painting it, which ran at 16fps against a 60fps ceiling."
[tag frames]
[tag {:style {:left (at% @(rf/subscribe [::render/open-frame]) frames)}}])
(let [f @(rf/subscribe [::render/open-frame])]
[tag {:style {:left (edge% f frames) :width (edge% 1 frames)}}
(when (= tag :div.tl-knob) f)]))
(defn- outside-marks
"The frames playback leaves out, shaded, and the span it plays, banded on the
@ -1352,8 +1354,22 @@
:width (str (abs (- x2 x)) "px") :height (str (abs (- y2 y)) "px")
:border "1px solid var(--pick)" :background "color-mix(in srgb, var(--pick) 15%, transparent)"}}])))
(defn- frame-step
"How many frames apart the grid's fine lines are: every frame where a frame
is wide enough to see, else the fewest that divide a second evenly and are —
so a line still falls on every second — or nil when not even that fits under
the second lines."
[frame-px fps]
(first (filter #(and (zero? (mod fps %)) (<= 6 (* % frame-px)) (< % fps))
(range 1 fps))))
(defn- timeline-view []
(r/with-let [scrubbing (r/atom false)
;; How wide the tracks are drawn, for how many pixels a frame
;; gets: the grid and the playhead change with it.
tracks-px (r/atom nil)
sizer (js/ResizeObserver.
(fn [entries] (reset! tracks-px (.. (aget entries 0) -contentRect -width))))
;; The row a carried row is over and which part of it, for the
;; highlight.
over (r/atom nil)
@ -1461,6 +1477,8 @@
;; FPS-blind 20/40/60 ruler.
fps (max 1 (or (:fps clip) 1))
step (* fps (max 1 (js/Math.ceil (/ frames (* fps 10)))))
frame-px (/ (or @tracks-px 0) frames)
fine (frame-step frame-px fps)
choose-row! (fn [e target]
(let [xs (vec (keep :select visible))
anchor (or @row-anchor selection target)
@ -1595,7 +1613,10 @@
;; The rows and ruler share this exact major interval. Keeping a
;; second, hard-coded five-frame grid here made its lines disagree
;; with the numbered marks whenever the project's FPS changed.
:style {"--tick" (str (* 100 (/ step frames)) "%")}}
:ref #(when % (.observe sizer %))
:class (when (< frame-px 4) "narrow")
:style {"--tick" (str (* 100 (/ step frames)) "%")
"--fine" (if fine (str (* 100 (/ fine frames)) "%") "none")}}
[:div.tl-ruler
{:on-pointer-down (fn [^js e]
(rf/dispatch [::pb/seek (frame-at e frames)])
@ -1633,10 +1654,14 @@
:key-anchor key-anchor :key-state key-state :key-elements key-elements :choose-row! choose-row!}])
{:key (str (:path row))})))
[:div.tl-empty "nothing in this symbol"])
;; Over the rows, through the cels, as Flash draws its frames: a frame
;; is a cell you can see wherever there is time.
[:div.tl-grid {:class (when-not fine "coarse")}]
[outside-marks frames false]
[playhead :div.tl-playhead frames]
[key-marquee marquee]]]
[cursor-hint hint]])))
[cursor-hint hint]])
(finally (.disconnect sizer))))
(defn view []
[timeline-view])