Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Centre the transport on the video, put the clock beside the heading

Bitti049d2f59860e
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index 2ee44ed..69a783b 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -541,6 +541,22 @@ describe("project workspace timecode", () => {
// It sits in the timeline toolbar now, not under the program monitor.
expect(container.querySelector(".monitor-transport")).toBeNull();
expect(container.querySelector(".timeline-toolbar .timeline-transport")).not.toBeNull();
+ /* The transport is the three controls and NOTHING else. The clock and the
+ format used to ride inside it, which pushed the buttons off to one side
+ of whatever the cluster happened to measure — and the cluster has to be
+ centred on the picture above it, which only works if its own contents are
+ symmetrical. They live beside the heading now instead; jsdom lays nothing
+ out, so what is pinned here is the arrangement the CSS centres, and the
+ measured geometry is recorded against --video-centre-shift. */
+ expect(Array.from(container.querySelectorAll(".timeline-transport > *")).map((el) => el.getAttribute("aria-label")))
+ .toEqual(["Go to beginning", "Play", "Step forward one second"]);
+ const lead = container.querySelector(".timeline-toolbar__lead")!;
+ expect(lead.querySelector("h2")!.textContent).toBe("Timeline");
+ expect(lead.querySelector(".transport-time")).not.toBeNull();
+ expect(lead.querySelector(".transport-format")).not.toBeNull();
+ // Reading order left to right: what this panel is, where it stands, what it
+ // is. The heading has to come first or the clock is a label on nothing.
+ expect(Array.from(lead.children).map((el) => el.tagName)).toEqual(["H2", "STRONG", "SPAN"]);
// the playhead time is printed once. The toolbar used to print it beside
// the heading while the monitor printed it again, which reads as two clocks.
expect(container.textContent!.match(/\d\d:\d\d:\d\d:\d\d/g)).toHaveLength(1);
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index ab844dd..2d0418c 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -510,20 +510,32 @@ export function TimelineView({ config, folderPath, onChange, onMeasured, onOpenG
<section className="pro-timeline">
<header className="timeline-toolbar">
- <h2>Timeline</h2>
+ {/* What the timeline IS and where it currently stands, reading left to
+ right from the panel's own heading: name, clock, format. The clock
+ used to sit inside the transport cluster, which pushed the buttons
+ off-centre and put a number nobody is aiming at in the middle of
+ the row. It is still the only timecode on the screen. */}
+ <div className="timeline-toolbar__lead">
+ <h2>Timeline</h2>
+ <strong className="transport-time" title="Playhead position">{timecode(playhead)}</strong>
+ <span className="transport-format">{config.settings.resolution.toUpperCase()} · {config.settings.frameRate} fps</span>
+ </div>
{/* The transport belongs to the timeline, not to the picture: it drives
the playhead, and the playhead is drawn a few pixels below this row.
Under the monitor it also printed the same timecode this toolbar was
already printing, so one clock was shown twice and could be read as
- two. One transport, one timecode, beside the ruler they refer to. */}
+ two. One transport, one timecode, beside the ruler they refer to.
+
+ It is centred on the PICTURE rather than on this row, which are not
+ the same point: the toolbar runs the full width while the monitor
+ sits between two side panels of unequal width. See
+ --video-centre-shift in timeline.css. */}
<div className="timeline-transport">
<button onClick={() => setPlayhead(0)} aria-label="Go to beginning" title={transportBlockedBy ?? "Go to beginning"} disabled={transportBlockedBy !== null}><SkipBack size={18} /></button>
{/* Nothing to play means nothing to play: running the clock over an
empty timeline reads as playback of footage that isn't there. */}
<button className="play-button" onClick={() => setPlaying((value) => !value)} aria-label={playing ? "Pause" : "Play"} disabled={transportBlockedBy !== null} title={transportBlockedBy ?? (playing ? "Pause" : "Play")}>{playing ? <Pause size={18} fill="currentColor" /> : <Play size={18} fill="currentColor" />}</button>
<button onClick={() => setPlayhead(Math.min(duration, playhead + 1000))} aria-label="Step forward one second" title={transportBlockedBy ?? "Step forward one second"} disabled={transportBlockedBy !== null}><SkipForward size={18} /></button>
- <strong className="transport-time" title="Playhead position">{timecode(playhead)}</strong>
- <span className="transport-format">{config.settings.resolution.toUpperCase()} · {config.settings.frameRate} fps</span>
</div>
<div className="timeline-tools">
<button onClick={addScene} title="Draft a new scene"><Plus size={16} /> Add</button>
diff --git a/src/styles/timeline.css b/src/styles/timeline.css
index 5a39ded..466142a 100644
--- a/src/styles/timeline.css
+++ b/src/styles/timeline.css
@@ -13,6 +13,20 @@
/* 372px = toolbar 48 + ruler 36 + four 72px track rows. The grid scrolls
vertically if a project carries more tracks than that. */
grid-template-rows: minmax(340px, 1fr) 372px;
+
+ /* How far the CENTRE OF THE PICTURE sits from the centre of a full-width row,
+ signed: negative is to the left. The timeline toolbar runs the whole width
+ while the program monitor is the middle column of .edit-panels between two
+ side panels of DIFFERENT widths, so the two centres are not the same point
+ and "centred in the toolbar" is not "centred under the video".
+
+ It is exactly half the difference between the side columns:
+ (296 - 340) / 2 = -22px
+ Anything that changes .edit-panels' columns must change this in the same
+ rule, the way --track-column and the playhead offset are kept in lockstep.
+ Measured in the shipped app at 1440px: monitor 296…1100 (centre 698),
+ toolbar 0…1440 (centre 720). */
+ --video-centre-shift: -22px;
}
/* The view itself is focusable (tabIndex={0}) so Space and Delete reach the
@@ -754,16 +768,36 @@
background: var(--panel);
}
+/* Three tracks, and the two outer ones are the SAME width whatever they hold —
+ that is the whole point. With `flex: space-between` the middle group's
+ position was decided by however wide the heading and the tool buttons
+ happened to render, so the transport sat wherever it landed (measured 244px
+ left of the picture's centre). Two equal 1fr rails put the middle track's
+ centre on the row's centre no matter what the rails contain, and
+ --video-centre-shift then moves it the rest of the way onto the picture.
+
+ The padding has to be SYMMETRIC for that to hold: it was 12px on the right
+ and 16px on the left, which would drop the middle 2px off-centre before the
+ shift was even applied. */
.timeline-toolbar {
height: var(--control-lg);
- display: flex;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
align-items: center;
- justify-content: space-between;
gap: var(--space-4);
- padding: 0 var(--space-3) 0 var(--space-4);
+ padding: 0 var(--space-4);
border-bottom: 1px solid var(--line);
}
+/* Heading, clock, format — left-aligned as one run, so the timecode reads as
+ part of the timeline's own header rather than as a label on the buttons. */
+.timeline-toolbar__lead {
+ min-width: 0;
+ display: flex;
+ align-items: center;
+ gap: var(--space-3);
+}
+
.timeline-toolbar h2 {
min-width: 0;
margin: 0;
@@ -781,10 +815,23 @@
playhead is drawn immediately below this row; keeping it two panels away
also meant printing the same timecode in two places. */
+/* Centred on the picture, not on the row. The middle grid track already sits
+ centred in the toolbar; a margin on ONE side makes the track that much wider
+ and, because a grid item stretches to its track minus its own margins, slides
+ the buttons half that margin the other way. Doubling the shift and halving it
+ again is what lands the cluster's centre exactly on --video-centre-shift.
+
+ A margin rather than a transform so the space is really reserved: a transform
+ would let the buttons ride over the heading or the tools at narrow widths
+ instead of pushing them. max() picks the side, since the shift is signed and
+ a negative margin would pull the cluster the wrong way. */
.timeline-transport {
display: flex;
align-items: center;
+ justify-content: center;
gap: var(--space-1);
+ margin-left: max(0px, calc(var(--video-centre-shift) * 2));
+ margin-right: max(0px, calc(var(--video-centre-shift) * -2));
}
/* 36px is the floor for a hit target and these are round, so the width is the
@@ -839,21 +886,25 @@
}
/* The only timecode on the screen. Tabular figures so the row does not twitch
- as the digits change under playback. */
+ as the digits change under playback, and no shrinking: the heading beside it
+ already ellipsises, and a half-eaten clock is worse than a short title. */
+.transport-time,
+.transport-format {
+ flex: 0 0 auto;
+ padding-left: var(--space-3);
+ border-left: 1px solid var(--line);
+ white-space: nowrap;
+}
+
.transport-time {
- margin-left: var(--space-2);
color: var(--text-primary);
font: var(--weight-medium) var(--text-sm) / 1 var(--font-mono);
font-variant-numeric: tabular-nums;
}
.transport-format {
- margin-left: var(--space-1);
- padding-left: var(--space-3);
- border-left: 1px solid var(--line);
color: var(--text-muted);
font: var(--weight-medium) var(--text-xs) / 1 var(--font-mono);
- white-space: nowrap;
}
.timeline-tools {
@@ -885,9 +936,13 @@
background: var(--panel-3);
}
+/* Same rule as the transport's disabled state, which this row had drifted from:
+ --text-faint is the dimmest text the tokens allow because it is the last one
+ that still clears 4.5:1, and multiplying it by 0.55 put it back under the
+ floor. A disabled button still has to be legible — its title is the only
+ explanation of why it is off, and nobody hovers what they cannot read. */
.timeline-tools button:disabled {
color: var(--text-faint);
- opacity: 0.55;
cursor: not-allowed;
}
@@ -1195,6 +1250,12 @@
grid-template-columns: 256px minmax(0, 1fr) 300px;
}
+ /* (256 - 300) / 2 — the columns shrank by the same 40px on both sides, so
+ the picture's centre has not moved relative to the row. */
+ .timeline-view {
+ --video-centre-shift: -22px;
+ }
+
.scene-card {
grid-template-columns: 88px minmax(0, 1fr);
}
@@ -1217,11 +1278,22 @@
display: none;
}
+ /* With the inspector gone the picture runs to the right edge, so its centre
+ is (232 - 0) / 2 = 116px RIGHT of the row's centre — and that is the one
+ width where the toolbar cannot pay for it. Measured at 1040, 1000 and 900:
+ the two 1fr rails have already collapsed onto the heading and the four tool
+ buttons with only the 16px gaps left over, so the row has ZERO slack.
+ Reserving 232px of empty middle there would push the tool buttons off the
+ end. The transport takes the row's own centre instead, 116px from the
+ picture; below 840px there is one column left and the two centres agree
+ again on their own. */
+ .timeline-view {
+ --video-centre-shift: 0px;
+ }
+
.timeline-grid {
--track-column: 184px;
}
-
-
}
@media (max-width: 840px) {