Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into codex/studio-transition-triangles

JonnyBurgere5bc4f23e8fb
diff --cc packages/studio/src/components/Timeline/TimelineSequence.tsx
index fdd85103fd,9b067ed9db..64cf6e886f
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@@ -92,8 -88,8 +91,9 @@@ import
} from './timeline-sequence-label';
import {timelineSourceOnlyCursor} from './timeline-source-only-cursor';
import {
- TIMELINE_PACKED_AUXILIARY_ROW_HEIGHT,
+ getTimelineSequenceHeight,
+ hasTimelineTrackMediaLabel,
+ TIMELINE_PACKED_TRACK_HEIGHT,
} from './timeline-track-groups';
import {timelineTrimEdgeCursor} from './timeline-trim-edge-cursor';
import {TimelineImageInfo} from './TimelineImageInfo';
@@@ -440,12 -426,7 +440,14 @@@ const TimelineSequenceBar: React.FC<
const {onSelect, selectable, selected, selectionItem} =
useTimelineRowSelection(nodePathInfo);
const containsSelection = useTimelineRowContainsSelection(nodePathInfo);
- useTimelineMarqueeSelectableItem(selectionItem, ref, marqueeHorizontalBounds);
+ const isTransition = s.timelineTrack?.role === 'transition';
++ const isPackedClip =
++ s.timelineTrack?.role === 'clip' && s.timelineTrack.seriesOffset !== null;
+ useTimelineMarqueeSelectableItem(
+ selectionItem,
+ ref,
+ isTransition ? null : marqueeHorizontalBounds,
+ );
const onPointerDown = useCallback(
(e: React.PointerEvent<HTMLDivElement>) => {
@@@ -490,33 -466,8 +492,33 @@@
sceneRange !== null && frameIncrement !== null
? sceneRange.end * frameIncrement - Number(style.marginLeft)
: Infinity;
+ let labelLeft =
+ 2.5 + Math.max(labelOffset, negativeStartEnd + (premount?.width ?? 0));
+ let labelFollowsTransitionMarker = false;
+ if (
- s.timelineTrack?.role === 'clip' &&
++ isPackedClip &&
+ sceneRange !== null &&
+ sceneRange.transitionInEnd !== null &&
+ frameIncrement !== null
+ ) {
+ const incomingTransitionWidth =
+ (sceneRange.transitionInEnd - sceneRange.from) * frameIncrement;
+ labelFollowsTransitionMarker =
+ incomingTransitionWidth >= minTransitionAreaWidth;
+ const afterTransition = labelFollowsTransitionMarker
+ ? Math.round(sceneRange.transitionInEnd * frameIncrement) + 4
+ : sceneRange.transitionInEnd * frameIncrement + 2.5;
+ labelLeft = Math.max(labelLeft, afterTransition - Number(style.marginLeft));
+ }
+
const paintedStart = Math.max(negativeStartEnd, sceneLeft);
const paintedEnd = Math.max(0, Math.min(Number(style.width), sceneRight));
+ const sceneOwnsRightGap =
+ sceneRange !== null &&
+ sceneRange.transitionOutStart !== null &&
+ // The scene contour already includes the pixel-aligned outgoing gap.
+ // Allow for floating-point error when the bar ends at the same frame.
+ sceneRight <= Number(style.width) + 0.0001;
// Shared child rows need the same gap as Track clips, including when the
// scene clips their trailing edge. Only inset the paint: timing, hit areas,
// and trim handles keep their full width. Preserve tiny clips when zoomed out.
@@@ -529,86 -479,6 +531,82 @@@
paintedEnd +
Math.min(1, Math.max(0, paintedEnd - paintedStart - 1))
: 0;
+ const selectionLeft = selectionBounds?.left ?? 0;
+ const selectionRight = Math.max(
+ visualRightInset,
+ Number(style.width) - selectionLeft - (selectionBounds?.width ?? 0),
+ );
+ const selectionWidth = Number(style.width) - selectionLeft - selectionRight;
+ const selectionShape = useMemo(() => {
+ if (
+ !(selected || containsSelection) ||
+ isTransition ||
+ frameIncrement === null ||
+ sceneRange === null ||
+ (sceneRange.transitionInEnd === null &&
+ sceneRange.transitionOutStart === null)
+ ) {
+ return null;
+ }
+
+ return getTimelineSceneShape({
+ sceneRange,
+ offsetInFrames:
+ (Number(style.marginLeft) + selectionLeft) / frameIncrement,
+ durationInFrames: selectionWidth / frameIncrement,
+ pixelsPerFrame: frameIncrement,
- height:
- s.timelineTrack?.role === 'clip'
- ? Number(style.height)
- : (sceneClipHeight ?? Number(style.height)),
- seamY:
- s.timelineTrack?.role === 'clip'
- ? Number(style.height) / 2
- : TIMELINE_CHILD_TRANSITION_SEAM_Y,
++ height: isPackedClip
++ ? Number(style.height)
++ : (sceneClipHeight ?? Number(style.height)),
++ seamY: isPackedClip
++ ? Number(style.height) / 2
++ : TIMELINE_CHILD_TRANSITION_SEAM_Y,
+ cropHeight: Number(style.height),
+ });
+ }, [
+ containsSelection,
+ frameIncrement,
+ isTransition,
- s.timelineTrack?.role,
++ isPackedClip,
+ sceneClipHeight,
+ sceneRange,
+ selected,
+ selectionLeft,
+ selectionWidth,
+ style.height,
+ style.marginLeft,
+ ]);
+ const trimShape = useMemo(() => {
+ if (activeTrimEdge === null || isTransition || frameIncrement === null) {
+ return null;
+ }
+
+ return getTimelineSceneShape({
+ sceneRange,
+ offsetInFrames: Number(style.marginLeft) / frameIncrement,
+ durationInFrames: Number(style.width) / frameIncrement,
+ pixelsPerFrame: frameIncrement,
- height:
- s.timelineTrack?.role === 'clip'
- ? Number(style.height)
- : (sceneClipHeight ?? Number(style.height)),
- seamY:
- s.timelineTrack?.role === 'clip'
- ? Number(style.height) / 2
- : TIMELINE_CHILD_TRANSITION_SEAM_Y,
++ height: isPackedClip
++ ? Number(style.height)
++ : (sceneClipHeight ?? Number(style.height)),
++ seamY: isPackedClip
++ ? Number(style.height) / 2
++ : TIMELINE_CHILD_TRANSITION_SEAM_Y,
+ cropHeight: Number(style.height),
+ });
+ }, [
+ activeTrimEdge,
+ isTransition,
+ frameIncrement,
+ sceneRange,
+ style.marginLeft,
+ style.width,
+ style.height,
- s.timelineTrack?.role,
++ isPackedClip,
+ sceneClipHeight,
+ ]);
+ const transitionTrimEdge =
+ activeTrimEdge === null ? null : (trimShape?.edges[activeTrimEdge] ?? null);
// Back the antialiased rounded edge only when the glow is at the painted layer edge.
const trimHighlightColor = isAtTrimLimit ? RED : '#00E500';
const sequenceBackground =
@@@ -620,20 -489,27 +618,20 @@@
const sceneClippingStyle: React.CSSProperties = useMemo(() => {
return {
- maskImage:
- s.timelineTrack?.role === 'clip' && frameIncrement !== null
- ? getTimelineSceneMask({
+ clipPath:
- s.timelineTrack?.role === 'clip' && frameIncrement !== null
++ isPackedClip && frameIncrement !== null
+ ? getTimelineSceneClipPath({
sceneRange,
offsetInFrames: Number(style.marginLeft) / frameIncrement,
durationInFrames: Number(style.width) / frameIncrement,
+ pixelsPerFrame: frameIncrement,
+ height: Number(style.height),
+ seamY: Number(style.height) / 2,
+ cropHeight: null,
})
: undefined,
- clipPath:
- s.timelineTrack?.role === 'clip' && sceneRange !== null
- ? `inset(0 ${Math.max(0, Number(style.width) - sceneRight)}px 0 ${Math.max(0, sceneLeft)}px)`
- : undefined,
};
- }, [style, s.timelineTrack?.role, frameIncrement, sceneRange]);
- }, [
- style,
- s.timelineTrack?.role,
- frameIncrement,
- sceneRange,
- sceneLeft,
- sceneRight,
- ]);
++ }, [style, isPackedClip, frameIncrement, sceneRange]);
const actualStyle: React.CSSProperties = useMemo(
() => ({
@@@ -687,14 -585,17 +685,17 @@@
<div
style={{
position: 'absolute',
- left:
- 2.5 +
- Math.max(labelOffset, negativeStartEnd + (premount?.width ?? 0)),
+ left: labelLeft,
+ // The containing scene clips the label along the transition contour.
right: 0,
bottom: PACKED_LABEL_BOTTOM,
+ ...(hasTimelineTrackMediaLabel(s)
+ ? {top: getTimelineLayerHeight(s.type)}
+ : {}),
display: 'flex',
- flexDirection: 'column',
- alignItems: 'flex-start',
+ flexDirection: labelFollowsTransitionMarker ? 'row' : 'column',
+ alignItems: labelFollowsTransitionMarker ? 'center' : 'flex-start',
+ gap: labelFollowsTransitionMarker ? 4 : 0,
overflow: 'hidden',
pointerEvents: 'none',
userSelect: 'none',
diff --cc packages/studio/src/components/Timeline/timeline-series-layout.ts
index d516c2fe4f,82c3b2fc03..22c39bed92
--- a/packages/studio/src/components/Timeline/timeline-series-layout.ts
+++ b/packages/studio/src/components/Timeline/timeline-series-layout.ts
@@@ -80,10 -73,6 +81,12 @@@ export const getTimelineSeriesLayout =
.sort((a, b) => a.sequence.from - b.sequence.from);
scenesBySeries.set(index, scenes);
+ transitionsBySeries.set(
+ index,
- getTimelineTransitionRanges(row.items.map((item) => item.sequence)),
++ getTimelineTransitionRanges(
++ row.childScenes.map((item) => item.sequence),
++ ),
+ );
for (const scene of scenes) {
seriesByScene.set(scene.sequence.id, index);
}