🎥 Make videos programmatically with React
Merge remote-tracking branch 'origin/main' into codex/track-prototype
Jonny Burgera3b963c08ac9
diff --cc packages/core/src/Sequence.tsxindex 72d074a5b6,8f7a0e39d3..4834960b14--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@@ -745,9 -723,8 +746,10 @@@ const RegularSequenceRefForwardingFunct};}, [id,+ timelineTrack,+ timelineTrackRole,getCurrentFrame,+ getStack,timelineClipName,playbackRate,parentSequence?.id,diff --cc packages/core/src/use-media-in-timeline.tsindex d4261ab64a,254d0409ab..5a54ae8524--- a/packages/core/src/use-media-in-timeline.ts+++ b/packages/core/src/use-media-in-timeline.ts@@@ -316,8 -308,7 +318,8 @@@ export const useMediaInTimeline = (}, [duration,id,+ timelineTrack,- parentSequence,+ parentSequence?.id,src,volumes,doesVolumeChange,diff --cc packages/studio/src/components/Timeline/TimelineSequence.tsxindex a8098ef01d,0b4acb6397..5e89aa1b08--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@@ -28,8 -28,6 +28,7 @@@ importTIMELINE_VIDEO_GRADIENT,TRANSPARENT,WHITE,+ WHITE_ALPHA_20,- WHITE_ALPHA_50,} from '../../helpers/colors';import {createDragAwareDoubleClickTracker} from '../../helpers/drag-aware-double-click';import {@@@ -308,9 -297,8 +308,9 @@@ const TimelineSequenceNegativeStart = RTimelineSequenceNegativeStartInner,);- const TimelineSequenceCurrentFrame: React.FC<{+ const TimelineSequenceBar: React.FC<{readonly s: TSequence;+ readonly connectedComposition: _InternalTypes['AnyComposition'] | null;readonly annotationLocation: ResolvedStackLocation | null;readonly activeTrimEdge: 'left' | 'right' | null;readonly leftTrimHighlight: {@@@ -470,120 -417,41 +451,104 @@@const content = (<>- {premount ? (- <TimelineSequenceMountIndicator- from={s.from}- displayDurationInFrames={displayDurationInFrames}- mountDurationInFrames={s.premountDisplay ?? 0}- mountType="premount"- left={premount.left}- width={premount.width}- />- ) : null}+ {compactPremount ? null : premountIndicator}{postmount ? (- <div- style={{- left: postmount.left,- width: postmount.width,- height: '100%',- background: `repeating-linear-gradient(- -45deg,- ${TRANSPARENT},- ${TRANSPARENT} 2px,- ${isPostmounting ? WHITE_ALPHA_50 : WHITE_ALPHA_20} 2px,- ${isPostmounting ? WHITE_ALPHA_50 : WHITE_ALPHA_20} 4px- )`,- position: 'absolute',- }}+ <TimelineSequenceMountIndicator+ from={s.from}+ displayDurationInFrames={displayDurationInFrames}+ mountDurationInFrames={s.postmountDisplay ?? 0}+ mountType="postmount"+ left={postmount.left}+ width={postmount.width}/>) : null}{children}- {s.type !== 'audio' &&+ {transitionWidth === null ? null : (+ <svg+ aria-hidden="true"+ style={{+ position: 'absolute',+ left: -(marqueeHorizontalBounds?.cropLeft ?? 0),+ top: 0,+ width: transitionWidth,+ height: PACKED_TRANSITION_HEIGHT,+ pointerEvents: 'none',+ }}+ >+ <rect+ x={0.5}+ y={0.5}+ width={Math.max(0, transitionWidth - 1)}+ height={PACKED_TRANSITION_HEIGHT - 1}+ fill="none"+ stroke={WHITE}+ strokeWidth={1}+ />+ <line+ x1={0.5}+ y1={PACKED_TRANSITION_HEIGHT - 0.5}+ x2={Math.max(0.5, transitionWidth - 0.5)}+ y2={0.5}+ stroke={WHITE}+ strokeWidth={1}+ />+ </svg>+ )}++ {s.timelineTrack && s.timelineTrack.role !== 'transition' ? (+ <div+ style={{+ position: 'absolute',+ left: 5 + negativeStartEnd + (premount?.width ?? 0),+ right: 4,+ bottom: PACKED_LABEL_BOTTOM,+ display: 'flex',+ alignItems: 'center',+ gap: 4,+ overflow: 'hidden',+ pointerEvents: 'none',+ userSelect: 'none',+ WebkitUserSelect: 'none',+ }}+ >+ {connectedComposition ? (+ <CompositionOrStillIcon+ composition={connectedComposition}+ color={WHITE}+ style={{flexShrink: 0, height: 12, width: 12}}+ />+ ) : null}+ <span+ style={{+ fontSize: 11,+ lineHeight: `${PACKED_LABEL_HEIGHT}px`,+ color: WHITE,+ minWidth: 0,+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ }}+ >+ {s.timelineTrack.role === 'overlay' ? 'Overlay' : s.displayName}+ </span>+ </div>+ ) : null}++ {!s.timelineTrack &&+ s.type !== 'audio' &&s.type !== 'video' &&s.type !== 'image' &&- s.loopDisplay === undefined &&- (frozenFrame !== null || isInRange || isPremounting || isPostmounting) ? (- <div- style={{- paddingLeft: 5 + negativeStartEnd + (premount?.width ?? 0),- height: '100%',- display: 'flex',- alignItems: 'center',- }}- >- <TimelineSequenceFrame- premounted={isPremounting}- postmounted={isPostmounting ? s.duration - 1 : null}- roundedFrame={roundedFrame}- frozenFrame={frozenFrame}- />- </div>+ s.loopDisplay === undefined ? (+ <TimelineSequenceFrame+ s={s}+ sequenceFrameOffset={sequenceFrameOffset}+ displayDurationInFrames={displayDurationInFrames}+ paddingLeft={5 + negativeStartEnd + (premount?.width ?? 0)}+ frozenFrame={frozenFrame}+ />) : null}{activeTrimEdge === null ||@@@ -1746,9 -1573,8 +1711,9 @@@ const TimelineSequenceInner: React.FC<: 0;const sequence = (- <TimelineSequenceCurrentFrame+ <TimelineSequenceBars={s}+ connectedComposition={connectedCompositions[0] ?? null}annotationLocation={originalLocation}activeTrimEdge={activeTrimEdge}leftTrimHighlight={diff --cc packages/studio/src/components/Timeline/TimelineSequenceItem.tsxindex c8f22c74e3,ebc3006e2d..7340741baa--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx@@@ -1088,13 -1075,21 +1082,24 @@@ const TimelineSequenceItemInner: React.);const outerHeight = useMemo(- () => getTimelineLayerHeight(sequence.type) + TIMELINE_ITEM_BORDER_BOTTOM,- [sequence.type],+ () =>+ (isPackedTrack+ ? TIMELINE_PACKED_TRACK_HEIGHT+ : getTimelineLayerHeight(sequence.type)) + TIMELINE_ITEM_BORDER_BOTTOM,+ [isPackedTrack, sequence.type],);+ const connectedCompositionIconStyle = useMemo(+ (): React.CSSProperties => ({+ flexShrink: 0,+ height: 12,+ // Center the icon on whole pixels, including in taller audio/video rows.+ marginBottom: (outerHeight - TIMELINE_ITEM_BORDER_BOTTOM) % 2,+ width: 12,+ }),+ [outerHeight],+ );+const inner: React.CSSProperties = useMemo(() => {return {height: TIMELINE_LIST_ITEM_ROW_HEIGHT,diff --cc packages/studio/src/components/Timeline/TimelineVirtualization.tsxindex 4434746530,82ddb5a377..7967332610--- a/packages/studio/src/components/Timeline/TimelineVirtualization.tsx+++ b/packages/studio/src/components/Timeline/TimelineVirtualization.tsx@@@ -116,37 -99,29 +119,37 @@@ export const TimelineVirtualizationProvoffsets[index + 1] = offsets[index] + trackHeights[index];}- const rows = timeline.map((track, index): TimelineVirtualRow => {- const afterDropLineOffset =- offsets[subtreeEndIndexes[index]] - offsets[index];- const siblingIndex = siblingIndexes[index];- const previous = rowsRef.current[index];- if (- previous?.track === track &&- previous.afterDropLineOffset === afterDropLineOffset &&- previous.siblingIndex === siblingIndex- ) {- return previous;- }+ const rows = timeline.map(+ ({track, items, auxiliaryRows}, index): TimelineVirtualRow => {+ const afterDropLineOffset =+ offsets[subtreeEndIndexes[index]] - offsets[index];+ const siblingIndex = siblingIndexes[index];- const previous = previousRowsRef.current[index];++ const previous = rowsRef.current[index];+ if (+ previous?.track === track &&+ previous.items === items &&+ previous.auxiliaryRows === auxiliaryRows &&+ previous.afterDropLineOffset === afterDropLineOffset &&+ previous.siblingIndex === siblingIndex+ ) {+ return previous;+ }- return {afterDropLineOffset, siblingIndex, track};- });+ return {afterDropLineOffset, siblingIndex, track, items, auxiliaryRows};+ },+ );const rootTrackIndexes = new Map<string, number>();for (let index = 0; index < timeline.length; index++) {- const {nodePathInfo} = timeline[index];- if (nodePathInfo !== null) {- rootTrackIndexes.set(- getTimelineSequenceSelectionKey(nodePathInfo),- index,- );+ for (const {nodePathInfo} of [+ timeline[index].track,+ ...(timeline[index].items ?? []),+ ]) {+ if (nodePathInfo !== null) {+ rootTrackIndexes.set(+ getTimelineSequenceSelectionKey(nodePathInfo),+ index,+ );+ }}}