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:
parent
b45f7307a3
commit
e72d63214c
2 changed files with 69 additions and 17 deletions
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -1066,12 +1066,21 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
|||
min-width: max(340px, calc((100% - var(--label)) * var(--tl-zoom, 1)));
|
||||
position: relative;
|
||||
background: #fff;
|
||||
/* The major frame grid, using the same whole-second interval as the numbered
|
||||
ruler. It is a background rather than an element per mark; `--tick` is set
|
||||
by the component because only it knows the open symbol's length and FPS. */
|
||||
}
|
||||
|
||||
/* THE FRAME GRID, over the rows so it shows through the cels as Flash's does:
|
||||
a hairline at every frame (or every few, when a frame is too narrow to see —
|
||||
`--fine` is set by the component, which knows how wide a frame is drawn) and
|
||||
a stronger line at every whole second, the interval the ruler numbers. */
|
||||
.tl-grid {
|
||||
position: absolute; inset: 0; z-index: 1; pointer-events: none;
|
||||
background-image:
|
||||
repeating-linear-gradient(90deg,
|
||||
var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
|
||||
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%)),
|
||||
repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px var(--fine));
|
||||
}
|
||||
.tl-grid.coarse {
|
||||
background-image:
|
||||
repeating-linear-gradient(90deg, var(--grid-5) 0 1px, transparent 1px var(--tick, 10%));
|
||||
}
|
||||
|
||||
.tl-label,
|
||||
|
|
@ -1180,6 +1189,12 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
|||
.tl-ruler {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
/* The fine grid's ticks along its foot, so the frames under the numbers can
|
||||
be counted too. */
|
||||
background-image: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px var(--fine));
|
||||
background-size: 100% 4px;
|
||||
background-position: bottom;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.tl-ruler .tick {
|
||||
|
|
@ -1315,27 +1330,39 @@ button.share-button:hover, button.share-button.on { filter: brightness(1.1); }
|
|||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* THE PLAYHEAD IS THE FRAME, a cell wide: tinted over the tracks, with its line
|
||||
on the frame's left edge, where its time begins and where the ruler's number
|
||||
sits. A frame too narrow to tint is the line alone. */
|
||||
.tl-playhead {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
background: var(--playhead);
|
||||
min-width: 1px;
|
||||
box-sizing: border-box;
|
||||
border-left: 1px solid var(--playhead);
|
||||
background: color-mix(in srgb, var(--playhead) 13%, transparent);
|
||||
pointer-events: none;
|
||||
z-index: 3;
|
||||
}
|
||||
.tl-tracks.narrow .tl-playhead { background: none; }
|
||||
|
||||
/* The playhead's head, in the ruler rather than on the line, so it stays at the
|
||||
top with the ruler while the rows scroll. */
|
||||
/* Its head, on the same cell in the ruler and carrying the frame number, so
|
||||
where you are is read where you are looking. In the ruler rather than on the
|
||||
line, so it stays at the top while the rows scroll. */
|
||||
.tl-knob {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
min-width: 16px;
|
||||
box-sizing: border-box;
|
||||
padding: 0 3px;
|
||||
pointer-events: none;
|
||||
margin-left: -4px;
|
||||
top: 1px;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: var(--playhead);
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
line-height: var(--ruler);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.tl-empty { padding: 9px; color: var(--dim); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue