Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(library): a click previews a file without putting it on the timeline

Jareere43e10693128
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index dde588ab..86da8c6b 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Kontur",
"presets.subtitle": "Untertitel",
+ "previewPane.backToTimeline": "Zurück zur Zeitleiste",
"previewPane.fitFramePane": "Bild in den Bereich einpassen",
"previewPane.half": "Halb",
"previewPane.nextFrame": "Nächstes Bild",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Vorheriges Bild",
"previewPane.quarter": "Viertel",
"previewPane.saveFrameAs": "Videobild speichern unter…",
+ "previewPane.source": "Quelle",
"project.hdrMonitorNote": "Der Monitor zeigt eine HDR-Timeline auf SDR tonegemappt, bis die HDR-Vorschau kommt.",
"project.output": "Ausgabe · {0}",
"project.project": "Projekt",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 7d2dd71e..0fa429d8 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Outline",
"presets.subtitle": "Subtitle",
+ "previewPane.backToTimeline": "Back to the timeline",
"previewPane.fitFramePane": "Fit the frame to the pane",
"previewPane.half": "Half",
"previewPane.nextFrame": "Next frame",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Previous frame",
"previewPane.quarter": "Quarter",
"previewPane.saveFrameAs": "Save Video Frame As…",
+ "previewPane.source": "Source",
"project.hdrMonitorNote": "The monitor shows an HDR timeline tone-mapped to SDR, until HDR preview arrives.",
"project.output": "Output · {0}",
"project.project": "Project",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index adfd44ac..eab38561 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -689,6 +689,7 @@
"presets.neon": "Neón",
"presets.outline": "Contorno",
"presets.subtitle": "Subtítulo",
+ "previewPane.backToTimeline": "Volver a la línea de tiempo",
"previewPane.fitFramePane": "Ajustar el cuadro al panel",
"previewPane.half": "Media",
"previewPane.nextFrame": "Fotograma siguiente",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Fotograma anterior",
"previewPane.quarter": "Un cuarto",
"previewPane.saveFrameAs": "Guardar fotograma como…",
+ "previewPane.source": "Origen",
"project.hdrMonitorNote": "El monitor muestra una línea de tiempo HDR convertida a SDR hasta que llegue la vista previa HDR.",
"project.output": "Salida · {0}",
"project.project": "Proyecto",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index c94ff8fe..733e85ce 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -689,6 +689,7 @@
"presets.neon": "نئون",
"presets.outline": "حاشیه",
"presets.subtitle": "زیرعنوان",
+ "previewPane.backToTimeline": "بازگشت به خط زمانی",
"previewPane.fitFramePane": "جای‌دادن فریم در پنل",
"previewPane.half": "نصف",
"previewPane.nextFrame": "فریم بعدی",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "فریم قبلی",
"previewPane.quarter": "یک‌چهارم",
"previewPane.saveFrameAs": "ذخیرهٔ فریم ویدیو به‌عنوان…",
+ "previewPane.source": "منبع",
"project.hdrMonitorNote": "مانیتور تا رسیدن پیش‌نمایش HDR، تایم‌لاین HDR را با Tone Mapping به SDR نشان می‌دهد.",
"project.output": "خروجی · {0}",
"project.project": "پروژه",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index e95c1efa..33f36817 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -689,6 +689,7 @@
"presets.neon": "Néon",
"presets.outline": "Contour",
"presets.subtitle": "Sous-titre",
+ "previewPane.backToTimeline": "Revenir à la timeline",
"previewPane.fitFramePane": "Ajuster l'image au panneau",
"previewPane.half": "Moitié",
"previewPane.nextFrame": "Image suivante",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Image précédente",
"previewPane.quarter": "Quart",
"previewPane.saveFrameAs": "Enregistrer l’image vidéo sous…",
+ "previewPane.source": "Source",
"project.hdrMonitorNote": "Le moniteur affiche une timeline HDR ramenée en SDR, en attendant l'aperçu HDR.",
"project.output": "Sortie · {0}",
"project.project": "Projet",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index de0cb4be..fde37d4b 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Kontura",
"presets.subtitle": "Podnaslov",
+ "previewPane.backToTimeline": "Natrag na vremensku crtu",
"previewPane.fitFramePane": "Prilagodi kadar panelu",
"previewPane.half": "Pola",
"previewPane.nextFrame": "Sljedeća sličica",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Prethodna sličica",
"previewPane.quarter": "Četvrtina",
"previewPane.saveFrameAs": "Spremi sličicu videa kao…",
+ "previewPane.source": "Izvor",
"project.hdrMonitorNote": "Monitor prikazuje HDR vremensku crtu mapiranu u SDR, dok ne stigne HDR pregled.",
"project.output": "Izlaz · {0}",
"project.project": "Projekt",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 8f39e0cd..d1064b24 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Contorno",
"presets.subtitle": "Sottotitolo",
+ "previewPane.backToTimeline": "Torna alla timeline",
"previewPane.fitFramePane": "Adatta il fotogramma al pannello",
"previewPane.half": "Metà",
"previewPane.nextFrame": "Fotogramma successivo",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Fotogramma precedente",
"previewPane.quarter": "Un quarto",
"previewPane.saveFrameAs": "Salva fotogramma come…",
+ "previewPane.source": "Sorgente",
"project.hdrMonitorNote": "Il monitor mostra una timeline HDR convertita in SDR, finché non arriva l'anteprima HDR.",
"project.output": "Uscita · {0}",
"project.project": "Progetto",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 2f361ac8..0d3d60a2 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -689,6 +689,7 @@
"presets.neon": "ネオン",
"presets.outline": "縁取り",
"presets.subtitle": "サブタイトル",
+ "previewPane.backToTimeline": "タイムラインに戻る",
"previewPane.fitFramePane": "フレームをパネルに合わせる",
"previewPane.half": "1/2",
"previewPane.nextFrame": "次のフレーム",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "前のフレーム",
"previewPane.quarter": "1/4",
"previewPane.saveFrameAs": "ビデオフレームを別名で保存…",
+ "previewPane.source": "ソース",
"project.hdrMonitorNote": "HDR プレビューに対応するまで、モニターは HDR タイムラインを SDR にトーンマッピングして表示します。",
"project.output": "出力 · {0}",
"project.project": "プロジェクト",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 6d2a8a4a..6f477728 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -689,6 +689,7 @@
"presets.neon": "네온",
"presets.outline": "외곽선",
"presets.subtitle": "부제",
+ "previewPane.backToTimeline": "타임라인으로 돌아가기",
"previewPane.fitFramePane": "프레임을 패널에 맞추기",
"previewPane.half": "1/2",
"previewPane.nextFrame": "다음 프레임",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "이전 프레임",
"previewPane.quarter": "1/4",
"previewPane.saveFrameAs": "비디오 프레임을 다른 이름으로 저장…",
+ "previewPane.source": "소스",
"project.hdrMonitorNote": "HDR 미리보기가 나오기 전까지 모니터는 HDR 타임라인을 SDR로 톤 매핑해 보여 줍니다.",
"project.output": "출력 · {0}",
"project.project": "프로젝트",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index be98b2d6..00d0d41a 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Contorno",
"presets.subtitle": "Subtítulo",
+ "previewPane.backToTimeline": "Voltar à linha do tempo",
"previewPane.fitFramePane": "Ajustar o quadro ao painel",
"previewPane.half": "Metade",
"previewPane.nextFrame": "Próximo quadro",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Quadro anterior",
"previewPane.quarter": "Um quarto",
"previewPane.saveFrameAs": "Salvar quadro do vídeo como…",
+ "previewPane.source": "Origem",
"project.hdrMonitorNote": "O monitor mostra uma linha do tempo HDR convertida para SDR até chegar a prévia em HDR.",
"project.output": "Saída · {0}",
"project.project": "Projeto",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index efd514b0..b49d4d25 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -689,6 +689,7 @@
"presets.neon": "Неон",
"presets.outline": "Обводка",
"presets.subtitle": "Подзаголовок",
+ "previewPane.backToTimeline": "Вернуться к таймлайну",
"previewPane.fitFramePane": "Вписать кадр в панель",
"previewPane.half": "Половина",
"previewPane.nextFrame": "Следующий кадр",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Предыдущий кадр",
"previewPane.quarter": "Четверть",
"previewPane.saveFrameAs": "Сохранить кадр как…",
+ "previewPane.source": "Источник",
"project.hdrMonitorNote": "Пока нет HDR-просмотра, монитор показывает HDR-таймлайн, приведённый к SDR.",
"project.output": "Вывод · {0}",
"project.project": "Проект",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 92c8658f..fbb068a3 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -689,6 +689,7 @@
"presets.neon": "Neon",
"presets.outline": "Dış çizgi",
"presets.subtitle": "Alt başlık",
+ "previewPane.backToTimeline": "Zaman çizelgesine dön",
"previewPane.fitFramePane": "Kareyi panele sığdır",
"previewPane.half": "Yarım",
"previewPane.nextFrame": "Sonraki kare",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "Önceki kare",
"previewPane.quarter": "Çeyrek",
"previewPane.saveFrameAs": "Video karesini farklı kaydet…",
+ "previewPane.source": "Kaynak",
"project.hdrMonitorNote": "HDR önizleme gelene kadar monitör, HDR zaman çizelgesini SDR'ye ton eşlemeli gösterir.",
"project.output": "Çıkış · {0}",
"project.project": "Proje",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index e93dea05..22336ef3 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -689,6 +689,7 @@
"presets.neon": "霓虹",
"presets.outline": "描边",
"presets.subtitle": "字幕",
+ "previewPane.backToTimeline": "返回时间线",
"previewPane.fitFramePane": "使画面适合面板",
"previewPane.half": "一半",
"previewPane.nextFrame": "下一帧",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "上一帧",
"previewPane.quarter": "四分之一",
"previewPane.saveFrameAs": "视频帧另存为…",
+ "previewPane.source": "源",
"project.hdrMonitorNote": "在支持 HDR 预览之前,监视器会把 HDR 时间线色调映射为 SDR 显示。",
"project.output": "输出 · {0}",
"project.project": "项目",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 6dfa818f..a2ed3ed2 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -689,6 +689,7 @@
"presets.neon": "霓虹",
"presets.outline": "描邊",
"presets.subtitle": "字幕",
+ "previewPane.backToTimeline": "返回時間軸",
"previewPane.fitFramePane": "使畫面符合面板大小",
"previewPane.half": "一半",
"previewPane.nextFrame": "下一個影格",
@@ -698,6 +699,7 @@
"previewPane.previousFrame": "上一個影格",
"previewPane.quarter": "四分之一",
"previewPane.saveFrameAs": "影片畫格另存為…",
+ "previewPane.source": "來源",
"project.hdrMonitorNote": "在支援 HDR 預覽之前,監看器會把 HDR 時間軸色調映射為 SDR 顯示。",
"project.output": "輸出 · {0}",
"project.project": "專案",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 99390950..4bad2f5e 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -46,6 +46,7 @@ pub use platform::{FilePicker, install_file_picker};
mod panes;
mod prefs;
mod presets;
+mod source;
mod studio;
mod sysinfo;
/// Native Wayland file drops, which winit does not report; see the module.
@@ -1120,6 +1121,13 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.on_play_toggled(on_window!(|state| {
state.play_toggle();
}));
+ app.global::<SourcePreview>().on_closed(on_window!(|state| {
+ state.close_source();
+ }));
+ app.global::<SourcePreview>()
+ .on_seek(on_window!(|state, seconds: f32| {
+ state.source_seek(f64::from(seconds));
+ }));
// ── the stage ──
editor.on_stage_pressed(on_window!(|state, x: f32, y: f32, additive: bool| {
diff --git a/src/crates/concat/src/panes/media_bin.rs b/src/crates/concat/src/panes/media_bin.rs
index 588d8c66..3b90b901 100644
--- a/src/crates/concat/src/panes/media_bin.rs
+++ b/src/crates/concat/src/panes/media_bin.rs
@@ -103,7 +103,12 @@ impl MediaBin {
else {
return;
};
- self.select(id, additive);
+ self.select(id.clone(), additive);
+ // A plain click shows a picture on the monitor, or plays a
+ // sound, without putting it on the timeline.
+ if !additive {
+ studio.preview_media(&id, row);
+ }
}
MediaMsg::Band {
columns,
@@ -185,6 +190,8 @@ impl MediaBin {
}
}
MediaMsg::AddSelectedAtPlayhead => {
+ // Onto the timeline: the monitor goes back to it.
+ studio.close_source();
let ids: Vec<String> = studio
.project()
.media
diff --git a/src/crates/concat/src/panes/monitor.rs b/src/crates/concat/src/panes/monitor.rs
index 8dded292..5d32ecbc 100644
--- a/src/crates/concat/src/panes/monitor.rs
+++ b/src/crates/concat/src/panes/monitor.rs
@@ -241,10 +241,11 @@ impl MonitorPane {
time: f64::from(studio.preview_time()),
width,
height,
- moving: studio.playing,
+ moving: studio.playing || studio.source.as_ref().is_some_and(|source| source.playing),
// Playback reads the proxies at Half and Quarter; Full plays
// the files themselves, or Full would be the proxy blurred up.
- proxy: studio.playing && quality > 0,
+ proxy: (studio.playing || studio.source.as_ref().is_some_and(|source| source.playing))
+ && quality > 0,
color_space: studio.project().active().video.color_space,
};
if !studio.playing {
diff --git a/src/crates/concat/src/source.rs b/src/crates/concat/src/source.rs
new file mode 100644
index 00000000..fe770f51
--- /dev/null
+++ b/src/crates/concat/src/source.rs
@@ -0,0 +1,220 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! The source preview: a file from the library seen and heard on its own,
+//! before it is anywhere near the timeline (#197).
+//!
+//! A click on a video or a still in the bin shows it on the monitor,
+//! paused at its start, with a chip that names it; Play and Space play it,
+//! the monitor's timecode moves through it. A click on a sound plays it at
+//! once, with a line moving across its card; a second click pauses it.
+//! The timeline is not touched: the monitor and the speakers are lent a
+//! scratch copy of the project holding the one clip, and given back the
+//! moment the person clicks the timeline or the chip's cross.
+
+use std::sync::Arc;
+
+use concat_project::Command;
+use concat_project::commands::{self, IdMint};
+use concat_project::model::{MediaKind, Project};
+
+use crate::studio::Studio;
+use crate::ui::SourcePreview;
+use slint::ComponentHandle;
+
+/// The file lent to the monitor and the speakers.
+pub struct Source {
+ pub media_id: String,
+ pub name: String,
+ pub kind: MediaKind,
+ /// The bin's row for the file, for its card to show the playing line.
+ pub row: i32,
+ /// The scratch project flattened, as the monitor draws it.
+ pub clips: Arc<Vec<concat_export::ExportClip>>,
+ pub duration: f64,
+ pub time: f64,
+ pub playing: bool,
+ /// Follows the speakers' clock while it plays.
+ timer: slint::Timer,
+}
+
+/// The project as it is, with its active timeline holding only `media_id`
+/// from zero: what the source preview draws and plays.
+fn scratch(project: &Project, media_id: &str) -> Option<Project> {
+ let mut scratch = project.clone();
+ let timeline = scratch.active_mut();
+ timeline.clips.clear();
+ let track_id = timeline.tracks.first()?.id.clone();
+ commands::apply(
+ &mut scratch,
+ &mut IdMint::default(),
+ Command::AddClip {
+ media_id: media_id.to_owned(),
+ track_id,
+ start: 0.0,
+ ripple: false,
+ },
+ )
+ .ok()?;
+ Some(scratch)
+}
+
+impl Studio {
+ /// A card was clicked. A sound plays, or pauses when it is the one
+ /// playing; a picture goes on the monitor, paused at its start.
+ pub fn preview_media(&mut self, media_id: &str, row: i32) {
+ if let Some(source) = self.source.as_ref()
+ && source.media_id == media_id
+ {
+ if source.kind == MediaKind::Audio {
+ self.source_toggle();
+ }
+ return;
+ }
+ let Some(media) = self.project().media_by_id(media_id).cloned() else {
+ return;
+ };
+ let Some(project_dir) = self
+ .session
+ .as_ref()
+ .map(|session| std::path::PathBuf::from(session.path()))
+ else {
+ return;
+ };
+ let Some(scratch) = scratch(self.project(), media_id) else {
+ return;
+ };
+ // The timeline stops: the speakers and the monitor are the
+ // source's now.
+ self.pause();
+ if let Some(old) = self.source.take() {
+ old.timer.stop();
+ }
+ let clips = Arc::new(concat_export::flatten::flatten_timeline_in(
+ &scratch,
+ None,
+ Some(&project_dir),
+ ));
+ let duration = scratch
+ .active()
+ .clips
+ .first()
+ .map_or(0.0, |clip| clip.duration);
+ self.host
+ .playback
+ .set_clips(project_dir, crate::studio::audio_specs(&clips));
+ self.host.playback.seek(0.0);
+ self.source = Some(Source {
+ media_id: media_id.to_owned(),
+ name: media.name.clone(),
+ kind: media.kind,
+ row,
+ clips,
+ duration,
+ time: 0.0,
+ playing: false,
+ timer: slint::Timer::default(),
+ });
+ if media.kind == MediaKind::Audio {
+ self.source_toggle();
+ }
+ self.request_preview();
+ }
+
+ /// Back to the timeline: its picture on the monitor, its sound in the
+ /// speakers, the transport where the playhead was.
+ pub fn close_source(&mut self) {
+ let Some(source) = self.source.take() else {
+ return;
+ };
+ source.timer.stop();
+ self.host.playback.pause();
+ self.sync_audio();
+ self.host.playback.seek(f64::from(self.playhead));
+ self.request_preview();
+ }
+
+ /// Play or pause the source, from where it stands; from its start
+ /// again once it has played to the end.
+ pub fn source_toggle(&mut self) {
+ let Some(source) = self.source.as_mut() else {
+ return;
+ };
+ if source.playing {
+ source.playing = false;
+ source.timer.stop();
+ self.host.playback.pause();
+ return;
+ }
+ if source.time >= source.duration - 1e-3 {
+ source.time = 0.0;
+ }
+ source.playing = true;
+ self.host.playback.play(source.time);
+ source.timer.start(
+ slint::TimerMode::Repeated,
+ std::time::Duration::from_millis(16),
+ || {
+ crate::host::Shell::with(|shell, app| {
+ let mut studio = shell.studio.borrow_mut();
+ let position = studio.host.playback.position_now();
+ let Some(source) = studio.source.as_mut() else {
+ return;
+ };
+ source.time = position.min(source.duration);
+ let ended = source.time >= source.duration;
+ if ended {
+ source.playing = false;
+ source.timer.stop();
+ }
+ if ended {
+ studio.host.playback.pause();
+ }
+ studio.request_preview();
+ studio.publish_source(&app);
+ });
+ },
+ );
+ }
+
+ /// The monitor's timecode moved through the source.
+ pub fn source_seek(&mut self, seconds: f64) {
+ let Some(source) = self.source.as_mut() else {
+ return;
+ };
+ source.time = seconds.clamp(0.0, source.duration);
+ let time = source.time;
+ if source.playing {
+ self.host.playback.play(time);
+ } else {
+ self.host.playback.seek(time);
+ }
+ self.request_preview();
+ }
+
+ /// What the window shows of the source: the chip, the card's line, the
+ /// monitor's readout.
+ pub fn publish_source(&self, app: &crate::ui::App) {
+ let preview = app.global::<SourcePreview>();
+ match self.source.as_ref() {
+ Some(source) => {
+ preview.set_open(true);
+ preview.set_name(source.name.as_str().into());
+ preview.set_row(source.row);
+ preview.set_time(source.time as f32);
+ preview.set_duration(source.duration as f32);
+ preview.set_playing(source.playing);
+ preview.set_progress(if source.duration > 0.0 {
+ (source.time / source.duration) as f32
+ } else {
+ 0.0
+ });
+ }
+ None => {
+ preview.set_open(false);
+ preview.set_row(-1);
+ preview.set_playing(false);
+ }
+ }
+ }
+}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 4a35c479..a566d515 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -893,6 +893,9 @@ pub struct Studio {
pub project_sheet: crate::panes::project::ProjectPane,
pub captions: crate::panes::captions::CaptionsPane,
pub speech: crate::panes::speech::SpeechPane,
+ /// A file from the library lent the monitor and the speakers; see
+ /// `crate::source`.
+ pub source: Option<crate::source::Source>,
/// The voiceover take, while one runs.
pub voiceover: crate::panes::voiceover::VoiceoverPane,
/// Every speaker the voice engine offers, in its own order.
@@ -1993,6 +1996,7 @@ impl Studio {
project_sheet: crate::panes::project::ProjectPane::default(),
captions: crate::panes::captions::CaptionsPane::default(),
speech: crate::panes::speech::SpeechPane::default(),
+ source: None,
voiceover: crate::panes::voiceover::VoiceoverPane::default(),
text_presets,
installed_fonts: presets::installed_fonts(&host.dirs),
@@ -2425,46 +2429,16 @@ impl Studio {
}
/// The audible clip set, handed to playback whenever the edit changes.
- fn sync_audio(&mut self) {
+ /// Not while a library file has the speakers: the timeline's sound is
+ /// handed back when it lets them go.
+ pub(crate) fn sync_audio(&mut self) {
+ if self.source.is_some() {
+ return;
+ }
let Some(session) = self.session.as_ref() else {
return;
};
- let clips = session.flattened_clips();
- let specs: Vec<ClipSpec> = clips
- .iter()
- .filter(|clip| {
- !clip.muted
- && (clip.kind == concat_export::ClipKind::Audio
- || (clip.kind == concat_export::ClipKind::Video
- && clip.has_audio.unwrap_or(true)))
- })
- // Through the exporter's own cut into pieces, so a curve or a
- // reverse sounds in the window as it will in the file.
- .flat_map(concat_export::audio_pieces)
- .map(|piece| ClipSpec {
- path: piece.path.to_string_lossy().into_owned(),
- audio_stream: piece.stream.map(|index| index as u32),
- start: piece.start,
- duration: piece.duration,
- source_start: piece.source_start,
- volume: piece.volume as f32,
- volume_curve: piece
- .volume_curve
- .keys()
- .iter()
- .map(|key| concat_host::playback::GainKey {
- at: key.at,
- gain: key.value,
- ease: [key.ease.x1, key.ease.y1, key.ease.x2, key.ease.y2],
- })
- .collect(),
- fade_in: piece.fade_in,
- fade_out: piece.fade_out,
- speed: piece.speed,
- preserve_pitch: piece.preserve_pitch,
- chain: piece.filter_chain,
- })
- .collect();
+ let specs = audio_specs(&session.flattened_clips());
self.host
.playback
.set_clips(std::path::PathBuf::from(session.path()), specs);
@@ -2491,6 +2465,10 @@ impl Studio {
concat_project::DocumentSettings,
)> {
let session = self.session.as_ref()?;
+ // A library file on the monitor: its clip alone, flattened once.
+ if let Some(source) = self.source.as_ref() {
+ return Some((std::sync::Arc::clone(&source.clips), session.settings()));
+ }
// The echo when there is one: a picture being dragged on the stage
// is drawn where the pointer has it, not where the document last
// had it. Same flattening the session does for itself, project
@@ -2611,6 +2589,11 @@ impl Studio {
// ── playback ──
pub fn play_toggle(&mut self) {
+ // The monitor's play button and Space play what it shows.
+ if self.source.is_some() {
+ self.source_toggle();
+ return;
+ }
if self.playing {
self.pause();
return;
@@ -2701,6 +2684,8 @@ impl Studio {
/// lets it, which is the default, so the ruler can be clicked beyond the
/// last clip and something placed at the playhead there.
pub fn seek(&mut self, seconds: f32) {
+ // The timeline was clicked: it has the monitor back.
+ self.close_source();
self.playhead = seconds.max(0.0);
if self.prefs.playhead_stops_at_end {
self.playhead = self.playhead.min(self.duration().max(0.0));
@@ -2716,6 +2701,9 @@ impl Studio {
/// The instant the monitor shows: the pointer's while it crosses the
/// lanes with the preview axis on, else the playhead's.
pub fn preview_time(&self) -> f32 {
+ if let Some(source) = self.source.as_ref() {
+ return source.time as f32;
+ }
self.hover.unwrap_or(self.playhead)
}
@@ -7026,6 +7014,7 @@ impl Studio {
self.captions.progress = 0.0;
self.speech.running = false;
self.speech.progress = 0.0;
+ self.source = None;
// A take running as the project closes stops, keeping its file;
// the next project's speakers are not left silent.
self.voiceover = Default::default();
@@ -9222,6 +9211,7 @@ impl Studio {
self.speech.sample_detail_rows(self),
);
app.set_speech(self.speech.data(self));
+ self.publish_source(app);
editor.set_recording(self.voiceover.recording());
let bar = self.menu_bar();
@@ -10096,6 +10086,47 @@ impl Studio {
}
}
+/// The clips a flattened edit makes audible, as playback takes them:
+/// through the exporter's own cut into pieces, so a curve or a reverse
+/// sounds in the window as it will in the file.
+pub(crate) fn audio_specs(clips: &[concat_export::ExportClip]) -> Vec<ClipSpec> {
+ clips
+ .iter()
+ .filter(|clip| {
+ !clip.muted
+ && (clip.kind == concat_export::ClipKind::Audio
+ || (clip.kind == concat_export::ClipKind::Video
+ && clip.has_audio.unwrap_or(true)))
+ })
+ // Through the exporter's own cut into pieces, so a curve or a
+ // reverse sounds in the window as it will in the file.
+ .flat_map(concat_export::audio_pieces)
+ .map(|piece| ClipSpec {
+ path: piece.path.to_string_lossy().into_owned(),
+ audio_stream: piece.stream.map(|index| index as u32),
+ start: piece.start,
+ duration: piece.duration,
+ source_start: piece.source_start,
+ volume: piece.volume as f32,
+ volume_curve: piece
+ .volume_curve
+ .keys()
+ .iter()
+ .map(|key| concat_host::playback::GainKey {
+ at: key.at,
+ gain: key.value,
+ ease: [key.ease.x1, key.ease.y1, key.ease.x2, key.ease.y2],
+ })
+ .collect(),
+ fade_in: piece.fade_in,
+ fade_out: piece.fade_out,
+ speed: piece.speed,
+ preserve_pitch: piece.preserve_pitch,
+ chain: piece.filter_chain,
+ })
+ .collect()
+}
+
#[cfg(test)]
mod tests {
use super::{
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index 71e81522..cf36e477 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -19,7 +19,7 @@ import "../../concat-text/fonts/HankenGrotesk-Italic.ttf";
import { Theme } from "theme/theme.slint";
import { Bezier, Curves, Fmt, Focus, Payload } from "util.slint";
import { EffectData } from "demo/effects-panel.slint";
-import { MediaFilter, MediaItemData, MediaKind, TextPresetData } from "workspace/media-pane.slint";
+import { MediaFilter, MediaItemData, MediaKind, SourcePreview, TextPresetData } from "workspace/media-pane.slint";
import { ContextMenu, MenuItemData, MenuRow } from "primitives/context-menu.slint";
import { ExportData, ExportDialog, ExportPhase } from "dialogs/export.slint";
import { ModelData, SettingsData, SettingsDialog, SystemFactData } from "dialogs/settings.slint";
@@ -54,7 +54,7 @@ export {
Curves, Fmt, Focus, Payload, Theme, Bezier, Editor, I18n,
AppliedEntryData, AppliedParamData, CatalogueEntryData, Library, LibraryViewData, ParamFormat,
DockDivider, DockSide, PaneKind, SeatBox,
- EffectData, MediaFilter, MediaItemData, MediaKind, TextPresetData,
+ EffectData, MediaFilter, MediaItemData, MediaKind, SourcePreview, TextPresetData,
ClipData, ClipField, ClipKeyData, ClipKind, ClipTextField, DropData, Keyframes,
KeyEditor, KeyMarkData, KeyRowData,
SelectedClipData, SelectedTransitionData, StageGuideData, StageItemData, TextAlignment, TimelineTabData,
diff --git a/src/crates/concat/ui/workspace/media-pane.slint b/src/crates/concat/ui/workspace/media-pane.slint
index b1679aad..889db59f 100644
--- a/src/crates/concat/ui/workspace/media-pane.slint
+++ b/src/crates/concat/ui/workspace/media-pane.slint
@@ -26,6 +26,24 @@ export enum MediaKind { video, audio, image }
/// shelf: what the editor read aloud, which the Media rows leave out.
export enum MediaFilter { all, video, audio, images, speech, processed }
+/// The library file lent to the monitor and the speakers, published by
+/// Rust (see concat's source.rs): its card shows how far it has played,
+/// the monitor names it, and its transport runs through it.
+export global SourcePreview {
+ in property <bool> open;
+ in property <string> name;
+ /// The card's row, or -1.
+ in property <int> row: -1;
+ in property <float> time;
+ in property <float> duration;
+ in property <float> progress;
+ in property <bool> playing;
+ /// The monitor's chip was closed: the timeline has it back.
+ callback closed();
+ /// The monitor's timecode moved through the source.
+ callback seek(seconds: float);
+}
+
/// One look a title can be given, as the Text page's Presets shelf shows
/// it: enough of the style to draw the name in it. Published by Rust from
/// the preset list; the id is what is placed, and ids are stable for ever
@@ -581,6 +599,33 @@ export component MediaCard inherits Rectangle {
}
}
+ // The card that is playing, or on the monitor: how far it has
+ // got, as a line across it, and a sound's play or pause in
+ // the middle - a second click does the other.
+ if SourcePreview.row == root.item.id: Rectangle {
+ x: parent.width * Math.clamp(SourcePreview.progress, 0, 1) - 1px;
+ y: 0;
+ width: 2px;
+ height: parent.height;
+ background: Theme.accent;
+ }
+ if SourcePreview.row == root.item.id && root.item.kind == MediaKind.audio: Rectangle {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ width: 26px;
+ height: 26px;
+ border-radius: 13px;
+ background: Theme.scrim;
+
+ Icon {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ glyph: SourcePreview.playing ? Glyph.pause : Glyph.play;
+ size: 12px;
+ tint: Theme.on-scrim;
+ }
+ }
+
// Hover-only: a permanent delete button on every card in a
// full bin is one bin's worth of invitations to lose work.
if card.has-hover && root.removable: Rectangle {
diff --git a/src/crates/concat/ui/workspace/preview-pane.slint b/src/crates/concat/ui/workspace/preview-pane.slint
index 8fae91b2..3ef7ca98 100644
--- a/src/crates/concat/ui/workspace/preview-pane.slint
+++ b/src/crates/concat/ui/workspace/preview-pane.slint
@@ -6,6 +6,7 @@ import { Theme } from "../theme/theme.slint";
import { Fmt } from "../util.slint";
import { Glyph, Icon } from "../icons.slint";
import { IconButton } from "../primitives/panel.slint";
+import { Tip } from "../primitives/tooltip.slint";
import { NumberField } from "../primitives/number-field.slint";
import { Select } from "../primitives/select.slint";
import { Pane, PaneHeader } from "pane.slint";
@@ -632,6 +633,10 @@ export component PreviewPane inherits Rectangle {
/// for one.
in property <bool> has-picture;
in property <string> clip-name;
+ /// A library file shown instead of the timeline, by name; empty when
+ /// the monitor is the timeline's.
+ in property <string> source-name;
+ callback source-closed();
/// The decoded frame. Drawn fitted to the stage when there is one.
in property <image> frame;
/// Every picture under the playhead, for the selection drawn over the
@@ -961,6 +966,58 @@ export component PreviewPane inherits Rectangle {
root.frame-token += 1;
}
}
+
+ // A library file on the monitor: its name, and the cross that
+ // gives the monitor back to the timeline. Over the selection's
+ // overlay, which has nothing to show while a source is up.
+ if root.source-name != "": Rectangle {
+ x: stage.x + 8px;
+ y: stage.y + 8px;
+ width: chip-row.preferred-width;
+ height: 24px;
+ border-radius: 12px;
+ background: Theme.scrim;
+
+ chip-row := HorizontalLayout {
+ padding-left: 10px;
+ padding-right: 4px;
+ spacing: 6px;
+
+ Text {
+ text: I18n.t("previewPane.source") + " · " + root.source-name;
+ color: Theme.on-scrim;
+ font-size: Theme.fs-sm;
+ vertical-alignment: center;
+ overflow: elide;
+ max-width: stage.width - 60px;
+ }
+ VerticalLayout {
+ alignment: center;
+ Rectangle {
+ width: 18px;
+ height: 18px;
+ border-radius: 9px;
+ background: close-touch.has-hover ? Theme.on-scrim.with-alpha(0.2) : transparent;
+
+ Icon {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ glyph: Glyph.close;
+ size: 10px;
+ tint: Theme.on-scrim;
+ }
+ close-touch := TouchArea {
+ mouse-cursor: pointer;
+ clicked => { root.source-closed(); }
+ }
+ Tip {
+ text: I18n.t("previewPane.backToTimeline");
+ active: close-touch.has-hover;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index 817019ae..8d47c1ac 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -7,7 +7,7 @@ import { DockSide } from "../dock.slint";
import { PaneKind } from "pane-switcher.slint";
import { Editor } from "../editor.slint";
import { ConfigPane } from "config-pane.slint";
-import { MediaPane } from "media-pane.slint";
+import { MediaPane, SourcePreview } from "media-pane.slint";
import { PreviewPane } from "preview-pane.slint";
import { TimelinePane } from "timeline-pane.slint";
import { KeyframesPane } from "keyframes-pane.slint";
@@ -164,14 +164,17 @@ export component Seat inherits Rectangle {
frame-rate: Editor.frame-rate;
ratio-index: Editor.ratio-index;
quality-index: Editor.quality-index;
- playhead: Editor.playhead;
- duration: Editor.preview-duration;
- playhead-free: Editor.playhead-free;
- playing: Editor.playing;
+ // A library file on the monitor has its transport: the readout,
+ // the play button and the timecode run through the source.
+ playhead: SourcePreview.open ? SourcePreview.time : Editor.playhead;
+ duration: SourcePreview.open ? SourcePreview.duration : Editor.preview-duration;
+ playhead-free: Editor.playhead-free && !SourcePreview.open;
+ playing: SourcePreview.open ? SourcePreview.playing : Editor.playing;
+ source-name: SourcePreview.open ? SourcePreview.name : "";
has-picture: Editor.has-picture;
clip-name: Editor.preview-clip-name;
frame: Editor.preview-frame;
- stage-items: Editor.stage-items;
+ stage-items: SourcePreview.open ? [] : Editor.stage-items;
stage-guides: Editor.stage-guides;
stroke-path: Editor.stroke-path;
stroke-width: Editor.stroke-width;
@@ -179,8 +182,21 @@ export component Seat inherits Rectangle {
painting: Editor.painting && Editor.selected-clip.cutout == 2;
play-toggled => { Editor.play-toggled(); }
- seek(seconds) => { Editor.seek(seconds); }
- step(frames) => { Editor.step-frames(frames); }
+ seek(seconds) => {
+ if (SourcePreview.open) {
+ SourcePreview.seek(seconds);
+ } else {
+ Editor.seek(seconds);
+ }
+ }
+ step(frames) => {
+ if (SourcePreview.open) {
+ SourcePreview.seek(SourcePreview.time + frames / Editor.frame-rate);
+ } else {
+ Editor.step-frames(frames);
+ }
+ }
+ source-closed => { SourcePreview.closed(); }
ratio-changed(index) => { Editor.ratio-changed(index); }
quality-changed(index) => { Editor.quality-changed(index); }
stage-pressed(x, y, additive) => {