Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(captions): give the inspector a horizontal offset, and honest slider bounds
EtienneLescotf83cab27dc06
diff --git a/src/components/ai-edition/CaptionsPane.tsx b/src/components/ai-edition/CaptionsPane.tsxindex 7b4142fbf..2bcd8c5ab 100644--- a/src/components/ai-edition/CaptionsPane.tsx+++ b/src/components/ai-edition/CaptionsPane.tsx@@ -13,7 +13,7 @@ import { Captions as CaptionsIcon, Languages, Loader2, Trash2 } from "lucide-reaimport { useMemo, useState } from "react";import { useScopedT } from "@/contexts/I18nContext";import type { CaptionTextAlign, CaptionVerticalPosition } from "@/lib/ai-edition/captions";-import { untranslatedUnits } from "@/lib/ai-edition/captions";+import { captionOffsetRange, untranslatedUnits } from "@/lib/ai-edition/captions";import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import {useTimelineTranscriptGate,@@ -25,6 +25,16 @@ import { ColorField } from "./ColorField";import styles from "./NewEditorShell.module.css";import { SliderCell, Toggle } from "./RightPanes";+/** A hundred stops across whatever span the offset currently has.+ *+ * The bounds are geometry, so they are rarely round numbers. A fixed `step` of 1+ * would leave `max` unreachable whenever the span isn't a whole number of steps —+ * the caption would stop just short of the frame edge, which is the very thing+ * #396 is about. Deriving the step from the span puts both ends exactly on a stop. */+function sliderStep(range: { min: number; max: number }): number {+ return Math.max((range.max - range.min) / 100, Number.EPSILON);+}+/** The families `src/index.css` already loads for on-canvas text — anything else* would render in the preview but fall back to a default in the export canvas. */const CAPTION_FONTS = [@@ -113,6 +123,11 @@ export function CaptionsPane() {const disabled = !hasDocument;const languageOptions = useMemo(() => Object.values(translations), [translations]);+ // The reach depends on the anchor, the width and the font size, so it moves as the+ // user works. Taking the sliders' bounds from the same function the geometry clamps+ // with is what keeps every position on them a position the band can actually take.+ const offsetRange = useMemo(() => captionOffsetRange(settings), [settings]);+const handleTranslate = async () => {const doc = useProjectStore.getState().document;if (!doc) return;@@ -466,13 +481,30 @@ export function CaptionsPane() {<SliderCelllabel={t("captions.verticalOffset")}value={settings.offsetY}- min={-45}- max={45}+ min={offsetRange.y.min}+ max={offsetRange.y.max}+ step={sliderStep(offsetRange.y)}+ decimals={1}suffix="%"disabled={disabled}onChange={(v) => setLive({ offsetY: v })}onCommit={() => void commit()}/>+ <SliderCell+ label={t("captions.horizontalOffset")}+ value={settings.offsetX}+ min={offsetRange.x.min}+ max={offsetRange.x.max}+ step={sliderStep(offsetRange.x)}+ decimals={1}+ suffix="%"+ // A full-width band is already flush with both frame edges, so there is+ // no travel to offer. Leaving the slider live would let the user drag a+ // control that cannot move anything, which reads as a bug.+ disabled={disabled || offsetRange.x.max <= offsetRange.x.min}+ onChange={(v) => setLive({ offsetX: v })}+ onCommit={() => void commit()}+ /><SliderCelllabel={t("captions.width")}value={settings.width}diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.jsonindex 917a24d90..26c10e26f 100644--- a/src/i18n/locales/ar/settings.json+++ b/src/i18n/locales/ar/settings.json@@ -293,7 +293,8 @@"alignLeft": "يسار","alignCenter": "توسيط","alignRight": "يمين",- "verticalOffset": "الإزاحة",+ "verticalOffset": "الإزاحة الرأسية",+ "horizontalOffset": "الإزاحة الأفقية","width": "العرض","lineLength": "طول السطر","minWords": "أقل عدد كلمات في السطر",diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex 00bc205be..653d652b0 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -293,7 +293,8 @@"alignLeft": "Left","alignCenter": "Center","alignRight": "Right",- "verticalOffset": "Offset",+ "verticalOffset": "Vertical offset",+ "horizontalOffset": "Horizontal offset","width": "Width","lineLength": "Line length","minWords": "Min words per line",diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex ae96ab53c..e4a71a8b3 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -293,7 +293,8 @@"alignLeft": "Izquierda","alignCenter": "Centro","alignRight": "Derecha",- "verticalOffset": "Desplazamiento",+ "verticalOffset": "Desplazamiento vertical",+ "horizontalOffset": "Desplazamiento horizontal","width": "Ancho","lineLength": "Longitud de línea","minWords": "Mín. palabras por línea",diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 2b38cc4f9..69fe1e89a 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -293,7 +293,8 @@"alignLeft": "Gauche","alignCenter": "Centre","alignRight": "Droite",- "verticalOffset": "Décalage",+ "verticalOffset": "Décalage vertical",+ "horizontalOffset": "Décalage horizontal","width": "Largeur","lineLength": "Longueur des lignes","minWords": "Mots min. par ligne",diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.jsonindex 797e0a213..4fd93214f 100644--- a/src/i18n/locales/it/settings.json+++ b/src/i18n/locales/it/settings.json@@ -293,7 +293,8 @@"alignLeft": "Sinistra","alignCenter": "Centro","alignRight": "Destra",- "verticalOffset": "Scostamento",+ "verticalOffset": "Scostamento verticale",+ "horizontalOffset": "Scostamento orizzontale","width": "Larghezza","lineLength": "Lunghezza riga","minWords": "Parole min. per riga",diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex 8cbce2715..e42d9fffd 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -293,7 +293,8 @@"alignLeft": "左","alignCenter": "中央","alignRight": "右",- "verticalOffset": "オフセット",+ "verticalOffset": "垂直オフセット",+ "horizontalOffset": "水平オフセット","width": "幅","lineLength": "行の長さ","minWords": "1 行の最小単語数",diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex a986c2ee8..7ca326d35 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -293,7 +293,8 @@"alignLeft": "왼쪽","alignCenter": "가운데","alignRight": "오른쪽",- "verticalOffset": "오프셋",+ "verticalOffset": "세로 오프셋",+ "horizontalOffset": "가로 오프셋","width": "너비","lineLength": "줄 길이","minWords": "줄당 최소 단어 수",diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.jsonindex 203846fcb..cc9589479 100644--- a/src/i18n/locales/pt-BR/settings.json+++ b/src/i18n/locales/pt-BR/settings.json@@ -293,7 +293,8 @@"alignLeft": "Esquerda","alignCenter": "Centro","alignRight": "Direita",- "verticalOffset": "Deslocamento",+ "verticalOffset": "Deslocamento vertical",+ "horizontalOffset": "Deslocamento horizontal","width": "Largura","lineLength": "Comprimento da linha","minWords": "Mín. de palavras por linha",diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.jsonindex 70acfb8ab..3ff87aa11 100644--- a/src/i18n/locales/ru/settings.json+++ b/src/i18n/locales/ru/settings.json@@ -293,7 +293,8 @@"alignLeft": "Слева","alignCenter": "По центру","alignRight": "Справа",- "verticalOffset": "Смещение",+ "verticalOffset": "Смещение по вертикали",+ "horizontalOffset": "Смещение по горизонтали","width": "Ширина","lineLength": "Длина строки","minWords": "Мин. слов в строке",diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 565eb982c..091e6496c 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -293,7 +293,8 @@"alignLeft": "Sol","alignCenter": "Orta","alignRight": "Sağ",- "verticalOffset": "Kaydırma",+ "verticalOffset": "Dikey kaydırma",+ "horizontalOffset": "Yatay kaydırma","width": "Genişlik","lineLength": "Satır uzunluğu","minWords": "Satır başına en az kelime",diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.jsonindex b5f02ea6c..02a4929eb 100644--- a/src/i18n/locales/vi/settings.json+++ b/src/i18n/locales/vi/settings.json@@ -293,7 +293,8 @@"alignLeft": "Trái","alignCenter": "Giữa","alignRight": "Phải",- "verticalOffset": "Độ lệch",+ "verticalOffset": "Độ lệch dọc",+ "horizontalOffset": "Độ lệch ngang","width": "Chiều rộng","lineLength": "Độ dài dòng","minWords": "Số từ tối thiểu mỗi dòng",diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex e2e05ebb1..984d3e372 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -293,7 +293,8 @@"alignLeft": "左对齐","alignCenter": "居中","alignRight": "右对齐",- "verticalOffset": "偏移",+ "verticalOffset": "垂直偏移",+ "horizontalOffset": "水平偏移","width": "宽度","lineLength": "行长","minWords": "每行最少词数",diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex 5dd728b4e..0778cd0e1 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -294,7 +294,8 @@"alignLeft": "靠左","alignCenter": "置中","alignRight": "靠右",- "verticalOffset": "位移",+ "verticalOffset": "垂直位移",+ "horizontalOffset": "水平位移","width": "寬度","lineLength": "行長","minWords": "每行最少字數",diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex d5fdc7c9d..fe5631804 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -1617,6 +1617,73 @@ describe("buildSceneDescription.captions", () => {expect(buildSceneDescription(docWithCaptions(false)).annotations).toHaveLength(0);});+ it("marks captions as frame-space so the compositor stops measuring the footage", () => {+ const scene = buildSceneDescription(docWithCaptions(true));+ expect(scene.annotations[0].space).toBe("frame");+ });++ it("holds the caption still while padding shrinks the screen rect", () => {+ // Issue #396. Padding pulls `screenRect` in; a subtitle belongs to the frame the+ // viewer sees, so its rect must not follow. Three points, because two could agree+ // by coincidence — `paddingFit` is 1 - padding/100 * 0.4, so 1.0 / 0.8 / 0.6.+ const rects = [0, 50, 100].map((padding) => {+ const base = docWithCaptions(true);+ const scene = buildSceneDescription({+ ...base,+ legacyEditor: { ...(base.legacyEditor as Record<string, unknown>), padding },+ } as AxcutDocument);+ const caption = scene.annotations[0];+ return {+ screenWidth: scene.layout.screenRect?.width,+ caption: { x: caption.x, y: caption.y, w: caption.w, h: caption.h },+ fontSizeRel: caption.text?.fontSizeRel,+ };+ });++ // The screen rect really does move — otherwise this test proves nothing.+ expect(new Set(rects.map((r) => r.screenWidth)).size).toBe(3);+ // ...and the caption does not, in position or in size.+ expect(rects[1].caption).toEqual(rects[0].caption);+ expect(rects[2].caption).toEqual(rects[0].caption);+ // The font denominator has to follow the rect, or the caption holds still and+ // still shrinks its text with the padding slider.+ expect(rects[1].fontSizeRel).toBe(rects[0].fontSizeRel);+ expect(rects[2].fontSizeRel).toBe(rects[0].fontSizeRel);+ });++ it("leaves the space key off a real annotation entirely", () => {+ // Not `space: undefined` — an explicit key would change the annotation payload that+ // shipped binaries already parse. `in` is the only check that tells them apart.+ const doc = makeDoc({+ annotations: [+ {+ id: "ann1",+ startMs: 0,+ endMs: 1000,+ type: "text",+ content: "hi",+ position: { x: 10, y: 10 },+ size: { width: 20, height: 10 },+ style: {+ color: "#fff",+ backgroundColor: "transparent",+ fontSize: 48,+ fontFamily: "Inter",+ fontWeight: "normal",+ fontStyle: "normal",+ textDecoration: "none",+ textAlign: "center",+ textAnimation: "none",+ },+ zIndex: 1,+ },+ ],+ });+ const annotation = buildSceneDescription(doc).annotations[0];+ expect(annotation).toBeDefined();+ expect("space" in annotation).toBe(false);+ });+it("carries the caption font size as a fraction, like every annotation", () => {const scene = buildSceneDescription(docWithCaptions(true));// 48px authored against a 1080-high frame.