Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): text settings sidebar with presets and layout controls
Richie McIlroy2351bfc09a3c
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex 677748724..0f0ded813 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -50,6 +50,7 @@ import imageBg from "~/assets/illustrations/image.webp";import transparentBg from "~/assets/illustrations/transparent.webp";import { Toggle } from "~/components/Toggle";import { generalSettingsStore } from "~/store";+import { listSystemFonts } from "~/utils/fonts";import { normalizeOpaqueHexColor } from "~/utils/hex-color";import {createSelectedOrganization,@@ -64,7 +65,6 @@ import {type CameraYPosition,type CaptionTrackSegment,type ClipOffsets,- type ClipSpeedAudioMode,type CursorAnimationStyle,type CursorType,commands,@@ -78,6 +78,9 @@ import {type XY,type ZoomSegment,} from "~/utils/tauri";+import IconLucideAlignCenter from "~icons/lucide/align-center";+import IconLucideAlignLeft from "~icons/lucide/align-left";+import IconLucideAlignRight from "~icons/lucide/align-right";import IconLucideArrowLeftRight from "~icons/lucide/arrow-left-right";import IconLucideBoxSelect from "~icons/lucide/box-select";import IconLucideColumns2 from "~icons/lucide/columns-2";@@ -86,6 +89,7 @@ import IconLucideFlipHorizontal2 from "~icons/lucide/flip-horizontal-2";import IconLucideFlipVertical2 from "~icons/lucide/flip-vertical-2";import IconLucideGrid from "~icons/lucide/grid";import IconLucideImageOff from "~icons/lucide/image-off";+import IconLucideItalic from "~icons/lucide/italic";import IconLucideKeyboard from "~icons/lucide/keyboard";import IconLucideLaptop from "~icons/lucide/laptop";import IconLucideMonitor from "~icons/lucide/monitor";@@ -110,8 +114,10 @@ import {import { BrandColorsDropdown } from "./BrandColorsDropdown";import { ColorCorrectionSection } from "./ColorCorrectionSection";import { syncCaptionWordsWithText } from "./captions";+import { type ClipTransition, clipSourceTimeAt } from "./clip-transitions";import { getColorPreviewBorderColor, hexToRgb, RgbInput } from "./color-utils";import { type CornerRoundingType, useEditorContext } from "./context";+import { FontPicker } from "./FontPicker";import { GradientEditor } from "./GradientEditor";import { KeyboardTab } from "./KeyboardTab";import {@@ -136,8 +142,20 @@ import { TextInput } from "./TextInput";import {TEXT_FONT_SIZE_MAX,TEXT_FONT_SIZE_MIN,+ type TextAlign,+ type TextLayout,type TextSegment,} from "./text";+import {+ applyTextPreset,+ matchTextPreset,+ TEXT_PRESETS,+ type TextPreset,+} from "./text-presets";+import {+ TEXT_ANIMATION_OPTIONS,+ TEXT_SEGMENT_WEIGHT_OPTIONS,+} from "./text-style";import {ANGLE_PRESETS,anglePresetMotion,@@ -173,6 +191,7 @@ import {matchAnglePreset,setMotion,} from "./three-d";+import { heldTimeBefore, holdWindows } from "./timeline-holds";import {ComingSoonTooltip,EditorButton,@@ -186,6 +205,7 @@ import {topSlideAnimateClasses,} from "./ui";import { formatTime } from "./utils";+import { ZoomModeHelper } from "./ZoomModeHelper";// Split out of the sidebar chunk: the captions tab is not visible at first// paint (Kobalte only mounts the selected tab), and its code is heavy. The@@ -552,12 +572,19 @@ export function ConfigSidebar() {| "captions",});+ // Clip selection is a timeline-only affordance (highlight, Delete key,+ // multi-select); it must not swap the sidebar away from the current tab.+ const sidebarSelection = () => {+ const selection = editorState.timeline.selection;+ return selection && selection.type !== "clip" ? selection : null;+ };+let scrollRef!: HTMLDivElement;return (<KTabsvalue={- editorState.timeline.selection ||+ sidebarSelection() ||editorState.timeline.audioPicker !== null ||editorState.timeline.camera3dSetup !== null? undefined@@ -598,13 +625,13 @@ export function ConfigSidebar() {value={item.id}class={cx("flex relative z-10 flex-1 justify-center items-center px-4 py-2 transition-colors group disabled:opacity-50 focus:outline-hidden",- editorState.timeline.selection+ sidebarSelection()? "text-gray-11": "text-gray-11 data-selected:text-gray-12",)}onClick={() => {// Clear any active selection first- if (editorState.timeline.selection) {+ if (sidebarSelection()) {setEditorState("timeline", "selection", null);}if (editorState.timeline.audioPicker !== null) {@@ -639,7 +666,7 @@ export function ConfigSidebar() {{/** Center the indicator with the icon */}<Showwhen={- !editorState.timeline.selection &&+ !sidebarSelection() &&editorState.timeline.audioPicker === null &&editorState.timeline.camera3dSetup === null}@@ -657,7 +684,7 @@ export function ConfigSidebar() {class="custom-scroll overflow-x-hidden overflow-y-scroll text-[0.875rem] flex-1 min-h-0"classList={{hidden:- !!editorState.timeline.selection ||+ !!sidebarSelection() ||editorState.timeline.audioPicker !== null ||editorState.timeline.audioReplace !== null ||editorState.timeline.camera3dSetup !== null,@@ -786,6 +813,7 @@ export function ConfigSidebar() {/></Field>)}+ <SyncOffsetsConfig /></KTabs.Content><KTabs.Contentvalue="cursor"@@ -1053,12 +1081,12 @@ export function ConfigSidebar() {class="custom-scroll p-4 top-16 left-0 right-0 bottom-0 text-[0.875rem] space-y-4 bg-gray-1 dark:bg-gray-2 z-50"classList={{hidden:- !editorState.timeline.selection &&+ !sidebarSelection() &&editorState.timeline.audioPicker === null &&editorState.timeline.audioReplace === null &&editorState.timeline.camera3dSetup === null,"animate-in slide-in-from-bottom-2 fade-in":- !!editorState.timeline.selection ||+ !!sidebarSelection() ||editorState.timeline.audioPicker !== null ||editorState.timeline.audioReplace !== null ||editorState.timeline.camera3dSetup !== null,@@ -1067,7 +1095,7 @@ export function ConfigSidebar() {<Showwhen={editorState.timeline.audioPicker !== null &&- !editorState.timeline.selection &&+ !sidebarSelection() &&editorState.timeline.audioReplace === null}>@@ -1081,7 +1109,7 @@ export function ConfigSidebar() {</Show><Showwhen={- !editorState.timeline.selection &&+ !sidebarSelection() &&editorState.timeline.audioPicker === null &&editorState.timeline.audioReplace === null? editorState.timeline.camera3dSetup@@ -1117,7 +1145,7 @@ export function ConfigSidebar() {<Showwhen={editorState.timeline.audioReplace === null- ? editorState.timeline.selection+ ? sidebarSelection(): null}>@@ -1496,68 +1524,89 @@ export function ConfigSidebar() {return { selection: zoomSelection, segments };})()}>- {(value) => (- <div class="space-y-4">- <div class="flex flex-row justify-between items-center">- <div class="flex gap-2 items-center">+ {(value) => {+ const totalZoomSegments = () =>+ project.timeline?.zoomSegments?.length ?? 0;++ // The sidebar header is narrow, so the count stays terse and+ // "Select all" is an inline text action rather than a third+ // full button, which would wrap.+ const selectionLabel = () => {+ const count = value().segments.length;+ const total = totalZoomSegments();+ if (total > 1 && count === total)+ return `All ${total} selected`;+ if (total > 1) return `${count} of ${total} selected`;+ return `${count} selected`;+ };++ return (+ <div class="space-y-4">+ <div class="flex flex-row justify-between items-center">+ <div class="flex gap-2 items-center min-w-0">+ <EditorButton+ onClick={() =>+ setEditorState("timeline", "selection", null)+ }+ leftIcon={<IconLucideCheck />}+ >+ Done+ </EditorButton>+ <span class="text-sm text-gray-10 whitespace-nowrap">+ {selectionLabel()}+ </span>+ <Show+ when={value().segments.length < totalZoomSegments()}+ >+ <button+ type="button"+ class="text-sm font-medium whitespace-nowrap text-blue-11 hover:underline outline-hidden focus-visible:underline"+ onClick={() =>+ setEditorState("timeline", "selection", {+ type: "zoom",+ indices: Array.from(+ { length: totalZoomSegments() },+ (_, i) => i,+ ),+ })+ }+ >+ Select all+ </button>+ </Show>+ </div><EditorButton- onClick={() =>- setEditorState("timeline", "selection", null)- }- leftIcon={<IconLucideCheck />}+ variant="danger"+ onClick={() => {+ projectActions.deleteZoomSegments(+ value().segments.map((s) => s.index),+ );+ }}+ leftIcon={<IconCapTrash />}>- Done+ Delete</EditorButton>- <span class="text-sm text-gray-10">- {value().segments.length} zoom{" "}- {value().segments.length === 1- ? "segment"- : "segments"}{" "}- selected- </span></div>- <EditorButton- variant="danger"- onClick={() => {- projectActions.deleteZoomSegments(- value().segments.map((s) => s.index),- );- }}- leftIcon={<IconCapTrash />}+ <Show+ when={value().segments.length === 1}+ fallback={+ <ZoomMultiSegmentConfig segments={value().segments} />+ }>- Delete- </EditorButton>+ <For each={value().segments}>+ {(item) => (+ <div class="p-4 rounded-lg border border-gray-200">+ <ZoomSegmentConfig+ segment={item.segment}+ segmentIndex={item.index}+ />+ </div>+ )}+ </For>+ </Show></div>- <Show- when={value().segments.length === 1}- fallback={- <div class="grid grid-cols-3 gap-4">- <Index each={value().segments}>- {(item, index) => (- <div class="p-2.5 rounded-lg border border-gray-4 bg-gray-3">- <ZoomSegmentPreview- segment={item().segment}- segmentIndex={index}- />- </div>- )}- </Index>- </div>- }- >- <For each={value().segments}>- {(item) => (- <div class="p-4 rounded-lg border border-gray-200">- <ZoomSegmentConfig- segment={item.segment}- segmentIndex={item.index}- />- </div>- )}- </For>- </Show>- </div>- )}+ );+ }}</Show><Showwhen={(() => {@@ -1705,79 +1754,6 @@ export function ConfigSidebar() {</Show>)}</Show>- <Show- when={(() => {- const clipSelection = selection();- if (clipSelection.type !== "clip") return;-- const segments = clipSelection.indices- .map((idx) => ({- segment: project.timeline?.segments?.[idx],- index: idx,- }))- .filter(- (s): s is { segment: TimelineSegment; index: number } =>- s.segment !== undefined,- );-- if (segments.length === 0) return;- return { selection: clipSelection, segments };- })()}- >- {(value) => (- <Show when={value().segments[0]}>- {(firstSegment) => (- <Show- when={value().segments.length > 1}- fallback={- <ClipSegmentConfig- segment={firstSegment().segment}- segmentIndex={firstSegment().index}- />- }- >- <div class="space-y-4">- <div class="flex flex-row justify-between items-center">- <div class="flex gap-2 items-center">- <EditorButton- onClick={() =>- setEditorState("timeline", "selection", null)- }- leftIcon={<IconLucideCheck />}- >- Done- </EditorButton>- <span class="text-sm text-gray-10">- {value().segments.length} clip{" "}- {value().segments.length === 1- ? "segment"- : "segments"}{" "}- selected- </span>- </div>- <EditorButton- variant="danger"- onClick={() => {- const indices = value().selection.indices;-- // Delete segments in reverse order to maintain indices- [...indices]- .sort((a, b) => b - a)- .forEach((idx) => {- projectActions.deleteClipSegment(idx);- });- }}- leftIcon={<IconCapTrash />}- >- Delete- </EditorButton>- </div>- </div>- </Show>- )}- </Show>- )}- </Show></Suspense>)}</Show>@@ -3488,12 +3464,161 @@ function HexColorInput(props: {);}+function TextStyleSelect<T extends string | number>(props: {+ options: { label: string; value: T }[];+ value: T;+ onChange: (value: T) => void;+ fallbackLabel?: (value: T) => string;+}) {+ const selected = () =>+ props.options.find((option) => option.value === props.value) ?? {+ label: props.fallbackLabel?.(props.value) ?? String(props.value),+ value: props.value,+ };++ return (+ <KSelect+ options={props.options}+ optionValue="value"+ optionTextValue="label"+ value={selected()}+ onChange={(option) => {+ if (option) props.onChange(option.value);+ }}+ itemComponent={(selectItemProps) => (+ <MenuItem<typeof KSelect.Item>+ as={KSelect.Item}+ item={selectItemProps.item}+ >+ <KSelect.ItemLabel class="flex-1">+ {selectItemProps.item.rawValue.label}+ </KSelect.ItemLabel>+ <KSelect.ItemIndicator class="ml-auto text-blue-9">+ <IconCapCircleCheck />+ </KSelect.ItemIndicator>+ </MenuItem>+ )}+ >+ <KSelect.Trigger class="flex w-full items-center justify-between rounded-md border border-gray-3 bg-gray-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:border-gray-4 hover:bg-gray-3 focus:border-blue-9 focus:outline-hidden focus:ring-1 focus:ring-blue-9">+ <KSelect.Value<{ label: string; value: T }> class="truncate">+ {(state) => state.selectedOption()?.label ?? selected().label}+ </KSelect.Value>+ <KSelect.Icon>+ <IconCapChevronDown class="size-4 shrink-0 transform transition-transform data-expanded:rotate-180 text-(--gray-500)" />+ </KSelect.Icon>+ </KSelect.Trigger>+ <KSelect.Portal>+ <PopperContent<typeof KSelect.Content>+ as={KSelect.Content}+ class={cx(topSlideAnimateClasses, "z-50")}+ >+ <MenuItemList<typeof KSelect.Listbox>+ class="overflow-y-auto max-h-52"+ as={KSelect.Listbox}+ />+ </PopperContent>+ </KSelect.Portal>+ </KSelect>+ );+}++const TEXT_PRESET_HOVER_FX: Record<string, string> = {+ fade: "group-hover:opacity-70",+ slideUp: "group-hover:-translate-y-1",+ slideDown: "group-hover:translate-y-1",+ pop: "group-hover:scale-110",+ typewriter: "",+ none: "",+};++function TextPresetCard(props: {+ preset: TextPreset;+ active: boolean;+ onApply: () => void;+}) {+ const style = () => props.preset.style;+ const stackCss = () =>+ style()+ .fontStack.map((family) =>+ ["sans-serif", "serif", "monospace"].includes(family)+ ? family+ : `"${family}"`,+ )+ .join(", ");++ return (+ <button+ type="button"+ onClick={() => props.onApply()}+ class={cx(+ "group relative flex h-16 flex-col items-center justify-center overflow-hidden rounded-lg border px-2 pb-3 transition-colors",+ props.active+ ? "border-blue-9 ring-1 ring-blue-9"+ : "border-gray-3 hover:border-gray-5",+ )}+ style={{+ background: "linear-gradient(135deg, #17181c 0%, #2a2c33 100%)",+ }}+ >+ <span+ class={cx(+ "max-w-full truncate text-white transition-all duration-200",+ TEXT_PRESET_HOVER_FX[style().animationIn],+ )}+ style={{+ "font-family": stackCss(),+ "font-weight": String(style().fontWeight),+ "font-style": style().italic ? "italic" : "normal",+ "font-size": `${Math.min(Math.max(style().fontSize * 0.22, 11), 24)}px`,+ "letter-spacing": `${style().letterSpacing * 0.35}px`,+ "line-height": 1.1,+ "text-shadow":+ style().shadow > 0+ ? `0 1px 3px rgba(0, 0, 0, ${0.45 + style().shadow * 0.4})`+ : "none",+ }}+ >+ {props.preset.sample}+ </span>+ <span class="absolute inset-x-0 bottom-1 text-center text-[10px] font-medium text-white/50">+ {props.preset.name}+ </span>+ </button>+ );+}++// The renderer also supports splitLeft/splitRight takeovers; only these two+// are exposed for now.+const TEXT_LAYOUT_OPTIONS: {+ value: TextLayout;+ label: string;+ icon: ValidComponent;+}[] = [+ { value: "overlay", label: "Overlay", icon: IconLucideBoxSelect },+ { value: "fullscreen", label: "Fullscreen", icon: IconLucideMaximize },+];++const TEXT_LAYOUT_CENTERS: Partial<+ Record<TextLayout, { x: number; y: number }>+> = {+ fullscreen: { x: 0.5, y: 0.5 },+};++const TEXT_ALIGN_OPTIONS: { value: TextAlign; icon: ValidComponent }[] = [+ { value: "left", icon: IconLucideAlignLeft },+ { value: "center", icon: IconLucideAlignCenter },+ { value: "right", icon: IconLucideAlignRight },+];+function TextSegmentConfig(props: {segmentIndex: number;segment: TextSegment;brandColorSwatches: OrganizationBrandColorSwatch[];}) {const { setProject } = useEditorContext();+ const [installedFonts] = createResource(listSystemFonts, {+ initialValue: [],+ });const clampNumber = (value: number, min: number, max: number) =>Math.min(Math.max(Number.isFinite(value) ? value : min, min), max);@@ -3509,6 +3634,24 @@ function TextSegmentConfig(props: {);};+ const activePresetId = createMemo(() =>+ matchTextPreset(props.segment, installedFonts()),+ );++ const setAnimationDuration = (+ key: "animationInDuration" | "animationOutDuration",+ value: number,+ ) =>+ updateSegment((segment) => {+ segment[key] = clampNumber(value, 0, 3);+ // Old builds only know fadeDuration; keep it tracking the slower+ // edge so a project opened there still fades sensibly.+ segment.fadeDuration = Math.max(+ segment.animationInDuration ?? 0.15,+ segment.animationOutDuration ?? 0.15,+ );+ });+return (<div class="space-y-4"><Field@@ -3538,148 +3681,318 @@ function TextSegmentConfig(props: {</div></div></Field>- <Field name="Size" icon={<IconCapEnlarge class="size-4" />}>- <Slider- value={[- clampNumber(- props.segment.fontSize,- TEXT_FONT_SIZE_MIN,- TEXT_FONT_SIZE_MAX,- ),- ]}- onChange={([value]) =>- updateSegment((segment) => {- const newFontSize = clampNumber(- value,- TEXT_FONT_SIZE_MIN,- TEXT_FONT_SIZE_MAX,- );- const oldFontSize = segment.fontSize || 48;- const scale = newFontSize / oldFontSize;-- segment.fontSize = newFontSize;-- // Scale the box with the font so line wrapping is- // preserved; keep the top edge fixed since the renderer- // anchors text at the top of the box (the canvas overlay- // re-hugs the box to the exact glyph bounds when visible).- if (segment.size && segment.center) {- const topEdge = segment.center.y - segment.size.y / 2;- segment.size.x = Math.min(segment.size.x * scale, 1);- segment.size.y = segment.size.y * scale;- segment.center.y = topEdge + segment.size.y / 2;- }- })- }- minValue={TEXT_FONT_SIZE_MIN}- maxValue={TEXT_FONT_SIZE_MAX}- step={1}- />+ <Field name="Layout" icon={<IconLucideBoxSelect class="size-4" />}>+ <div class="flex flex-col gap-3">+ <div class="grid grid-cols-2 gap-1 rounded-lg border border-gray-3 bg-gray-2 p-1">+ <For each={TEXT_LAYOUT_OPTIONS}>+ {(option) => (+ <button+ type="button"+ title={option.label}+ class={cx(+ "flex flex-col items-center gap-1 rounded-md py-1.5 transition-colors",+ (props.segment.layout ?? "overlay") === option.value+ ? "bg-gray-5 text-gray-12"+ : "text-gray-10 hover:text-gray-12",+ )}+ onClick={() =>+ updateSegment((segment) => {+ if ((segment.layout ?? "overlay") === option.value)+ return;+ segment.layout = option.value;+ // A takeover layout implies where the text+ // belongs; place it there so the result reads+ // immediately (still draggable afterwards).+ const center = TEXT_LAYOUT_CENTERS[option.value];+ if (center) segment.center = { ...center };+ })+ }+ >+ <Dynamic component={option.icon} class="size-4" />+ <span class="text-[9px] font-medium leading-none">+ {option.label}+ </span>+ </button>+ )}+ </For>+ </div>+ <Show when={(props.segment.layout ?? "overlay") === "fullscreen"}>+ <p class="text-xs leading-snug text-gray-10">+ Pauses the video while the text is shown, then resumes where it+ left off.+ </p>+ </Show>+ <Show when={(props.segment.layout ?? "overlay") !== "overlay"}>+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Screen transition</span>+ <Slider+ value={[+ clampNumber(props.segment.layoutTransition ?? 0.5, 0.1, 1.5),+ ]}+ onChange={([value]) =>+ updateSegment((segment) => {+ segment.layoutTransition = clampNumber(value, 0.1, 1.5);+ })+ }+ minValue={0.1}+ maxValue={1.5}+ step={0.05}+ formatTooltip="s"+ />+ </div>+ </Show>+ </div>+ </Field>+ <Field name="Templates" icon={<IconLucideSparkles class="size-4" />}>+ <div class="grid grid-cols-2 gap-2">+ <For each={TEXT_PRESETS}>+ {(preset) => (+ <TextPresetCard+ preset={preset}+ active={activePresetId() === preset.id}+ onApply={() =>+ updateSegment((segment) =>+ applyTextPreset(segment, preset, installedFonts()),+ )+ }+ />+ )}+ </For>+ </div></Field>- <Field name="Style" icon={<IconLucideSparkles class="size-4" />}>+ <Field name="Font" icon={<IconLucideType class="size-4" />}><div class="flex flex-col gap-2">- <KSelect- options={[- { label: "Normal", value: 400 },- { label: "Medium", value: 500 },- { label: "Bold", value: 700 },- ]}- optionValue="value"- optionTextValue="label"- value={{- label: "Custom",- value: props.segment.fontWeight,- }}- onChange={(value) => {- if (!value) return;+ <FontPicker+ value={props.segment.fontFamily ?? "sans-serif"}+ onChange={(family) =>updateSegment((segment) => {- segment.fontWeight = value.value;- });- }}- itemComponent={(selectItemProps) => (- <MenuItem<typeof KSelect.Item>- as={KSelect.Item}- item={selectItemProps.item}- >- <KSelect.ItemLabel class="flex-1">- {selectItemProps.item.rawValue.label}- </KSelect.ItemLabel>- <KSelect.ItemIndicator class="ml-auto text-blue-9">- <IconCapCircleCheck />- </KSelect.ItemIndicator>- </MenuItem>- )}- >- <KSelect.Trigger class="flex w-full items-center justify-between rounded-md border border-gray-3 bg-gray-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:border-gray-4 hover:bg-gray-3 focus:border-blue-9 focus:outline-hidden focus:ring-1 focus:ring-blue-9">- <KSelect.Value<{ label: string; value: number }> class="truncate">- {(state) => {- const selected = state.selectedOption();- if (selected) return selected.label;- const weight = props.segment.fontWeight;- const option = [- { label: "Normal", value: 400 },- { label: "Medium", value: 500 },- { label: "Bold", value: 700 },- ].find((o) => o.value === weight);- if (option) return option.label;- if (weight != null) return `Custom (${weight})`;- return "Normal";- }}- </KSelect.Value>- <KSelect.Icon>- <IconCapChevronDown class="size-4 shrink-0 transform transition-transform data-expanded:rotate-180 text-(--gray-500)" />- </KSelect.Icon>- </KSelect.Trigger>- <KSelect.Portal>- <PopperContent<typeof KSelect.Content>- as={KSelect.Content}- class={cx(topSlideAnimateClasses, "z-50")}- >- <MenuItemList<typeof KSelect.Listbox>- class="overflow-y-auto max-h-40"- as={KSelect.Listbox}- />- </PopperContent>- </KSelect.Portal>- </KSelect>-- <div class="flex items-center justify-between pt-1">- <span class="text-xs text-gray-11">Italic</span>- <Toggle- checked={props.segment.italic}- onChange={(value) =>+ segment.fontFamily = family;+ })+ }+ />+ <div class="flex items-center gap-2">+ <div class="flex-1">+ <TextStyleSelect+ options={TEXT_SEGMENT_WEIGHT_OPTIONS}+ value={props.segment.fontWeight}+ onChange={(value) =>+ updateSegment((segment) => {+ segment.fontWeight = value;+ })+ }+ fallbackLabel={(value) => `Custom (${value})`}+ />+ </div>+ <button+ type="button"+ title="Italic"+ class={cx(+ "flex size-9 shrink-0 items-center justify-center rounded-md border transition-colors",+ props.segment.italic+ ? "border-blue-9 bg-blue-9/10 text-blue-9"+ : "border-gray-3 bg-gray-2 text-gray-11 hover:bg-gray-3",+ )}+ onClick={() =>+ updateSegment((segment) => {+ segment.italic = !segment.italic;+ })+ }+ >+ <IconLucideItalic class="size-4" />+ </button>+ </div>+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Size</span>+ <Slider+ value={[+ clampNumber(+ props.segment.fontSize,+ TEXT_FONT_SIZE_MIN,+ TEXT_FONT_SIZE_MAX,+ ),+ ]}+ onChange={([value]) =>updateSegment((segment) => {- segment.italic = value;+ const newFontSize = clampNumber(+ value,+ TEXT_FONT_SIZE_MIN,+ TEXT_FONT_SIZE_MAX,+ );+ const oldFontSize = segment.fontSize || 48;+ const scale = newFontSize / oldFontSize;++ segment.fontSize = newFontSize;++ // Scale the box with the font so line wrapping is+ // preserved; keep the top edge fixed since the renderer+ // anchors text at the top of the box (the canvas overlay+ // re-hugs the box to the exact glyph bounds when visible).+ if (segment.size && segment.center) {+ const topEdge = segment.center.y - segment.size.y / 2;+ segment.size.x = Math.min(segment.size.x * scale, 1);+ segment.size.y = segment.size.y * scale;+ segment.center.y = topEdge + segment.size.y / 2;+ }})}+ minValue={TEXT_FONT_SIZE_MIN}+ maxValue={TEXT_FONT_SIZE_MAX}+ step={1}/></div></div></Field>- <Field name="Color" icon={<IconLucidePalette class="size-4" />}>- <HexColorInput- value={props.segment.color}- brandColorSwatches={props.brandColorSwatches}- onChange={(value) =>- updateSegment((segment) => {- segment.color = value;- })- }- />+ <Field name="Layout" icon={<IconLucideAlignCenter class="size-4" />}>+ <div class="flex flex-col gap-3">+ <div class="grid grid-cols-3 gap-1 rounded-lg border border-gray-3 bg-gray-2 p-1">+ <For each={TEXT_ALIGN_OPTIONS}>+ {(option) => (+ <button+ type="button"+ class={cx(+ "flex items-center justify-center rounded-md py-1.5 transition-colors",+ (props.segment.align ?? "center") === option.value+ ? "bg-gray-5 text-gray-12"+ : "text-gray-10 hover:text-gray-12",+ )}+ onClick={() =>+ updateSegment((segment) => {+ segment.align = option.value;+ })+ }+ >+ <Dynamic component={option.icon} class="size-4" />+ </button>+ )}+ </For>+ </div>+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Line height</span>+ <Slider+ value={[clampNumber(props.segment.lineHeight ?? 1.2, 0.8, 2)]}+ onChange={([value]) =>+ updateSegment((segment) => {+ segment.lineHeight = clampNumber(value, 0.8, 2);+ })+ }+ minValue={0.8}+ maxValue={2}+ step={0.05}+ />+ </div>+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Letter spacing</span>+ <Slider+ value={[clampNumber(props.segment.letterSpacing ?? 0, -2, 20)]}+ onChange={([value]) =>+ updateSegment((segment) => {+ segment.letterSpacing = clampNumber(value, -2, 20);+ })+ }+ minValue={-2}+ maxValue={20}+ step={0.5}+ formatTooltip="px"+ />+ </div>+ </div></Field>- <Field name="Fade Duration" icon={<IconLucideTimer class="size-4" />}>- <Slider- value={[clampNumber(props.segment.fadeDuration ?? 0.15, 0, 1)]}- onChange={([value]) =>- updateSegment((segment) => {- segment.fadeDuration = clampNumber(value, 0, 1);- })- }- minValue={0}- maxValue={1}- step={0.01}- formatTooltip="s"- />+ <Field name="Color" icon={<IconLucidePalette class="size-4" />}>+ <div class="flex flex-col gap-3">+ <HexColorInput+ value={props.segment.color}+ brandColorSwatches={props.brandColorSwatches}+ onChange={(value) =>+ updateSegment((segment) => {+ segment.color = value;+ })+ }+ />+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Opacity</span>+ <Slider+ value={[clampNumber(props.segment.opacity ?? 1, 0, 1)]}+ onChange={([value]) =>+ updateSegment((segment) => {+ segment.opacity = clampNumber(value, 0, 1);+ })+ }+ minValue={0}+ maxValue={1}+ step={0.01}+ />+ </div>+ <div class="flex flex-col gap-1">+ <span class="text-xs text-gray-11">Shadow</span>+ <Slider+ value={[clampNumber(props.segment.shadow ?? 0, 0, 1)]}+ onChange={([value]) =>+ updateSegment((segment) => {+ segment.shadow = clampNumber(value, 0, 1);+ })+ }+ minValue={0}+ maxValue={1}+ step={0.01}+ />+ </div>+ </div>+ </Field>+ <Field name="Animation" icon={<IconLucideTimer class="size-4" />}>+ <div class="flex flex-col gap-3">+ <div class="flex flex-col gap-2">+ <span class="text-xs text-gray-11">In</span>+ <TextStyleSelect+ options={TEXT_ANIMATION_OPTIONS}+ value={props.segment.animationIn ?? "fade"}+ onChange={(value) =>+ updateSegment((segment) => {+ segment.animationIn = value;+ })+ }+ />+ <Show when={(props.segment.animationIn ?? "fade") !== "none"}>+ <Slider+ value={[+ clampNumber(props.segment.animationInDuration ?? 0.15, 0, 3),+ ]}+ onChange={([value]) =>+ setAnimationDuration("animationInDuration", value)+ }+ minValue={0}+ maxValue={3}+ step={0.05}+ formatTooltip="s"+ />+ </Show>+ </div>+ <div class="flex flex-col gap-2">+ <span class="text-xs text-gray-11">Out</span>+ <TextStyleSelect+ options={TEXT_ANIMATION_OPTIONS}+ value={props.segment.animationOut ?? "fade"}+ onChange={(value) =>+ updateSegment((segment) => {+ segment.animationOut = value;+ })+ }+ />+ <Show when={(props.segment.animationOut ?? "fade") !== "none"}>+ <Slider+ value={[+ clampNumber(props.segment.animationOutDuration ?? 0.15, 0, 3),+ ]}+ onChange={([value]) =>+ setAnimationDuration("animationOutDuration", value)+ }+ minValue={0}+ maxValue={3}+ step={0.05}+ formatTooltip="s"+ />+ </Show>+ </div>+ </div></Field></div>);@@ -5116,32 +5429,57 @@ function Camera3DSegmentConfig(props: {);}+// Maps a zoom segment's start (held-output time on the edited timeline) to+// the recording-segment file and the time within it whose frame is on screen+// at that moment. Split/trimmed timelines mean neither can be read off the+// zoom segment directly.+function zoomPreviewSource(+ timeline:+ | {+ segments: TimelineSegment[];+ transitions?: ClipTransition[];+ textSegments?: TextSegment[];+ }+ | null+ | undefined,+ editedTime: number,+): { recordingSegment: number; sourceTime: number } {+ const gapless =+ editedTime -+ heldTimeBefore(holdWindows(timeline?.textSegments), editedTime);+ return (+ clipSourceTimeAt(+ timeline?.segments ?? [],+ timeline?.transitions ?? [],+ gapless,+ ) ?? { recordingSegment: 0, sourceTime: gapless }+ );+}++// The mapping memos return fresh objects; compare by value so unrelated+// timeline edits don't restart the preview <video>.+const zoomPreviewSourceEquals = (+ a: { recordingSegment: number; sourceTime: number },+ b: { recordingSegment: number; sourceTime: number },+) => a.recordingSegment === b.recordingSegment && a.sourceTime === b.sourceTime;+function ZoomSegmentPreview(props: {segmentIndex: number;segment: ZoomSegment;}) {const { project, editorInstance } = useEditorContext();- const start = createMemo(() => props.segment.start);-- const clipSegment = createMemo(() => {- const st = start();- return project.timeline?.segments.find((s) => s.start <= st && s.end > st);- });-- const relativeTime = createMemo(() => {- const st = start();- const segment = clipSegment();- if (!segment) return 0;- return Math.max(0, st - segment.start);- });+ const source = createMemo(+ () => zoomPreviewSource(project.timeline, props.segment.start),+ undefined,+ { equals: zoomPreviewSourceEquals },+ );const video = document.createElement("video");createEffect(() => {- // TODO: make this not hardcodedconst path = convertFileSrc(`${editorInstance.path}/content/segments/segment-${- clipSegment()?.recordingSegment ?? 0+ source().recordingSegment}/display.mp4`,);video.src = path;@@ -5150,8 +5488,7 @@ function ZoomSegmentPreview(props: {});createEffect(() => {- const t = relativeTime();- if (t === undefined) return;+ const t = source().sourceTime;if (video.readyState >= 2) {video.currentTime = t;@@ -5173,7 +5510,10 @@ function ZoomSegmentPreview(props: {ctx.imageSmoothingEnabled = false;ctx.clearRect(0, 0, canvasRef.width, canvasRef.height);- const raw = editorInstance.recordings.segments[0].display;+ const raw = (+ editorInstance.recordings.segments[source().recordingSegment] ??+ editorInstance.recordings.segments[0]+ ).display;const croppedPosition = project.background.crop?.position || { x: 0, y: 0 };const croppedSize = project.background.crop?.size || {x: raw.width,@@ -5304,6 +5644,17 @@ function ZoomSegmentConfig(props: {<div class="flex-1 bg-gray-3" /></KTabs.Indicator></KTabs.List>+ <div class="space-y-3">+ <Show when={!generalSettings.data?.custom_cursor_capture2}>+ <p class="text-xs text-gray-11">+ Auto mode needs cursor capture. Enable "Custom cursor capture+ (Studio)" in Settings → General.+ </p>+ </Show>+ <ZoomModeHelper+ mode={props.segment.mode === "auto" ? "auto" : "manual"}+ />+ </div><KTabs.Content value="manual" tabIndex=""><Showwhen={(() => {@@ -5314,39 +5665,30 @@ function ZoomSegmentConfig(props: {})()}>{(mode) => {- const start = createMemo<number>((prev) => {- if (projectHistory.isPaused()) return prev;-- return props.segment.start;- }, 0);-- const segmentIndex = createMemo<number>((prev) => {- if (projectHistory.isPaused()) return prev;-- const st = start();- const i = project.timeline?.segments.findIndex(- (s) => s.start <= st && s.end > st,- );- if (i === undefined || i === -1) return 0;- return i;- }, 0);-- // Calculate the time relative to the video segment- const relativeTime = createMemo(() => {- const st = start();- const segment = project.timeline?.segments[segmentIndex()];- if (!segment) return 0;- // The time within the actual video file- return Math.max(0, st - segment.start);- });+ // Frozen while history is paused so drags don't thrash the+ // <video> seek.+ const source = createMemo<{+ recordingSegment: number;+ sourceTime: number;+ }>(+ (prev) => {+ if (projectHistory.isPaused()) return prev;++ return zoomPreviewSource(+ project.timeline,+ props.segment.start,+ );+ },+ { recordingSegment: 0, sourceTime: 0 },+ { equals: zoomPreviewSourceEquals },+ );const video = document.createElement("video");createEffect(() => {const path = convertFileSrc(- // TODO: this shouldn't be so hardcoded- `${- editorInstance.path- }/content/segments/segment-${segmentIndex()}/display.mp4`,+ `${editorInstance.path}/content/segments/segment-${+ source().recordingSegment+ }/display.mp4`,);video.src = path;video.preload = "auto";@@ -5355,8 +5697,7 @@ function ZoomSegmentConfig(props: {});createEffect(() => {- const t = relativeTime();- if (t === undefined) return;+ const t = source().sourceTime;// Ensure video is ready before seekingif (video.readyState >= 2) {@@ -5429,7 +5770,11 @@ function ZoomSegmentConfig(props: {const [ref, setRef] = createSignal<HTMLDivElement>();const bounds = createElementBounds(ref);const rawSize = () => {- const raw = editorInstance.recordings.segments[0].display;+ const raw = (+ editorInstance.recordings.segments[+ source().recordingSegment+ ] ?? editorInstance.recordings.segments[0]+ ).display;return { x: raw.width, y: raw.height };};@@ -5531,192 +5876,303 @@ function ZoomSegmentConfig(props: {);}-function ClipSegmentConfig(props: {- segmentIndex: number;- segment: TimelineSegment;+// Bulk editor shown when multiple zoom segments are selected: one set of+// controls that writes to every selected segment, with "Mixed" badges when+// the selected segments' values differ.+function ZoomMultiSegmentConfig(props: {+ segments: { index: number; segment: ZoomSegment }[];}) {- const { setProject, setEditorState, project, projectActions, meta } =- useEditorContext();+ const generalSettings = generalSettingsStore.createQuery();+ const { setProject, setEditorState } = useEditorContext();++ const amounts = () => props.segments.map((s) => s.segment.amount);+ const sharedAmount = () => {+ const [first, ...rest] = amounts();+ if (first === undefined) return null;+ return rest.every((a) => a === first) ? first : null;+ };+ const averageAmount = () => {+ const values = amounts();+ if (values.length === 0) return 1;+ return values.reduce((sum, v) => sum + v, 0) / values.length;+ };++ const sharedMode = (): "auto" | "manual" | "mixed" => {+ const modes = props.segments.map((s) =>+ s.segment.mode === "auto" ? ("auto" as const) : ("manual" as const),+ );+ const [first, ...rest] = modes;+ if (first === undefined) return "mixed";+ return rest.every((m) => m === first) ? first : "mixed";+ };++ const manualPositions = () =>+ props.segments.map((s) =>+ s.segment.mode === "auto" ? { x: 0.5, y: 0.5 } : s.segment.mode.manual,+ );++ const manualPositionsMixed = () => {+ const [first, ...rest] = manualPositions();+ if (!first) return false;+ return rest.some((p) => p.x !== first.x || p.y !== first.y);+ };++ const averageManualPosition = () => {+ const positions = manualPositions();+ if (positions.length === 0) return { x: 0.5, y: 0.5 };+ return {+ x: positions.reduce((sum, p) => sum + p.x, 0) / positions.length,+ y: positions.reduce((sum, p) => sum + p.y, 0) / positions.length,+ };+ };++ const setAllAmounts = (amount: number) =>+ batch(() => {+ for (const { index } of props.segments)+ setProject("timeline", "zoomSegments", index, "amount", amount);+ });++ // Switching to manual keeps each segment's existing focal point; only+ // segments coming from auto get the centered default.+ const setAllModes = (mode: "auto" | "manual") =>+ batch(() => {+ for (const { index, segment } of props.segments) {+ if (mode === "auto")+ setProject("timeline", "zoomSegments", index, "mode", "auto");+ else if (segment.mode === "auto")+ setProject("timeline", "zoomSegments", index, "mode", {+ manual: { x: 0.5, y: 0.5 },+ });+ }+ });- // Get current clip configuration- const clipConfig = () =>- project.clips?.find((c) => c.index === props.segmentIndex);- const offsets = () => clipConfig()?.offsets || {};- const offsetsAutoCalculated = () =>- clipConfig()?.offsetsAutoCalculated === true;+ const setAllManualPositions = (pos: XY<number>) =>+ batch(() => {+ for (const { index } of props.segments)+ setProject("timeline", "zoomSegments", index, "mode", {+ manual: { ...pos },+ });+ });- function setOffset(type: keyof ClipOffsets, offset: number) {- if (Number.isNaN(offset)) return;+ const removeFromSelection = (segmentIndex: number) => {+ const remaining = props.segments+ .map((s) => s.index)+ .filter((index) => index !== segmentIndex);+ setEditorState(+ "timeline",+ "selection",+ remaining.length > 0 ? { type: "zoom", indices: remaining } : null,+ );+ };++ const modeButtonClass =+ "flex-1 py-2.5 rounded-[0.6rem] text-gray-11 transition-colors duration-100 outline-hidden data-[selected='true']:bg-gray-3 data-[selected='true']:text-gray-12 not-data-[selected='true']:hover:text-gray-12 disabled:opacity-40 disabled:cursor-not-allowed";++ return (+ <div class="space-y-4">+ <div class="flex flex-col gap-6 p-4 rounded-lg border border-gray-200">+ <Field+ name="Zoom Amount"+ icon={<IconLucideSearch />}+ value={+ <Show when={sharedAmount() === null}>+ <span class="text-[10px] px-1.5 py-0.5 bg-gray-3 rounded-full text-gray-11 font-medium">+ Mixed+ </span>+ </Show>+ }+ >+ <Slider+ value={[sharedAmount() ?? averageAmount()]}+ onChange={(v) => setAllAmounts(v[0])}+ minValue={1}+ maxValue={4.5}+ step={0.001}+ formatTooltip="x"+ />+ </Field>+ <Field+ name="Zoom Mode"+ icon={<IconCapSettings />}+ value={+ <Show when={sharedMode() === "mixed"}>+ <span class="text-[10px] px-1.5 py-0.5 bg-gray-3 rounded-full text-gray-11 font-medium">+ Mixed+ </span>+ </Show>+ }+ >+ <div class="flex flex-row items-center p-px rounded-lg border">+ <button+ type="button"+ disabled={!generalSettings.data?.custom_cursor_capture2}+ data-selected={sharedMode() === "auto"}+ onClick={() => setAllModes("auto")}+ class={modeButtonClass}+ >+ Auto+ </button>+ <button+ type="button"+ data-selected={sharedMode() === "manual"}+ onClick={() => setAllModes("manual")}+ class={modeButtonClass}+ >+ Manual+ </button>+ </div>+ <Show when={!generalSettings.data?.custom_cursor_capture2}>+ <p class="text-xs text-gray-11">+ Auto mode needs cursor capture. Enable "Custom cursor capture+ (Studio)" in Settings → General.+ </p>+ </Show>+ <Show+ when={(() => {+ const mode = sharedMode();+ return mode === "mixed" ? null : mode;+ })()}+ >+ {(mode) => <ZoomModeHelper mode={mode()} />}+ </Show>+ <Show when={sharedMode() === "manual"}>+ <div class="space-y-1.5">+ <PositionPad+ value={averageManualPosition}+ onChange={setAllManualPositions}+ />+ <Show when={manualPositionsMixed()}>+ <p class="text-xs text-gray-10">+ Segments zoom into different spots. Drag to move them all to+ the same one.+ </p>+ </Show>+ </div>+ </Show>+ </Field>+ </div>+ <div class="grid grid-cols-3 gap-4">+ <Index each={[...props.segments].sort((a, b) => a.index - b.index)}>+ {(item) => (+ <div class="relative p-2.5 rounded-lg border border-gray-4 bg-gray-3 group">+ <button+ type="button"+ class="hidden absolute top-1.5 right-1.5 z-10 justify-center items-center rounded-full transition-colors group-hover:flex bg-gray-5 hover:bg-gray-6 text-gray-11 hover:text-gray-12 size-5"+ aria-label="Remove from selection"+ onClick={() => removeFromSelection(item().index)}+ >+ <IconLucideX class="size-3" />+ </button>+ <ZoomSegmentPreview+ segment={item().segment}+ segmentIndex={item().index}+ />+ </div>+ )}+ </Index>+ </div>+ </div>+ );+}++// A/V sync offsets are per recording segment (project.clips is keyed by+// recording segment index), so they live with the audio settings rather+// than any one timeline segment.+function SyncOffsetsConfig() {+ const { project, setProject, editorInstance, meta } = useEditorContext();++ const clipConfig = (recordingIndex: number) =>+ project.clips?.find((c) => c.index === recordingIndex);++ const hasAnySource = () =>+ meta().hasSystemAudio || meta().hasMicrophone || meta().hasCamera;++ function setOffset(+ recordingIndex: number,+ type: keyof ClipOffsets,+ offsetMs: number,+ ) {+ if (Number.isNaN(offsetMs)) return;setProject(produce((proj) => {if (!proj.clips) proj.clips = [];- const clips = proj.clips;- let clip = clips.find(- (clip) => clip.index === (props.segment.recordingSegment ?? 0),- );+ let clip = proj.clips.find((c) => c.index === recordingIndex);if (!clip) {- clip = { index: 0, offsets: {} };- clips.push(clip);+ clip = { index: recordingIndex, offsets: {} };+ proj.clips.push(clip);}- clip.offsets[type] = offset / 1000;+ clip.offsets[type] = offsetMs / 1000;clip.offsetsAutoCalculated = false;}),);}- function setSpeedAudioMode(value: string) {- if (- value === "mute" ||- value === "maintainPitch" ||- value === "matchSpeed"- ) {- projectActions.setClipSegmentSpeedAudioMode(- props.segmentIndex,- value satisfies ClipSpeedAudioMode,- );- }- }-return (- <>- <div class="flex flex-row justify-between items-center">- <div class="flex gap-2 items-center">- <EditorButton- onClick={() => setEditorState("timeline", "selection", null)}- leftIcon={<IconLucideCheck />}- >- Done- </EditorButton>- </div>- <EditorButton- variant="danger"- onClick={() => {- projectActions.deleteClipSegment(props.segmentIndex);- }}- disabled={(project.timeline?.segments.length ?? 0) < 2}- leftIcon={<IconCapTrash />}- >- Delete- </EditorButton>- </div>-- <div class="space-y-0.5">- <h3 class="font-medium text-gray-12">Segment Settings</h3>- <p class="text-gray-11">- These settings apply to only the selected segment- </p>- </div>-- <Field name="Speed" icon={<IconLucideFastForward class="size-4" />}>- <KRadioGroup- class="flex flex-row gap-1.5 -mt-1"- value={props.segment.timescale.toString()}- onChange={(v) => {- projectActions.setClipSegmentTimescale(- props.segmentIndex,- parseFloat(v),- );- }}- >- <For each={[0.25, 0.5, 1, 1.5, 2, 4, 8]}>- {(mult) => (- <KRadioGroup.Item value={mult.toString()}>- <KRadioGroup.ItemControl class="px-2 py-1 text-gray-11 hover:text-gray-12 bg-gray-1 border border-gray-3 rounded-md data-checked:bg-gray-3 data-checked:border-gray-4 data-checked:text-gray-12">- {mult}x- </KRadioGroup.ItemControl>- </KRadioGroup.Item>- )}- </For>- </KRadioGroup>-- <Show when={props.segment.timescale !== 1}>- <div class="space-y-2 pt-2">- <p class="text-gray-11">- Mute is fastest. Maintain pitch keeps voices natural, while Match- speed raises or lowers pitch with playback speed.- </p>- <KRadioGroup- class="grid grid-cols-3 gap-1.5"- value={props.segment.speedAudioMode ?? "mute"}- onChange={setSpeedAudioMode}- >- <For- each={[- { value: "mute", label: "Mute" },- { value: "maintainPitch", label: "Maintain pitch" },- { value: "matchSpeed", label: "Match speed" },- ]}- >- {(option) => (- <KRadioGroup.Item value={option.value}>- <KRadioGroup.ItemControl class="w-full px-2 py-1.5 text-xs text-gray-11 hover:text-gray-12 bg-gray-1 border border-gray-3 rounded-md data-checked:bg-gray-3 data-checked:border-gray-4 data-checked:text-gray-12">- {option.label}- </KRadioGroup.ItemControl>- </KRadioGroup.Item>- )}- </For>- </KRadioGroup>- </div>- </Show>- </Field>-- <div class="space-y-0.5 pt-2">- <h3 class="font-medium text-gray-12">Clip Settings</h3>- <p class="text-gray-11">- These settings apply to all segments for the current clip- </p>- <Show when={offsetsAutoCalculated()}>+ <Show when={hasAnySource()}>+ <div class="flex flex-col gap-6">+ <div class="space-y-0.5">+ <h3 class="font-medium text-gray-12">Sync</h3><p class="text-gray-11">- Cap calculated these offsets automatically to keep audio in sync- with the video. Adjust them if anything still sounds off.+ Fine-tune source offsets if audio or camera drifts out of sync with+ the screen recording.</p>- </Show>- </div>-- {meta().hasSystemAudio && (- <SourceOffsetField- name="System Audio Offset"- value={offsets().system_audio}- autoCalculated={offsetsAutoCalculated()}- onChange={(offset) => {- setOffset("system_audio", offset);- }}- />- )}- {meta().hasMicrophone && (- <SourceOffsetField- name="Microphone Offset"- value={offsets().mic}- autoCalculated={offsetsAutoCalculated()}- onChange={(offset) => {- setOffset("mic", offset);- }}- />- )}- {meta().hasCamera && (- <SourceOffsetField- name="Camera Offset"- value={offsets().camera}- autoCalculated={offsetsAutoCalculated()}- onChange={(offset) => {- setOffset("camera", offset);- }}- />- )}+ </div>- {/*<ComingSoonTooltip>- <Field name="Hide Cursor" disabled value={<Toggle disabled />} />- </ComingSoonTooltip>- <ComingSoonTooltip>- <Field- name="Disable Smooth Cursor Movement"- disabled- value={<Toggle disabled />}- />- </ComingSoonTooltip>*/}- </>+ <For each={editorInstance.recordings.segments}>+ {(_, index) => (+ <div class="flex flex-col gap-6">+ <Show when={editorInstance.recordings.segments.length > 1}>+ <span class="font-medium text-gray-12">Clip {index()}</span>+ </Show>+ <Show when={clipConfig(index())?.offsetsAutoCalculated === true}>+ <p class="text-gray-11">+ Cap calculated these offsets automatically to keep audio in+ sync with the video. Adjust them if anything still sounds off.+ </p>+ </Show>+ {meta().hasSystemAudio && (+ <SourceOffsetField+ name="System Audio Offset"+ value={clipConfig(index())?.offsets.system_audio}+ autoCalculated={+ clipConfig(index())?.offsetsAutoCalculated === true+ }+ onChange={(offset) => {+ setOffset(index(), "system_audio", offset);+ }}+ />+ )}+ {meta().hasMicrophone && (+ <SourceOffsetField+ name="Microphone Offset"+ value={clipConfig(index())?.offsets.mic}+ autoCalculated={+ clipConfig(index())?.offsetsAutoCalculated === true+ }+ onChange={(offset) => {+ setOffset(index(), "mic", offset);+ }}+ />+ )}+ {meta().hasCamera && (+ <SourceOffsetField+ name="Camera Offset"+ value={clipConfig(index())?.offsets.camera}+ autoCalculated={+ clipConfig(index())?.offsetsAutoCalculated === true+ }+ onChange={(offset) => {+ setOffset(index(), "camera", offset);+ }}+ />+ )}+ </div>+ )}+ </For>+ </div>+ </Show>);}diff --git a/apps/desktop/src/routes/editor/TextOverlay.tsx b/apps/desktop/src/routes/editor/TextOverlay.tsxindex 41a3e5192..3d527d99b 100644--- a/apps/desktop/src/routes/editor/TextOverlay.tsx+++ b/apps/desktop/src/routes/editor/TextOverlay.tsx@@ -23,6 +23,7 @@ import {TEXT_FONT_SIZE_MAX,TEXT_FONT_SIZE_MIN,TEXT_REFERENCE_HEIGHT,+ type TextAlign,type TextSegment,} from "./text";@@ -264,9 +265,16 @@ type SegmentWithDefaults = {fontWeight: number;italic: boolean;color: string;+ align: TextAlign;+ letterSpacing: number;+ lineHeight: number;};function normalizeSegment(segment: TauriTextSegment): SegmentWithDefaults {+ // The generated bindings lag behind the Rust schema until the next debug+ // run regenerates them; the style fields are always present at runtime.+ const styled = segment as TauriTextSegment &+ Partial<Pick<TextSegment, "align" | "letterSpacing" | "lineHeight">>;return {start: segment.start,end: segment.end,@@ -279,6 +287,9 @@ function normalizeSegment(segment: TauriTextSegment): SegmentWithDefaults {fontWeight: segment.fontWeight ?? 700,italic: segment.italic ?? false,color: segment.color ?? "#ffffff",+ align: styled.align ?? "center",+ letterSpacing: styled.letterSpacing ?? 0,+ lineHeight: styled.lineHeight ?? 1.2,};}@@ -358,9 +369,10 @@ function TextSegmentOverlay(props: {};// Fit the stored box to the measured text. The box adapts to the glyphs,- // never the other way around: the top edge and horizontal center stay- // fixed (the renderer anchors text at the top of the box and centers each- // line), so a hug never moves pixels on screen.+ // never the other way around: the top edge stays fixed (the renderer+ // anchors text at the top of the box) and the horizontal edge the text is+ // aligned to stays pinned — center for centered text, left/right edge for+ // left/right-aligned — so a hug never moves pixels on screen.const applyHug = () => {const ink = measureInk();if (!ink) return;@@ -372,8 +384,16 @@ function TextSegmentOverlay(props: {Math.abs(ink.y - seg.size.y) < epsY)return;+ const align = seg.align;props.updateSegment((s) => {const topEdge = s.center.y - s.size.y / 2;+ if (align === "left") {+ const leftEdge = s.center.x - s.size.x / 2;+ s.center.x = leftEdge + ink.x / 2;+ } else if (align === "right") {+ const rightEdge = s.center.x + s.size.x / 2;+ s.center.x = rightEdge - ink.x / 2;+ }s.size.x = ink.x;s.size.y = ink.y;s.center.y = topEdge + ink.y / 2;@@ -388,6 +408,9 @@ function TextSegmentOverlay(props: {fontWeight: segment().fontWeight,fontFamily: segment().fontFamily,italic: segment().italic,+ align: segment().align,+ letterSpacing: segment().letterSpacing,+ lineHeight: segment().lineHeight,width: props.size.width,height: props.size.height,}),@@ -695,12 +718,18 @@ function TextSegmentOverlay(props: {top: rect().top >= 28 ? "-24px" : `${Math.max(6, 6 - rect().top)}px`,});+ // Letter spacing is authored in px at the 1080p reference height, like+ // fontSize; scale it to preview px the same way.+ const letterSpacingPx = () =>+ (segment().letterSpacing * props.size.height) / TEXT_REFERENCE_HEIGHT;+const textStyle = () => ({"font-family": segment().fontFamily,"font-size": `${fontPx()}px`,"font-weight": segment().fontWeight,"font-style": segment().italic ? "italic" : "normal",- "line-height": 1.2,+ "line-height": segment().lineHeight,+ "letter-spacing": `${letterSpacingPx()}px`,});return (@@ -765,9 +794,10 @@ function TextSegmentOverlay(props: {<Show when={editing()}><textarearef={textareaRef}- class="absolute inset-0 p-0 text-center bg-transparent border-none outline-none resize-none overflow-hidden"+ class="absolute inset-0 p-0 bg-transparent border-none outline-none resize-none overflow-hidden"style={{...textStyle(),+ "text-align": segment().align,color: segment().color,"caret-color": segment().color,"white-space": "pre-wrap",diff --git a/apps/desktop/src/routes/editor/ZoomModeHelper.tsx b/apps/desktop/src/routes/editor/ZoomModeHelper.tsxnew file mode 100644index 000000000..ddcdbfab5--- /dev/null+++ b/apps/desktop/src/routes/editor/ZoomModeHelper.tsx@@ -0,0 +1,62 @@+import { Collapsible as KCollapsible } from "@kobalte/core/collapsible";+import IconLucideInfo from "~icons/lucide/info";++export function ZoomModeHelper(props: { mode: "auto" | "manual" }) {+ return (+ <KCollapsible>+ <KCollapsible.Trigger class="flex flex-row gap-1.5 items-center w-full text-xs font-medium transition-colors duration-200 group text-gray-11 hover:text-gray-12 outline-hidden">+ <IconLucideInfo class="size-3.5" />+ How does it work?+ <IconCapChevronDown class="ml-auto transition-transform duration-200 size-3.5 group-data-expanded:rotate-180" />+ </KCollapsible.Trigger>+ <KCollapsible.Content class="overflow-hidden opacity-0 transition-opacity animate-collapsible-up data-expanded:animate-collapsible-down data-expanded:opacity-100">+ <div class="pt-2 space-y-1.5">+ <style>+ {`+ @keyframes cap-zoom-mode-helper-path {+ 0% { left: 26%; top: 36%; }+ 30% { left: 72%; top: 30%; }+ 55% { left: 64%; top: 68%; }+ 80% { left: 32%; top: 64%; }+ 100% { left: 26%; top: 36%; }+ }+ .cap-zoom-mode-helper-cursor,+ .cap-zoom-mode-helper-viewport-auto {+ left: 26%;+ top: 36%;+ animation: cap-zoom-mode-helper-path 7s ease-in-out infinite;+ }+ .cap-zoom-mode-helper-viewport-auto {+ animation-delay: 0.35s;+ }+ @media (prefers-reduced-motion: reduce) {+ .cap-zoom-mode-helper-cursor,+ .cap-zoom-mode-helper-viewport-auto {+ animation: none;+ }+ }+ `}+ </style>+ <div class="overflow-hidden relative w-full rounded-lg border bg-gray-3 border-gray-4 h-[88px]">+ <div+ data-visible={props.mode === "auto"}+ class="cap-zoom-mode-helper-viewport-auto absolute rounded-md border-2 opacity-0 transition-opacity duration-300 -translate-x-1/2 -translate-y-1/2 border-blue-9/60 bg-blue-9/10 w-[42%] h-[55%] data-[visible='true']:opacity-100"+ />+ <div+ data-visible={props.mode === "manual"}+ class="absolute left-1/2 top-1/2 rounded-md border-2 opacity-0 transition-opacity duration-300 -translate-x-1/2 -translate-y-1/2 border-blue-9/60 bg-blue-9/10 w-[42%] h-[55%] data-[visible='true']:opacity-100"+ />+ <div class="cap-zoom-mode-helper-cursor absolute">+ <IconCapCursor class="text-gray-12 size-3.5" />+ </div>+ </div>+ <p class="text-xs text-gray-11">+ {props.mode === "auto"+ ? "Automatic zoom follows your cursor around the screen."+ : "Manual zoom stays on a fixed spot you pick below."}+ </p>+ </div>+ </KCollapsible.Content>+ </KCollapsible>+ );+}diff --git a/apps/desktop/src/routes/editor/clip-transitions.ts b/apps/desktop/src/routes/editor/clip-transitions.tsindex ed82bc526..ecca62ae6 100644--- a/apps/desktop/src/routes/editor/clip-transitions.ts+++ b/apps/desktop/src/routes/editor/clip-transitions.ts@@ -105,6 +105,44 @@ export function clipTimelineOffsets(return offsets;}+/**+ * Maps an edited-timeline timestamp to the recording-segment file and the+ * time within that file which plays at that moment. Mirrors the Rust+ * `TimelineConfiguration::get_segment_time` (minus holds); where a transition+ * overlaps two segments the incoming segment wins. Times outside the timeline+ * clamp to the nearest edge. Returns null only when there are no segments.+ */+export function clipSourceTimeAt(+ segments: TimelineSegment[],+ transitions: ClipTransition[],+ editedTime: number,+): {+ segmentIndex: number;+ recordingSegment: number;+ sourceTime: number;+} | null {+ if (segments.length === 0) return null;++ const offsets = clipTimelineOffsets(segments, transitions);++ for (let index = segments.length - 1; index >= 0; index--) {+ const segment = segments[index];+ const local = editedTime - offsets[index];+ if (local >= 0 || index === 0) {+ return {+ segmentIndex: index,+ recordingSegment: segment.recordingSegment ?? 0,+ sourceTime:+ segment.start ++ Math.min(Math.max(local, 0), clipDuration(segment)) *+ segment.timescale,+ };+ }+ }++ return null;+}+export function normalizeClipTransitions(segments: TimelineSegment[],transitions: ClipTransition[],diff --git a/apps/desktop/src/routes/editor/text-presets.ts b/apps/desktop/src/routes/editor/text-presets.tsnew file mode 100644index 000000000..750b47e37--- /dev/null+++ b/apps/desktop/src/routes/editor/text-presets.ts@@ -0,0 +1,265 @@+import type { TextAlign, TextAnimation, TextSegment } from "./text";++export type TextPresetStyle = {+ fontStack: string[];+ fontSize: number;+ fontWeight: number;+ italic: boolean;+ align: TextAlign;+ letterSpacing: number;+ lineHeight: number;+ shadow: number;+ animationIn: TextAnimation;+ animationInDuration: number;+ animationOut: TextAnimation;+ animationOutDuration: number;+};++export type TextPreset = {+ id: string;+ name: string;+ sample: string;+ style: TextPresetStyle;+ // Presets that imply placement (e.g. a lower third) reposition the box.+ center?: { x: number; y: number };+};++export const TEXT_PRESETS: TextPreset[] = [+ {+ id: "title",+ name: "Title",+ sample: "Big Title",+ style: {+ fontStack: ["Helvetica Neue", "Segoe UI", "Inter", "sans-serif"],+ fontSize: 96,+ fontWeight: 700,+ italic: false,+ align: "center",+ letterSpacing: -1,+ lineHeight: 1.1,+ shadow: 0.35,+ animationIn: "slideUp",+ animationInDuration: 0.35,+ animationOut: "fade",+ animationOutDuration: 0.25,+ },+ },+ {+ id: "subtitle",+ name: "Subtitle",+ sample: "A calmer supporting line",+ style: {+ fontStack: ["Helvetica Neue", "Segoe UI", "Inter", "sans-serif"],+ fontSize: 44,+ fontWeight: 500,+ italic: false,+ align: "center",+ letterSpacing: 0,+ lineHeight: 1.3,+ shadow: 0.25,+ animationIn: "fade",+ animationInDuration: 0.3,+ animationOut: "fade",+ animationOutDuration: 0.25,+ },+ },+ {+ id: "lower-third",+ name: "Lower Third",+ sample: "Name / Context",+ center: { x: 0.22, y: 0.85 },+ style: {+ fontStack: ["Helvetica Neue", "Segoe UI", "Inter", "sans-serif"],+ fontSize: 40,+ fontWeight: 600,+ italic: false,+ align: "left",+ letterSpacing: 0,+ lineHeight: 1.25,+ shadow: 0.4,+ animationIn: "slideUp",+ animationInDuration: 0.3,+ animationOut: "slideDown",+ animationOutDuration: 0.25,+ },+ },+ {+ id: "kicker",+ name: "Kicker",+ sample: "NEW FEATURE",+ style: {+ fontStack: ["Helvetica Neue", "Segoe UI", "Inter", "sans-serif"],+ fontSize: 26,+ fontWeight: 700,+ italic: false,+ align: "center",+ letterSpacing: 6,+ lineHeight: 1.2,+ shadow: 0.2,+ animationIn: "fade",+ animationInDuration: 0.2,+ animationOut: "fade",+ animationOutDuration: 0.2,+ },+ },+ {+ id: "stat",+ name: "Big Stat",+ sample: "128%",+ style: {+ fontStack: ["Helvetica Neue", "Segoe UI", "Inter", "sans-serif"],+ fontSize: 160,+ fontWeight: 800,+ italic: false,+ align: "center",+ letterSpacing: -2,+ lineHeight: 1,+ shadow: 0.3,+ animationIn: "pop",+ animationInDuration: 0.4,+ animationOut: "fade",+ animationOutDuration: 0.25,+ },+ },+ {+ id: "quote",+ name: "Quote",+ sample: "“Make it feel effortless”",+ style: {+ fontStack: ["Georgia", "Times New Roman", "serif"],+ fontSize: 56,+ fontWeight: 500,+ italic: true,+ align: "center",+ letterSpacing: 0,+ lineHeight: 1.35,+ shadow: 0.2,+ animationIn: "fade",+ animationInDuration: 0.4,+ animationOut: "fade",+ animationOutDuration: 0.3,+ },+ },+ {+ id: "code",+ name: "Code",+ sample: "$ cap record",+ style: {+ fontStack: ["Menlo", "Consolas", "monospace"],+ fontSize: 36,+ fontWeight: 400,+ italic: false,+ align: "left",+ letterSpacing: 0,+ lineHeight: 1.4,+ shadow: 0,+ animationIn: "fade",+ animationInDuration: 0.2,+ animationOut: "fade",+ animationOutDuration: 0.2,+ },+ },+ {+ id: "typewriter",+ name: "Typewriter",+ sample: "typing it out…",+ style: {+ fontStack: ["Menlo", "Consolas", "monospace"],+ fontSize: 44,+ fontWeight: 500,+ italic: false,+ align: "left",+ letterSpacing: 0,+ lineHeight: 1.3,+ shadow: 0,+ animationIn: "typewriter",+ animationInDuration: 0.8,+ animationOut: "fade",+ animationOutDuration: 0.2,+ },+ },+];++// First family of the stack that is actually installed; the generic at the+// end of every stack is the fallback (the renderer resolves generics itself).+export function pickFontFamily(stack: string[], installedFonts: string[]) {+ const installed = new Set(installedFonts.map((name) => name.toLowerCase()));+ for (const family of stack) {+ const normalized = family.toLowerCase();+ if (+ normalized === "sans-serif" ||+ normalized === "serif" ||+ normalized === "monospace"+ )+ return normalized;+ if (installed.has(normalized)) return family;+ }+ return stack[stack.length - 1] ?? "sans-serif";+}++// Everything the preset styles is applied; content, timing, color (kept from+// the auto black/white pick) and — unless the preset implies placement —+// position stay the user's.+export function applyTextPreset(+ segment: TextSegment,+ preset: TextPreset,+ installedFonts: string[],+) {+ const style = preset.style;+ // Scale the box with the font change, top edge fixed, like the Size+ // slider — the canvas overlay re-hugs to exact glyph bounds when visible.+ const boxScale = style.fontSize / (segment.fontSize || 48);+ if (segment.size && segment.center) {+ const topEdge = segment.center.y - segment.size.y / 2;+ segment.size.x = Math.min(segment.size.x * boxScale, 1);+ segment.size.y = segment.size.y * boxScale;+ segment.center.y = topEdge + segment.size.y / 2;+ }+ segment.fontFamily = pickFontFamily(style.fontStack, installedFonts);+ segment.fontSize = style.fontSize;+ segment.fontWeight = style.fontWeight;+ segment.italic = style.italic;+ segment.align = style.align;+ segment.letterSpacing = style.letterSpacing;+ segment.lineHeight = style.lineHeight;+ segment.opacity = 1;+ segment.shadow = style.shadow;+ segment.animationIn = style.animationIn;+ segment.animationOut = style.animationOut;+ segment.animationInDuration = style.animationInDuration;+ segment.animationOutDuration = style.animationOutDuration;+ segment.fadeDuration = Math.max(+ style.animationInDuration,+ style.animationOutDuration,+ );+ if (preset.center) {+ segment.center = { ...preset.center };+ }+}++const near = (a: number, b: number, eps = 0.011) => Math.abs(a - b) < eps;++export function matchTextPreset(+ segment: TextSegment,+ installedFonts: string[],+): string | null {+ for (const preset of TEXT_PRESETS) {+ const style = preset.style;+ if (+ segment.fontFamily === pickFontFamily(style.fontStack, installedFonts) &&+ segment.fontWeight === style.fontWeight &&+ segment.italic === style.italic &&+ segment.align === style.align &&+ near(segment.letterSpacing, style.letterSpacing) &&+ near(segment.lineHeight, style.lineHeight) &&+ near(segment.shadow, style.shadow) &&+ segment.animationIn === style.animationIn &&+ segment.animationOut === style.animationOut &&+ near(segment.animationInDuration, style.animationInDuration) &&+ near(segment.animationOutDuration, style.animationOutDuration)+ ) {+ return preset.id;+ }+ }+ return null;+}