🎥 Make videos programmatically with React
`@remotion/studio`: Show negative sequence starts in timeline
JonnyBurgera645637a03fa
diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mtsindex 56df1df239..03f8193da2 100644--- a/packages/example/e2e/studio.test.mts+++ b/packages/example/e2e/studio.test.mts@@ -201,6 +201,40 @@ test.describe('visual mode', () => {expect(await mountedTrackLabels.count()).toBeLessThan(120);});+ test('should show negative sequence timing in the frame-zero gutter', async ({+ page,+ }) => {+ await page.goto(`${STUDIO_URL}/timeline-negative-start`);+ await expect(page).toHaveURL(/timeline-negative-start/, {+ timeout: 15_000,+ });++ const timelineScrollable = page.locator('[data-timeline-scrollable]');+ const negativeSequence = page.locator(+ '[data-timeline-marquee-item][title="Negative start"]',+ );+ const zeroSequence = page.locator(+ '[data-timeline-marquee-item][title="Zero start"]',+ );+ await expect(negativeSequence).toBeVisible();+ await expect(zeroSequence).toBeVisible();++ const [timelineRect, negativeSequenceRect, zeroSequenceRect] =+ await Promise.all([+ timelineScrollable.boundingBox(),+ negativeSequence.boundingBox(),+ zeroSequence.boundingBox(),+ ]);+ expect(timelineRect).not.toBeNull();+ expect(negativeSequenceRect).not.toBeNull();+ expect(zeroSequenceRect).not.toBeNull();+ expect(negativeSequenceRect!.x).toBeGreaterThanOrEqual(timelineRect!.x);+ expect(negativeSequenceRect!.x).toBeLessThan(zeroSequenceRect!.x);+ expect(zeroSequenceRect!.x - negativeSequenceRect!.x).toBeLessThanOrEqual(+ 16,+ );+ });+test('should commit a color drag before the picker closes', async ({page,}) => {diff --git a/packages/example/src/E2eTestRoot.tsx b/packages/example/src/E2eTestRoot.tsxindex b5a0bbcb4e..2cd5d275e0 100644--- a/packages/example/src/E2eTestRoot.tsx+++ b/packages/example/src/E2eTestRoot.tsx@@ -15,6 +15,7 @@ import {MacCursorsExample} from './MacCursors';import {NewVideoComp} from './NewVideo';import {RotationKeyframeE2e} from './RotationKeyframeE2e';import {SchemaTest, schemaTestSchema} from './SchemaTest';+import {TimelineNegativeFromResize} from './TimelineNegativeFromResize';import {TimelineVirtualizationTestbed} from './TimelineVirtualizationTestbed';import {VisualControls} from './VisualControls';import {VisualMode3D} from './VisualMode3D';@@ -216,6 +217,14 @@ export const E2eTestRoot: React.FC = () => {fps={30}durationInFrames={30}/>+ <Composition+ id="timeline-negative-start"+ component={TimelineNegativeFromResize}+ width={1080}+ height={1080}+ fps={30}+ durationInFrames={90}+ /><Compositionid="inspector-control-layout-e2e"component={InspectorControlLayoutE2e}diff --git a/packages/example/src/TimelineNegativeFromResize/index.tsx b/packages/example/src/TimelineNegativeFromResize/index.tsxindex a6ebe3910d..aa7672cc8c 100644--- a/packages/example/src/TimelineNegativeFromResize/index.tsx+++ b/packages/example/src/TimelineNegativeFromResize/index.tsx@@ -4,14 +4,17 @@ import {AbsoluteFill, Sequence} from 'remotion';export const TimelineNegativeFromResize: React.FC = () => {return (- <AbsoluteFill style={{backgroundColor: '#202020'}}>+ <AbsoluteFill style={{backgroundColor: '#202020'}} from={-1}><Sequence- from={-3}+ name="Negative start"durationInFrames={36}style={{backgroundColor: 'black'}}><Starburst rays={16} colors={['#ffdd00', '#ff8800']} /></Sequence>+ <Sequence name="Zero start" durationInFrames={36}>+ <div />+ </Sequence></AbsoluteFill>);};diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsxindex 9dfc85eb94..39b4ee4b17 100644--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@ -4,6 +4,7 @@ import {Internals, useCurrentFrame} from 'remotion';import {StudioServerConnectionCtx} from '../../helpers/client-id';import {BLUE,+ TIMELINE_BACKGROUND_COLOR,TIMELINE_AUDIO_GRADIENT,TIMELINE_IMAGE_GRADIENT,TIMELINE_VIDEO_GRADIENT,@@ -75,7 +76,16 @@ const TimelineSequenceFn: React.FC<{readonly connectedCompositions: readonly _InternalTypes['AnyComposition'][];readonly nodePathInfo: SequenceNodePathInfo | null;readonly sequenceFrameOffset: number;-}> = ({s, connectedCompositions, nodePathInfo, sequenceFrameOffset}) => {+ readonly cascadedStart: number;+ readonly localStart: number;+}> = ({+ s,+ connectedCompositions,+ nodePathInfo,+ sequenceFrameOffset,+ cascadedStart,+ localStart,+}) => {const windowWidth = useContext(TimelineWidthContext);if (windowWidth === null) {@@ -89,15 +99,74 @@ const TimelineSequenceFn: React.FC<{connectedCompositions={connectedCompositions}nodePathInfo={nodePathInfo}sequenceFrameOffset={sequenceFrameOffset}+ cascadedStart={cascadedStart}+ localStart={localStart}/>);};+const TimelineSequenceNegativeStart: React.FC<{+ readonly left: number;+ readonly width: number;+ readonly leftEdgeVisible: boolean;+ readonly clipped: boolean;+}> = ({left, width, leftEdgeVisible, clipped}) => {+ // WHITE_ALPHA_10 composited over the timeline background (#15181B).+ const backgroundColor = '#2C2F32';+ // The same stroke composited over the indicator background.+ const borderColor = '#414446';+ const showLeftEdge = leftEdgeVisible && !clipped;+ const maskImage = clipped+ ? 'linear-gradient(to right, transparent, black 20%)'+ : undefined;++ return (+ <div+ style={{+ backgroundColor: clipped ? TIMELINE_BACKGROUND_COLOR : undefined,+ height: '100%',+ left,+ minWidth: 2,+ pointerEvents: 'none',+ position: 'absolute',+ top: 0,+ width,+ }}+ >+ <div+ style={{+ backgroundColor,+ border: `${SEQUENCE_BORDER_WIDTH}px solid ${borderColor}`,+ borderBottomLeftRadius: showLeftEdge ? 2 : 0,+ borderLeft: showLeftEdge+ ? `${SEQUENCE_BORDER_WIDTH}px solid ${borderColor}`+ : 'none',+ borderRight: 'none',+ borderTopLeftRadius: showLeftEdge ? 2 : 0,+ boxSizing: 'border-box',+ height: '100%',+ maskImage,+ position: 'absolute',+ top: 0,+ WebkitMaskImage: maskImage,+ width: '100%',+ }}+ />+ </div>+ );+};+const TimelineSequenceCurrentFrame: React.FC<{readonly s: TSequence;readonly displayDurationInFrames: number;readonly premount: {readonly left: number; readonly width: number} | null;readonly postmount: {readonly left: number; readonly width: number} | null;+ readonly negativeStart: {+ readonly left: number;+ readonly width: number;+ } | null;+ readonly leftEdgeVisible: boolean;+ readonly negativeStartClipped: boolean;readonly style: React.CSSProperties;readonly children: React.ReactNode;readonly nodePathInfo: SequenceNodePathInfo | null;@@ -113,6 +182,9 @@ const TimelineSequenceCurrentFrame: React.FC<{displayDurationInFrames,premount,postmount,+ negativeStart,+ leftEdgeVisible,+ negativeStartClipped,style,children,nodePathInfo,@@ -172,6 +244,9 @@ const TimelineSequenceCurrentFrame: React.FC<{relativeFrameWithPostmount >= 0 &&relativeFrameWithPostmount < (s.postmountDisplay ?? 0) &&!isInRange;+ const negativeStartEnd = negativeStart+ ? negativeStart.left + negativeStart.width+ : 0;const actualStyle: React.CSSProperties = useMemo(() => {const hasSelectedTrack = selectedItems.some(@@ -180,19 +255,14 @@ const TimelineSequenceCurrentFrame: React.FC<{return {...style,+ background: negativeStart ? TRANSPARENT : style.background,+ border: negativeStart ? 'none' : style.border,opacity: hasSelectedTrack && !selected && !containsSelection ? 0.75 : 1,};- }, [containsSelection, selected, selectedItems, style]);+ }, [containsSelection, negativeStart, selected, selectedItems, style]);- return (- <div- ref={ref}- {...{[TIMELINE_MARQUEE_ITEM_ATTR]: true}}- style={actualStyle}- title={s.displayName}- onPointerDown={selectable ? onPointerDown : undefined}- onDoubleClick={onDoubleClick}- >+ const content = (+ <>{premount ? (<divstyle={{@@ -238,7 +308,8 @@ const TimelineSequenceCurrentFrame: React.FC<{(isInRange || isPremounting || isPostmounting) ? (<divstyle={{- paddingLeft: 5 + (premount?.width ?? 0),+ paddingLeft:+ 5 + (negativeStart?.width ?? 0) + (premount?.width ?? 0),height: '100%',display: 'flex',alignItems: 'center',@@ -252,6 +323,61 @@ const TimelineSequenceCurrentFrame: React.FC<{/></div>) : null}+ </>+ );++ return (+ <div+ ref={ref}+ {...{[TIMELINE_MARQUEE_ITEM_ATTR]: true}}+ style={actualStyle}+ title={s.displayName}+ onPointerDown={selectable ? onPointerDown : undefined}+ onDoubleClick={onDoubleClick}+ >+ {negativeStart ? (+ <>+ <TimelineSequenceNegativeStart+ left={negativeStart.left}+ width={negativeStart.width}+ leftEdgeVisible={leftEdgeVisible}+ clipped={negativeStartClipped}+ />+ <div+ style={{+ background: style.background,+ border: style.border,+ borderBottomLeftRadius: 0,+ borderBottomRightRadius: style.borderBottomRightRadius,+ borderLeft: 'none',+ borderRightColor: style.borderRightColor,+ borderTopLeftRadius: 0,+ borderTopRightRadius: style.borderTopRightRadius,+ boxSizing: 'border-box',+ height: '100%',+ left: negativeStartEnd,+ overflow: 'hidden',+ position: 'absolute',+ top: 0,+ width: `calc(100% - ${negativeStartEnd}px)`,+ }}+ >+ <div+ style={{+ height: '100%',+ left: -negativeStartEnd,+ position: 'absolute',+ top: 0,+ width: style.width,+ }}+ >+ {content}+ </div>+ </div>+ </>+ ) : (+ content+ )}</div>);};@@ -262,12 +388,16 @@ const TimelineSequenceInner: React.FC<{readonly windowWidth: number;readonly nodePathInfo: SequenceNodePathInfo | null;readonly sequenceFrameOffset: number;+ readonly cascadedStart: number;+ readonly localStart: number;}> = ({s,connectedCompositions,windowWidth,nodePathInfo,sequenceFrameOffset,+ cascadedStart,+ localStart,}) => {// If a duration is 1, it is essentially a still and it should have width 0// Some compositions may not be longer than their media duration,@@ -569,10 +699,18 @@ const TimelineSequenceInner: React.FC<{? s.loopDisplay.durationInFrames * s.loopDisplay.numberOfTimes: s.duration;- const {marginLeft, width, premountWidth, postmountWidth} = useMemo(() => {+ const {+ marginLeft,+ width,+ negativeStartWidth,+ negativeStartClipped,+ premountWidth,+ postmountWidth,+ } = useMemo(() => {return getTimelineSequenceLayout({durationInFrames: displayDurationInFrames,startFrom: s.loopDisplay ? s.from + s.loopDisplay.startOffset : s.from,+ cascadedStart,startFromMedia:s.type === 'sequence' || s.type === 'image' ? 0 : s.startMediaFrom,maxMediaDuration: effectiveMaxMediaDuration,@@ -582,6 +720,7 @@ const TimelineSequenceInner: React.FC<{postmountDisplay: s.postmountDisplay,});}, [+ cascadedStart,displayDurationInFrames,effectiveMaxMediaDuration,s,@@ -596,12 +735,20 @@ const TimelineSequenceInner: React.FC<{return getTimelineSequenceVisibleLayout({marginLeft,width,+ negativeStartWidth,premountWidth: premountWidth ?? 0,postmountWidth: postmountWidth ?? 0,renderWindowLeft: renderWindow.left - TIMELINE_PADDING,renderWindowWidth: renderWindow.width,});- }, [marginLeft, postmountWidth, premountWidth, renderWindow, width]);+ }, [+ marginLeft,+ negativeStartWidth,+ postmountWidth,+ premountWidth,+ renderWindow,+ width,+ ]);const mediaVisualizationStyle = useMemo((): React.CSSProperties => {return {width: visibleLayout?.media?.width ?? 0,@@ -609,6 +756,10 @@ const TimelineSequenceInner: React.FC<{height: '100%',};}, [visibleLayout]);+ const showLeftBorderRadius =+ visibleLayout?.leftEdgeVisible === true &&+ localStart >= 0 &&+ (s.trimBefore ?? 0) === 0;const style: React.CSSProperties = useMemo(() => {return {@@ -621,14 +772,15 @@ const TimelineSequenceInner: React.FC<{? TIMELINE_IMAGE_GRADIENT: BLUE,border: `${SEQUENCE_BORDER_WIDTH}px solid ${WHITE_ALPHA_20}`,- borderLeftColor: visibleLayout?.leftEdgeVisible- ? WHITE_ALPHA_20- : TRANSPARENT,+ borderLeftColor:+ visibleLayout?.leftEdgeVisible && !negativeStartClipped+ ? WHITE_ALPHA_20+ : TRANSPARENT,borderRightColor: visibleLayout?.rightEdgeVisible? WHITE_ALPHA_20: TRANSPARENT,- borderTopLeftRadius: visibleLayout?.leftEdgeVisible ? 2 : 0,- borderBottomLeftRadius: visibleLayout?.leftEdgeVisible ? 2 : 0,+ borderTopLeftRadius: showLeftBorderRadius ? 2 : 0,+ borderBottomLeftRadius: showLeftBorderRadius ? 2 : 0,borderTopRightRadius: visibleLayout?.rightEdgeVisible ? 2 : 0,borderBottomRightRadius: visibleLayout?.rightEdgeVisible ? 2 : 0,position: 'absolute',@@ -638,7 +790,7 @@ const TimelineSequenceInner: React.FC<{color: WHITE,overflow: 'hidden',};- }, [s.type, visibleLayout]);+ }, [negativeStartClipped, s.type, showLeftBorderRadius, visibleLayout]);const showRightEdgeDragHandle =isTimelineSequenceDurationDraggable(s) &&@@ -672,6 +824,9 @@ const TimelineSequenceInner: React.FC<{displayDurationInFrames={displayDurationInFrames}premount={visibleLayout.premount}postmount={visibleLayout.postmount}+ negativeStart={visibleLayout.negativeStart}+ leftEdgeVisible={visibleLayout.leftEdgeVisible}+ negativeStartClipped={negativeStartClipped}style={style}nodePathInfo={nodePathInfo}sequenceFrameOffset={sequenceFrameOffset}@@ -738,6 +893,7 @@ const TimelineSequenceInner: React.FC<{)}{showLeftEdgeDragHandle &&visibleLayout.leftEdgeVisible &&+ negativeStartWidth === 0 &&nodePathInfo &&validatedLocation ? (<TimelineSequenceLeftEdgeDragHandlediff --git a/packages/studio/src/components/Timeline/TimelineTrack.tsx b/packages/studio/src/components/Timeline/TimelineTrack.tsxindex a2d629b260..bdf46d1f80 100644--- a/packages/studio/src/components/Timeline/TimelineTrack.tsx+++ b/packages/studio/src/components/Timeline/TimelineTrack.tsx@@ -63,6 +63,8 @@ const TimelineTrackUnmemoized: React.FC<{) : null}<TimelineSequences={track.sequence}+ cascadedStart={track.cascadedStart}+ localStart={track.localStart}connectedCompositions={track.connectedCompositions ?? emptyConnectedCompositions}diff --git a/packages/studio/src/components/Timeline/get-timeline-sequence-visible-layout.ts b/packages/studio/src/components/Timeline/get-timeline-sequence-visible-layout.tsindex f5feffe294..e0bde27006 100644--- a/packages/studio/src/components/Timeline/get-timeline-sequence-visible-layout.ts+++ b/packages/studio/src/components/Timeline/get-timeline-sequence-visible-layout.ts@@ -4,6 +4,10 @@ type TimelineSequenceVisibleLayout = {readonly cropLeft: number;readonly leftEdgeVisible: boolean;readonly rightEdgeVisible: boolean;+ readonly negativeStart: {+ readonly left: number;+ readonly width: number;+ } | null;readonly premount: {readonly left: number; readonly width: number} | null;readonly postmount: {readonly left: number; readonly width: number} | null;readonly media: {@@ -40,6 +44,7 @@ const getVisibleSection = ({export const getTimelineSequenceVisibleLayout = ({marginLeft,width,+ negativeStartWidth,premountWidth,postmountWidth,renderWindowLeft,@@ -47,6 +52,7 @@ export const getTimelineSequenceVisibleLayout = ({}: {readonly marginLeft: number;readonly width: number;+ readonly negativeStartWidth: number;readonly premountWidth: number;readonly postmountWidth: number;readonly renderWindowLeft: number;@@ -63,7 +69,8 @@ export const getTimelineSequenceVisibleLayout = ({const cropStart = visibleStart - itemStart;const cropEnd = visibleEnd - itemStart;- const mediaStart = premountWidth;+ const premountStart = negativeStartWidth;+ const mediaStart = negativeStartWidth + premountWidth;const mediaEnd = Math.max(mediaStart, width - postmountWidth);const media = getVisibleSection({sectionStart: mediaStart,@@ -78,9 +85,15 @@ export const getTimelineSequenceVisibleLayout = ({cropLeft: cropStart,leftEdgeVisible: visibleStart === itemStart,rightEdgeVisible: visibleEnd === itemEnd,- premount: getVisibleSection({+ negativeStart: getVisibleSection({sectionStart: 0,- sectionEnd: premountWidth,+ sectionEnd: negativeStartWidth,+ cropStart,+ cropEnd,+ }),+ premount: getVisibleSection({+ sectionStart: premountStart,+ sectionEnd: premountStart + premountWidth,cropStart,cropEnd,}),diff --git a/packages/studio/src/helpers/calculate-timeline.ts b/packages/studio/src/helpers/calculate-timeline.tsindex f8d32a28fc..49c2bec662 100644--- a/packages/studio/src/helpers/calculate-timeline.ts+++ b/packages/studio/src/helpers/calculate-timeline.ts@@ -124,6 +124,7 @@ export const calculateTimeline = ({},depth: getTimelineNestedLevel(sequence, sortedSequences, 0),cascadedStart,+ localStart: sequence.from,cascadedDuration: sequence.duration,keyframeDisplayOffset: hasKeyframeRows? cascadedStartWithTrim - effectiveFrom@@ -153,7 +154,7 @@ export const calculateTimeline = ({return sortKeyA.localeCompare(sortKeyB);}).map((track) => {- const {cascadedDuration, cascadedStart, ...cleanTrack} = track;+ const {cascadedDuration, ...cleanTrack} = track;return cleanTrack;});diff --git a/packages/studio/src/helpers/get-timeline-sequence-layout.ts b/packages/studio/src/helpers/get-timeline-sequence-layout.tsindex c07f6572ea..98120a9a79 100644--- a/packages/studio/src/helpers/get-timeline-sequence-layout.ts+++ b/packages/studio/src/helpers/get-timeline-sequence-layout.ts@@ -28,6 +28,7 @@ const getWidthOfTrack = ({export const getTimelineSequenceLayout = ({durationInFrames,startFrom,+ cascadedStart,maxMediaDuration,startFromMedia,video,@@ -37,6 +38,7 @@ export const getTimelineSequenceLayout = ({}: {durationInFrames: number;startFrom: number;+ cascadedStart: number;startFromMedia: number;maxMediaDuration: number | null;video: VideoConfig;@@ -47,6 +49,7 @@ export const getTimelineSequenceLayout = ({const maxMediaSequenceDuration =(maxMediaDuration ?? Infinity) - startFromMedia;const timelineDuration = video.durationInFrames ?? 1;+ const fullWidth = windowWidth - TIMELINE_PADDING * 2;const spatialDuration = Math.max(0,@@ -64,9 +67,20 @@ export const getTimelineSequenceLayout = ({);const marginLeft =- timelineDuration <= 0- ? 0- : (startFrom / timelineDuration) * (windowWidth - TIMELINE_PADDING * 2);+ timelineDuration <= 0 ? 0 : (startFrom / timelineDuration) * fullWidth;++ const naturalNegativeStartWidth =+ timelineDuration > 0 &&+ startFrom === 0 &&+ cascadedStart < 0 &&+ durationInFrames > 0+ ? Math.max(0, (-cascadedStart / timelineDuration) * fullWidth)+ : 0;+ const negativeStartWidth = Math.min(+ TIMELINE_PADDING,+ naturalNegativeStartWidth,+ );+ const negativeStartClipped = naturalNegativeStartWidth > TIMELINE_PADDING;const nonNegativeMarginLeft = Math.min(marginLeft, 0);@@ -107,9 +121,13 @@ export const getTimelineSequenceLayout = ({: null;return {- marginLeft: Math.max(marginLeft, 0) - (premountWidth ?? 0),- width: width + (premountWidth ?? 0) + (postmountWidth ?? 0),+ marginLeft:+ Math.max(marginLeft, 0) - negativeStartWidth - (premountWidth ?? 0),+ width:+ width + negativeStartWidth + (premountWidth ?? 0) + (postmountWidth ?? 0),naturalWidth: naturalWidth + (premountWidth ?? 0) + (postmountWidth ?? 0),+ negativeStartWidth,+ negativeStartClipped,premountWidth,postmountWidth,};diff --git a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts b/packages/studio/src/helpers/get-timeline-sequence-sort-key.tsindex 0d75755fd9..691f8466a1 100644--- a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts+++ b/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts@@ -19,10 +19,11 @@ export type TimelineTrackData = {nodePathInfo: SequenceNodePathInfo | null;keyframeDisplayOffset: number;sequenceFrameOffset: number;+ cascadedStart: number;+ localStart: number;};export type TimelineTrackWithOriginalTimings = TimelineTrackData & {- cascadedStart: number;cascadedDuration: number;};diff --git a/packages/studio/src/test/sequenced-timeline.test.ts b/packages/studio/src/test/sequenced-timeline.test.tsindex ee34274081..480b02c0de 100644--- a/packages/studio/src/test/sequenced-timeline.test.ts+++ b/packages/studio/src/test/sequenced-timeline.test.ts@@ -5,15 +5,30 @@ import {calculateTimeline} from '../helpers/calculate-timeline';const getStack = () => null;const withoutKeyframeDisplayOffset = <- T extends {keyframeDisplayOffset: number; sequenceFrameOffset: number},+ T extends {+ keyframeDisplayOffset: number;+ sequenceFrameOffset: number;+ cascadedStart: number;+ localStart: number;+ },>(tracks: T[],) =>- tracks.map(({keyframeDisplayOffset, sequenceFrameOffset, ...track}) => {- expect(keyframeDisplayOffset).toBe(0);- expect(sequenceFrameOffset).toBeGreaterThanOrEqual(0);- return track;- });+ tracks.map(+ ({+ keyframeDisplayOffset,+ sequenceFrameOffset,+ cascadedStart,+ localStart,+ ...track+ }) => {+ expect(keyframeDisplayOffset).toBe(0);+ expect(sequenceFrameOffset).toBeGreaterThanOrEqual(0);+ expect(typeof cascadedStart).toBe('number');+ expect(typeof localStart).toBe('number');+ return track;+ },+ );test('Should calculate sequences correctly', () => {const timeline = calculateTimeline({diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.tsindex a786de345b..c46001a524 100644--- a/packages/studio/src/test/timeline-selection.test.ts+++ b/packages/studio/src/test/timeline-selection.test.ts@@ -5793,6 +5793,8 @@ test('Derived selectable timeline items follow expanded timeline order', () => {selectedItems: [],timeline: [{+ cascadedStart: 0,+ localStart: 0,depth: 0,keyframeDisplayOffset: 0,nodePathInfo: sequenceNodePathInfo,diff --git a/packages/studio/src/test/timeline-sequence-layout.test.ts b/packages/studio/src/test/timeline-sequence-layout.test.tsindex 924acc63cb..4284c3114a 100644--- a/packages/studio/src/test/timeline-sequence-layout.test.ts+++ b/packages/studio/src/test/timeline-sequence-layout.test.ts@@ -22,6 +22,7 @@ test('Should test timeline sequence layout without max media duration', () => {getTimelineSequenceLayout({durationInFrames: 400,startFrom: 2023,+ cascadedStart: 2023,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -47,6 +48,8 @@ test('Should test timeline sequence layout without max media duration', () => {marginLeft: 1154.0226668902187,premountWidth: null,postmountWidth: null,+ negativeStartWidth: 0,+ negativeStartClipped: false,width: 227.18045810978126,naturalWidth: 227.18045810978126,});@@ -56,6 +59,7 @@ test('Should test timeline sequence layout with max media duration', () => {getTimelineSequenceLayout({durationInFrames: 400,startFrom: 2023,+ cascadedStart: 2023,maxMediaDuration: 400,startFromMedia: 10,premountDisplay: null,@@ -81,6 +85,8 @@ test('Should test timeline sequence layout with max media duration', () => {marginLeft: 1154.0226668902187,premountWidth: null,postmountWidth: null,+ negativeStartWidth: 0,+ negativeStartClipped: false,width: 221.47594665703676,naturalWidth: 221.47594665703676,});@@ -92,6 +98,7 @@ test('naturalWidth > width when segment is clipped by timeline end', () => {const clipped = getTimelineSequenceLayout({durationInFrames: 100,startFrom: 250,+ cascadedStart: 250,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -109,6 +116,7 @@ test('naturalWidth === width when segment fits within timeline', () => {const result = getTimelineSequenceLayout({durationInFrames: 100,startFrom: 100,+ cascadedStart: 100,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -124,6 +132,7 @@ test('one-frame segments have a one-frame width', () => {const result = getTimelineSequenceLayout({durationInFrames: 1,startFrom: 0,+ cascadedStart: 0,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -140,6 +149,7 @@ test('adjacent sequences have no visual gap', () => {const first = getTimelineSequenceLayout({durationInFrames: 23.5,startFrom: 0,+ cascadedStart: 0,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -150,6 +160,7 @@ test('adjacent sequences have no visual gap', () => {const second = getTimelineSequenceLayout({durationInFrames: 20,startFrom: 23.5,+ cascadedStart: 23.5,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -167,6 +178,7 @@ test('media trimmed past its duration has zero width', () => {const result = getTimelineSequenceLayout({durationInFrames: 300,startFrom: 0,+ cascadedStart: 0,startFromMedia: 500,maxMediaDuration: 300,premountDisplay: null,@@ -183,6 +195,7 @@ test('media trimmed past its duration and timeline end has zero width', () => {const result = getTimelineSequenceLayout({durationInFrames: 200,startFrom: 200,+ cascadedStart: 200,startFromMedia: 500,maxMediaDuration: 300,premountDisplay: null,@@ -200,6 +213,7 @@ test('Loop overshoot: naturalWidth > width when total loop duration exceeds compconst overshoot = getTimelineSequenceLayout({durationInFrames: 400,startFrom: 0,+ cascadedStart: 0,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -214,6 +228,7 @@ test('Loop overshoot: naturalWidth > width when total loop duration exceeds compconst exact = getTimelineSequenceLayout({durationInFrames: 350,startFrom: 0,+ cascadedStart: 0,startFromMedia: 0,maxMediaDuration: null,premountDisplay: null,@@ -232,6 +247,7 @@ test('naturalWidth is constrained by maxMediaDuration but not by timeline end',const clippedByBoth = getTimelineSequenceLayout({durationInFrames: 200,startFrom: 800,+ cascadedStart: 800,startFromMedia: 0,maxMediaDuration: 150,premountDisplay: null,@@ -247,6 +263,7 @@ test('naturalWidth is constrained by maxMediaDuration but not by timeline end',const clippedByMediaOnly = getTimelineSequenceLayout({durationInFrames: 200,startFrom: 100,+ cascadedStart: 100,startFromMedia: 0,maxMediaDuration: 150,premountDisplay: null,@@ -259,3 +276,55 @@ test('naturalWidth is constrained by maxMediaDuration but not by timeline end',// both constrained by maxMediaDurationexpect(clippedByMediaOnly.naturalWidth).toBe(clippedByMediaOnly.width);});++test('negative starts use the left timeline gutter without shifting frame zero', () => {+ const oneFrameBeforeZero = getTimelineSequenceLayout({+ durationInFrames: 99,+ startFrom: 0,+ cascadedStart: -1,+ startFromMedia: 0,+ maxMediaDuration: null,+ premountDisplay: null,+ postmountDisplay: null,+ video: makeVideoConfig(100),+ windowWidth: 1032,+ });++ expect(oneFrameBeforeZero.marginLeft).toBe(-10);+ expect(oneFrameBeforeZero.negativeStartWidth).toBe(10);+ expect(oneFrameBeforeZero.negativeStartClipped).toBe(false);+ expect(oneFrameBeforeZero.width).toBe(999);++ const clippedToGutter = getTimelineSequenceLayout({+ durationInFrames: 80,+ startFrom: 0,+ cascadedStart: -20,+ startFromMedia: 0,+ maxMediaDuration: null,+ premountDisplay: null,+ postmountDisplay: null,+ video: makeVideoConfig(100),+ windowWidth: 1032,+ });++ expect(clippedToGutter.marginLeft).toBe(-16);+ expect(clippedToGutter.negativeStartWidth).toBe(16);+ expect(clippedToGutter.negativeStartClipped).toBe(true);+});++test('does not show negative timing that is clipped by a positive parent', () => {+ const result = getTimelineSequenceLayout({+ durationInFrames: 20,+ startFrom: 30,+ cascadedStart: -10,+ startFromMedia: 0,+ maxMediaDuration: null,+ premountDisplay: null,+ postmountDisplay: null,+ video: makeVideoConfig(100),+ windowWidth: 1032,+ });++ expect(result.marginLeft).toBe(300);+ expect(result.negativeStartWidth).toBe(0);+});diff --git a/packages/studio/src/test/timeline-sequence-visible-layout.test.ts b/packages/studio/src/test/timeline-sequence-visible-layout.test.tsindex 217ae9c717..4efa7ce942 100644--- a/packages/studio/src/test/timeline-sequence-visible-layout.test.ts+++ b/packages/studio/src/test/timeline-sequence-visible-layout.test.ts@@ -5,6 +5,7 @@ test('clips a very wide sequence to the render window', () => {const layout = getTimelineSequenceVisibleLayout({marginLeft: 100,width: 10_000,+ negativeStartWidth: 0,premountWidth: 50,postmountWidth: 75,renderWindowLeft: 1_000,@@ -17,6 +18,7 @@ test('clips a very wide sequence to the render window', () => {cropLeft: 900,leftEdgeVisible: false,rightEdgeVisible: false,+ negativeStart: null,premount: null,postmount: null,media: {@@ -32,6 +34,7 @@ test('preserves the real item edges and mount regions when visible', () => {const layout = getTimelineSequenceVisibleLayout({marginLeft: 100,width: 500,+ negativeStartWidth: 0,premountWidth: 50,postmountWidth: 75,renderWindowLeft: 0,@@ -44,6 +47,7 @@ test('preserves the real item edges and mount regions when visible', () => {cropLeft: 0,leftEdgeVisible: true,rightEdgeVisible: true,+ negativeStart: null,premount: {left: 0, width: 50},postmount: {left: 425, width: 75},media: {@@ -65,6 +69,7 @@ test('preserves a real edge when floating-point subtraction changes the width',const layout = getTimelineSequenceVisibleLayout({marginLeft,width,+ negativeStartWidth: 0,premountWidth: 0,postmountWidth: 0,renderWindowLeft: 0,@@ -80,6 +85,7 @@ test('does not render a sequence outside the render window', () => {getTimelineSequenceVisibleLayout({marginLeft: 2_000,width: 500,+ negativeStartWidth: 0,premountWidth: 0,postmountWidth: 0,renderWindowLeft: 0,@@ -87,3 +93,24 @@ test('does not render a sequence outside the render window', () => {}),).toBeNull();});++test('keeps negative timing separate from premount and media', () => {+ const layout = getTimelineSequenceVisibleLayout({+ marginLeft: -10,+ width: 110,+ negativeStartWidth: 10,+ premountWidth: 20,+ postmountWidth: 0,+ renderWindowLeft: -16,+ renderWindowWidth: 200,+ });++ expect(layout?.negativeStart).toEqual({left: 0, width: 10});+ expect(layout?.premount).toEqual({left: 10, width: 20});+ expect(layout?.media).toEqual({+ left: 30,+ width: 80,+ offset: 0,+ fullWidth: 80,+ });+});diff --git a/packages/studio/src/test/timeline.test.ts b/packages/studio/src/test/timeline.test.tsindex 5735550d8f..bc395a9723 100644--- a/packages/studio/src/test/timeline.test.ts+++ b/packages/studio/src/test/timeline.test.ts@@ -6,15 +6,30 @@ import {calculateTimeline} from '../helpers/calculate-timeline';const getStack = () => null;const withoutKeyframeDisplayOffset = <- T extends {keyframeDisplayOffset: number; sequenceFrameOffset: number},+ T extends {+ keyframeDisplayOffset: number;+ sequenceFrameOffset: number;+ cascadedStart: number;+ localStart: number;+ },>(tracks: T[],) =>- tracks.map(({keyframeDisplayOffset, sequenceFrameOffset, ...track}) => {- expect(keyframeDisplayOffset).toBe(0);- expect(sequenceFrameOffset).toBe(0);- return track;- });+ tracks.map(+ ({+ keyframeDisplayOffset,+ sequenceFrameOffset,+ cascadedStart,+ localStart,+ ...track+ }) => {+ expect(keyframeDisplayOffset).toBe(0);+ expect(sequenceFrameOffset).toBe(0);+ expect(cascadedStart).toBeGreaterThanOrEqual(0);+ expect(typeof localStart).toBe('number');+ return track;+ },+ );test('Should calculate timeline with no sequences', () => {const calculated = calculateTimeline({@@ -289,6 +304,7 @@ test('Should calculate sequence frame offset for negative from values', () => {expect(calculated[0].sequence.from).toBe(0);expect(calculated[0].sequenceFrameOffset).toBe(37);+ expect(calculated[0].cascadedStart).toBe(-37);});test('Should calculate sequence frame offset for trimBefore values', () => {