Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

refine(editor): tidy the audio toolbar button and inspector pane

Benjamin Freeman2688b283888b
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index ae4297378..00367d43d 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -16,8 +16,6 @@ import {
Music,
Sliders,
Trash2,
- Volume2,
- VolumeX,
} from "lucide-react";
import {
@@ -2340,9 +2338,10 @@ type TimelineApi = ReturnType<typeof useTimeline>;
// Per-track controls for the selected imported audio track (issue #350). Shown by
// the inspector in place of the facet when an audio track is selected (see
-// FloatingInspector). Volume drives a local live value during the drag and only
-// writes (one undo step) on release, the same shape as the global output-gain
-// slider; mute / offset / remove each write once.
+// FloatingInspector). The header is the generic "Audio track"; the body leads
+// with the file name, then the volume (a local live value during the drag,
+// committed as one undo step on release), then a delete button styled like the
+// region panes' (position and mute are edited on the lane itself).
export function AudioTrackPane({ tl }: { tl: TimelineApi }) {
const ts = useScopedT("settings");
const trackId = tl.selectedAudioTrackId;
@@ -2350,20 +2349,44 @@ export function AudioTrackPane({ tl }: { tl: TimelineApi }) {
const asset = track ? tl.assets.find((a) => a.id === track.assetId) : undefined;
// Live-drag value for the volume slider; null means "show the committed gain".
const [liveGain, setLiveGain] = useState<number | null>(null);
- // Draft text for the offset field; null means "show the track's real offset".
- const [offsetDraft, setOffsetDraft] = useState<string | null>(null);
if (!track) return null;
- const label = track.label || asset?.label || ts("audioTrack.defaultLabel");
-
- const commitOffset = () => {
- if (offsetDraft === null) return;
- const parsed = Number.parseFloat(offsetDraft);
- if (Number.isFinite(parsed)) void tl.moveAudioTrack(track.id, Math.max(0, parsed));
- setOffsetDraft(null);
+ const fileName = track.label || asset?.label || asset?.originalPath?.split(/[\\/]/).pop() || "";
+
+ // Match the region panes' danger-outlined delete button (see SelectionPane).
+ const deleteBtnStyle: CSSProperties = {
+ display: "inline-flex",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 7,
+ padding: "9px 14px",
+ borderRadius: 10,
+ border: "1px solid var(--danger)",
+ background: "var(--danger-soft)",
+ color: "var(--danger)",
+ font: "600 13px var(--font-display)",
+ cursor: "pointer",
};
return (
- <Pane title={label} icon={<Music size={14} />} helpText={ts("audioTrack.help")}>
+ <Pane
+ title={ts("audioTrack.defaultLabel")}
+ icon={<Music size={14} />}
+ helpText={ts("audioTrack.help")}
+ >
+ <div
+ title={fileName}
+ style={{
+ fontSize: 13,
+ fontWeight: 600,
+ color: "var(--fg)",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ margin: "0 0 10px",
+ }}
+ >
+ {fileName}
+ </div>
<div className={styles.sliderGrid}>
<SliderCell
label={ts("audioTrack.volume")}
@@ -2373,7 +2396,6 @@ export function AudioTrackPane({ tl }: { tl: TimelineApi }) {
step={0.5}
decimals={1}
suffix=" dB"
- disabled={track.mute}
onChange={(value) => setLiveGain(value)}
onCommit={() => {
if (liveGain !== null) void tl.setAudioTrackGain(track.id, liveGain);
@@ -2381,52 +2403,10 @@ export function AudioTrackPane({ tl }: { tl: TimelineApi }) {
}}
/>
</div>
- <label
- style={{
- display: "flex",
- alignItems: "center",
- justifyContent: "space-between",
- gap: 8,
- fontSize: 12,
- color: "var(--meta)",
- margin: "2px 0 8px",
- }}
- >
- <span>{ts("audioTrack.offset")}</span>
- <input
- type="number"
- min={0}
- step={0.1}
- value={offsetDraft ?? track.timelineStartSec.toFixed(2)}
- onChange={(e) => setOffsetDraft(e.target.value)}
- onBlur={commitOffset}
- onKeyDown={(e) => {
- if (e.key === "Enter") e.currentTarget.blur();
- }}
- style={{
- width: 84,
- padding: "4px 6px",
- background: "var(--surface-warm)",
- border: "1px solid var(--border-soft)",
- borderRadius: "var(--r-sm)",
- color: "var(--fg)",
- font: "12px var(--font-body)",
- textAlign: "right",
- }}
- />
- </label>
<button
type="button"
- className={styles.secondaryBtn}
- onClick={() => void tl.toggleAudioTrackMute(track.id)}
- >
- {track.mute ? <VolumeX size={14} /> : <Volume2 size={14} />}
- {track.mute ? ts("audioTrack.unmute") : ts("audioTrack.mute")}
- </button>
- <button
- type="button"
- className={styles.secondaryBtn}
onClick={() => void tl.removeAudioTrack(track.id)}
+ style={deleteBtnStyle}
>
<Trash2 size={14} />
{ts("audioTrack.remove")}
diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx
index fd14d7ce3..b945c7dcf 100644
--- a/src/components/ai-edition/v4/V4Timeline.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.tsx
@@ -1534,6 +1534,15 @@ export function V4Timeline({
</div>
</PopoverContent>
</Popover>
+ <button
+ type="button"
+ className={styles.tlToolBtn}
+ title={ts("audioTrack.add")}
+ aria-label={ts("audioTrack.add")}
+ onClick={() => void handleAddAudio()}
+ >
+ <Music size={15} />
+ </button>
<span className={styles.tlToolSep} aria-hidden />
{tools.map((tool) => (
<button
@@ -1588,16 +1597,6 @@ export function V4Timeline({
>
<Maximize2 size={15} />
</button>
- <span className={styles.tlToolSep} aria-hidden />
- <button
- type="button"
- className={styles.tlToolBtn}
- title={ts("audioTrack.add")}
- aria-label={ts("audioTrack.add")}
- onClick={() => void handleAddAudio()}
- >
- <Music size={15} />
- </button>
</div>
) : (
// Media is an ARRANGING surface: add, remove, reorder. Nothing here
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index 6df193528..7fd43c328 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index c6a395253..d000776a9 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -83,11 +83,8 @@
"add": "Add audio track",
"importFailed": "Could not add audio",
"defaultLabel": "Audio track",
- "help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
+ "help": "Volume for this imported audio track. It mixes over the recording in the preview and the export. Drag the track on the timeline to move or trim it.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
},
"effects": {
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index f38a8fb15..f9990d4ce 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index eb27b38c3..1f977ceaf 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index 1ab8cdeed..ac59a30e7 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index 680224ea1..4ebf04a29 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index 8b5476d24..88cd20e14 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index 662cfa8e5..400146a55 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index 0ff2a0c55..f7c1500a9 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index a4e0c8fff..0a0292ac4 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index 772353638..6391bee1b 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index 74b088d38..622f17f2f 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -333,9 +333,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index 05bb60f79..b1b5729b2 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -334,9 +334,6 @@
"defaultLabel": "Audio track",
"help": "Volume, position, and mute for this imported audio track. It mixes over the recording in the preview and the export.",
"volume": "Volume",
- "offset": "Start (s)",
- "mute": "Mute",
- "unmute": "Unmute",
"remove": "Remove track"
}
}