Skip to content

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

fix(window): new projects on an iPhone, a second Untitled project, a click that moved a clip, Detach that said nothing, and no dialog under the studio borrow (#299, #151, #247, #310, #283)

Jareer132f68df45a5
diff --git a/src/crates/concat/locales/bn.json b/src/crates/concat/locales/bn.json
index 2ef17b83..936ee8d6 100644
--- a/src/crates/concat/locales/bn.json
+++ b/src/crates/concat/locales/bn.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0}টি কাস্টম প্যাকেজ লোড হয়নি; প্রথমটি: {1}",
"studio.deleteClip": "ক্লিপ মুছুন",
"studio.deleteClips": "{0}টি ক্লিপ মুছুন",
+ "studio.detachAlready": "এই ক্লিপের অডিও আগেই আলাদা করা হয়েছে।",
"studio.detachAudio": "অডিও আলাদা করুন",
+ "studio.detachNoSound": "এই ক্লিপে আলাদা করার মতো কোনো অডিও নেই।",
"studio.duplicate": "ডুপ্লিকেট",
"studio.enhance": "এনহ্যান্স: {0}",
"studio.enhanceAlreadyWorkOne": "এনহ্যান্স ইতিমধ্যে কাজ করছে; একবারে একটি ক্লিপ",
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index cb799f1c..fb1ba1bb 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} eigene Pakete wurden nicht geladen; das erste: {1}",
"studio.deleteClip": "Clip löschen",
"studio.deleteClips": "{0} Clips löschen",
+ "studio.detachAlready": "Das Audio dieses Clips ist bereits getrennt.",
"studio.detachAudio": "Audio trennen",
+ "studio.detachNoSound": "Dieser Clip hat kein Audio, das sich trennen ließe.",
"studio.duplicate": "Duplizieren",
"studio.enhance": "Verbessern: {0}",
"studio.enhanceAlreadyWorkOne": "Verbessern läuft bereits; ein Clip nach dem anderen",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index af042419..5174887f 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} custom packages did not load; the first: {1}",
"studio.deleteClip": "Delete clip",
"studio.deleteClips": "Delete {0} clips",
+ "studio.detachAlready": "This clip's audio is already detached.",
"studio.detachAudio": "Detach audio",
+ "studio.detachNoSound": "This clip has no audio to detach.",
"studio.duplicate": "Duplicate",
"studio.enhance": "Enhance: {0}",
"studio.enhanceAlreadyWorkOne": "Enhance is already at work; one clip at a time",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index ba44de4e..406f5239 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} paquetes personalizados no se cargaron; el primero: {1}",
"studio.deleteClip": "Eliminar clip",
"studio.deleteClips": "Eliminar {0} clips",
+ "studio.detachAlready": "El audio de este clip ya está separado.",
"studio.detachAudio": "Separar audio",
+ "studio.detachNoSound": "Este clip no tiene audio que separar.",
"studio.duplicate": "Duplicar",
"studio.enhance": "Mejorar: {0}",
"studio.enhanceAlreadyWorkOne": "Mejorar ya está en marcha; un clip cada vez",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 6a5f855d..784a256a 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} بسته سفارشی بارگذاری نشدند؛ اولین مورد: {1}",
"studio.deleteClip": "حذف کلیپ",
"studio.deleteClips": "حذف {0} کلیپ",
+ "studio.detachAlready": "صدای این کلیپ از قبل جدا شده است.",
"studio.detachAudio": "جدا کردن صدا",
+ "studio.detachNoSound": "این کلیپ صدایی برای جدا کردن ندارد.",
"studio.duplicate": "تکثیر",
"studio.enhance": "بهبود کیفیت: {0}",
"studio.enhanceAlreadyWorkOne": "بهبود کیفیت در حال انجام است؛ هر بار فقط یک کلیپ",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 70adff32..645b579e 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} paquets personnalisés n'ont pas été chargés ; le premier : {1}",
"studio.deleteClip": "Supprimer le clip",
"studio.deleteClips": "Supprimer {0} clips",
+ "studio.detachAlready": "L'audio de ce clip est déjà détaché.",
"studio.detachAudio": "Détacher l'audio",
+ "studio.detachNoSound": "Ce clip n'a pas d'audio à détacher.",
"studio.duplicate": "Dupliquer",
"studio.enhance": "Amélioration : {0}",
"studio.enhanceAlreadyWorkOne": "L'amélioration est déjà en cours ; un clip à la fois",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 24a49b7f..a17d1021 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} prilagođenih paketa nije se učitalo; prvi: {1}",
"studio.deleteClip": "Obriši klip",
"studio.deleteClips": "Obriši {0} klipova",
+ "studio.detachAlready": "Zvuk ovog isječka već je odvojen.",
"studio.detachAudio": "Odvoji zvuk",
+ "studio.detachNoSound": "Ovaj isječak nema zvuka koji bi se mogao odvojiti.",
"studio.duplicate": "Udvostruči",
"studio.enhance": "Poboljšanje: {0}",
"studio.enhanceAlreadyWorkOne": "Poboljšanje već radi; jedan klip odjednom",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 79b819c4..416aad78 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} pacchetti personalizzati non si sono caricati; il primo: {1}",
"studio.deleteClip": "Elimina clip",
"studio.deleteClips": "Elimina {0} clip",
+ "studio.detachAlready": "L'audio di questa clip è già separato.",
"studio.detachAudio": "Separa l'audio",
+ "studio.detachNoSound": "Questa clip non ha audio da separare.",
"studio.duplicate": "Duplica",
"studio.enhance": "Migliora: {0}",
"studio.enhanceAlreadyWorkOne": "Migliora è già al lavoro: una clip alla volta",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 8fea217d..adb4bd02 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} 個のカスタムパッケージを読み込めませんでした。最初のもの : {1}",
"studio.deleteClip": "クリップを削除",
"studio.deleteClips": "{0} 個のクリップを削除",
+ "studio.detachAlready": "このクリップの音声はすでに分離されています。",
"studio.detachAudio": "音声を分離",
+ "studio.detachNoSound": "このクリップには分離できる音声がありません。",
"studio.duplicate": "複製",
"studio.enhance": "高画質化 : {0}",
"studio.enhanceAlreadyWorkOne": "高画質化はすでに実行中です。一度に一つのクリップだけ処理できます",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 0da48b0e..c73b4e12 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "사용자 지정 패키지 {0}개를 불러오지 못했습니다. 첫 번째: {1}",
"studio.deleteClip": "클립 삭제",
"studio.deleteClips": "클립 {0}개 삭제",
+ "studio.detachAlready": "이 클립의 오디오는 이미 분리되어 있습니다.",
"studio.detachAudio": "오디오 분리",
+ "studio.detachNoSound": "이 클립에는 분리할 오디오가 없습니다.",
"studio.duplicate": "복제",
"studio.enhance": "향상: {0}",
"studio.enhanceAlreadyWorkOne": "향상이 이미 진행 중입니다. 한 번에 한 클립씩만 가능합니다",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index b8519e6b..315b54ad 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} pacotes personalizados não carregaram; o primeiro: {1}",
"studio.deleteClip": "Excluir clipe",
"studio.deleteClips": "Excluir {0} clipes",
+ "studio.detachAlready": "O áudio deste clipe já está separado.",
"studio.detachAudio": "Separar áudio",
+ "studio.detachNoSound": "Este clipe não tem áudio para separar.",
"studio.duplicate": "Duplicar",
"studio.enhance": "Melhorar: {0}",
"studio.enhanceAlreadyWorkOne": "Melhorar já está em andamento; um clipe por vez",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index 08797eac..ec18ff36 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "Не загрузились пользовательские пакеты: {0}; первый: {1}",
"studio.deleteClip": "Удалить клип",
"studio.deleteClips": "Удалить клипы: {0}",
+ "studio.detachAlready": "Звук этого клипа уже отделён.",
"studio.detachAudio": "Отделить звук",
+ "studio.detachNoSound": "У этого клипа нет звука, который можно отделить.",
"studio.duplicate": "Дублировать",
"studio.enhance": "Улучшение: {0}",
"studio.enhanceAlreadyWorkOne": "Улучшение уже идёт; по одному клипу за раз",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 87769e37..7e8d471e 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} özel paket yüklenemedi; ilki: {1}",
"studio.deleteClip": "Klibi sil",
"studio.deleteClips": "{0} klibi sil",
+ "studio.detachAlready": "Bu klibin sesi zaten ayrılmış.",
"studio.detachAudio": "Sesi ayır",
+ "studio.detachNoSound": "Bu klipte ayrılacak ses yok.",
"studio.duplicate": "Çoğalt",
"studio.enhance": "İyileştirme: {0}",
"studio.enhanceAlreadyWorkOne": "İyileştirme zaten çalışıyor; aynı anda tek klip",
diff --git a/src/crates/concat/locales/vi.json b/src/crates/concat/locales/vi.json
index 2ea54e99..24c3112a 100644
--- a/src/crates/concat/locales/vi.json
+++ b/src/crates/concat/locales/vi.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "Không tải được {0} gói tùy chỉnh; gói đầu tiên: {1}",
"studio.deleteClip": "Xóa clip",
"studio.deleteClips": "Xóa {0} clip",
+ "studio.detachAlready": "Âm thanh của clip này đã được tách.",
"studio.detachAudio": "Tách âm thanh",
+ "studio.detachNoSound": "Clip này không có âm thanh để tách.",
"studio.duplicate": "Nhân bản",
"studio.enhance": "Nâng cao: {0}",
"studio.enhanceAlreadyWorkOne": "Tính năng Nâng cao đang chạy; mỗi lần chỉ xử lý một clip",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 1c94fdd9..b5d8bbf8 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} 个自定义包未能加载;第一个:{1}",
"studio.deleteClip": "删除片段",
"studio.deleteClips": "删除 {0} 个片段",
+ "studio.detachAlready": "此片段的音频已经分离。",
"studio.detachAudio": "分离音频",
+ "studio.detachNoSound": "此片段没有可分离的音频。",
"studio.duplicate": "创建副本",
"studio.enhance": "增强:{0}",
"studio.enhanceAlreadyWorkOne": "增强正在进行中;一次只能处理一个片段",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 4f7d765f..998d9b14 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -877,7 +877,9 @@
"studio.customPackagesDidNot": "{0} 個自訂套件未能載入;第一個:{1}",
"studio.deleteClip": "刪除片段",
"studio.deleteClips": "刪除 {0} 個片段",
+ "studio.detachAlready": "此片段的音訊已經分離。",
"studio.detachAudio": "分離音訊",
+ "studio.detachNoSound": "此片段沒有可分離的音訊。",
"studio.duplicate": "複製",
"studio.enhance": "增強:{0}",
"studio.enhanceAlreadyWorkOne": "增強正在進行中;一次只能處理一個片段",
diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rs
index f8770a41..b8d725ce 100644
--- a/src/crates/concat/src/host.rs
+++ b/src/crates/concat/src/host.rs
@@ -367,6 +367,38 @@ pub fn after_dialog<T: Send + 'static>(
});
}
+/// [`after_dialog`] for files, on every platform. The desktop's dialog is
+/// asked on a turn of its own with the studio unborrowed. A phone's picker
+/// is another screen, which answers later from whichever thread it likes,
+/// so it is asked the same way and answered through [`on_ui`]. `then` is
+/// not called for a picker dismissed with nothing chosen. `filter` names a
+/// family and its extensions, for the desktop's dialog; a phone's offers
+/// every kind of media on its own.
+pub fn pick_files_then(
+ title: String,
+ filter: Option<(String, &'static [&'static str])>,
+ then: impl FnOnce(&mut Studio, &App, &Models, Vec<std::path::PathBuf>) + Send + 'static,
+) {
+ if cfg!(any(target_os = "android", target_os = "ios")) {
+ let _ = slint::invoke_from_event_loop(move || {
+ let filter = filter.as_ref().map(|(name, list)| (name.as_str(), *list));
+ crate::platform::pick_files_async(&title, filter, move |paths| {
+ if !paths.is_empty() {
+ on_ui(move |studio, app, models| then(studio, app, models, paths));
+ }
+ });
+ });
+ } else {
+ after_dialog(
+ move || {
+ let filter = filter.as_ref().map(|(name, list)| (name.as_str(), *list));
+ crate::platform::pick_files(&title, filter)
+ },
+ then,
+ );
+ }
+}
+
fn on_ui_gated(epoch: Option<u64>, body: impl FnOnce(&mut Studio, &App, &Models) + Send + 'static) {
let _ = slint::invoke_from_event_loop(move || {
Shell::with(|shell, app| {
diff --git a/src/crates/concat/src/launch.rs b/src/crates/concat/src/launch.rs
index 9bcb8766..201d5e28 100644
--- a/src/crates/concat/src/launch.rs
+++ b/src/crates/concat/src/launch.rs
@@ -6,46 +6,83 @@
use std::ffi::OsString;
use std::path::PathBuf;
+const USAGE: &str = "usage: concat [--project <PROJECT_DIRECTORY> | --version | --smoke]";
+
+/// What one run of the binary was asked to do.
+#[derive(Debug, PartialEq, Eq)]
+pub enum Launch {
+ /// The window, on the launch screen or on the project it names.
+ Normal(Option<PathBuf>),
+ /// Print the version and exit, before logging, the GPU or a window: a
+ /// run that gets this far has proved the executable and every library
+ /// it links were found and loaded, which on Windows fails before `main`.
+ Version,
+ /// Start the way a desktop launch does, through the first publish of
+ /// the window's models, and exit instead of entering the event loop.
+ /// For CI, which has no one to close a window.
+ Smoke,
+}
+
/// No arguments preserves the launch screen; a project names its directory.
-pub fn project(args: impl IntoIterator<Item = OsString>) -> Result<Option<PathBuf>, String> {
+pub fn parse(args: impl IntoIterator<Item = OsString>) -> Result<Launch, String> {
let mut args = args.into_iter();
let Some(option) = args.next() else {
- return Ok(None);
+ return Ok(Launch::Normal(None));
+ };
+ let launch = if option == "--version" {
+ Launch::Version
+ } else if option == "--smoke" {
+ Launch::Smoke
+ } else if option == "--project" {
+ let path = args
+ .next()
+ .filter(|path| !path.is_empty() && path != "--project")
+ .ok_or_else(|| "--project requires a project directory".to_string())?;
+ Launch::Normal(Some(PathBuf::from(path)))
+ } else {
+ return Err(USAGE.into());
};
- if option != "--project" {
- return Err("usage: concat [--project <PROJECT_DIRECTORY>]".into());
- }
- let path = args
- .next()
- .filter(|path| !path.is_empty() && path != "--project")
- .ok_or_else(|| "--project requires a project directory".to_string())?;
if args.next().is_some() {
- return Err("usage: concat [--project <PROJECT_DIRECTORY>]".into());
+ return Err(USAGE.into());
}
- Ok(Some(PathBuf::from(path)))
+ Ok(launch)
}
#[cfg(test)]
mod tests {
use super::*;
- fn parse(args: &[&str]) -> Result<Option<PathBuf>, String> {
- project(args.iter().map(|arg| OsString::from(*arg)))
+ fn parse_strs(args: &[&str]) -> Result<Launch, String> {
+ parse(args.iter().map(|arg| OsString::from(*arg)))
}
#[test]
fn no_arguments_keeps_the_launch_screen() {
- assert_eq!(parse(&[]).unwrap(), None);
+ assert_eq!(parse_strs(&[]).unwrap(), Launch::Normal(None));
}
#[test]
fn accepts_a_directory_with_spaces_and_unicode() {
assert_eq!(
- parse(&["--project", "podcasts/Café com amigos"]).unwrap(),
- Some(PathBuf::from("podcasts/Café com amigos"))
+ parse_strs(&["--project", "podcasts/Café com amigos"]).unwrap(),
+ Launch::Normal(Some(PathBuf::from("podcasts/Café com amigos")))
);
}
+ #[test]
+ fn version_and_smoke_take_no_arguments() {
+ assert_eq!(parse_strs(&["--version"]).unwrap(), Launch::Version);
+ assert_eq!(parse_strs(&["--smoke"]).unwrap(), Launch::Smoke);
+ for args in [
+ vec!["--version", "--smoke"],
+ vec!["--smoke", "--project", "one"],
+ vec!["--version", "extra"],
+ vec!["--project", "one", "--smoke"],
+ ] {
+ assert!(parse_strs(&args).is_err(), "{args:?}");
+ }
+ }
+
#[test]
fn rejects_missing_empty_duplicate_and_unknown_arguments() {
for args in [
@@ -56,7 +93,7 @@ mod tests {
vec!["--unknown"],
vec!["one"],
] {
- assert!(parse(&args).is_err(), "{args:?}");
+ assert!(parse_strs(&args).is_err(), "{args:?}");
}
}
@@ -66,8 +103,8 @@ mod tests {
use std::os::unix::ffi::OsStringExt;
let path = OsString::from_vec(vec![b'/', 0xff]);
assert_eq!(
- project([OsString::from("--project"), path.clone()]).unwrap(),
- Some(PathBuf::from(path))
+ parse([OsString::from("--project"), path.clone()]).unwrap(),
+ Launch::Normal(Some(PathBuf::from(path)))
);
}
}
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index e1c172e1..0606cd7f 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -80,7 +80,7 @@ mod wayland_drop {
}
use dock::{Dock, METERS_MIN_W, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
-use host::{Host, Shell, on_ui};
+use host::{Host, Shell};
use panes::Msg;
use panes::captions::CaptionsMsg;
use panes::export::ExportMsg;
@@ -140,6 +140,25 @@ pub fn run() -> Result<(), slint::PlatformError> {
/// unreadable project leaves the launch screen open with the usual error notice.
/// Each invocation creates its own window; this does not control another instance.
pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint::PlatformError> {
+ start(project, false)
+}
+
+/// Starts the way [`run`] does, as far as the window's first publish, and
+/// exits the process with status 0 there instead of entering the event
+/// loop, so nothing is shown and nobody has to close anything.
+///
+/// For CI: a smoke run goes through everything a launch on a fresh machine
+/// does - the GPU, the engine's services, the window's component, the
+/// studio and its packages, every model handed to the window - and fails
+/// the way a launch would, with the reason in the log and an `Err` here.
+/// No project is opened, so the recents list is not touched; the
+/// preferences are read, and a log file written, as on any launch.
+pub fn smoke() -> Result<(), slint::PlatformError> {
+ start(None, true)
+}
+
+/// [`run_with_project`], or [`smoke`] when `smoke` is set.
+fn start(project: Option<std::path::PathBuf>, smoke: bool) -> Result<(), slint::PlatformError> {
// The shell doesn't exist yet - it needs the window the backend is about
// to help create - but `Shell::with` is a no-op until `Shell::install`
// runs, and by the time an OS drop can actually happen, it has. Import
@@ -680,26 +699,24 @@ pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint
state.handle(Msg::Media(MediaMsg::RemoveSelected));
}));
// Not through the handler macro: nothing here changes the state, and
- // the import is asynchronous - a phone's picker is another screen, and
- // the files come back later, on whatever thread, to be imported on the
- // window's. A desktop's dialog answers before this returns.
+ // the dialog is asked on a turn of its own with the studio unborrowed;
+ // a phone's picker is another screen, and its files come back later.
+ // See `host::pick_files_then`.
editor.on_import_media(|| {
Shell::with(|shell, _| {
if shell.studio.borrow().session.is_none() {
return;
}
- platform::pick_files_async(
- &i18n::t("lib.importMedia"),
+ host::pick_files_then(
+ i18n::t("lib.importMedia"),
Some((
- i18n::t("common.media").as_str(),
+ i18n::t("common.media"),
&[
"mp4", "mov", "mkv", "webm", "avi", "m4v", "mp3", "wav", "aac", "m4a",
"flac", "ogg", "png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff",
],
)),
- |paths| {
- on_ui(move |studio, _, _| studio.handle(Msg::Media(MediaMsg::Import(paths))))
- },
+ |studio, _, _, paths| studio.handle(Msg::Media(MediaMsg::Import(paths))),
);
});
});
@@ -713,10 +730,10 @@ pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint
if shell.studio.borrow().session.is_none() {
return;
}
- platform::pick_files_async(
- &i18n::t("lib.importFont"),
- Some((i18n::t("lib.fonts").as_str(), &["ttf", "otf", "ttc"])),
- |paths| on_ui(move |studio, _, _| studio.import_fonts(paths)),
+ host::pick_files_then(
+ i18n::t("lib.importFont"),
+ Some((i18n::t("lib.fonts"), &["ttf", "otf", "ttc"])),
+ |studio, _, _, paths| studio.import_fonts(paths),
);
});
});
@@ -754,9 +771,9 @@ pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint
editor.on_library_save_template(on_window!(|state| {
state.save_template();
}));
- editor.on_library_import_lut(on_window!(|state| {
- state.import_lut();
- }));
+ // Nothing borrowed: the dialog is asked on a turn of its own, and the
+ // files it answers with are imported there; see `host::after_dialog`.
+ editor.on_library_import_lut(Studio::import_lut);
editor.on_library_reload_packages(on_window!(|state| {
state.reload_packages(true);
}));
@@ -1632,17 +1649,16 @@ pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint
// cannot drift into disagreeing about what a project
// folder is.
"open" => state.handle(Msg::Start(StartMsg::Open)),
- "import" => {
- platform::pick_files_async(
- &i18n::t("lib.importMedia"),
- None,
- |paths| {
- on_ui(move |studio, _, _| {
- studio.handle(Msg::Media(MediaMsg::Import(paths)))
- })
- },
- );
- }
+ // Asked with the studio unborrowed - it is
+ // borrowed for this whole match - and on a turn of
+ // its own; see `host::after_dialog`.
+ "import" => host::pick_files_then(
+ i18n::t("lib.importMedia"),
+ None,
+ |studio, _, _, paths| {
+ studio.handle(Msg::Media(MediaMsg::Import(paths)))
+ },
+ ),
"export" => state.handle(Msg::Export(ExportMsg::Open)),
"template" => state.save_template(),
"speech" => state.handle(Msg::Speech(SpeechMsg::Open)),
@@ -1864,6 +1880,16 @@ pub fn run_with_project(project: Option<std::path::PathBuf>) -> Result<(), slint
shell.studio.borrow().publish(&app, &shell.models);
}
+ // As far as a smoke run goes: everything the first frame needs exists
+ // and has been handed to the window. The exit is the one the event
+ // loop's end takes below, for the same reason - the engine's threads
+ // are not waited on.
+ if smoke {
+ log::info!("smoke: ok");
+ log::logger().flush();
+ std::process::exit(0);
+ }
+
// Decoders nobody has asked a frame of for ten seconds are closed,
// looked at every five: each holds buffers of its own, and the playhead
// leaves files behind. One reopens on its next frame. Held here, for
diff --git a/src/crates/concat/src/main.rs b/src/crates/concat/src/main.rs
index c98bee25..6f54e8a8 100644
--- a/src/crates/concat/src/main.rs
+++ b/src/crates/concat/src/main.rs
@@ -9,15 +9,39 @@
mod launch;
+use launch::Launch;
+
fn main() -> Result<(), slint::PlatformError> {
+ let launch = launch::parse(std::env::args_os().skip(1));
+ // Before the log, the GPU and the window: all this proves is that the
+ // executable and the libraries it links were loaded, and it should
+ // prove nothing else. A write that fails - a closed pipe, a GUI build
+ // with no standard output - is not a reason to panic.
+ if launch == Ok(Launch::Version) {
+ use std::io::Write;
+ let _ = writeln!(std::io::stdout(), "concat {}", env!("CARGO_PKG_VERSION"));
+ return Ok(());
+ }
// A desktop's console is its standard error, which a packaged build
// has wired to nowhere; hence the file underneath it.
concat::open_logging(None);
// A failure here is the one this binary would otherwise swallow: with
// no console, the runtime's "Error: ..." on standard error is lost.
// https://github.com/jub0t/Concat/issues/135
- let project = launch::project(std::env::args_os().skip(1))
+ let launch = launch
.map_err(slint::PlatformError::Other)
.inspect_err(concat::report_startup_failure)?;
- concat::run_with_project(project).inspect_err(concat::report_startup_failure)
+ match launch {
+ Launch::Normal(project) => {
+ concat::run_with_project(project).inspect_err(concat::report_startup_failure)
+ }
+ // Logged and returned, never put up in a dialog: a smoke run is a
+ // machine's, and a modal box with nobody to press OK would hang it
+ // rather than fail it. Returning the error exits non-zero.
+ Launch::Smoke => concat::smoke().inspect_err(|error| {
+ log::error!("smoke: could not start: {error}");
+ }),
+ // Answered above, before the log was opened.
+ Launch::Version => Ok(()),
+ }
}
diff --git a/src/crates/concat/src/panes/start.rs b/src/crates/concat/src/panes/start.rs
index 13244854..662d6607 100644
--- a/src/crates/concat/src/panes/start.rs
+++ b/src/crates/concat/src/panes/start.rs
@@ -5,6 +5,8 @@
//! and rate, the verb that opens one that already exists, and the project
//! grid's own two verbs.
+use std::path::{Path, PathBuf};
+
use concat_host::projects;
use crate::i18n::{t, tf};
@@ -40,6 +42,8 @@ pub enum StartMsg {
Create,
/// Open a project that already exists, picked from disk.
Open,
+ /// The folder the Open picker answered with.
+ OpenChosen(PathBuf),
OpenRecent(String),
ForgetRecent(String),
}
@@ -71,7 +75,7 @@ impl Default for StartPane {
fn default() -> Self {
Self {
composing: false,
- name: "Untitled project".into(),
+ name: UNTITLED.into(),
location: default_location(),
aspect: 0,
// 1080p, not the first of the three. The size everything else
@@ -86,20 +90,66 @@ impl Default for StartPane {
}
}
-/// Where a new project goes unless told otherwise: a Concat folder on the
-/// desktop. The desktop the system names, not `~/Desktop`: on Windows
-/// OneDrive often moves it, and on Linux it is called what the desktop's
-/// language calls it. A phone has no desk: its projects live at the top of
-/// the folder the file manager shows for the app.
+/// Where a new project goes unless told otherwise; see [`location_on`].
+/// On an iPhone the folder is made here, so that the Files app shows it
+/// from the first launch and not only from the first project.
fn default_location() -> String {
- if cfg!(target_os = "android") {
- return home_folder("Concat");
- }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
- if let Some(desktop) = dirs::desktop_dir() {
- return desktop.join("Concat").to_string_lossy().into_owned();
+ let desktop = dirs::desktop_dir();
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ let desktop = None;
+ let location = location_on(std::env::consts::OS, desktop, home_folder);
+ if cfg!(target_os = "ios")
+ && !location.is_empty()
+ && let Err(error) = std::fs::create_dir_all(&location)
+ {
+ log::warn!("could not make {location}: {error}");
+ }
+ location
+}
+
+/// Where a new project goes on `os`: a Concat folder on the desktop. The
+/// desktop the system names, not `~/Desktop`: on Windows OneDrive often
+/// moves it, and on Linux it is called what the desktop's language calls
+/// it. A phone has no desk. An Android phone's projects live at the top of
+/// the folder the file manager shows for the app. An iPhone's live in the
+/// app's Documents, the one folder of its sandbox the Files app can show:
+/// `~/Desktop` there is a folder the app is not allowed to make, and every
+/// new project failed with EPERM. https://github.com/jub0t/Concat/issues/299
+fn location_on(os: &str, desktop: Option<PathBuf>, home: impl Fn(&str) -> String) -> String {
+ match os {
+ "android" => home("Concat"),
+ "ios" => home("Documents/Concat"),
+ _ => desktop
+ .map(|desktop| desktop.join("Concat").to_string_lossy().into_owned())
+ .unwrap_or_else(|| home("Desktop/Concat")),
}
- home_folder("Desktop/Concat")
+}
+
+/// What an unnamed project is called.
+const UNTITLED: &str = "Untitled project";
+
+/// Whether `name` is one this sheet made up rather than one somebody
+/// typed: "Untitled project", or that with a number after it.
+fn is_untitled(name: &str) -> bool {
+ let name = name.trim();
+ name.is_empty()
+ || name == UNTITLED
+ || name
+ .strip_prefix(UNTITLED)
+ .and_then(|rest| rest.strip_prefix(' '))
+ .is_some_and(|number| number.parse::<u32>().is_ok_and(|n| n >= 2))
+}
+
+/// The first of "Untitled project", "Untitled project 2", ... whose folder
+/// is not `taken`. A second new project in the same place used to be
+/// refused as "already exists" until it was renamed by hand.
+/// https://github.com/jub0t/Concat/issues/151
+fn first_free_untitled(taken: impl Fn(&str) -> bool) -> String {
+ std::iter::once(UNTITLED.to_owned())
+ .chain((2..).map(|n| format!("{UNTITLED} {n}")))
+ .find(|name| !taken(&projects::folder_name(name)))
+ .expect("the numbers do not run out")
}
impl StartPane {
@@ -107,7 +157,14 @@ impl StartPane {
/// this runs the studio's copy of the pane is a blank it must not read.
pub fn update(&mut self, msg: StartMsg, studio: &mut Studio) {
match msg {
- StartMsg::Compose => self.composing = true,
+ StartMsg::Compose => {
+ self.composing = true;
+ // A name somebody typed is kept for next time; one this
+ // sheet made up moves on past the folders already there.
+ if is_untitled(&self.name) {
+ self.name = self.free_untitled();
+ }
+ }
StartMsg::Dismiss => {
self.composing = false;
// The notice belongs to the attempt it reported on, not to
@@ -157,7 +214,8 @@ impl StartPane {
}
StartMsg::FolderChosen(folder) => self.location = folder,
StartMsg::Create => self.create(studio),
- StartMsg::Open => self.open(studio),
+ StartMsg::Open => self.open(),
+ StartMsg::OpenChosen(folder) => Self::open_chosen(&folder, studio),
// Both of the grid's verbs report through the toast, as Open
// does: the sheet is down while a card is pressed, and a notice
// inside it would go unseen.
@@ -182,7 +240,7 @@ impl StartPane {
fn create(&mut self, studio: &mut Studio) {
let name = self.name.trim().to_owned();
let name = if name.is_empty() {
- "Untitled project".to_owned()
+ self.free_untitled()
} else {
name
};
@@ -216,12 +274,25 @@ impl StartPane {
/// through the toast rather than through the sheet's notice: the sheet
/// is down when this is pressed, and half the presses of this never see
/// the launch screen at all.
- fn open(&mut self, studio: &mut Studio) {
- let Some(folder) = platform::pick_folder(&t("start.openAProject"), &self.location) else {
- return;
- };
+ ///
+ /// The picker runs with the studio unborrowed, as Browse's does, and
+ /// the folder comes back as [`StartMsg::OpenChosen`]; see
+ /// `host::after_dialog`.
+ fn open(&self) {
+ let title = t("start.openAProject");
+ let current = self.location.clone();
+ crate::host::after_dialog(
+ move || platform::pick_folder(&title, &current),
+ |studio, _, _, folder| {
+ studio.handle(crate::panes::Msg::Start(StartMsg::OpenChosen(folder)));
+ },
+ );
+ }
+
+ /// The folder Open was answered with: checked, then opened.
+ fn open_chosen(folder: &Path, studio: &mut Studio) {
let path = folder.to_string_lossy().into_owned();
- if !projects::is_project(&folder) {
+ if !projects::is_project(folder) {
studio.notify(&tf("start.notConcatProjectFolder", &[&path]), true);
return;
}
@@ -230,6 +301,17 @@ impl StartPane {
}
}
+ /// The first untitled name with no folder of that name where the sheet
+ /// says the project goes. Any folder counts, not only a project: a new
+ /// project is not made inside something that is already there.
+ fn free_untitled(&self) -> String {
+ let location = self.location.trim();
+ if location.is_empty() {
+ return UNTITLED.to_owned();
+ }
+ first_free_untitled(|folder| Path::new(location).join(folder).exists())
+ }
+
/// Whether the frame is typed rather than picked.
fn custom_frame(&self) -> bool {
self.size >= SIZES.len()
@@ -282,3 +364,81 @@ impl StartPane {
}
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ /// An iPhone's projects go in its Documents, whatever a desktop would
+ /// have said; a desktop's go on the desktop the system names.
+ #[test]
+ fn each_platform_has_a_place_for_new_projects() {
+ let home = |name: &str| format!("/home/{name}");
+ let desktop = || Some(PathBuf::from("/desk"));
+ assert_eq!(
+ location_on("ios", desktop(), home),
+ "/home/Documents/Concat"
+ );
+ assert_eq!(location_on("ios", None, home), "/home/Documents/Concat");
+ assert_eq!(location_on("android", None, home), "/home/Concat");
+ assert_eq!(
+ PathBuf::from(location_on("macos", desktop(), home)),
+ Path::new("/desk").join("Concat")
+ );
+ assert_eq!(location_on("linux", None, home), "/home/Desktop/Concat");
+ }
+
+ /// The next untitled name skips every folder already there, and starts
+ /// over at the plain name once that is free again.
+ #[test]
+ fn a_second_untitled_project_gets_a_name_of_its_own() {
+ assert_eq!(first_free_untitled(|_| false), "Untitled project");
+ let taken = ["Untitled project", "Untitled project 2"];
+ assert_eq!(
+ first_free_untitled(|folder| taken.contains(&folder)),
+ "Untitled project 3"
+ );
+ let taken = ["Untitled project 2"];
+ assert_eq!(
+ first_free_untitled(|folder| taken.contains(&folder)),
+ "Untitled project"
+ );
+ }
+
+ /// Only a name the sheet made up is replaced; a typed one is kept.
+ #[test]
+ fn only_a_made_up_name_moves_on() {
+ for name in [
+ "",
+ " ",
+ "Untitled project",
+ "Untitled project 2",
+ "Untitled project 41",
+ ] {
+ assert!(is_untitled(name), "{name:?}");
+ }
+ for name in [
+ "My film",
+ "Untitled project 1",
+ "Untitled project two",
+ "Untitled projects",
+ "Untitled project 2 final",
+ ] {
+ assert!(!is_untitled(name), "{name:?}");
+ }
+ }
+
+ /// Composing again after a project was made in the same place offers
+ /// the next free name, not the one that would be refused.
+ #[test]
+ fn compose_offers_a_name_that_is_free_in_the_location() {
+ let root = std::env::temp_dir().join(format!("concat-untitled-{}", std::process::id()));
+ std::fs::create_dir_all(root.join("Untitled project")).unwrap();
+ let pane = StartPane {
+ location: root.to_string_lossy().into_owned(),
+ ..StartPane::default()
+ };
+ assert_eq!(pane.free_untitled(), "Untitled project 2");
+ let _ = std::fs::remove_dir_all(&root);
+ }
+}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 07c17716..025b9385 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -4390,7 +4390,12 @@ impl Studio {
})
.collect();
self.echo = None;
- if !moves.is_empty() {
+ // A press and a release with no drag between them is a
+ // click: nothing moved, and a MoveClips of the clips onto
+ // their own places is still an undo step and still a pass
+ // through the drop's rules, which can put a clip elsewhere.
+ // https://github.com/jub0t/Concat/issues/247
+ if moved_any(&moves, |id| self.clip(id)) {
self.apply(Command::MoveClips { moves });
}
}
@@ -7553,13 +7558,21 @@ impl Studio {
/// that reads it, the table (see `concat_effects::looks`) - and the
/// catalogue is rebuilt so the Filters page shows them, their cards
/// drawn by their own shaders.
- pub fn import_lut(&mut self) {
- let Some(paths) = crate::platform::pick_files(
- &t("studio.importLut"),
- Some((t("studio.lut").as_str(), &["cube"])),
- ) else {
- return;
- };
+ /// Asks for `.cube` files to import as looks. The dialog is asked with
+ /// the studio unborrowed, and the files come back to [`import_luts`];
+ /// see `host::after_dialog`.
+ ///
+ /// [`import_luts`]: Studio::import_luts
+ pub fn import_lut() {
+ let (title, family) = (t("studio.importLut"), t("studio.lut"));
+ crate::host::after_dialog(
+ move || crate::platform::pick_files(&title, Some((family.as_str(), &["cube"]))),
+ |studio, _, _, paths| studio.import_luts(paths),
+ );
+ }
+
+ /// Imports `.cube` files as looks, and says how many arrived.
+ pub fn import_luts(&mut self, paths: Vec<std::path::PathBuf>) {
let dir = Self::looks_dir(&self.host.dirs);
let mut imported = 0;
for path in paths {
@@ -7778,6 +7791,7 @@ impl Studio {
wave: wave.0,
wave_from: wave.1,
wave_span: wave.2,
+ has_audio: self.clip_has_sound(clip),
strip: self.strip_of(clip),
}
})
@@ -10232,6 +10246,71 @@ impl Studio {
/// One of the clip menu's verbs on clip `id`. The menu's rows and the
/// keyboard's chords both land here, so a shortcut and the row that
/// advertises it cannot disagree.
+ /// Takes a video clip's sound off onto a lane of its own, and selects
+ /// what came off: the lane it lands on may be a new one, out of view,
+ /// and a detach that changed nothing anyone could see read as one that
+ /// did nothing. One that cannot happen says why instead of nothing.
+ /// https://github.com/jub0t/Concat/issues/310
+ fn detach_audio(&mut self, clip: &Clip) {
+ let has_audio = self
+ .project()
+ .media_by_id(&clip.media_id)
+ .is_some_and(|media| media.has_audio);
+ let detached = self
+ .timeline()
+ .clips
+ .iter()
+ .any(|other| other.detached_from.as_deref() == Some(clip.id.as_str()));
+ let detach = Command::DetachAudio {
+ clip_id: clip.id.clone(),
+ };
+ let command = match detach_plan(clip, has_audio, detached) {
+ DetachPlan::NoSound => {
+ self.notify(&t("studio.detachNoSound"), false);
+ return;
+ }
+ DetachPlan::Already => {
+ self.notify(&t("studio.detachAlready"), false);
+ return;
+ }
+ DetachPlan::Detach => detach,
+ // Its sound was taken off once and that clip deleted, which
+ // left the picture silent with nothing to reattach. Unmuted
+ // and taken off again, as one step: the sound comes back as a
+ // clip, which is what was asked for.
+ DetachPlan::Again => Command::Batch {
+ commands: vec![
+ Command::UpdateClip {
+ clip_id: clip.id.clone(),
+ patch: ClipPatch {
+ muted: Some(false),
+ ..Default::default()
+ },
+ },
+ detach,
+ ],
+ },
+ };
+ let token = self.toast.token;
+ self.apply(command);
+ let sounds: Vec<String> = self
+ .timeline()
+ .clips
+ .iter()
+ .filter(|other| other.detached_from.as_deref() == Some(clip.id.as_str()))
+ .map(|other| other.id.clone())
+ .collect();
+ if sounds.is_empty() {
+ // A failure has said so already.
+ if self.toast.token == token {
+ self.notify(&t("studio.detachNoSound"), false);
+ }
+ return;
+ }
+ self.transition_selected = None;
+ self.selection = sounds;
+ }
+
pub fn clip_action(&mut self, id: &str, action: &str) {
log::info!("clip menu: {action} on {id}");
let Some(clip) = self.clip(id).cloned() else {
@@ -10258,11 +10337,7 @@ impl Studio {
self.inspector_jump = (self.inspector_jump.0 + 1, "Video", "Enhance");
}
"export-audio" => self.export_clip_audio(id),
- "detach" => {
- self.apply(Command::DetachAudio {
- clip_id: id.to_owned(),
- });
- }
+ "detach" => self.detach_audio(&clip),
"reattach" => {
self.apply(Command::ReattachAudio {
clip_id: id.to_owned(),
@@ -10331,6 +10406,48 @@ impl Studio {
}
}
+/// How a detach goes, or why it cannot; see [`detach_plan`].
+#[derive(Debug, PartialEq, Eq)]
+enum DetachPlan {
+ /// The sound comes off.
+ Detach,
+ /// The picture is still muted by a detach whose sound clip has since
+ /// been deleted: it is unmuted, then its sound comes off.
+ Again,
+ /// Not a video, or its file has no sound.
+ NoSound,
+ /// Its sound is on the timeline already, detached.
+ Already,
+}
+
+/// How a detach of `clip` goes, given whether its file has sound and
+/// whether a sound detached from it is on the timeline. `DetachAudio`
+/// itself changes nothing when it cannot happen, and says nothing; the
+/// last two answers are what the window says instead.
+fn detach_plan(clip: &Clip, has_audio: bool, detached: bool) -> DetachPlan {
+ if clip.kind != model::ClipKind::Video || !has_audio {
+ DetachPlan::NoSound
+ } else if detached {
+ DetachPlan::Already
+ } else if clip.muted == Some(true) {
+ DetachPlan::Again
+ } else {
+ DetachPlan::Detach
+ }
+}
+
+/// Whether a move puts any clip somewhere other than where `before` has
+/// it: another lane, or another start. A drag works in `f32` seconds, so a
+/// start is compared as the drag holds it; one that only went through that
+/// rounding has not moved.
+fn moved_any<'a>(moves: &[ClipMove], before: impl Fn(&str) -> Option<&'a Clip>) -> bool {
+ moves.iter().any(|wanted| {
+ before(&wanted.clip_id).is_some_and(|clip| {
+ clip.track_id != wanted.track_id || clip.start as f32 != wanted.start as f32
+ })
+ })
+}
+
/// 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.
@@ -10424,6 +10541,54 @@ mod tests {
);
}
+ /// A detach that cannot happen has a reason to give, and a picture
+ /// left muted by a deleted sound clip detaches again.
+ #[test]
+ fn a_detach_says_why_it_cannot_happen() {
+ use super::{DetachPlan, detach_plan};
+ use concat_project::model::{Clip, ClipKind};
+ let video = Clip::blank("v", "t", ClipKind::Video, "v", 0.0, 2.0);
+ assert_eq!(detach_plan(&video, true, false), DetachPlan::Detach);
+ assert_eq!(detach_plan(&video, false, false), DetachPlan::NoSound);
+ assert_eq!(detach_plan(&video, true, true), DetachPlan::Already);
+ let silenced = Clip {
+ muted: Some(true),
+ ..video.clone()
+ };
+ assert_eq!(detach_plan(&silenced, true, false), DetachPlan::Again);
+ assert_eq!(detach_plan(&silenced, true, true), DetachPlan::Already);
+ let sound = Clip::blank("a", "t", ClipKind::Audio, "a", 0.0, 2.0);
+ assert_eq!(detach_plan(&sound, true, false), DetachPlan::NoSound);
+ }
+
+ /// A click on a clip is a move to where it already is, and is no edit;
+ /// a start that only went through the drag's `f32` is no move either.
+ #[test]
+ fn a_click_moves_nothing() {
+ use concat_project::commands::ClipMove;
+ use concat_project::model::{Clip, ClipKind};
+ let clip = Clip::blank("c", "t", ClipKind::Video, "c", 1.1, 2.0);
+ let before = |id: &str| (id == "c").then_some(&clip);
+ let to = |start: f64, track: &str| {
+ vec![ClipMove {
+ clip_id: "c".into(),
+ start,
+ track_id: track.into(),
+ }]
+ };
+ assert!(!super::moved_any(&to(1.1, "t"), before));
+ assert!(!super::moved_any(&to(f64::from(1.1_f32), "t"), before));
+ assert!(super::moved_any(&to(1.2, "t"), before));
+ assert!(super::moved_any(&to(1.1, "u"), before));
+ // A clip that has gone is not a move.
+ let gone = vec![ClipMove {
+ clip_id: "x".into(),
+ start: 9.0,
+ track_id: "t".into(),
+ }];
+ assert!(!super::moved_any(&gone, before));
+ }
+
/// A wheel is keyed as one knob: named by itself or by any of its own
/// keys, it keys its puck and master; its master's key takes the puck's
/// with it in the keyframes pane; any other knob keys alone.
diff --git a/src/crates/concat/ui/timeline/lanes.slint b/src/crates/concat/ui/timeline/lanes.slint
index 5b1fa0c6..d81a783b 100644
--- a/src/crates/concat/ui/timeline/lanes.slint
+++ b/src/crates/concat/ui/timeline/lanes.slint
@@ -182,11 +182,14 @@ component Clip inherits Rectangle {
property <length> chip-w: Math.max(root.chip, 14px);
property <length> body-h: Math.max(0px, root.height - root.header-h);
/// The sound band at the foot of a video clip: its file's waveform
- /// under its frames, a third of the body and never a sliver, and there
- /// whether or not the file has sound - a silent file shows the empty
- /// band, so a video that has gone quiet is tellable from one that
- /// never spoke. https://github.com/jub0t/Concat/issues/137
- property <bool> banded: root.item.kind == ClipKind.video;
+ /// under its frames, a third of the body and never a sliver. A video
+ /// that has gone quiet - muted, or its sound detached - keeps the
+ /// empty band, so it is tellable from one that never spoke
+ /// (https://github.com/jub0t/Concat/issues/137); a file with no sound
+ /// at all has none, and its frames take the whole body, since a band
+ /// there promised a sound that was never in it.
+ /// https://github.com/jub0t/Concat/issues/283
+ property <bool> banded: root.item.kind == ClipKind.video && root.item.has-audio;
property <length> band-h: root.banded
? Math.clamp(root.body-h * 0.34, 8px, 30px)
: 0px;
@@ -581,12 +584,15 @@ component Clip inherits Rectangle {
moved => {
// Past a few pixels it is a drag, not a click, and the playhead
- // stays where it was.
+ // stays where it was. Short of them it is nothing at all: a
+ // hand that shook on a click reported a move of a pixel or two,
+ // which snapped, or rounded, the clip somewhere else.
+ // https://github.com/jub0t/Concat/issues/247
if (Math.abs(self.absolute-position.x + self.mouse-x - self.origin-x) > 4px
|| Math.abs(self.absolute-position.y + self.mouse-y - self.origin-y) > 4px) {
self.travelled = true;
}
- if (root.tool == TimelineTool.select) {
+ if (self.travelled && root.tool == TimelineTool.select) {
root.pointer-at(self.mouse-x);
root.dragged(
(self.absolute-position.x + self.mouse-x - self.origin-x)
@@ -1443,9 +1449,17 @@ export component Lanes inherits Rectangle {
// onto every clip would be one more thing to keep in step.
locked: root.tracks[entry.row].locked;
+ // A press is not yet a drag: the edge scroll waits for the
+ // first report of one, which brings the pointer with it. Set
+ // here, with the last drag's pointer still in `pointer-x`, a
+ // click near the lanes' edge scrolled the view and moved the
+ // clip by the last drag's distance.
+ // https://github.com/jub0t/Concat/issues/247
pressed(additive, edge) => {
root.press-scroll = root.scroll-left;
- root.clip-dragging = true;
+ root.drag-seconds = 0;
+ root.drag-pixels = 0;
+ root.clip-dragging = false;
root.clip-pressed(entry.id, additive, edge);
}
split-at(x) => {
@@ -1458,6 +1472,7 @@ export component Lanes inherits Rectangle {
dragged(seconds, pixels) => {
root.drag-seconds = seconds;
root.drag-pixels = pixels;
+ root.clip-dragging = true;
root.clip-dragged(seconds + (root.scroll-left - root.press-scroll), pixels);
}
pointer-at(x) => { root.pointer-x = self.x + x; }
diff --git a/src/crates/concat/ui/timeline/model.slint b/src/crates/concat/ui/timeline/model.slint
index 4557d0fc..f7f95c02 100644
--- a/src/crates/concat/ui/timeline/model.slint
+++ b/src/crates/concat/ui/timeline/model.slint
@@ -124,6 +124,9 @@ export struct ClipData {
/// of the clip's, since only the window on screen is built.
wave-from: float,
wave-span: float,
+ /// Whether the clip has sound: a sound clip, or a video whose file
+ /// carries an audio stream. A silent video draws no sound band.
+ has-audio: bool,
/// The frames a picture clip tiles along its body; `frames` is 0 when
/// there are none yet.
strip: StripData,