🎥 Make videos programmatically with React
Follow inherited transition outlines in nested series
JonnyBurgerfe1daa20e56a
diff --git a/packages/studio/src/components/Timeline/TimelineSceneRangeContext.ts b/packages/studio/src/components/Timeline/TimelineSceneRangeContext.tsindex 3d8124e457..058f620fa9 100644--- a/packages/studio/src/components/Timeline/TimelineSceneRangeContext.ts+++ b/packages/studio/src/components/Timeline/TimelineSceneRangeContext.ts@@ -4,6 +4,9 @@ import type {TimelineSceneRange} from './timeline-series-layout';export const TimelineSceneRangeContext =createContext<TimelineSceneRange | null>(null);+export const TimelineInheritedSceneRangeContext =+ createContext<TimelineSceneRange | null>(null);+export const TimelineSceneClipHeightContext = createContext<number | null>(null,);diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsxindex 549720cca8..1150ac77fc 100644--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx@@ -98,6 +98,7 @@ import {import {timelineTrimEdgeCursor} from './timeline-trim-edge-cursor';import {TimelineImageInfo} from './TimelineImageInfo';import {+ TimelineInheritedSceneRangeContext,TimelineSceneClipHeightContext,TimelineSceneRangeContext,} from './TimelineSceneRangeContext';@@ -434,6 +435,7 @@ const TimelineSequenceBar: React.FC<{const ref = useRef<HTMLDivElement>(null);const showLayerFrameNumbers = getStudioShowLayerFrameNumbers();const sceneRange = useContext(TimelineSceneRangeContext);+ const inheritedSceneRange = useContext(TimelineInheritedSceneRangeContext);const sceneClipHeight = useContext(TimelineSceneClipHeightContext);const timelineWidth = useContext(TimelineWidthContext);const video = Internals.useUnsafeVideoConfig();@@ -535,45 +537,62 @@ const TimelineSequenceBar: React.FC<{Number(style.width) - selectionLeft - (selectionBounds?.width ?? 0),);const selectionWidth = Number(style.width) - selectionLeft - selectionRight;- const selectionShape = useMemo(() => {+ const selectionShapes = useMemo(() => {if (!(selected || containsSelection) ||isTransition ||- frameIncrement === null ||- sceneRange === null ||- (sceneRange.transitionInEnd === null &&- sceneRange.transitionOutStart === null)+ frameIncrement === null) {- return null;+ return [];}- return getTimelineSceneShape({- sceneRange,- offsetInFrames:- (Number(style.marginLeft) + selectionLeft) / frameIncrement,- durationInFrames: selectionWidth / frameIncrement,- pixelsPerFrame: frameIncrement,- height: isPackedClip- ? Number(style.height)- : (sceneClipHeight ?? Number(style.height)),- seamY: isPackedClip- ? Number(style.height) / 2- : TIMELINE_CHILD_TRANSITION_SEAM_Y,- transitionCutout: isPackedClip- ? {- top: transitionVerticalInset,- height: transitionHeight,- radius: 4,- minWidth: minTransitionAreaWidth,- }- : null,- cropHeight: Number(style.height),+ // A nested series has its own clip shape inside the parent scene's+ // contour. Stroke both boundaries; their containing clips intersect them.+ return [+ {key: 'sequence', range: sceneRange, packed: isPackedClip},+ {+ key: 'inherited',+ range: inheritedSceneRange === sceneRange ? null : inheritedSceneRange,+ packed: false,+ },+ ].flatMap(({key, range, packed}) => {+ if (+ range === null ||+ (range.transitionInEnd === null && range.transitionOutStart === null)+ ) {+ return [];+ }++ const shape = getTimelineSceneShape({+ sceneRange: range,+ offsetInFrames:+ (Number(style.marginLeft) + selectionLeft) / frameIncrement,+ durationInFrames: selectionWidth / frameIncrement,+ pixelsPerFrame: frameIncrement,+ height: packed+ ? Number(style.height)+ : (sceneClipHeight ?? Number(style.height)),+ seamY: packed+ ? Number(style.height) / 2+ : TIMELINE_CHILD_TRANSITION_SEAM_Y,+ transitionCutout: packed+ ? {+ top: transitionVerticalInset,+ height: transitionHeight,+ radius: 4,+ minWidth: minTransitionAreaWidth,+ }+ : null,+ cropHeight: Number(style.height),+ });+ return shape === null ? [] : [{key, shape}];});}, [containsSelection,frameIncrement,isTransition,isPackedClip,+ inheritedSceneRange,sceneClipHeight,sceneRange,selected,@@ -945,30 +964,33 @@ const TimelineSequenceBar: React.FC<{{!isTransition &&(selected || containsSelection) &&selectionBounds ? (- selectionShape ? (- <svg- aria-hidden="true"- style={{- position: 'absolute',- left: selectionLeft,- top: 0,- width: selectionWidth,- height: Number(style.height),- clipPath: selectionShape.clipPath,- overflow: 'hidden',- pointerEvents: 'none',- }}- >- <path- d={selectionShape.path}- fill="none"- stroke={WHITE}- // Half the stroke is clipped, matching the 2px inset outline.- strokeWidth={4}- strokeLinejoin="round"- vectorEffect="non-scaling-stroke"- />- </svg>+ selectionShapes.length > 0 ? (+ selectionShapes.map(({key, shape}) => (+ <svg+ key={key}+ aria-hidden="true"+ style={{+ position: 'absolute',+ left: selectionLeft,+ top: 0,+ width: selectionWidth,+ height: Number(style.height),+ clipPath: shape.clipPath,+ overflow: 'hidden',+ pointerEvents: 'none',+ }}+ >+ <path+ d={shape.path}+ fill="none"+ stroke={WHITE}+ // Half the stroke is clipped, matching the 2px inset outline.+ strokeWidth={4}+ strokeLinejoin="round"+ vectorEffect="non-scaling-stroke"+ />+ </svg>+ ))) : (<divaria-hidden="true"diff --git a/packages/studio/src/components/Timeline/TimelineTracks.tsx b/packages/studio/src/components/Timeline/TimelineTracks.tsxindex 54ac9bd035..a4db4455d7 100644--- a/packages/studio/src/components/Timeline/TimelineTracks.tsx+++ b/packages/studio/src/components/Timeline/TimelineTracks.tsx@@ -10,6 +10,7 @@ import {timelineDurationRef, timelineLayerLayoutsRef} from './timeline-refs';import type {TimelineSceneRange} from './timeline-series-layout';import {TimelinePackedTrack} from './TimelinePackedTrack';import {+ TimelineInheritedSceneRangeContext,TimelineSceneClipHeightContext,TimelineSceneRangeContext,} from './TimelineSceneRangeContext';@@ -39,9 +40,11 @@ const TimelineSceneTrackContent: React.FC<{const active = frame >= sceneRange.activeFrom && frame < sceneRange.activeEnd;return (<TimelineSceneClipHeightContext.Provider value={height}>- <TimelineSceneRangeContext.Provider value={sceneRange}>- <div style={{opacity: active ? 1 : 0.5}}>{children}</div>- </TimelineSceneRangeContext.Provider>+ <TimelineInheritedSceneRangeContext.Provider value={sceneRange}>+ <TimelineSceneRangeContext.Provider value={sceneRange}>+ <div style={{opacity: active ? 1 : 0.5}}>{children}</div>+ </TimelineSceneRangeContext.Provider>+ </TimelineInheritedSceneRangeContext.Provider></TimelineSceneClipHeightContext.Provider>);});