Open source CapCut alternative.
TypeScript
feat(site): group panel keeps every kind's own settings
David Le5688eda0ede2
diff --git a/docs/guides/cut/README.md b/docs/guides/cut/README.mdindex efd96357..579e670f 100644--- a/docs/guides/cut/README.md+++ b/docs/guides/cut/README.md@@ -46,7 +46,7 @@ Browser previews use the browser compositor and replace one cached proxy in OPFSCloud source media, generated media, and retained exports count toward storage. Derived previews, share cards, and HLS ladders are quota-exempt; staging inputs are temporary. Garbage collection also corrects accounting for older preview and card objects in bounded batches. Transports expose structured storage, credit, and authentication failures. Each host chooses their presentation; the website mounts its storage dialog separately.-Timeline and preview share selection: ⌘/Ctrl-click or Shift-click toggles items, and dragging moves them together with one undo step. Items move independently until grouped, and groups save with the project. On the preview the selection wears one frame whose grips scale the set and whose button turns it, while a drag on any member moves them all. Selecting two or more items opens the group panel: it shows the fields every selected item has, reads a field as Mixed where they differ, and writes each edit to all of them in one undo step.+Timeline and preview share selection: ⌘/Ctrl-click or Shift-click toggles items, and dragging moves them together with one undo step. Items move independently until grouped, and groups save with the project. On the preview the selection wears one frame whose grips scale the set and whose button turns it, while a drag on any member moves them all. Selecting two or more items opens the group panel: it shows the fields every selected item has, reads a field as Mixed where they differ, and writes each edit to all of them in one undo step. A selection of one kind keeps that kind's own rows and its Color and Animation views, and an effect brings only its amount and Hidden.Guides draw over the preview from the button beside the timeline zoom: thirds, center, safe margins, the short-form keep-out zone where TikTok, Reels and Shorts draw their own UI or crop the sides of a 9:16 frame, and custom lines dragged into place on the preview. They save with the project, snap a dragged element to their edges, never export, and the assistant reads the safe area they leave when it places graphics.diff --git a/site/src/cut/components/ColorPanel.tsx b/site/src/cut/components/ColorPanel.tsxindex 9e72078a..32c717c0 100644--- a/site/src/cut/components/ColorPanel.tsx+++ b/site/src/cut/components/ColorPanel.tsx@@ -49,14 +49,15 @@ import { Switch } from "@/components/ui/switch";* checkpoint per gesture, and preview, filmstrip and exports render the same* numbers.*/-export function ColorPanel({ clip }: { clip: VideoClip }) {+export function ColorPanel({ clip, peers }: { clip: VideoClip; peers?: readonly VideoClip[] }) {// The open level holds for the session per clip, so deselecting and coming- // back lands on the same view.+ // back lands on the same view. A multi-selection reads the first clip's+ // grade and lands every write on all of them.const [view, setView] = usePanelState<"presets" | "adjust">(clip.id, "colorView", "presets");if (view === "adjust") {- return <AdjustView clip={clip} onBack={() => setView("presets")} />;+ return <AdjustView clip={clip} peers={peers} onBack={() => setView("presets")} />;}- return <PresetView clip={clip} onAdjust={() => setView("adjust")} />;+ return <PresetView clip={clip} peers={peers} onAdjust={() => setView("adjust")} />;}/** The tools of the Adjust view; `dirty` feeds each tab's marker dot. */@@ -71,7 +72,7 @@ type Tool = (typeof TOOLS)[number]["id"];/** Shared write path: normalize and store a whole grade, transiently while a* gesture is live, committed at its end. */-function useGradeWriter(clip: VideoClip) {+function useGradeWriter(clip: VideoClip, peers?: readonly VideoClip[]) {const ck = useSliderCheckpoint();const write = (g: ColorGrade | undefined) => {// The checkpoint taken on the gesture's first change is the whole undo@@ -79,7 +80,8 @@ function useGradeWriter(clip: VideoClip) {// the transient updater. updateClip would push a second checkpoint and// make ⌘Z a two-press affair.ck.begin();- useEditor.getState().updateClipTransient(clip.id, { grade: normalizeGrade(g) });+ const grade = normalizeGrade(g);+ useEditor.getState().updateClipsTransient((peers ?? [clip]).map((c) => ({ id: c.id, patch: { grade } })));};const commit = (g: ColorGrade | undefined) => {write(g);@@ -92,7 +94,7 @@ function useGradeWriter(clip: VideoClip) {/* Level 1: presets *//* ------------------------------------------------------------------ */-function PresetView({ clip, onAdjust }: { clip: VideoClip; onAdjust: () => void }) {+function PresetView({ clip, peers, onAdjust }: { clip: VideoClip; peers?: readonly VideoClip[]; onAdjust: () => void }) {const [category, setCategory] = usePanelState<GradePresetCategory | "all">(clip.id,"colorPresetCategory",@@ -102,7 +104,7 @@ function PresetView({ clip, onAdjust }: { clip: VideoClip; onAdjust: () => void// The clip's own frame, ungraded: a swatch shows what its preset does to the// footage, never what the clip's current grade already did.const frame = useClipSourceFrame(clip.id);- const { draft, commit } = useGradeWriter(clip);+ const { draft, commit } = useGradeWriter(clip, peers);const active = clip.grade?.preset;const manualDirty = TOOLS.some((t) => gradeToolDirty(clip.grade, t.id));const presets =@@ -360,11 +362,11 @@ function StandInScene({ filter, tint }: { filter: string; tint: string | null })/* Level 2: adjust *//* ------------------------------------------------------------------ */-function AdjustView({ clip, onBack }: { clip: VideoClip; onBack: () => void }) {+function AdjustView({ clip, peers, onBack }: { clip: VideoClip; peers?: readonly VideoClip[]; onBack: () => void }) {// The picked tool holds for the session, the same way the open level does.const [tool, setTool] = usePanelState<Tool>(clip.id, "colorTool", "basic");const toolScroll = useRememberedScroll(clip.id, `color-adjust:${tool}`);- const { draft, commit } = useGradeWriter(clip);+ const { draft, commit } = useGradeWriter(clip, peers);const grade = clip.grade;// Manual adjustments only — reset-all keeps the preset layer.const manualDirty = TOOLS.some((t) => gradeToolDirty(grade, t.id));diff --git a/site/src/cut/components/GroupPanel.tsx b/site/src/cut/components/GroupPanel.tsxindex 972525cf..fcce4899 100644--- a/site/src/cut/components/GroupPanel.tsx+++ b/site/src/cut/components/GroupPanel.tsx@@ -1,33 +1,50 @@"use client";-import { useMemo } from "react";-import { Bold, Italic, Type } from "lucide-react";-import { hasOverlayKeys, lineLikeShape, poseAt } from "@donkeycut/effects-kit";+import { useMemo, useState } from "react";+import { AlignCenter, AlignHorizontalSpaceAround, AlignLeft, AlignRight, AlignVerticalSpaceAround, Bold, FlipHorizontal2, FlipVertical2, Italic, StretchHorizontal, StretchVertical, Type } from "lucide-react";+import { hasOverlayKeys, hasSpeedCurve, lineLikeShape, poseAt, retimeOf, ZOOM_LEVELS, ZOOM_RAMP_MAX, zoomRampOf } from "@donkeycut/effects-kit";import { ColorField } from "@/cut/components/ColorField";import { FontPicker } from "@/cut/components/FontPicker";+import { LETTER_SPACINGS, LINE_HEIGHTS, SoundQualityPanel, SoundQualityRow, STRETCHES, StylePresetsRow } from "@/cut/components/Inspector";import { NumberField } from "@/cut/components/NumberField";import { Field, Row, Section, SegGroup, SegToggle, useSliderCheckpoint, Value } from "@/cut/components/panelBits";-import { parseNumberInput, parsePercentInput, parseSecondsInput, ScrubValue } from "@/cut/components/ScrubValue";+import { parseNumberInput, parsePercentInput, parseSecondsInput, parseSpeedInput, ScrubValue } from "@/cut/components/ScrubValue";import { ValueSlider } from "@/cut/components/ValueSlider";import { Switch } from "@/components/ui/switch";+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";import { selectionCenter, selectionSummary, selectionTranslation, sharedNumber, sharedValue } from "@/cut/lib/groupEdit";+import { usePanelState } from "@/cut/lib/panelState";import { usePreviewTime } from "@/cut/lib/playhead";import { clipWindow, maxClipFade, useEditor } from "@/cut/lib/store";+import { PLATE_COLOR, PLATE_OPACITY, PLATE_RADIUS } from "@/cut/lib/textRender";import { TEXT_SIZES } from "@/cut/lib/textStyle";import {clampOverlayPos,+ CLIP_MAX_ZOOM,clipKeyed,clipPoseAt,+ clipZoom,+ isEffectOverlay,isShapeOverlay,+ isStickerOverlay,isTextOverlay,+ SPEED_FLOOR,+ SPEED_MAX,+ SPEED_MIN,type AudioClip,+ type BoxStyle,+ type ClipShadow,+ type ClipSound,+ type EffectOverlay,type Overlay,type OverlayPatch,type Selection,type ShapeOverlay,+ type StickerOverlay,type TextOverlay,type VideoClip,} from "@/cut/lib/types";+import { cn } from "@/lib/utils";/*** The panel for several items at once: a group, or any multi-selection. It@@ -35,7 +52,8 @@ import {* they agree and as Mixed when they differ, and writes every edit to all of* them in one undo step. Fields one kind has and another lacks stay off the* panel, so a selection of shapes and titles edits its transform and nothing- * a shape cannot carry.+ * a shape cannot carry. Each kind's own rows mirror its single-item panel:+ * what one title, clip, shape, sticker or effect can set, several can.*/export function GroupPanel({ selection }: { selection: readonly NonNullable<Selection>[] }) {const overlays = useEditor((s) => s.overlays);@@ -55,7 +73,32 @@ export function GroupPanel({ selection }: { selection: readonly NonNullable<Seleconst title = !group.mixed && group.value ? "Group" : `${all.length} items`;const texts = items.overlays.filter(isTextOverlay);const shapes = items.overlays.filter(isShapeOverlay);+ const stickers = items.overlays.filter(isStickerOverlay);+ const effects = items.overlays.filter(isEffectOverlay);const onlyOverlays = !items.clips.length && !items.audios.length;+ const onlyClips = items.clips.length > 0 && !items.audios.length && !items.overlays.length;+ const key = `group:${selection.map((s) => s.id).join()}`;+ // The sound quality view pushes over the panel, as it does on one clip.+ const [view, setView] = usePanelState<"main" | "sound">(key, "soundView", "main");+ const write = useGroupWrite();+ if (view === "sound" && !items.overlays.length) {+ const sound = items.clips[0]?.sound ?? items.audios[0]?.sound;+ return (+ <SoundQualityPanel+ itemId={key}+ sound={sound}+ write={(next, phase) => {+ const run = () => {+ patchClips(items.clips, () => ({ sound: next }));+ patchAudios(items.audios, () => ({ sound: next }));+ };+ if (phase === "commit") write.commit(run);+ else write.draft(run);+ }}+ onBack={() => setView("main")}+ />+ );+ }return (<><div className="flex h-10 shrink-0 items-center px-3.5">@@ -65,8 +108,13 @@ export function GroupPanel({ selection }: { selection: readonly NonNullable<Sele<div className="mb-1 text-[11px] text-muted-foreground">{selectionSummary(items)}</div>{onlyOverlays && texts.length === items.overlays.length && <TextRows texts={texts} />}{onlyOverlays && shapes.length === items.overlays.length && <ShapeRows shapes={shapes} />}- {!items.clips.length && !items.overlays.length && <AudioRows audios={items.audios} />}+ {onlyOverlays && stickers.length === items.overlays.length && <StickerRows stickers={stickers} />}+ {onlyOverlays && effects.length === items.overlays.length && <EffectRows effects={effects} />}+ {!items.overlays.length && <SoundRows clips={items.clips} audios={items.audios} onOpenSound={() => setView("sound")} />}+ {onlyClips && <ClipPictureRows clips={items.clips} />}<TransformRows items={items} />+ {onlyClips && <ClipBorderRows clips={items.clips} />}+ {onlyClips && <ClipShadowRows clips={items.clips} />}</div></>);@@ -91,6 +139,12 @@ function useGroupWrite() {st().pushHistory();run();},+ /** Per-item store actions that each seal their own history, run as one step. */+ batch(run: () => void) {+ st().beginHistoryBatch();+ run();+ st().endHistoryBatch();+ },};}@@ -101,7 +155,13 @@ const patchClips = (clips: readonly VideoClip[], patch: (c: VideoClip) => Partiaconst patchAudios = (audios: readonly AudioClip[], patch: (a: AudioClip) => Partial<AudioClip>) =>st().updateAudiosTransient(audios.map((a) => ({ id: a.id, patch: patch(a) })));+/** The live copy of a clip, so a patch layers on what earlier drag frames wrote. */+const liveClip = (c: VideoClip) => st().clips.find((x) => x.id === c.id) ?? c;+const SLIDER = { sliderClassName: "data-horizontal:w-24", valueClassName: "w-9 text-muted-foreground" };+const formatPercent = (v: number) => `${Math.round(v * 100)}%`;+const formatSpeed = (v: number) => `${v.toFixed(2)}×`;+const parsePercentText = (raw: string) => parseNumberInput(raw.replace(/%$/, ""));function MixedSwitch({ label, values, onChange }: { label: string; values: boolean[]; onChange: (v: boolean) => void }) {const shared = sharedValue(values);@@ -113,17 +173,53 @@ function MixedSwitch({ label, values, onChange }: { label: string; values: boole);}+/** A two-way choice over the set, the bordered pill the single panels use;+ * a mixed set lights neither side. */+function MixedSeg<T extends string>({+ options,+ shared,+ onPick,+}: {+ options: readonly { id: T; label: string }[];+ shared: { value: T; mixed: boolean };+ onPick: (id: T) => void;+}) {+ return (+ <div className="flex rounded-lg border border-input p-0.5">+ {options.map((opt) => {+ const active = !shared.mixed && shared.value === opt.id;+ return (+ <button+ key={opt.id}+ type="button"+ className={cn(+ "rounded-md px-2.5 py-1 text-[11.5px] font-medium transition-colors",+ active ? "bg-neutral-900 text-white" : "text-muted-foreground hover:text-foreground"+ )}+ aria-pressed={active}+ onClick={() => onPick(opt.id)}+ >+ {opt.label}+ </button>+ );+ })}+ </div>+ );+}+/*** Position, rotation, opacity and hidden, over whichever of the selection* carries them. Position is the selection's center and moves the whole set* with its offsets kept; rotation and opacity land the same value on each* item. A keyed item takes the edit at the playhead, as its own panel does.+ * An effect has no transform: it joins the Hidden row and nothing else.*/function TransformRows({ items }: { items: { overlays: Overlay[]; clips: VideoClip[]; audios: AudioClip[] } }) {const write = useGroupWrite();const now = usePreviewTime();- const { overlays, clips, audios } = items;- const visual = !audios.length;+ const { clips, audios } = items;+ const overlays = items.overlays.filter((o) => !isEffectOverlay(o));+ const visual = !audios.length && (overlays.length > 0 || clips.length > 0);const local = (o: { start: number; end: number }) => Math.max(0, Math.min(now - o.start, Math.max(0.1, o.end - o.start)));const overlayPose = (o: Overlay) => (hasOverlayKeys(o) ? poseAt(o, local(o)) : { x: o.x, y: o.y, rotation: o.rotation ?? 0, opacity: o.opacity ?? 1 });const clipPose = (c: VideoClip) => {@@ -146,7 +242,7 @@ function TransformRows({ items }: { items: { overlays: Overlay[]; clips: VideoClif (pose.keyed) return st().setClipKey(c.id, pose.tLocal, patch, { transient: true });st().updateClipTransient(c.id, {...(patch.rotation !== undefined ? { rotation: patch.rotation === 0 ? undefined : patch.rotation } : {}),- ...(patch.opacity !== undefined ? { opacity: patch.opacity >= 0.995 ? undefined : patch.opacity } : {}),+ ...(patch.opacity !== undefined ? { opacity: patch.opacity >= 0.999 ? undefined : patch.opacity } : {}),});};const poses = overlays.map(overlayPose);@@ -168,21 +264,21 @@ function TransformRows({ items }: { items: { overlays: Overlay[]; clips: VideoCloverlays.forEach((o) => setOverlay(o, { opacity: a }));clips.forEach((c) => setClip(c, { opacity: a }));};- const hidden = [...overlays.map((o) => !!o.hidden), ...clips.map((c) => !!c.hidden), ...audios.map((a) => !!a.hidden)];+ const hidden = [...items.overlays.map((o) => !!o.hidden), ...clips.map((c) => !!c.hidden), ...audios.map((a) => !!a.hidden)];const hiddenRow = (<MixedSwitchlabel="Hidden"values={hidden}onChange={(v) =>write.once(() => {- patchOverlays(overlays, () => ({ hidden: v || undefined }));+ patchOverlays(items.overlays, () => ({ hidden: v || undefined }));patchClips(clips, () => ({ hidden: v }));patchAudios(audios, () => ({ hidden: v }));})}/>);- // Sound has no transform: a selection with audio in it shares only Hidden.+ // Sound and effects have no transform: such a selection shares only Hidden.if (!visual) return hiddenRow;return (<Section title="Transform">@@ -210,52 +306,91 @@ function TransformRows({ items }: { items: { overlays: Overlay[]; clips: VideoCl</Row>)}<Row label="Rotation">- <ValueSlider- label="Rotation"- {...SLIDER}- value={rotation.value}- mixed={rotation.mixed}- min={-180}- max={180}- step={1}- snap={[-90, 0, 90]}- format={(v) => `${Math.round(v)}°`}- parse={parseNumberInput}- onDraft={(v) => write.draft(() => rotate(v))}- onCommit={(v) => write.commit(() => rotate(v))}- />- </Row>+ <ValueSlider+ label="Rotation"+ {...SLIDER}+ value={rotation.value}+ mixed={rotation.mixed}+ min={-180}+ max={180}+ step={1}+ snap={[-90, 0, 90]}+ format={(v) => `${Math.round(v)}°`}+ parse={parseNumberInput}+ onDraft={(v) => write.draft(() => rotate(v))}+ onCommit={(v) => write.commit(() => rotate(v))}+ />+ </Row><Row label="Opacity">- <ValueSlider- label="Opacity"- {...SLIDER}- value={opacity.value}- mixed={opacity.mixed}- min={0}- max={1}- step={0.01}- format={(v) => String(Math.round(v * 100))}- parse={parsePercentInput}- onDraft={(v) => write.draft(() => fade(v))}- onCommit={(v) => write.commit(() => fade(v))}- />- </Row>+ <ValueSlider+ label="Opacity"+ {...SLIDER}+ value={opacity.value}+ mixed={opacity.mixed}+ min={0}+ max={1}+ step={0.01}+ format={(v) => String(Math.round(v * 100))}+ parse={parsePercentInput}+ onDraft={(v) => write.draft(() => fade(v))}+ onCommit={(v) => write.commit(() => fade(v))}+ />+ </Row>{hiddenRow}</Section>);}-/** Face, size, weight, slant and color, over a selection of titles only. */+/** A title's whole look over a selection of titles: saved styles, face,+ * weight and slant, alignment, size, spacing, stretch, color, outline,+ * shadow and backdrop. */function TextRows({ texts }: { texts: TextOverlay[] }) {const write = useGroupWrite();const font = sharedValue(texts.map((t) => t.font));const size = sharedNumber(texts.map((t) => t.size));const bold = sharedValue(texts.map((t) => t.weight === 700));const italic = sharedValue(texts.map((t) => !!t.italic));+ const align = sharedValue(texts.map((t) => t.align ?? "center"));+ const lineHeight = sharedNumber(texts.map((t) => t.lineHeight ?? 1.25));+ const letterSpacing = sharedNumber(texts.map((t) => (t.letterSpacing ?? 0) * 100));+ const stretchX = sharedNumber(texts.map((t) => (t.stretchX ?? 1) * 100));+ const stretchY = sharedNumber(texts.map((t) => (t.stretchY ?? 1) * 100));const color = sharedValue(texts.map((t) => t.color.toLowerCase()));+ const outlined = texts.every((t) => !!t.stroke);+ const strokeColor = sharedValue(texts.map((t) => t.stroke?.color.toLowerCase() ?? ""));+ const strokeWidth = sharedNumber(texts.map((t) => (t.stroke?.width ?? 0.04) * 100));+ const shadowed = texts.every((t) => !!t.shadow);+ const shadowOf = (t: TextOverlay) => (typeof t.shadow === "object" ? t.shadow : {});+ const shadowColor = sharedValue(texts.map((t) => (shadowOf(t).color ?? "#000000").toLowerCase()));+ const shadowOpacity = sharedNumber(texts.map((t) => shadowOf(t).opacity ?? 0.65));+ const shadowBlur = sharedNumber(texts.map((t) => shadowOf(t).blur ?? 14));+ const plated = texts.every((t) => t.plate);+ const plateColor = sharedValue(texts.map((t) => (t.plateColor ?? PLATE_COLOR).toLowerCase()));+ const plateOpacity = sharedNumber(texts.map((t) => t.plateOpacity ?? PLATE_OPACITY));+ const plateRadius = sharedNumber(texts.map((t) => t.plateRadius ?? PLATE_RADIUS));const set = (patch: OverlayPatch) => patchOverlays(texts, () => patch);+ const setEach = (patch: (t: TextOverlay) => OverlayPatch) => patchOverlays(texts, (o) => patch(o as TextOverlay));+ const slide = (label: string, shared: { value: number; mixed: boolean }, range: { min: number; max: number; step: number; snap?: number[] }, format: (v: number) => string, parse: (raw: string) => number | null, apply: (v: number) => void) => (+ <Row label={label}>+ <ValueSlider+ label={label}+ {...SLIDER}+ value={shared.value}+ mixed={shared.mixed}+ min={range.min}+ max={range.max}+ step={range.step}+ snap={range.snap}+ format={format}+ parse={parse}+ onDraft={(v) => write.draft(() => apply(v))}+ onCommit={(v) => write.commit(() => apply(v))}+ />+ </Row>+ );return (<>+ <StylePresetsRow overlay={texts[0]} peers={texts} /><Field label="Font"><FontPicker value={font.value} mixed={font.mixed} onChange={(id) => write.once(() => set({ font: id as TextOverlay["font"] }))} /></Field>@@ -268,6 +403,24 @@ function TextRows({ texts }: { texts: TextOverlay[] }) {<Italic /></SegToggle></SegGroup>+ <SegGroup>+ {(+ [+ ["left", AlignLeft],+ ["center", AlignCenter],+ ["right", AlignRight],+ ] as const+ ).map(([a, Icon]) => (+ <SegToggle+ key={a}+ label={`Align ${a}`}+ active={!align.mixed && align.value === a}+ onClick={() => write.once(() => set({ align: a === "center" ? undefined : a }))}+ >+ <Icon />+ </SegToggle>+ ))}+ </SegGroup><NumberFieldlabel="Text size"className="ml-auto w-[74px]"@@ -284,6 +437,68 @@ function TextRows({ texts }: { texts: TextOverlay[] }) {onCommit={(v) => write.commit(() => set({ size: v }))}/></div>+ <div className="mt-1 grid grid-cols-2 gap-2">+ <Field label="Line height">+ <NumberField+ label="Line height"+ icon={<AlignVerticalSpaceAround />}+ value={lineHeight.value}+ mixed={lineHeight.mixed}+ min={0.8}+ max={2}+ step={0.05}+ snap={[1.25]}+ presets={LINE_HEIGHTS}+ format={(v) => v.toFixed(2)}+ parse={parseNumberInput}+ onDraft={(v) => write.draft(() => set({ lineHeight: Math.abs(v - 1.25) < 0.025 ? undefined : v }))}+ onCommit={(v) => write.commit(() => set({ lineHeight: Math.abs(v - 1.25) < 0.025 ? undefined : v }))}+ />+ </Field>+ <Field label="Letter spacing">+ <NumberField+ label="Letter spacing"+ icon={<AlignHorizontalSpaceAround />}+ value={letterSpacing.value}+ mixed={letterSpacing.mixed}+ min={-5}+ max={30}+ step={1}+ snap={[0]}+ presets={LETTER_SPACINGS}+ format={(v) => `${Math.round(v)}%`}+ parse={parsePercentText}+ onDraft={(v) => write.draft(() => set({ letterSpacing: Math.abs(v) < 0.25 ? undefined : v / 100 }))}+ onCommit={(v) => write.commit(() => set({ letterSpacing: Math.abs(v) < 0.25 ? undefined : v / 100 }))}+ />+ </Field>+ </div>+ <div className="mt-1 grid grid-cols-2 gap-2">+ {(+ [+ ["stretchX", "Width", stretchX, StretchHorizontal],+ ["stretchY", "Height", stretchY, StretchVertical],+ ] as const+ ).map(([axis, label, shared, Icon]) => (+ <Field key={axis} label={label}>+ <NumberField+ label={`${label} stretch`}+ icon={<Icon />}+ value={shared.value}+ mixed={shared.mixed}+ min={25}+ max={400}+ step={5}+ snap={[100]}+ presets={STRETCHES}+ format={(v) => `${Math.round(v)}%`}+ parse={parsePercentText}+ onDraft={(v) => write.draft(() => set({ [axis]: Math.abs(v - 100) < 0.5 ? undefined : v / 100 }))}+ onCommit={(v) => write.commit(() => set({ [axis]: Math.abs(v - 100) < 0.5 ? undefined : v / 100 }))}+ />+ </Field>+ ))}+ </div><Row label="Color"><ColorFieldvalue={color.value}@@ -294,6 +509,81 @@ function TextRows({ texts }: { texts: TextOverlay[] }) {onCommit={(c) => write.once(() => set({ color: c }))}/></Row>+ <Section+ title="Outline"+ enabled={outlined}+ onEnabledChange={(v) => write.once(() => setEach((t) => ({ stroke: v ? (t.stroke ?? { color: "#111114", width: 0.04 }) : undefined })))}+ >+ {outlined && (+ <>+ <Row label="Color">+ <ColorField+ value={strokeColor.value}+ mixed={strokeColor.mixed}+ label="Outline color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => setEach((t) => ({ stroke: { ...t.stroke!, color: c } }))}+ onCommit={(c) => write.once(() => setEach((t) => ({ stroke: { ...t.stroke!, color: c } })))}+ />+ </Row>+ {slide("Width", strokeWidth, { min: 1, max: 15, step: 0.5, snap: [4] }, (v) => String(Math.round(v)), parseNumberInput, (v) =>+ setEach((t) => ({ stroke: { ...t.stroke!, width: v / 100 } }))+ )}+ </>+ )}+ </Section>+ <Section title="Shadow" enabled={shadowed} onEnabledChange={(v) => write.once(() => set({ shadow: v }))}>+ {shadowed && (+ <>+ <Row label="Color">+ <ColorField+ value={shadowColor.value}+ mixed={shadowColor.mixed}+ label="Shadow color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => setEach((t) => ({ shadow: { ...shadowOf(t), color: c } }))}+ onCommit={(c) => write.once(() => setEach((t) => ({ shadow: { ...shadowOf(t), color: c } })))}+ opacity={{+ label: "Shadow opacity",+ value: shadowOpacity.value,+ mixed: shadowOpacity.mixed,+ onDraft: (v) => write.draft(() => setEach((t) => ({ shadow: { ...shadowOf(t), opacity: v } }))),+ onCommit: (v) => write.commit(() => setEach((t) => ({ shadow: { ...shadowOf(t), opacity: v } }))),+ }}+ />+ </Row>+ {slide("Blur", shadowBlur, { min: 0, max: 60, step: 1, snap: [14] }, (v) => String(Math.round(v)), parseNumberInput, (v) =>+ setEach((t) => ({ shadow: { ...shadowOf(t), blur: v } }))+ )}+ </>+ )}+ </Section>+ <Section title="Backdrop" enabled={plated} onEnabledChange={(v) => write.once(() => set({ plate: v }))}>+ {plated && (+ <>+ <Row label="Color">+ <ColorField+ value={plateColor.value}+ mixed={plateColor.mixed}+ label="Backdrop color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => set({ plateColor: c })}+ onCommit={(c) => write.once(() => set({ plateColor: c }))}+ opacity={{+ label: "Backdrop opacity",+ value: plateOpacity.value,+ mixed: plateOpacity.mixed,+ onDraft: (v) => write.draft(() => set({ plateOpacity: v })),+ onCommit: (v) => write.commit(() => set({ plateOpacity: v })),+ }}+ />+ </Row>+ {slide("Radius", plateRadius, { min: 0, max: 1, step: 0.01, snap: [PLATE_RADIUS] }, (v) => String(Math.round(v * 100)), parsePercentInput, (v) =>+ set({ plateRadius: v })+ )}+ </>+ )}+ </Section></>);}@@ -356,46 +646,166 @@ function ShapeRows({ shapes }: { shapes: ShapeOverlay[] }) {enabled={outlined}onEnabledChange={(v) => write.once(() => set((s) => ({ stroke: v ? (s.stroke ?? { color: "#111114", width: 6 }) : undefined })))}>- <Row label="Color">- <ColorField- value={strokeColor.value}- mixed={strokeColor.mixed}- label="Outline color"- onBegin={() => st().pushHistory()}- onLive={(c) => set((s) => ({ stroke: { ...s.stroke!, color: c } }))}- onCommit={(c) => write.once(() => set((s) => ({ stroke: { ...s.stroke!, color: c } })))}- />- </Row>- <Row label="Width">- <ValueSlider- label="Outline width"- {...SLIDER}- value={strokeWidth.value}- mixed={strokeWidth.mixed}- min={1}- max={40}- step={1}- snap={[6]}- format={(v) => String(Math.round(v))}- parse={parseNumberInput}- onDraft={(v) => write.draft(() => set((s) => ({ stroke: { ...s.stroke!, width: Math.round(v) } })))}- onCommit={(v) => write.commit(() => set((s) => ({ stroke: { ...s.stroke!, width: Math.round(v) } })))}- />- </Row>+ {outlined && (+ <>+ <Row label="Color">+ <ColorField+ value={strokeColor.value}+ mixed={strokeColor.mixed}+ label="Outline color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => set((s) => ({ stroke: { ...s.stroke!, color: c } }))}+ onCommit={(c) => write.once(() => set((s) => ({ stroke: { ...s.stroke!, color: c } })))}+ />+ </Row>+ <Row label="Width">+ <ValueSlider+ label="Outline width"+ {...SLIDER}+ value={strokeWidth.value}+ mixed={strokeWidth.mixed}+ min={1}+ max={40}+ step={1}+ snap={[6]}+ format={(v) => String(Math.round(v))}+ parse={parseNumberInput}+ onDraft={(v) => write.draft(() => set((s) => ({ stroke: { ...s.stroke!, width: Math.round(v) } })))}+ onCommit={(v) => write.commit(() => set((s) => ({ stroke: { ...s.stroke!, width: Math.round(v) } })))}+ />+ </Row>+ </>+ )}</Section>)}</>);}-/** Volume and fades, over a selection of audio clips only. */-function AudioRows({ audios }: { audios: AudioClip[] }) {+/** Size, over a selection of stickers only. */+function StickerRows({ stickers }: { stickers: StickerOverlay[] }) {+ const write = useGroupWrite();+ const size = sharedNumber(stickers.map((s) => s.w));+ return (+ <Row label="Size">+ <ValueSlider+ label="Sticker size"+ {...SLIDER}+ value={size.value}+ mixed={size.mixed}+ min={0.02}+ max={1}+ step={0.01}+ format={(v) => String(Math.round(v * 100))}+ parse={parsePercentInput}+ onDraft={(v) => write.draft(() => patchOverlays(stickers, () => ({ w: v })))}+ onCommit={(v) => write.commit(() => patchOverlays(stickers, () => ({ w: v })))}+ />+ </Row>+ );+}++/** An effect's knobs over a selection of effects: depth and speed when every+ * one is a zoom, amount otherwise. Where a zoom lands is aimed on its own+ * picture, so the focus stays per effect. */+function EffectRows({ effects }: { effects: EffectOverlay[] }) {+ const write = useGroupWrite();+ const amount = sharedNumber(effects.map((e) => e.amount ?? 0.5));+ const set = (patch: OverlayPatch) => patchOverlays(effects, () => patch);+ if (effects.every((e) => e.effect === "zoom")) {+ const ramp = sharedNumber(effects.map((e) => zoomRampOf(e.ramp)));+ return (+ <>+ <Row label="Depth" grow>+ <div className="flex min-w-0 grow rounded-lg border border-input p-0.5 text-[11.5px] font-medium">+ {ZOOM_LEVELS.map((l) => {+ const active = !amount.mixed && Math.abs(amount.value - l.amount) < 0.01;+ return (+ <button+ key={l.id}+ type="button"+ aria-pressed={active}+ className={cn(+ "flex-1 rounded-md px-1 py-1 whitespace-nowrap transition-colors",+ active ? "bg-neutral-900 text-white" : "text-muted-foreground hover:text-foreground"+ )}+ onClick={() => write.once(() => set({ amount: l.amount }))}+ >+ {l.label}+ </button>+ );+ })}+ </div>+ </Row>+ <Row label="Speed">+ <ValueSlider+ label="Zoom speed"+ {...SLIDER}+ value={ramp.value}+ mixed={ramp.mixed}+ min={0}+ max={ZOOM_RAMP_MAX}+ step={0.1}+ format={(v) => `${v.toFixed(1)}s`}+ parse={parseSecondsInput}+ onDraft={(v) => write.draft(() => set({ ramp: v }))}+ onCommit={(v) => write.commit(() => set({ ramp: v }))}+ />+ </Row>+ </>+ );+ }+ return (+ <Row label="Amount">+ <ValueSlider+ label="Effect amount"+ {...SLIDER}+ value={amount.value}+ mixed={amount.mixed}+ min={0.05}+ max={1}+ step={0.01}+ snap={[0.5]}+ format={(v) => String(Math.round(v * 100))}+ parse={parsePercentInput}+ onDraft={(v) => write.draft(() => set({ amount: v }))}+ onCommit={(v) => write.commit(() => set({ amount: v }))}+ />+ </Row>+ );+}++/**+ * Sound over a selection of video and audio clips: speed and reverse, volume,+ * the sound treatment, then what each kind alone carries — mute is the video+ * clip's own switch, ducking and fades belong to soundtrack clips.+ */+function SoundRows({ clips, audios, onOpenSound }: { clips: VideoClip[]; audios: AudioClip[]; onOpenSound: () => void }) {const write = useGroupWrite();- const volume = sharedNumber(audios.map((a) => a.volume));+ // A clip's rate lands once, on release: changing it resettles the row.+ const [speedDraft, setSpeedDraft] = useState<number | null>(null);+ const speed = sharedNumber([+ ...clips.map((c) => (hasSpeedCurve(c) ? retimeOf(c).rate : (c.speed ?? 1))),+ ...audios.map((a) => retimeOf(a).rate),+ ]);+ const audioSpeed = (v: number) => patchAudios(audios, () => ({ speed: Math.abs(v - 1) < 1e-4 ? undefined : v, speedCurve: undefined }));+ const commitSpeed = (v: number) => {+ setSpeedDraft(null);+ write.batch(() => {+ clips.forEach((c) => st().setClipSpeed(c.id, v));+ write.commit(() => audioSpeed(v));+ });+ };+ const volume = sharedNumber([...clips.map((c) => c.volume ?? 1), ...audios.map((a) => a.volume)]);+ const setVolume = (v: number) => {+ patchClips(clips, () => ({ volume: v === 1 ? undefined : v }));+ patchAudios(audios, () => ({ volume: v }));+ };+ const duck = sharedNumber(audios.map((a) => a.duck ?? 1));const fadeIn = sharedNumber(audios.map((a) => a.fadeIn ?? 0));const fadeOut = sharedNumber(audios.map((a) => a.fadeOut ?? 0));const maxFade = Math.min(...audios.map(maxClipFade));- const set = (patch: Partial<AudioClip>) => patchAudios(audios, () => patch);+ const sound: ClipSound | undefined = clips[0]?.sound ?? audios[0]?.sound;const fadeRow = (label: string, key: "fadeIn" | "fadeOut", shared: { value: number; mixed: boolean }) => (<Row label={label}><ValueSlider@@ -408,13 +818,44 @@ function AudioRows({ audios }: { audios: AudioClip[] }) {step={0.1}format={(v) => `${v.toFixed(1)}s`}parse={parseSecondsInput}- onDraft={(v) => write.draft(() => set({ [key]: v }))}- onCommit={(v) => write.commit(() => set({ [key]: v }))}+ onDraft={(v) => write.draft(() => patchAudios(audios, () => ({ [key]: v })))}+ onCommit={(v) => write.commit(() => patchAudios(audios, () => ({ [key]: v })))}/></Row>);return (<>+ <Row label="Speed">+ <ValueSlider+ label="Speed"+ {...SLIDER}+ value={speedDraft ?? speed.value}+ mixed={speedDraft === null && speed.mixed}+ min={SPEED_MIN}+ max={SPEED_MAX}+ step={0.05}+ snap={[1]}+ scrubMin={SPEED_FLOOR}+ scrubMax={Infinity}+ format={formatSpeed}+ parse={parseSpeedInput}+ onDraft={(v) => {+ setSpeedDraft(v);+ if (audios.length) write.draft(() => audioSpeed(v));+ }}+ onCommit={commitSpeed}+ />+ </Row>+ <MixedSwitch+ label="Reverse"+ values={[...clips.map((c) => !!c.reverse), ...audios.map((a) => !!a.reverse)]}+ onChange={(v) =>+ write.batch(() => {+ clips.forEach((c) => st().setClipReverse(c.id, v));+ write.once(() => patchAudios(audios, () => ({ reverse: v || undefined })));+ })+ }+ /><Row label="Volume"><ValueSliderlabel="Volume"@@ -425,14 +866,265 @@ function AudioRows({ audios }: { audios: AudioClip[] }) {max={3}step={0.05}snap={[1]}- format={(v) => `${Math.round(v * 100)}%`}+ format={formatPercent}+ parse={parsePercentInput}+ onDraft={(v) => write.draft(() => setVolume(v))}+ onCommit={(v) => write.commit(() => setVolume(v))}+ />+ </Row>+ {clips.length > 0 && (+ <MixedSwitch+ label="Mute audio"+ values={clips.map((c) => c.muted)}+ onChange={(v) => write.once(() => patchClips(clips, () => ({ muted: v })))}+ />+ )}+ {audios.length > 0 && !clips.length && (+ <Row label="Duck others">+ <ValueSlider+ label="Duck others"+ {...SLIDER}+ value={duck.value}+ mixed={duck.mixed}+ min={0}+ max={1}+ step={0.05}+ format={(v) => (v >= 0.999 ? "Off" : formatPercent(v))}+ parse={(raw) => (raw.trim().toLowerCase() === "off" ? 1 : parsePercentInput(raw))}+ onDraft={(v) => write.draft(() => patchAudios(audios, () => ({ duck: v < 0.999 ? v : undefined })))}+ onCommit={(v) => write.commit(() => patchAudios(audios, () => ({ duck: v < 0.999 ? v : undefined })))}+ />+ </Row>+ )}+ {audios.length > 0 && !clips.length && fadeRow("Fade in", "fadeIn", fadeIn)}+ {audios.length > 0 && !clips.length && fadeRow("Fade out", "fadeOut", fadeOut)}+ <SoundQualityRow sound={sound} onOpen={onOpenSound} />+ </>+ );+}++/** Framing, zoom and flip over a selection of video clips. Pan stays per+ * clip: where a picture has slack depends on that clip's own footage. */+function ClipPictureRows({ clips }: { clips: VideoClip[] }) {+ const write = useGroupWrite();+ const fit = sharedValue(clips.map((c) => c.fit ?? "fit"));+ const zoom = sharedNumber(clips.map(clipZoom));+ const flips = (key: "flipH" | "flipV") => sharedValue(clips.map((c) => !!c[key]));+ return (+ <>+ <Row label="Framing">+ <MixedSeg+ options={[+ { id: "fit", label: "Fit" },+ { id: "fill", label: "Fill" },+ ]}+ shared={fit}+ onPick={(mode) => write.once(() => patchClips(clips, () => ({ fit: mode, panX: 0, panY: 0 })))}+ />+ </Row>+ <Row label="Zoom">+ <ValueSlider+ label="Zoom"+ {...SLIDER}+ value={zoom.value}+ mixed={zoom.mixed}+ min={1}+ max={CLIP_MAX_ZOOM}+ step={0.01}+ snap={[1]}+ keyStep={0.05}+ format={formatPercent}parse={parsePercentInput}- onDraft={(v) => write.draft(() => set({ volume: v }))}- onCommit={(v) => write.commit(() => set({ volume: v }))}+ onDraft={(v) => write.draft(() => patchClips(clips, () => ({ zoom: v > 1.001 ? v : undefined })))}+ onCommit={(v) => write.commit(() => patchClips(clips, () => ({ zoom: v > 1.001 ? v : undefined })))}/></Row>- {fadeRow("Fade in", "fadeIn", fadeIn)}- {fadeRow("Fade out", "fadeOut", fadeOut)}+ <Row label="Flip">+ <div className="flex rounded-lg border border-input p-0.5">+ {(+ [+ ["flipH", "Flip horizontal", FlipHorizontal2],+ ["flipV", "Flip vertical", FlipVertical2],+ ] as const+ ).map(([key, label, Icon]) => {+ const shared = flips(key);+ const active = !shared.mixed && shared.value;+ return (+ <TooltipProvider key={key}>+ <Tooltip>+ <TooltipTrigger+ aria-label={label}+ aria-pressed={active}+ className={cn(+ "grid size-6 place-items-center rounded-md transition-colors",+ active ? "bg-neutral-900 text-white" : "text-muted-foreground hover:text-foreground"+ )}+ onClick={() => write.once(() => patchClips(clips, () => ({ [key]: active ? undefined : true })))}+ >+ <Icon className="size-3.5" />+ </TooltipTrigger>+ <TooltipContent side="bottom">{label}</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ );+ })}+ </div>+ </Row></>);}++/** Corner radius, border width and color over a selection of video clips. */+function ClipBorderRows({ clips }: { clips: VideoClip[] }) {+ const write = useGroupWrite();+ const bordered = clips.every((c) => !!c.boxStyle);+ const width = sharedNumber(clips.map((c) => c.boxStyle?.borderWidth ?? 0));+ const radius = sharedNumber(clips.map((c) => c.boxStyle?.radius ?? 0));+ const color = sharedValue(clips.map((c) => (c.boxStyle?.borderColor ?? "#FFFFFF").toLowerCase()));+ const set = (patch: Partial<BoxStyle>) => patchClips(clips, (c) => ({ boxStyle: { ...liveClip(c).boxStyle, ...patch } }));+ return (+ <Section+ title="Border"+ enabled={bordered}+ onEnabledChange={(v) =>+ write.once(() =>+ patchClips(clips, (c) => ({ boxStyle: v ? (c.boxStyle ?? { radius: 16, borderWidth: 6, borderColor: "#FFFFFF" }) : undefined }))+ )+ }+ >+ {bordered && (+ <>+ <Row label="Width">+ <ScrubValue+ label="Border width"+ className="w-9 text-muted-foreground"+ value={width.value}+ min={0}+ max={60}+ step={1}+ format={(v) => String(Math.round(v))}+ parse={parseNumberInput}+ onScrub={(v) => write.draft(() => set({ borderWidth: v }))}+ onCommit={(v) => write.commit(() => set({ borderWidth: v }))}+ />+ </Row>+ <Row label="Radius">+ <ScrubValue+ label="Corner radius"+ className="w-9 text-muted-foreground"+ value={radius.value}+ min={0}+ max={200}+ step={1}+ format={(v) => String(Math.round(v))}+ parse={parseNumberInput}+ onScrub={(v) => write.draft(() => set({ radius: v }))}+ onCommit={(v) => write.commit(() => set({ radius: v }))}+ />+ </Row>+ <Row label="Color">+ <ColorField+ value={color.value}+ mixed={color.mixed}+ label="Border color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => set({ borderColor: c })}+ onCommit={(c) => write.once(() => set({ borderColor: c }))}+ />+ </Row>+ </>+ )}+ </Section>+ );+}++/** Drop shadow over a selection of video clips. */+function ClipShadowRows({ clips }: { clips: VideoClip[] }) {+ const write = useGroupWrite();+ const shadowed = clips.every((c) => !!c.boxStyle?.shadow);+ const blur = sharedNumber(clips.map((c) => c.boxStyle?.shadow?.blur ?? 24));+ const offsetX = sharedNumber(clips.map((c) => c.boxStyle?.shadow?.x ?? 0));+ const offsetY = sharedNumber(clips.map((c) => c.boxStyle?.shadow?.y ?? 0));+ const opacity = sharedNumber(clips.map((c) => c.boxStyle?.shadow?.opacity ?? 0.35));+ const color = sharedValue(clips.map((c) => (c.boxStyle?.shadow?.color ?? "#000000").toLowerCase()));+ const set = (patch: Partial<ClipShadow>) =>+ patchClips(clips, (c) => {+ const cur = liveClip(c).boxStyle;+ return { boxStyle: { ...cur, shadow: { blur: cur?.shadow?.blur ?? 24, ...cur?.shadow, ...patch } } };+ });+ const scrub = (label: string, shared: { value: number; mixed: boolean }, range: { min: number; max: number }, apply: (v: number) => void) => (+ <ScrubValue+ label={label}+ className="w-9 text-muted-foreground"+ value={shared.value}+ min={range.min}+ max={range.max}+ step={1}+ format={(v) => String(Math.round(v))}+ parse={parseNumberInput}+ onScrub={(v) => write.draft(() => apply(v))}+ onCommit={(v) => write.commit(() => apply(v))}+ />+ );+ return (+ <Section+ title="Shadow"+ enabled={shadowed}+ onEnabledChange={(v) =>+ write.once(() =>+ patchClips(clips, (c) => ({+ boxStyle: v+ ? { ...c.boxStyle, shadow: c.boxStyle?.shadow ?? { blur: 24, y: 12 } }+ : c.boxStyle?.radius || c.boxStyle?.borderWidth+ ? { ...c.boxStyle, shadow: undefined }+ : undefined,+ }))+ )+ }+ >+ {shadowed && (+ <>+ <Row label="Blur">{scrub("Shadow blur", blur, { min: 0, max: 120 }, (v) => set({ blur: v }))}</Row>+ <Row label="Offset">+ {(+ [+ ["x", offsetX],+ ["y", offsetY],+ ] as const+ ).map(([axis, shared]) => (+ <span key={axis} className="flex items-center gap-1">+ <span className="text-[11px] text-muted-foreground/70 uppercase">{axis}</span>+ {scrub(`Shadow ${axis.toUpperCase()} offset`, shared, { min: -120, max: 120 }, (v) => set({ [axis]: Math.round(v) || undefined }))}+ </span>+ ))}+ </Row>+ <Row label="Opacity">+ <ValueSlider+ label="Shadow opacity"+ {...SLIDER}+ value={opacity.value}+ mixed={opacity.mixed}+ min={0}+ max={1}+ step={0.01}+ format={formatPercent}+ parse={parsePercentInput}+ onDraft={(v) => write.draft(() => set({ opacity: v }))}+ onCommit={(v) => write.commit(() => set({ opacity: v }))}+ />+ </Row>+ <Row label="Color">+ <ColorField+ value={color.value}+ mixed={color.mixed}+ label="Shadow color"+ onBegin={() => st().pushHistory()}+ onLive={(c) => set({ color: c })}+ onCommit={(c) => write.once(() => set({ color: c }))}+ />+ </Row>+ </>+ )}+ </Section>+ );+}diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsxindex 5866400f..869f1689 100644--- a/site/src/cut/components/Inspector.tsx+++ b/site/src/cut/components/Inspector.tsx@@ -119,6 +119,7 @@ import {isEffectOverlay,isShapeOverlay,isTextOverlay,+ type ClipAnim,LAYOUTS,onFontsChanged,rectOf,@@ -211,6 +212,12 @@ const CLIP_TABS: readonly RailTab[] = [/** An overlay's one deep view: its animation. */const ANIM_TAB: RailTab = { id: "animate", label: "Animation", Icon: Sparkles };+/** The deep views a selection of video clips shares. */+const GROUP_CLIP_TABS: readonly RailTab[] = [+ { id: "color", label: "Color", Icon: Palette },+ ANIM_TAB,+];+/*** The panel for one selection: the tab rail on its left, the open view's* body beside it. The view belongs to the selection — the column is keyed on@@ -243,7 +250,26 @@ function InspectorColumn({},[setView, setOpen]);- const tabs = clip ? CLIP_TABS : overlay ? [ANIM_TAB] : [];+ // A group's deep views are the ones every member has: clips share Color and+ // Animation, elements share Animation, and an effect (which animates+ // nothing) or a mix of kinds leaves the rail with Home alone.+ const allClips = useEditor((s) => s.clips);+ const allOverlays = useEditor((s) => s.overlays);+ const groupClips = useMemo(+ () => (group ? allClips.filter((c) => group.some((g) => g.kind === "clip" && g.id === c.id)) : []),+ [group, allClips]+ );+ const groupOverlays = useMemo(+ () => (group ? allOverlays.filter((o) => group.some((g) => g.kind === "overlay" && g.id === o.id)) : []),+ [group, allOverlays]+ );+ const groupTabs =+ group && groupClips.length === group.length+ ? GROUP_CLIP_TABS+ : group && groupOverlays.length === group.length && !groupOverlays.some(isEffectOverlay)+ ? [ANIM_TAB]+ : [];+ const tabs = clip ? CLIP_TABS : overlay ? [ANIM_TAB] : groupTabs;const shown = tabs.some((t) => t.id === view) ? view : "main";return (<>@@ -261,6 +287,12 @@ function InspectorColumn({<ClipColumn clip={clip} tab={shown} />) : overlay && shown === ANIM_TAB.id ? (<AnimationPanel overlay={overlay} />+ ) : group && shown === "color" && groupClips.length ? (+ <ColorPanel clip={groupClips[0]} peers={groupClips} />+ ) : group && shown === ANIM_TAB.id && groupClips.length ? (+ <ClipAnimationPanel clip={groupClips[0]} peers={groupClips} />+ ) : group && shown === ANIM_TAB.id && groupOverlays.length ? (+ <AnimationPanel overlay={groupOverlays[0]} peers={groupOverlays} />) : (<ScrollArea className="min-h-0 flex-1" {...homeScroll}>{group ? (@@ -887,7 +919,7 @@ const soundSummary = (sound: ClipSound | undefined) => {/** The row on an audio panel that opens the Sound quality view, reading* what the clip carries. */-function SoundQualityRow({ sound, onOpen }: { sound: ClipSound | undefined; onOpen: () => void }) {+export function SoundQualityRow({ sound, onOpen }: { sound: ClipSound | undefined; onOpen: () => void }) {return (<Row label="Sound quality"><button@@ -903,7 +935,7 @@ function SoundQualityRow({ sound, onOpen }: { sound: ClipSound | undefined; onOp}/** The Sound quality view, pushed over an audio panel. */-function SoundQualityPanel({+export function SoundQualityPanel({itemId,sound,write,@@ -1798,10 +1830,10 @@ function AudioPanel({ clip }: { clip: AudioClip }) {/** The sizes and spacings a title usually wants, offered under each field's* chevron; any value in range can still be typed or dragged. */-const LINE_HEIGHTS = [0.9, 1, 1.15, 1.25, 1.5, 1.75, 2];-const LETTER_SPACINGS = [-2, 0, 2, 5, 10, 20];+export const LINE_HEIGHTS = [0.9, 1, 1.15, 1.25, 1.5, 1.75, 2];+export const LETTER_SPACINGS = [-2, 0, 2, 5, 10, 20];/** Glyph stretch stops, percent of the face's own width or height. */-const STRETCHES = [50, 75, 100, 125, 150, 200];+export const STRETCHES = [50, 75, 100, 125, 150, 200];function TextPanel({ overlay: o }: { overlay: TextOverlay }) {const update = useEditor((s) => s.updateOverlay);@@ -2227,7 +2259,7 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {/** Named text-style presets from the shared Library: chips that apply a saved* look to the selected title, plus saving the current look under a name. */-function StylePresetsRow({ overlay: o }: { overlay: TextOverlay }) {+export function StylePresetsRow({ overlay: o, peers }: { overlay: TextOverlay; peers?: readonly TextOverlay[] }) {const [presets, setPresets] = useState<StylePreset[] | null>(null);const [naming, setNaming] = useState(false);const [name, setName] = useState("");@@ -2301,7 +2333,11 @@ function StylePresetsRow({ overlay: o }: { overlay: TextOverlay }) {type="button"title={`Apply ${p.name}`}className="flex items-center gap-1.5 rounded-md border border-input px-2 py-1 text-[11.5px] transition-colors hover:border-ring"- onClick={() => useEditor.getState().updateOverlay(o.id, { ...p.style })}+ onClick={() => {+ const st = useEditor.getState();+ st.pushHistory();+ st.updateOverlaysTransient((peers ?? [o]).map((el) => ({ id: el.id, patch: { ...p.style } })));+ }}><spanclassName="leading-none"@@ -2343,7 +2379,7 @@ function StylePresetsRow({ overlay: o }: { overlay: TextOverlay }) {/** Write an animation patch to the element — and its whole group, since a* grouped element's animation stamps the group. Neutral (all slots off)* stores as absence. */-function writeOverlayAnim(o: Overlay, anim: OverlayAnim, patch: Partial<OverlayAnim>) {+function writeOverlayAnim(o: Overlay, anim: OverlayAnim, patch: Partial<OverlayAnim>, peers?: readonly Overlay[]) {const next = { ...anim, ...patch };if (!next.in) delete next.in;if (!next.out) delete next.out;@@ -2352,8 +2388,9 @@ function writeOverlayAnim(o: Overlay, anim: OverlayAnim, patch: Partial<OverlayAif (!next.words) delete next.words;const value = hasOverlayAnim(next) ? next : undefined;const st = useEditor.getState();- const peers = o.groupId ? st.overlays.filter((x) => x.groupId === o.groupId) : [];- const targets = peers.length > 1 ? peers : [o];+ // A multi-selection names its targets; a lone grouped element stamps its group.+ const grouped = o.groupId ? st.overlays.filter((x) => x.groupId === o.groupId) : [];+ const targets = peers ?? (grouped.length > 1 ? grouped : [o]);st.updateOverlaysTransient(targets.map((el) => {if (!value?.words || !isTextOverlay(el)) return { id: el.id, patch: { anim: value } };@@ -2375,14 +2412,14 @@ function writeOverlayAnim(o: Overlay, anim: OverlayAnim, patch: Partial<OverlayA/** The move's strength: how hard the hold pushes. The slider sits in two* places — the collapsed section, and the animation panel's Move tab — so it* is one component. */-function MoveStrengthSlider({ overlay: o, label }: { overlay: Overlay; label: string }) {+function MoveStrengthSlider({ overlay: o, label, peers }: { overlay: Overlay; label: string; peers?: readonly Overlay[] }) {const ck = useSliderCheckpoint();const anim = o.anim ?? {};const move = anim.move;const write = (strength: number) => {if (!move) return;ck.begin();- writeOverlayAnim(o, anim, { move: { ...move, strength } });+ writeOverlayAnim(o, anim, { move: { ...move, strength } }, peers);};return (<Row label={label}>@@ -2413,7 +2450,7 @@ function MoveStrengthSlider({ overlay: o, label }: { overlay: Overlay; label: st* effect does not use is left out — a slider with nothing to move explains* nothing. With no effect picked the rows sit greyed, so the panel floor* keeps its height while the reader scrolls the grid. */-function WordSettings({ overlay: o }: { overlay: Overlay }) {+function WordSettings({ overlay: o, peers }: { overlay: Overlay; peers?: readonly Overlay[] }) {const ck = useSliderCheckpoint();const anim = o.anim ?? {};const words = anim.words;@@ -2425,11 +2462,11 @@ function WordSettings({ overlay: o }: { overlay: Overlay }) {const write = (patch: { scale?: number; dim?: number }) => {if (!words) return;ck.begin();- writeOverlayAnim(o, anim, { words: { ...words, ...patch } });+ writeOverlayAnim(o, anim, { words: { ...words, ...patch } }, peers);};const setColor = (color: string) => {if (!words) return;- writeOverlayAnim(o, anim, { words: { ...words, color } });+ writeOverlayAnim(o, anim, { words: { ...words, color } }, peers);};return (<>@@ -2535,7 +2572,7 @@ const CLIP_ANIM_SLOTS = ["in", "out"] as const;* grid, the ramp's length on the floor. A pick lands as the bar on that edge —* the timeline draws it, the Transitions tab marks it, and the assistant's* set_animation writes the same one — and plays itself on the footage. */-function ClipAnimationPanel({ clip }: { clip: VideoClip }) {+export function ClipAnimationPanel({ clip, peers }: { clip: VideoClip; peers?: readonly VideoClip[] }) {const [picked, setSlot] = usePanelState<"in" | "out">(clip.id, "animSlot", "in");const slot = picked === "out" ? "out" : "in";const tilesScroll = useRememberedScroll(clip.id, `anim:${slot}`);@@ -2543,16 +2580,25 @@ function ClipAnimationPanel({ clip }: { clip: VideoClip }) {// The ramp's length lands once, on release: every write to the edge is a// bar edit with its own undo step.const [secondsDraft, setSecondsDraft] = useState<number | null>(null);- const len = clipLen(clip);+ const targets = peers ?? [clip];+ // The ramp fits the shortest clip it lands on.+ const len = Math.min(...targets.map(clipLen));const rehearse = (seconds: number) =>- previewBar({ start: slot === "in" ? clip.start : clip.start + len - seconds, seconds });+ previewBar({ start: slot === "in" ? clip.start : clip.start + clipLen(clip) - seconds, seconds });+ // One undo step across every target.+ const setAll = (value: ClipAnim | null) => {+ const st = useEditor.getState();+ st.beginHistoryBatch();+ for (const c of targets) st.setClipAnim(c.id, slot, value);+ st.endHistoryBatch();+ };const pick = (style: AnimStyle | null) => {if (!style) {- if (anim) useEditor.getState().setClipAnim(clip.id, slot, null);+ if (anim) setAll(null);return;}const seconds = anim?.seconds ?? ANIM_DEFAULT_SECONDS;- useEditor.getState().setClipAnim(clip.id, slot, { style, seconds });+ setAll({ style, seconds });rehearse(seconds);};return (@@ -2596,7 +2642,7 @@ function ClipAnimationPanel({ clip }: { clip: VideoClip }) {onCommit={(v) => {setSecondsDraft(null);if (!anim) return;- useEditor.getState().setClipAnim(clip.id, slot, { ...anim, seconds: v });+ setAll({ ...anim, seconds: v });rehearse(v);}}/>@@ -2610,13 +2656,14 @@ function ClipAnimationPanel({ clip }: { clip: VideoClip }) {* the tile grid, the active slot's own control under it. The slots pick from* the same grid, one at a time — the tiles are big enough to read the motion,* which a stack of grids would not be. */-function AnimationPanel({ overlay: o }: { overlay: Overlay }) {+export function AnimationPanel({ overlay: o, peers }: { overlay: Overlay; peers?: readonly Overlay[] }) {const anim = o.anim ?? {};// The active slot holds for the session, like every settings view's tab.const [picked, setSlot] = usePanelState<AnimSlot>(o.id, "animSlot", "in");// Word emphasis is a title's slot; a shape or a sticker has no words, so// selecting one hands the picker back to the entrance.- const tabs: AnimSlot[] = isTextOverlay(o)+ // Word emphasis needs words on every target.+ const tabs: AnimSlot[] = (peers ?? [o]).every(isTextOverlay)? ["in", "out", "loop", "move", "words"]: ["in", "out", "loop", "move"];const slot = tabs.includes(picked) ? picked : "in";@@ -2642,7 +2689,7 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {}: undefined,};- writeOverlayAnim(o, anim, patch);+ writeOverlayAnim(o, anim, patch, peers);// The pick sweeps itself along the line, the same as any other slot.if (style) {const el = useEditor.getState().overlays.find((x) => x.id === o.id) ?? o;@@ -2658,7 +2705,7 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {const patch: Partial<OverlayAnim> = {move: style ? { style, strength: activeMove?.strength ?? 1 } : undefined,};- writeOverlayAnim(o, anim, patch);+ writeOverlayAnim(o, anim, patch, peers);// The pick plays itself on the stage, the same as any other slot.if (style) playAnimPreview({ ...o, anim: { ...anim, ...patch } }, "move");else stopAnimPreview();@@ -2667,7 +2714,7 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {if (!style) {stopAnimPreview();useEditor.getState().pushHistory();- writeOverlayAnim(o, anim, { [slot]: undefined });+ writeOverlayAnim(o, anim, { [slot]: undefined }, peers);return;}const patch: Partial<OverlayAnim> =@@ -2680,7 +2727,7 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {},};useEditor.getState().pushHistory();- writeOverlayAnim(o, anim, patch);+ writeOverlayAnim(o, anim, patch, peers);// The pick plays itself on the stage, for exactly its own length.playAnimPreview({ ...o, anim: { ...anim, ...patch } }, slot);};@@ -2738,7 +2785,7 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {onPick={pick}/></ScrollArea>- <AnimationToolbar overlay={o} slot={slot} />+ <AnimationToolbar overlay={o} slot={slot} peers={peers} /></div>);}@@ -2749,25 +2796,26 @@ function AnimationPanel({ overlay: o }: { overlay: Overlay }) {* pushes — so the bar shows the tab's own control and nothing else. It stays* put with the slot unset, greyed rather than gone, because a bar that comes* and goes moves the grid under the pointer. */-function AnimationToolbar({ overlay: o, slot }: { overlay: Overlay; slot: AnimSlot }) {+function AnimationToolbar({ overlay: o, slot, peers }: { overlay: Overlay; slot: AnimSlot; peers?: readonly Overlay[] }) {const ck = useSliderCheckpoint();const anim = o.anim ?? {};- const dur = Math.max(0.2, o.end - o.start);+ // The ramp fits the shortest element it lands on.+ const dur = Math.max(0.2, Math.min(...(peers ?? [o]).map((el) => el.end - el.start)));const edge = slot === "in" || slot === "out" ? anim[slot] : undefined;const bar = (children: React.ReactNode) => (<div className="shrink-0 border-t border-border bg-card px-3.5 py-0.5">{children}</div>);- if (slot === "move") return bar(<MoveStrengthSlider overlay={o} label="Strength" />);+ if (slot === "move") return bar(<MoveStrengthSlider overlay={o} label="Strength" peers={peers} />);- if (slot === "words") return bar(<WordSettings overlay={o} />);+ if (slot === "words") return bar(<WordSettings overlay={o} peers={peers} />);if (slot === "loop") {const write = (speed: number) => {if (!anim.loop) return;ck.begin();- writeOverlayAnim(o, anim, { loop: { ...anim.loop, speed } });+ writeOverlayAnim(o, anim, { loop: { ...anim.loop, speed } }, peers);};return bar(<Row label="Speed">@@ -2796,7 +2844,7 @@ function AnimationToolbar({ overlay: o, slot }: { overlay: Overlay; slot: AnimSlconst write = (secs: number) => {if (!edge) return;ck.begin();- writeOverlayAnim(o, anim, { [slot]: { ...edge, seconds: secs } });+ writeOverlayAnim(o, anim, { [slot]: { ...edge, seconds: secs } }, peers);};return bar(<Row label="Duration">diff --git a/site/src/cut/components/groupPanelParity.test.ts b/site/src/cut/components/groupPanelParity.test.tsnew file mode 100644index 00000000..ae41cf53--- /dev/null+++ b/site/src/cut/components/groupPanelParity.test.ts@@ -0,0 +1,47 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";+import { fileURLToPath } from "node:url";++/**+ * The group panel shows the fields every selected item has. Each timeline+ * kind's single-item panel names the plain-value settings a selection of that+ * kind must still be able to set together; a row that exists on one item and+ * vanishes on several is the bug this pins.+ */+const src = readFileSync(fileURLToPath(new URL("./GroupPanel.tsx", import.meta.url)), "utf8");+const inspector = readFileSync(fileURLToPath(new URL("./Inspector.tsx", import.meta.url)), "utf8");++// A row's label as the source spells it, whether on the row, handed to a+// helper, or built from a template; the sound quality row is the inspector's+// own, mounted here.+const names = (label: string) =>+ src.includes(`"${label}"`) || src.includes(`\`${label}`) || (label === "Sound quality" && src.includes("<SoundQualityRow"));++const SHARED: Record<string, string[]> = {+ "video clips": ["Speed", "Reverse", "Volume", "Mute audio", "Sound quality", "Framing", "Zoom", "Flip", "Rotation", "Opacity", "Hidden", "Border", "Shadow"],+ "audio clips": ["Speed", "Reverse", "Volume", "Duck others", "Fade in", "Fade out", "Sound quality", "Hidden"],+ titles: ["Font", "Bold", "Italic", "Align ${a}", "Text size", "Line height", "Letter spacing", "${label} stretch", "Color", "Outline", "Shadow", "Backdrop", "Position", "Rotation", "Opacity", "Hidden"],+ shapes: ["Fill color", "Corner radius", "Outline", "Position", "Rotation", "Opacity", "Hidden"],+ stickers: ["Sticker size", "Position", "Rotation", "Opacity", "Hidden"],+ effects: ["Effect amount", "Depth", "Zoom speed", "Hidden"],+};++describe("group panel parity", () => {+ for (const [kind, rows] of Object.entries(SHARED)) {+ test(`a selection of ${kind} keeps its rows`, () => {+ const missing = rows.filter((r) => !names(r));+ expect(missing).toEqual([]);+ });+ }++ test("a selection of clips opens Color and Animation; elements open Animation", () => {+ expect(/GROUP_CLIP_TABS[\s\S]*?id: "color"[\s\S]*?ANIM_TAB/.test(inspector)).toBe(true);+ expect(inspector).toContain("<ColorPanel clip={groupClips[0]} peers={groupClips} />");+ expect(inspector).toContain("<ClipAnimationPanel clip={groupClips[0]} peers={groupClips} />");+ expect(inspector).toContain("<AnimationPanel overlay={groupOverlays[0]} peers={groupOverlays} />");+ });++ test("an effect carries no transform and skews no selection center", () => {+ expect(src).toContain('const overlays = items.overlays.filter((o) => !isEffectOverlay(o));');+ });+});