Skip to content

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

feat(text): several titles selected are styled together, and a look can be kept for new ones

Jareer09f4a988732a
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 41c6d88e..d87980ed 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -924,6 +924,7 @@
"textPanel.content": "Inhalt",
"textPanel.cornerRadius": "Eckenradius",
"textPanel.dropShadow": "Schlagschatten",
+ "textPanel.editingTitles": "{0} Titel werden bearbeitet",
"textPanel.font": "Schrift",
"textPanel.fontWeight": "Schriftstärke",
"textPanel.horizontal": "Horizontal",
@@ -932,6 +933,7 @@
"textPanel.layout": "Layout",
"textPanel.lineHeight": "Zeilenhöhe",
"textPanel.lockThePaddingsTogether": "Beide Abstände koppeln",
+ "textPanel.newTitlesUseThisStyle": "Neue Titel und Untertitel verwenden diesen Stil",
"textPanel.padding": "Innenabstand",
"textPanel.position": "Position",
"textPanel.regular": "Normal",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Laufweite",
"textPanel.typography": "Typografie",
"textPanel.unlockThePaddings": "Abstände entkoppeln",
+ "textPanel.useForNewTitles": "Für neue Titel verwenden",
"textPanel.vertical": "Vertikal",
"timelinePane.freeze": "Einfrieren",
"timelinePane.mirror": "Spiegel",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 42fb0d2c..8f906383 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -924,6 +924,7 @@
"textPanel.content": "Content",
"textPanel.cornerRadius": "Corner radius",
"textPanel.dropShadow": "Drop shadow",
+ "textPanel.editingTitles": "Editing {0} titles",
"textPanel.font": "Font",
"textPanel.fontWeight": "Font Weight",
"textPanel.horizontal": "Horizontal",
@@ -932,6 +933,7 @@
"textPanel.layout": "Layout",
"textPanel.lineHeight": "Line height",
"textPanel.lockThePaddingsTogether": "Lock the paddings together",
+ "textPanel.newTitlesUseThisStyle": "New titles and captions will use this style",
"textPanel.padding": "Padding",
"textPanel.position": "Position",
"textPanel.regular": "Regular",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Tracking",
"textPanel.typography": "Typography",
"textPanel.unlockThePaddings": "Unlock the paddings",
+ "textPanel.useForNewTitles": "Use for new titles",
"textPanel.vertical": "Vertical",
"timelinePane.freeze": "Freeze",
"timelinePane.mirror": "Mirror",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 2b005567..e65c5bf1 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -924,6 +924,7 @@
"textPanel.content": "Contenido",
"textPanel.cornerRadius": "Radio de esquina",
"textPanel.dropShadow": "Sombra paralela",
+ "textPanel.editingTitles": "Editando {0} títulos",
"textPanel.font": "Fuente",
"textPanel.fontWeight": "Grosor de fuente",
"textPanel.horizontal": "Horizontal",
@@ -932,6 +933,7 @@
"textPanel.layout": "Disposición",
"textPanel.lineHeight": "Interlineado",
"textPanel.lockThePaddingsTogether": "Vincular ambos rellenos",
+ "textPanel.newTitlesUseThisStyle": "Los títulos y subtítulos nuevos usarán este estilo",
"textPanel.padding": "Relleno",
"textPanel.position": "Posición",
"textPanel.regular": "Regular",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Espaciado",
"textPanel.typography": "Tipografía",
"textPanel.unlockThePaddings": "Desvincular los rellenos",
+ "textPanel.useForNewTitles": "Usar para títulos nuevos",
"textPanel.vertical": "Vertical",
"timelinePane.freeze": "Congelar",
"timelinePane.mirror": "Espejo",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index ab906ce3..566f5ff1 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -924,6 +924,7 @@
"textPanel.content": "محتوا",
"textPanel.cornerRadius": "شعاع گوشه",
"textPanel.dropShadow": "سایه افتاده",
+ "textPanel.editingTitles": "در حال ویرایش {0} عنوان",
"textPanel.font": "فونت",
"textPanel.fontWeight": "وزن فونت",
"textPanel.horizontal": "افقی",
@@ -932,6 +933,7 @@
"textPanel.layout": "چیدمان",
"textPanel.lineHeight": "ارتفاع خط",
"textPanel.lockThePaddingsTogether": "قفل کردن دو حاشیه به هم",
+ "textPanel.newTitlesUseThisStyle": "عنوان‌ها و زیرنویس‌های جدید از این سبک استفاده می‌کنند",
"textPanel.padding": "حاشیهٔ داخلی",
"textPanel.position": "موقعیت",
"textPanel.regular": "معمولی",
@@ -943,6 +945,7 @@
"textPanel.tracking": "ردیابی (Tracking)",
"textPanel.typography": "تایپوگرافی",
"textPanel.unlockThePaddings": "باز کردن قفل حاشیه‌ها",
+ "textPanel.useForNewTitles": "استفاده برای عنوان‌های جدید",
"textPanel.vertical": "عمودی",
"timelinePane.freeze": "فریز",
"timelinePane.mirror": "آینه",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 6d27063e..bab0d80e 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -924,6 +924,7 @@
"textPanel.content": "Contenu",
"textPanel.cornerRadius": "Rayon des coins",
"textPanel.dropShadow": "Ombre portée",
+ "textPanel.editingTitles": "Modification de {0} titres",
"textPanel.font": "Police",
"textPanel.fontWeight": "Graisse de la police",
"textPanel.horizontal": "Horizontal",
@@ -932,6 +933,7 @@
"textPanel.layout": "Disposition",
"textPanel.lineHeight": "Interligne",
"textPanel.lockThePaddingsTogether": "Lier les deux marges",
+ "textPanel.newTitlesUseThisStyle": "Les nouveaux titres et sous-titres utiliseront ce style",
"textPanel.padding": "Marge intérieure",
"textPanel.position": "Position",
"textPanel.regular": "Normal",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Approche",
"textPanel.typography": "Typographie",
"textPanel.unlockThePaddings": "Délier les marges",
+ "textPanel.useForNewTitles": "Utiliser pour les nouveaux titres",
"textPanel.vertical": "Vertical",
"timelinePane.freeze": "Figer",
"timelinePane.mirror": "Miroir",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 8c6aa49c..eb2f57b9 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -924,6 +924,7 @@
"textPanel.content": "Sadržaj",
"textPanel.cornerRadius": "Polumjer kutova",
"textPanel.dropShadow": "Sjena",
+ "textPanel.editingTitles": "Uređivanje {0} naslova",
"textPanel.font": "Font",
"textPanel.fontWeight": "Debljina fonta",
"textPanel.horizontal": "Vodoravno",
@@ -932,6 +933,7 @@
"textPanel.layout": "Raspored",
"textPanel.lineHeight": "Visina retka",
"textPanel.lockThePaddingsTogether": "Zaključaj oba razmaka zajedno",
+ "textPanel.newTitlesUseThisStyle": "Novi naslovi i titlovi koristit će ovaj stil",
"textPanel.padding": "Unutarnji razmak",
"textPanel.position": "Položaj",
"textPanel.regular": "Obično",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Praćenje",
"textPanel.typography": "Tipografija",
"textPanel.unlockThePaddings": "Otključaj razmake",
+ "textPanel.useForNewTitles": "Koristi za nove naslove",
"textPanel.vertical": "Okomito",
"timelinePane.freeze": "Zamrzni",
"timelinePane.mirror": "Ogledalo",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index aaa9a800..ac4899fb 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -924,6 +924,7 @@
"textPanel.content": "Contenuto",
"textPanel.cornerRadius": "Raggio degli angoli",
"textPanel.dropShadow": "Ombra esterna",
+ "textPanel.editingTitles": "Modifica di {0} titoli",
"textPanel.font": "Carattere",
"textPanel.fontWeight": "Peso del carattere",
"textPanel.horizontal": "Orizzontale",
@@ -932,6 +933,7 @@
"textPanel.layout": "Impaginazione",
"textPanel.lineHeight": "Interlinea",
"textPanel.lockThePaddingsTogether": "Blocca le due spaziature insieme",
+ "textPanel.newTitlesUseThisStyle": "I nuovi titoli e sottotitoli useranno questo stile",
"textPanel.padding": "Spaziatura interna",
"textPanel.position": "Posizione",
"textPanel.regular": "Normale",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Spaziatura",
"textPanel.typography": "Tipografia",
"textPanel.unlockThePaddings": "Sblocca le spaziature",
+ "textPanel.useForNewTitles": "Usa per i nuovi titoli",
"textPanel.vertical": "Verticale",
"timelinePane.freeze": "Blocca",
"timelinePane.mirror": "Specchio",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 3c5e3bb1..608d3961 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -924,6 +924,7 @@
"textPanel.content": "内容",
"textPanel.cornerRadius": "角の半径",
"textPanel.dropShadow": "ドロップシャドウ",
+ "textPanel.editingTitles": "{0} 件のタイトルを編集中",
"textPanel.font": "フォント",
"textPanel.fontWeight": "フォントの太さ",
"textPanel.horizontal": "水平",
@@ -932,6 +933,7 @@
"textPanel.layout": "レイアウト",
"textPanel.lineHeight": "行の高さ",
"textPanel.lockThePaddingsTogether": "2つの余白を連動する",
+ "textPanel.newTitlesUseThisStyle": "新しいタイトルと字幕にこのスタイルを使います",
"textPanel.padding": "余白",
"textPanel.position": "位置",
"textPanel.regular": "標準",
@@ -943,6 +945,7 @@
"textPanel.tracking": "字間",
"textPanel.typography": "タイポグラフィ",
"textPanel.unlockThePaddings": "余白の連動を解除する",
+ "textPanel.useForNewTitles": "新しいタイトルに使う",
"textPanel.vertical": "垂直",
"timelinePane.freeze": "フリーズ",
"timelinePane.mirror": "ミラー",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 2ec8ceec..3adb618f 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -924,6 +924,7 @@
"textPanel.content": "내용",
"textPanel.cornerRadius": "모서리 반경",
"textPanel.dropShadow": "그림자",
+ "textPanel.editingTitles": "제목 {0}개 편집 중",
"textPanel.font": "글꼴",
"textPanel.fontWeight": "글꼴 굵기",
"textPanel.horizontal": "가로",
@@ -932,6 +933,7 @@
"textPanel.layout": "레이아웃",
"textPanel.lineHeight": "줄 높이",
"textPanel.lockThePaddingsTogether": "두 여백을 함께 잠그기",
+ "textPanel.newTitlesUseThisStyle": "새 제목과 자막에 이 스타일을 사용합니다",
"textPanel.padding": "여백",
"textPanel.position": "위치",
"textPanel.regular": "보통",
@@ -943,6 +945,7 @@
"textPanel.tracking": "자간",
"textPanel.typography": "타이포그래피",
"textPanel.unlockThePaddings": "여백 잠금 해제",
+ "textPanel.useForNewTitles": "새 제목에 사용",
"textPanel.vertical": "세로",
"timelinePane.freeze": "정지",
"timelinePane.mirror": "미러",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 67ca392a..84113f37 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -924,6 +924,7 @@
"textPanel.content": "Conteúdo",
"textPanel.cornerRadius": "Raio dos cantos",
"textPanel.dropShadow": "Sombra projetada",
+ "textPanel.editingTitles": "Editando {0} títulos",
"textPanel.font": "Fonte",
"textPanel.fontWeight": "Peso da fonte",
"textPanel.horizontal": "Horizontal",
@@ -932,6 +933,7 @@
"textPanel.layout": "Leiaute",
"textPanel.lineHeight": "Altura da linha",
"textPanel.lockThePaddingsTogether": "Vincular os dois preenchimentos",
+ "textPanel.newTitlesUseThisStyle": "Novos títulos e legendas usarão este estilo",
"textPanel.padding": "Preenchimento",
"textPanel.position": "Posição",
"textPanel.regular": "Regular",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Espaçamento",
"textPanel.typography": "Tipografia",
"textPanel.unlockThePaddings": "Desvincular os preenchimentos",
+ "textPanel.useForNewTitles": "Usar em novos títulos",
"textPanel.vertical": "Vertical",
"timelinePane.freeze": "Congelar",
"timelinePane.mirror": "Espelho",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index d1081a0d..164fbd8c 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -924,6 +924,7 @@
"textPanel.content": "Содержание",
"textPanel.cornerRadius": "Радиус углов",
"textPanel.dropShadow": "Тень",
+ "textPanel.editingTitles": "Редактирование {0} титров",
"textPanel.font": "Шрифт",
"textPanel.fontWeight": "Насыщенность шрифта",
"textPanel.horizontal": "По горизонтали",
@@ -932,6 +933,7 @@
"textPanel.layout": "Компоновка",
"textPanel.lineHeight": "Высота строки",
"textPanel.lockThePaddingsTogether": "Связать оба отступа",
+ "textPanel.newTitlesUseThisStyle": "Новые титры и субтитры будут использовать этот стиль",
"textPanel.padding": "Отступы",
"textPanel.position": "Положение",
"textPanel.regular": "Обычный",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Трекинг",
"textPanel.typography": "Типографика",
"textPanel.unlockThePaddings": "Разъединить отступы",
+ "textPanel.useForNewTitles": "Использовать для новых титров",
"textPanel.vertical": "По вертикали",
"timelinePane.freeze": "Стоп-кадр",
"timelinePane.mirror": "Зеркало",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index fb2041f6..e152b77d 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -924,6 +924,7 @@
"textPanel.content": "İçerik",
"textPanel.cornerRadius": "Köşe yarıçapı",
"textPanel.dropShadow": "Gölge",
+ "textPanel.editingTitles": "{0} başlık düzenleniyor",
"textPanel.font": "Yazı tipi",
"textPanel.fontWeight": "Yazı kalınlığı",
"textPanel.horizontal": "Yatay",
@@ -932,6 +933,7 @@
"textPanel.layout": "Yerleşim",
"textPanel.lineHeight": "Satır yüksekliği",
"textPanel.lockThePaddingsTogether": "İki boşluğu birlikte kilitle",
+ "textPanel.newTitlesUseThisStyle": "Yeni başlıklar ve altyazılar bu stili kullanacak",
"textPanel.padding": "İç boşluk",
"textPanel.position": "Konum",
"textPanel.regular": "Normal",
@@ -943,6 +945,7 @@
"textPanel.tracking": "Harf aralığı",
"textPanel.typography": "Tipografi",
"textPanel.unlockThePaddings": "Boşlukların kilidini aç",
+ "textPanel.useForNewTitles": "Yeni başlıklar için kullan",
"textPanel.vertical": "Dikey",
"timelinePane.freeze": "Dondur",
"timelinePane.mirror": "Ayna",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 65473982..572ebd95 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -924,6 +924,7 @@
"textPanel.content": "内容",
"textPanel.cornerRadius": "圆角半径",
"textPanel.dropShadow": "投影",
+ "textPanel.editingTitles": "正在编辑 {0} 个标题",
"textPanel.font": "字体",
"textPanel.fontWeight": "字重",
"textPanel.horizontal": "水平",
@@ -932,6 +933,7 @@
"textPanel.layout": "布局",
"textPanel.lineHeight": "行高",
"textPanel.lockThePaddingsTogether": "锁定两个内边距一致",
+ "textPanel.newTitlesUseThisStyle": "新标题和字幕将使用此样式",
"textPanel.padding": "内边距",
"textPanel.position": "位置",
"textPanel.regular": "常规",
@@ -943,6 +945,7 @@
"textPanel.tracking": "字距",
"textPanel.typography": "文字排版",
"textPanel.unlockThePaddings": "解锁内边距",
+ "textPanel.useForNewTitles": "用于新标题",
"textPanel.vertical": "竖屏",
"timelinePane.freeze": "定格",
"timelinePane.mirror": "镜像",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index aae96bd8..90126205 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -924,6 +924,7 @@
"textPanel.content": "內容",
"textPanel.cornerRadius": "圓角半徑",
"textPanel.dropShadow": "投影",
+ "textPanel.editingTitles": "正在編輯 {0} 個標題",
"textPanel.font": "字型",
"textPanel.fontWeight": "字重",
"textPanel.horizontal": "水平",
@@ -932,6 +933,7 @@
"textPanel.layout": "佈局",
"textPanel.lineHeight": "行高",
"textPanel.lockThePaddingsTogether": "鎖定兩個內邊距一致",
+ "textPanel.newTitlesUseThisStyle": "新標題和字幕將使用此樣式",
"textPanel.padding": "內邊距",
"textPanel.position": "位置",
"textPanel.regular": "標準",
@@ -943,6 +945,7 @@
"textPanel.tracking": "字距",
"textPanel.typography": "文字排版",
"textPanel.unlockThePaddings": "解除鎖定內邊距",
+ "textPanel.useForNewTitles": "用於新標題",
"textPanel.vertical": "垂直",
"timelinePane.freeze": "定格",
"timelinePane.mirror": "鏡像",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 32d5d6f2..7f8da6b5 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -672,6 +672,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
});
// Font files, the way media files come in: the system's picker, and
// the answer later, on the window's thread.
+ editor.on_text_style_default(on_window!(|state| {
+ state.use_title_style_for_new();
+ }));
editor.on_import_font(|| {
Shell::with(|shell, _| {
if shell.studio.borrow().session.is_none() {
diff --git a/src/crates/concat/src/panes/captions.rs b/src/crates/concat/src/panes/captions.rs
index 60f73612..618b5c16 100644
--- a/src/crates/concat/src/panes/captions.rs
+++ b/src/crates/concat/src/panes/captions.rs
@@ -137,6 +137,7 @@ impl CaptionsPane {
return;
};
let look = subject.look;
+ let base = studio.prefs.title_style.clone();
let commands: Vec<Command> = segments
.into_iter()
.filter_map(|segment| {
@@ -147,6 +148,7 @@ impl CaptionsPane {
subject.start + segment.start / subject.speed,
((segment.end - segment.start) / subject.speed).max(0.2),
look,
+ base.as_ref(),
)
})
})
@@ -185,10 +187,11 @@ impl CaptionsPane {
}
let look = self.look();
let mut at = f64::from(studio.playhead);
+ let base = studio.prefs.title_style.clone();
let commands: Vec<Command> = lines
.into_iter()
.map(|(text, seconds)| {
- let command = caption_clip(text, at, seconds, look);
+ let command = caption_clip(text, at, seconds, look, base.as_ref());
at += seconds;
command
})
@@ -266,19 +269,38 @@ impl CaptionsPane {
/// One caption as a title clip: its words, when and for how long, and
/// its look.
-fn caption_clip(text: String, start: f64, duration: f64, look: (f64, f64)) -> Command {
+fn caption_clip(
+ text: String,
+ start: f64,
+ duration: f64,
+ look: (f64, f64),
+ base: Option<&TextStyle>,
+) -> Command {
let (offset_y, font_size) = look;
- Command::AddTextClip {
- track_id: None,
- above: true,
- start,
- style: Some(TextStyle {
+ // The kept look where there is one - family, weight, colours, stroke,
+ // shadow, background - at the caption's own size and place; the
+ // bundled face otherwise.
+ let style = match base {
+ Some(base) => TextStyle {
+ content: text,
+ font_size,
+ max_width: 0.0,
+ max_height: 0.0,
+ ..base.clone()
+ },
+ None => TextStyle {
content: text,
font_family: "Hanken Grotesk".to_owned(),
font_size,
font_weight: 600.0,
..TextStyle::default()
- }),
+ },
+ };
+ Command::AddTextClip {
+ track_id: None,
+ above: true,
+ start,
+ style: Some(style),
duration: Some(duration),
offset_y: Some(offset_y),
}
diff --git a/src/crates/concat/src/panes/export.rs b/src/crates/concat/src/panes/export.rs
index 4b93b600..5779c526 100644
--- a/src/crates/concat/src/panes/export.rs
+++ b/src/crates/concat/src/panes/export.rs
@@ -247,11 +247,7 @@ impl ExportPane {
* pixels
* (rate / 30.0)
* self.codec(studio).size_factor()
- * if self.deep(studio) {
- 1.05
- } else {
- 1.0
- }
+ * if self.deep(studio) { 1.05 } else { 1.0 }
};
(video + AUDIO_BPS) * studio.duration().max(1.0) / 8.0
}
diff --git a/src/crates/concat/src/platform.rs b/src/crates/concat/src/platform.rs
index e8ebde7e..f65077ca 100644
--- a/src/crates/concat/src/platform.rs
+++ b/src/crates/concat/src/platform.rs
@@ -135,8 +135,11 @@ impl DropHandler {
wayland_tried: false,
cursor: None,
on_pressed_away: Box::new(on_pressed_away),
- edges: cfg!(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))
- && !phone(),
+ edges: cfg!(not(any(
+ target_os = "macos",
+ target_os = "windows",
+ target_os = "ios"
+ ))) && !phone(),
edge: None,
}
}
@@ -179,7 +182,9 @@ impl CustomApplicationHandler for DropHandler {
slint_window: Option<&slint::Window>,
event: &WindowEvent,
) -> EventResult {
- if !self.wayland_tried && let Some(window) = winit_window {
+ if !self.wayland_tried
+ && let Some(window) = winit_window
+ {
self.wayland_tried = true;
self.wayland = listen_for_wayland_drops(window, &self.arrived);
}
diff --git a/src/crates/concat/src/prefs.rs b/src/crates/concat/src/prefs.rs
index 96f3802a..f50334d7 100644
--- a/src/crates/concat/src/prefs.rs
+++ b/src/crates/concat/src/prefs.rs
@@ -68,6 +68,10 @@ pub struct Preferences {
/// The Concat API on a socket while the window is open.
#[serde(default)]
pub server: ServerPrefs,
+ /// The look new titles start from and generated captions are set in,
+ /// kept from a title by the Text panel's "Use for new titles"; its
+ /// words are empty. None starts titles in the bundled face.
+ pub title_style: Option<concat_project::model::TextStyle>,
}
impl Preferences {
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 054f4824..1822dc12 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -838,7 +838,9 @@ pub struct Studio {
/// then clears the selection on the release - and a commit that looked
/// the clip up in the selection at landing time found nothing and
/// dropped the words with the echo.
- commit_target: Option<String>,
+ /// The clips the echo was written for; see `commit_now`. Several when
+ /// the inspector edits every selected title at once.
+ commit_targets: Vec<String>,
commit_timer: slint::Timer,
/// What the catalogue shelves were last built from; while nothing in
/// it changes the shelves are not rebuilt.
@@ -971,12 +973,17 @@ fn align_of(align: TextAlign) -> TextAlignment {
}
/// A title as it is first placed: the embedded face, centred, white.
-fn new_title_style() -> TextStyle {
- TextStyle {
- content: "New title".to_owned(),
+fn new_title_style(prefs: &crate::prefs::Preferences) -> TextStyle {
+ // The look a title was kept as, when one was (see
+ // `Studio::use_title_style_for_new`); the bundled face otherwise.
+ let base = prefs.title_style.clone().unwrap_or_else(|| TextStyle {
font_family: "Hanken Grotesk".to_owned(),
font_weight: 600.0,
..TextStyle::default()
+ });
+ TextStyle {
+ content: "New title".to_owned(),
+ ..base
}
}
@@ -1263,6 +1270,98 @@ fn write_keyable(clip: &mut Clip, property: model::KeyProperty, value: f64, at:
}
}
+/// The commands that turn `before` into `after`, clip `id` as the echo
+/// left it against the document's: a transform, a cutout, a speed, the
+/// keys, and one patch for everything else that differs. Empty when
+/// nothing does.
+fn clip_commands(id: &str, before: &Clip, after: &Clip) -> Vec<Command> {
+ let mut commands = Vec::new();
+ if after.scale != before.scale
+ || after.offset_x != before.offset_x
+ || after.offset_y != before.offset_y
+ || after.rotation != before.rotation
+ || after.stretch_x != before.stretch_x
+ || after.stretch_y != before.stretch_y
+ {
+ commands.push(Command::SetClipTransform {
+ clip_id: id.to_owned(),
+ scale: Some(after.scale),
+ offset_x: Some(after.offset_x),
+ offset_y: Some(after.offset_y),
+ rotation: Some(after.rotation),
+ stretch_x: Some(after.stretch_x),
+ stretch_y: Some(after.stretch_y),
+ });
+ }
+ if after.cutout != before.cutout {
+ commands.push(Command::SetClipCutout {
+ clip_id: id.to_owned(),
+ cutout: after.cutout.clone(),
+ });
+ }
+ if after.speed != before.speed {
+ commands.push(Command::SetClipSpeed {
+ clip_id: id.to_owned(),
+ speed: after.speed,
+ });
+ }
+ let mut patch = ClipPatch::default();
+ if after.name != before.name {
+ patch.name = Some(after.name.clone());
+ }
+ if after.volume != before.volume {
+ patch.volume = Some(after.volume);
+ }
+ if after.fade_in != before.fade_in {
+ patch.fade_in = Some(after.fade_in);
+ }
+ if after.fade_out != before.fade_out {
+ patch.fade_out = Some(after.fade_out);
+ }
+ if after.opacity != before.opacity {
+ patch.opacity = Some(after.opacity);
+ }
+ if after.preserve_pitch != before.preserve_pitch {
+ patch.preserve_pitch = Some(after.preserve_pitch);
+ }
+ if after.audio_stream != before.audio_stream {
+ patch.audio_stream = Some(after.audio_stream);
+ }
+ if after.flip_h != before.flip_h {
+ patch.flip_h = Some(after.flip_h);
+ }
+ if after.flip_v != before.flip_v {
+ patch.flip_v = Some(after.flip_v);
+ }
+ if after.blend != before.blend {
+ patch.blend = Some(if after.blend.is_empty() {
+ "normal".to_owned()
+ } else {
+ after.blend.clone()
+ });
+ }
+ if after.crop != before.crop {
+ patch.crop = Some(after.crop);
+ }
+ commands.extend(key_commands(id, before, after));
+ if after.text != before.text {
+ patch.text = Some(after.text.clone());
+ }
+ if after.video_effects != before.video_effects {
+ patch.video_effects = Some(after.video_effects.clone());
+ }
+ if after.filters != before.filters {
+ patch.filters = Some(after.filters.clone());
+ }
+ if patch != ClipPatch::default() {
+ commands.push(Command::UpdateClip {
+ clip_id: id.to_owned(),
+ patch,
+ });
+ }
+ commands
+}
+
/// The commands that turn `before`'s keys into `after`'s: a `SetClipKey`
/// for every key added or changed, a `ClearClipKey` for every key gone.
/// Two keys within a hair of each other are the same key.
@@ -1778,7 +1877,7 @@ impl Studio {
revision: 0,
flat: None,
commit_pending: false,
- commit_target: None,
+ commit_targets: Vec::new(),
commit_timer: slint::Timer::default(),
shelf_stamp: std::cell::RefCell::new(None),
look_art: std::cell::RefCell::new(HashMap::new()),
@@ -3013,7 +3112,7 @@ impl Studio {
found.offset_y,
presets::install_font(&self.host.dirs, found),
),
- None => (new_title_style(), None, None),
+ None => (new_title_style(&self.prefs), None, None),
};
// Over the picture, not under it: the first free lane above every
// occupied one, minted at the top when there is none. A drop onto a
@@ -3035,6 +3134,29 @@ impl Studio {
}
/// The selected clip's id, when exactly one is selected.
+ /// The clips the inspector's knobs write to: the one selected clip, or
+ /// every selected clip when two or more are selected and all of them
+ /// are titles - a batch of captions styled together. Anything else
+ /// selected together is nothing the inspector edits.
+ /// https://github.com/jub0t/Concat/issues/224
+ pub fn edit_targets(&self) -> Vec<String> {
+ if let Some(id) = self.sole_selection() {
+ return vec![id];
+ }
+ if self.selection.len() < 2 {
+ return Vec::new();
+ }
+ let titles = self.selection.iter().all(|id| {
+ self.clip(id)
+ .is_some_and(|clip| clip.kind == model::ClipKind::Text)
+ });
+ if titles {
+ self.selection.clone()
+ } else {
+ Vec::new()
+ }
+ }
+
pub fn sole_selection(&self) -> Option<String> {
(self.selection.len() == 1).then(|| self.selection[0].clone())
}
@@ -3910,193 +4032,205 @@ impl Studio {
/// One field of the selected clip, on the echo. `clip_commit` turns the
/// accumulated edits into commands.
pub fn clip_set(&mut self, field: ClipField, value: f32) {
- let Some(id) = self.sole_selection() else {
+ let ids = self.edit_targets();
+ if ids.is_empty() {
return;
- };
- self.commit_target = Some(id.clone());
- // The media's tracks, read before the echo is borrowed: a row of
- // the Audio panel's list is a stream index of the file.
- let audio_tracks: Vec<u32> = if field == ClipField::AudioTrack {
- self.clip(&id)
- .and_then(|clip| self.project().media_by_id(&clip.media_id))
- .map(|item| item.audio_tracks.iter().map(|track| track.index).collect())
- .unwrap_or_default()
- } else {
- Vec::new()
- };
- // Where the playhead sits in the clip: a keyed property is written
- // there, as a key.
- let at = self
- .clip(&id)
- .map(|clip| place_in(clip, self.playhead))
- .unwrap_or(0.0);
+ }
+ self.commit_targets = ids.clone();
self.begin_echo();
let value = f64::from(value);
- let Some(clip) = self.echo_clip_mut(&id) else {
- return;
- };
- let text = clip.text.get_or_insert_with(TextStyle::default);
- match field {
- ClipField::Scale => {
- write_keyable(clip, model::KeyProperty::Scale, value.clamp(0.05, 8.0), at)
- }
- ClipField::AudioTrack => {
- // The first row is the file's default and is stored as such,
- // so a clip on the first track saves as every clip did before
- // there were tracks to choose.
- let row = value.max(0.0) as usize;
- clip.audio_stream = (row > 0).then(|| audio_tracks.get(row).copied()).flatten();
- }
- ClipField::StretchX => clip.stretch_x = value.clamp(0.1, 10.0),
- ClipField::StretchY => clip.stretch_y = value.clamp(0.1, 10.0),
- ClipField::OffsetX => write_keyable(
- clip,
- model::KeyProperty::OffsetX,
- value.clamp(-1.0, 1.0),
- at,
- ),
- ClipField::OffsetY => write_keyable(
- clip,
- model::KeyProperty::OffsetY,
- value.clamp(-1.0, 1.0),
- at,
- ),
- ClipField::Rotation => write_keyable(
- clip,
- model::KeyProperty::Rotation,
- value.clamp(-180.0, 180.0),
- at,
- ),
- ClipField::Opacity => {
- write_keyable(clip, model::KeyProperty::Opacity, value.clamp(0.0, 1.0), at)
- }
- ClipField::CutoutFeather => {
- clip.cutout.get_or_insert_with(model::Cutout::auto).feather =
- value.clamp(0.0, model::MAX_FEATHER);
- }
- ClipField::Volume => {
- write_keyable(clip, model::KeyProperty::Volume, value.max(0.0), at)
- }
- ClipField::Speed => {
- let speed = value.clamp(0.0625, 16.0);
- clip.duration = (clip.duration * clip.speed / speed).max(f64::from(MIN_DURATION));
- clip.speed = speed;
- }
- ClipField::PreservePitch => clip.preserve_pitch = value != 0.0,
- ClipField::FlipH => clip.flip_h = value != 0.0,
- ClipField::FlipV => clip.flip_v = value != 0.0,
- ClipField::Blend => {
- let mode = concat_core::Blend::ALL
- .get(value.max(0.0) as usize)
- .copied()
- .unwrap_or_default();
- clip.blend = if mode == concat_core::Blend::Normal {
- String::new()
- } else {
- mode.name().to_owned()
- };
- }
- ClipField::CropLeft
- | ClipField::CropTop
- | ClipField::CropRight
- | ClipField::CropBottom => {
- let mut crop = clip.crop.unwrap_or_default();
- let edge = match field {
- ClipField::CropLeft => &mut crop.left,
- ClipField::CropTop => &mut crop.top,
- ClipField::CropRight => &mut crop.right,
- _ => &mut crop.bottom,
- };
- *edge = value.clamp(0.0, 0.9);
- let crop = crop.tidy();
- clip.crop = (!crop.is_none()).then_some(crop);
- }
- ClipField::FadeIn => clip.fade_in = value.clamp(0.0, clip.duration / 2.0),
- ClipField::FadeOut => clip.fade_out = value.clamp(0.0, clip.duration / 2.0),
- ClipField::FontSize => text.font_size = value.clamp(0.01, 0.5),
- ClipField::FontWeight => text.font_weight = value.clamp(100.0, 900.0),
- ClipField::Italic => text.italic = value != 0.0,
- ClipField::TextOpacity => text.opacity = value.clamp(0.0, 1.0),
- ClipField::Align => {
- text.align = match value as i32 {
- 0 => TextAlign::Left,
- 2 => TextAlign::Right,
- _ => TextAlign::Center,
+ for id in ids {
+ // The media's tracks, read before the echo is borrowed: a row of
+ // the Audio panel's list is a stream index of the file.
+ let audio_tracks: Vec<u32> = if field == ClipField::AudioTrack {
+ self.clip(&id)
+ .and_then(|clip| self.project().media_by_id(&clip.media_id))
+ .map(|item| item.audio_tracks.iter().map(|track| track.index).collect())
+ .unwrap_or_default()
+ } else {
+ Vec::new()
+ };
+ // Where the playhead sits in the clip: a keyed property is written
+ // there, as a key.
+ let at = self
+ .clip(&id)
+ .map(|clip| place_in(clip, self.playhead))
+ .unwrap_or(0.0);
+ let Some(clip) = self.echo_clip_mut(&id) else {
+ continue;
+ };
+ let text = clip.text.get_or_insert_with(TextStyle::default);
+ match field {
+ ClipField::Scale => {
+ write_keyable(clip, model::KeyProperty::Scale, value.clamp(0.05, 8.0), at)
+ }
+ ClipField::AudioTrack => {
+ // The first row is the file's default and is stored as such,
+ // so a clip on the first track saves as every clip did before
+ // there were tracks to choose.
+ let row = value.max(0.0) as usize;
+ clip.audio_stream = (row > 0).then(|| audio_tracks.get(row).copied()).flatten();
+ }
+ ClipField::StretchX => clip.stretch_x = value.clamp(0.1, 10.0),
+ ClipField::StretchY => clip.stretch_y = value.clamp(0.1, 10.0),
+ ClipField::OffsetX => write_keyable(
+ clip,
+ model::KeyProperty::OffsetX,
+ value.clamp(-1.0, 1.0),
+ at,
+ ),
+ ClipField::OffsetY => write_keyable(
+ clip,
+ model::KeyProperty::OffsetY,
+ value.clamp(-1.0, 1.0),
+ at,
+ ),
+ ClipField::Rotation => write_keyable(
+ clip,
+ model::KeyProperty::Rotation,
+ value.clamp(-180.0, 180.0),
+ at,
+ ),
+ ClipField::Opacity => {
+ write_keyable(clip, model::KeyProperty::Opacity, value.clamp(0.0, 1.0), at)
+ }
+ ClipField::CutoutFeather => {
+ clip.cutout.get_or_insert_with(model::Cutout::auto).feather =
+ value.clamp(0.0, model::MAX_FEATHER);
+ }
+ ClipField::Volume => {
+ write_keyable(clip, model::KeyProperty::Volume, value.max(0.0), at)
+ }
+ ClipField::Speed => {
+ let speed = value.clamp(0.0625, 16.0);
+ clip.duration =
+ (clip.duration * clip.speed / speed).max(f64::from(MIN_DURATION));
+ clip.speed = speed;
+ }
+ ClipField::PreservePitch => clip.preserve_pitch = value != 0.0,
+ ClipField::FlipH => clip.flip_h = value != 0.0,
+ ClipField::FlipV => clip.flip_v = value != 0.0,
+ ClipField::Blend => {
+ let mode = concat_core::Blend::ALL
+ .get(value.max(0.0) as usize)
+ .copied()
+ .unwrap_or_default();
+ clip.blend = if mode == concat_core::Blend::Normal {
+ String::new()
+ } else {
+ mode.name().to_owned()
+ };
+ }
+ ClipField::CropLeft
+ | ClipField::CropTop
+ | ClipField::CropRight
+ | ClipField::CropBottom => {
+ let mut crop = clip.crop.unwrap_or_default();
+ let edge = match field {
+ ClipField::CropLeft => &mut crop.left,
+ ClipField::CropTop => &mut crop.top,
+ ClipField::CropRight => &mut crop.right,
+ _ => &mut crop.bottom,
+ };
+ *edge = value.clamp(0.0, 0.9);
+ let crop = crop.tidy();
+ clip.crop = (!crop.is_none()).then_some(crop);
+ }
+ ClipField::FadeIn => clip.fade_in = value.clamp(0.0, clip.duration / 2.0),
+ ClipField::FadeOut => clip.fade_out = value.clamp(0.0, clip.duration / 2.0),
+ ClipField::FontSize => text.font_size = value.clamp(0.01, 0.5),
+ ClipField::FontWeight => text.font_weight = value.clamp(100.0, 900.0),
+ ClipField::Italic => text.italic = value != 0.0,
+ ClipField::TextOpacity => text.opacity = value.clamp(0.0, 1.0),
+ ClipField::Align => {
+ text.align = match value as i32 {
+ 0 => TextAlign::Left,
+ 2 => TextAlign::Right,
+ _ => TextAlign::Center,
+ }
+ }
+ ClipField::StrokeWidth => text.stroke_width = value.clamp(0.0, 0.15),
+ ClipField::Shadow => text.shadow = value != 0.0,
+ ClipField::LineHeight => text.line_height = value.clamp(0.7, 2.5),
+ ClipField::Tracking => text.tracking = value.clamp(-0.05, 0.3),
+ ClipField::TextWidth => text.max_width = value.clamp(0.0, 2.0),
+ ClipField::TextHeight => text.max_height = value.clamp(0.0, 2.0),
+ // The stroke's opacity is its colour's alpha; see `hex_rgba`.
+ ClipField::StrokeOpacity => {
+ let edge = colour_of(&text.stroke_color);
+ text.stroke_color = hex_rgba(slint::Color::from_argb_u8(
+ (value.clamp(0.0, 1.0) * 255.0).round() as u8,
+ edge.red(),
+ edge.green(),
+ edge.blue(),
+ ));
+ }
+ // The background's opacity is its colour's alpha the same way.
+ // Never zero from the dial: fully transparent is how "no
+ // background" is stored, and the switch is what takes it away.
+ ClipField::BackgroundOpacity => {
+ let plate = colour_of(&text.background);
+ text.background = hex_with_alpha(slint::Color::from_argb_u8(
+ (value.clamp(0.01, 1.0) * 255.0).round() as u8,
+ plate.red(),
+ plate.green(),
+ plate.blue(),
+ ));
+ }
+ ClipField::BackgroundRadius => text.background_radius = value.clamp(0.0, 0.2),
+ ClipField::BackgroundPaddingX => {
+ text.background_padding_x = value.clamp(0.0, 0.5);
+ }
+ ClipField::BackgroundPaddingY => {
+ text.background_padding_y = value.clamp(0.0, 0.5);
}
}
- ClipField::StrokeWidth => text.stroke_width = value.clamp(0.0, 0.15),
- ClipField::Shadow => text.shadow = value != 0.0,
- ClipField::LineHeight => text.line_height = value.clamp(0.7, 2.5),
- ClipField::Tracking => text.tracking = value.clamp(-0.05, 0.3),
- ClipField::TextWidth => text.max_width = value.clamp(0.0, 2.0),
- ClipField::TextHeight => text.max_height = value.clamp(0.0, 2.0),
- // The stroke's opacity is its colour's alpha; see `hex_rgba`.
- ClipField::StrokeOpacity => {
- let edge = colour_of(&text.stroke_color);
- text.stroke_color = hex_rgba(slint::Color::from_argb_u8(
- (value.clamp(0.0, 1.0) * 255.0).round() as u8,
- edge.red(),
- edge.green(),
- edge.blue(),
- ));
- }
- // The background's opacity is its colour's alpha the same way.
- // Never zero from the dial: fully transparent is how "no
- // background" is stored, and the switch is what takes it away.
- ClipField::BackgroundOpacity => {
- let plate = colour_of(&text.background);
- text.background = hex_with_alpha(slint::Color::from_argb_u8(
- (value.clamp(0.01, 1.0) * 255.0).round() as u8,
- plate.red(),
- plate.green(),
- plate.blue(),
- ));
- }
- ClipField::BackgroundRadius => text.background_radius = value.clamp(0.0, 0.2),
- ClipField::BackgroundPaddingX => {
- text.background_padding_x = value.clamp(0.0, 0.5);
- }
- ClipField::BackgroundPaddingY => {
- text.background_padding_y = value.clamp(0.0, 0.5);
+ // A media clip has no text; the placeholder must not linger.
+ if clip.kind != model::ClipKind::Text {
+ clip.text = None;
}
}
- // A media clip has no text; the placeholder must not linger.
- if clip.kind != model::ClipKind::Text {
- clip.text = None;
- }
}
pub fn clip_set_text(&mut self, field: ClipTextField, value: &str) {
- let Some(id) = self.sole_selection() else {
+ let ids = self.edit_targets();
+ if ids.is_empty() {
return;
- };
+ }
+ // The words are each title's own: a batch is styled together, never
+ // made to say the same thing.
+ if field == ClipTextField::Content && ids.len() > 1 {
+ return;
+ }
// One of the app's own fonts goes on the project before the title
// is set in it, as a command of its own: the painter reads the
// project's fonts, and the echo below is not the project.
if field == ClipTextField::FontFamily {
self.ensure_font(value);
}
- self.commit_target = Some(id.clone());
+ self.commit_targets = ids.clone();
self.begin_echo();
- let Some(clip) = self.echo_clip_mut(&id) else {
- return;
- };
- if clip.kind != model::ClipKind::Text {
- return;
- }
- let text = clip.text.get_or_insert_with(TextStyle::default);
- match field {
- ClipTextField::Content => {
- text.content = value.to_owned();
- let first = value.lines().next().unwrap_or("").trim().to_owned();
- clip.name = if first.is_empty() {
- "Title".into()
- } else {
- first
- };
+ for id in ids {
+ let Some(clip) = self.echo_clip_mut(&id) else {
+ continue;
+ };
+ if clip.kind != model::ClipKind::Text {
+ continue;
+ }
+ let text = clip.text.get_or_insert_with(TextStyle::default);
+ match field {
+ ClipTextField::Content => {
+ text.content = value.to_owned();
+ let first = value.lines().next().unwrap_or("").trim().to_owned();
+ clip.name = if first.is_empty() {
+ "Title".into()
+ } else {
+ first
+ };
+ }
+ ClipTextField::FontFamily => text.font_family = value.to_owned(),
+ _ => {}
}
- ClipTextField::FontFamily => text.font_family = value.to_owned(),
- _ => {}
}
// The words are on the echo now; show them. A title being typed is
// painted in memory at the monitor's size, the way a grip drag is,
@@ -4207,24 +4341,48 @@ impl Studio {
}
pub fn clip_set_colour(&mut self, field: ClipTextField, value: slint::Color) {
- let Some(id) = self.sole_selection() else {
+ let ids = self.edit_targets();
+ if ids.is_empty() {
return;
- };
- self.commit_target = Some(id.clone());
+ }
+ self.commit_targets = ids.clone();
self.begin_echo();
- let Some(clip) = self.echo_clip_mut(&id) else {
+ for id in ids {
+ let Some(clip) = self.echo_clip_mut(&id) else {
+ continue;
+ };
+ if clip.kind != model::ClipKind::Text {
+ continue;
+ }
+ let text = clip.text.get_or_insert_with(TextStyle::default);
+ match field {
+ ClipTextField::Color => text.color = hex_of(value),
+ ClipTextField::StrokeColor => text.stroke_color = hex_rgba(value),
+ ClipTextField::Background => text.background = hex_with_alpha(value),
+ _ => {}
+ }
+ }
+ }
+
+ /// The selected title's look becomes the one new titles start from,
+ /// and the one generated captions are set in: its family, weight,
+ /// colours, stroke, shadow and background, never its words. Kept in
+ /// the preferences, so it outlives the project.
+ /// https://github.com/jub0t/Concat/issues/224
+ pub fn use_title_style_for_new(&mut self) {
+ let Some(mut style) = self
+ .edit_targets()
+ .first()
+ .and_then(|id| self.clip(id))
+ .filter(|clip| clip.kind == model::ClipKind::Text)
+ .and_then(|clip| clip.text.clone())
+ else {
return;
};
- if clip.kind != model::ClipKind::Text {
- return;
- }
- let text = clip.text.get_or_insert_with(TextStyle::default);
- match field {
- ClipTextField::Color => text.color = hex_of(value),
- ClipTextField::StrokeColor => text.stroke_color = hex_rgba(value),
- ClipTextField::Background => text.background = hex_with_alpha(value),
- _ => {}
- }
+ style.content.clear();
+ self.prefs.title_style = Some(style);
+ self.prefs.save(&self.host.dirs);
+ self.notify(&t("textPanel.newTitlesUseThisStyle"), false);
}
/// The inspector's gesture is over: what differs between the echo and
@@ -4261,117 +4419,37 @@ impl Studio {
}
fn commit_now(&mut self) {
- // The clip the echo was written for, whatever is selected now; see
- // `commit_target`. The selection is the fallback for a commit asked
+ // The clips the echo was written for, whatever is selected now; see
+ // `commit_targets`. The selection is the fallback for a commit asked
// for with nothing written, which has nothing to land anyway.
- let Some(id) = self.commit_target.take().or_else(|| self.sole_selection()) else {
- self.echo = None;
- return;
- };
- let (Some(after), Some(before)) = (
- self.echo
- .as_ref()
- .and_then(|echo| echo.active().clip(&id))
- .cloned(),
- self.session
- .as_ref()
- .and_then(|session| session.project().active().clip(&id))
- .cloned(),
- ) else {
- self.echo = None;
+ let mut ids = std::mem::take(&mut self.commit_targets);
+ if ids.is_empty() {
+ ids = self.sole_selection().into_iter().collect();
+ }
+ let Some(echo) = self.echo.take() else {
return;
};
let mut commands = Vec::new();
- if after.scale != before.scale
- || after.offset_x != before.offset_x
- || after.offset_y != before.offset_y
- || after.rotation != before.rotation
- || after.stretch_x != before.stretch_x
- || after.stretch_y != before.stretch_y
- {
- commands.push(Command::SetClipTransform {
- clip_id: id.clone(),
- scale: Some(after.scale),
- offset_x: Some(after.offset_x),
- offset_y: Some(after.offset_y),
- rotation: Some(after.rotation),
- stretch_x: Some(after.stretch_x),
- stretch_y: Some(after.stretch_y),
- });
- }
- if after.cutout != before.cutout {
- commands.push(Command::SetClipCutout {
- clip_id: id.clone(),
- cutout: after.cutout.clone(),
- });
- }
- if after.speed != before.speed {
- commands.push(Command::SetClipSpeed {
- clip_id: id.clone(),
- speed: after.speed,
- });
- }
- let mut patch = ClipPatch::default();
- if after.name != before.name {
- patch.name = Some(after.name.clone());
- }
- if after.volume != before.volume {
- patch.volume = Some(after.volume);
- }
- if after.fade_in != before.fade_in {
- patch.fade_in = Some(after.fade_in);
- }
- if after.fade_out != before.fade_out {
- patch.fade_out = Some(after.fade_out);
- }
- if after.opacity != before.opacity {
- patch.opacity = Some(after.opacity);
- }
- if after.preserve_pitch != before.preserve_pitch {
- patch.preserve_pitch = Some(after.preserve_pitch);
- }
- if after.audio_stream != before.audio_stream {
- patch.audio_stream = Some(after.audio_stream);
- }
- if after.flip_h != before.flip_h {
- patch.flip_h = Some(after.flip_h);
- }
- if after.flip_v != before.flip_v {
- patch.flip_v = Some(after.flip_v);
- }
- if after.blend != before.blend {
- patch.blend = Some(if after.blend.is_empty() {
- "normal".to_owned()
- } else {
- after.blend.clone()
- });
- }
- if after.crop != before.crop {
- patch.crop = Some(after.crop);
- }
- commands.extend(key_commands(&id, &before, &after));
- if after.text != before.text {
- patch.text = Some(after.text.clone());
- }
- if after.video_effects != before.video_effects {
- patch.video_effects = Some(after.video_effects.clone());
- }
- if after.filters != before.filters {
- patch.filters = Some(after.filters.clone());
- }
- if patch != ClipPatch::default() {
- commands.push(Command::UpdateClip { clip_id: id, patch });
+ for id in &ids {
+ let (Some(after), Some(before)) = (
+ echo.active().clip(id),
+ self.session
+ .as_ref()
+ .and_then(|session| session.project().active().clip(id)),
+ ) else {
+ continue;
+ };
+ commands.extend(clip_commands(id, before, after));
}
- self.echo = None;
if commands.is_empty() {
return;
}
// One undo step per gesture, not per pointer move: a commit that
- // changes the same things on the same clip as the last, within a
+ // changes the same things on the same clips as the last, within a
// moment of it, folds into the last one's step. The editor does the
// folding; this decides when a pause is long enough to be a new
// gesture on the same knob.
- let key = format!("{}:{}", after.id, commit_key(&commands));
+ let key = format!("{}:{}", ids.join("+"), commit_key(&commands));
let now = std::time::Instant::now();
let continues = self
.last_commit
@@ -7875,7 +7953,10 @@ impl Studio {
/// The selection, flattened for the inspector: exactly one clip or
/// nothing.
fn selected(&self) -> SelectedClipData {
- let Some(clip) = self.sole_selection().and_then(|id| self.clip(&id)) else {
+ // The one clip, or the first of a batch of titles: the panel shows
+ // its values and writes to all of them; see `edit_targets`.
+ let targets = self.edit_targets();
+ let Some(clip) = targets.first().and_then(|id| self.clip(id)) else {
return SelectedClipData::default();
};
// A keyed property shows what it is worth at the playhead, which is
@@ -7892,6 +7973,7 @@ impl Studio {
});
SelectedClipData {
present: true,
+ batch: targets.len() as i32,
frame_width: self.output_size().0 as i32,
frame_height: self.output_size().1 as i32,
id: clip.id.as_str().into(),
@@ -8472,7 +8554,13 @@ impl Studio {
};
let mut rows = vec![
- action("copy", t("common.copy"), Glyph::Copy, &platform::keys(&["Control", "C"]), true),
+ action(
+ "copy",
+ t("common.copy"),
+ Glyph::Copy,
+ &platform::keys(&["Control", "C"]),
+ true,
+ ),
action(
"duplicate",
t("studio.duplicate"),
@@ -8750,9 +8838,27 @@ impl Studio {
"",
has_selection_media,
),
- row("open", t("studio.openProject"), Glyph::Import, &platform::keys(&["Control", "O"]), true),
- row("import", t("studio.importMedia"), Glyph::Import, &platform::keys(&["Control", "I"]), true),
- row("save", t("studio.save"), Glyph::Import, &platform::keys(&["Control", "S"]), true),
+ row(
+ "open",
+ t("studio.openProject"),
+ Glyph::Import,
+ &platform::keys(&["Control", "O"]),
+ true,
+ ),
+ row(
+ "import",
+ t("studio.importMedia"),
+ Glyph::Import,
+ &platform::keys(&["Control", "I"]),
+ true,
+ ),
+ row(
+ "save",
+ t("studio.save"),
+ Glyph::Import,
+ &platform::keys(&["Control", "S"]),
+ true,
+ ),
row(
"export",
t("studio.export"),
@@ -8826,8 +8932,20 @@ impl Studio {
},
],
1 => vec![
- row("undo", t("studio.undo"), Glyph::Undo, &platform::keys(&["Control", "Z"]), can_undo),
- row("redo", t("studio.redo"), Glyph::Redo, &platform::keys(&["Control", "Shift", "Z"]), can_redo),
+ row(
+ "undo",
+ t("studio.undo"),
+ Glyph::Undo,
+ &platform::keys(&["Control", "Z"]),
+ can_undo,
+ ),
+ row(
+ "redo",
+ t("studio.redo"),
+ Glyph::Redo,
+ &platform::keys(&["Control", "Shift", "Z"]),
+ can_redo,
+ ),
rule(),
row(
"split",
diff --git a/src/crates/concat/src/wayland_drop.rs b/src/crates/concat/src/wayland_drop.rs
index 33e6183a..e1a0e09c 100644
--- a/src/crates/concat/src/wayland_drop.rs
+++ b/src/crates/concat/src/wayland_drop.rs
@@ -75,7 +75,10 @@ impl Listener {
// popup is not a drop on the editor. Unknowable means any.
// SAFETY: the caller's surface pointer is winit's live proxy.
let surface = unsafe {
- wayland_client::backend::ObjectId::from_ptr(WlSurface::interface(), surface.as_ptr().cast())
+ wayland_client::backend::ObjectId::from_ptr(
+ WlSurface::interface(),
+ surface.as_ptr().cast(),
+ )
}
.ok()
.map(|id| id.protocol_id());
@@ -121,12 +124,16 @@ struct State {
sink: Box<dyn Fn(Vec<PathBuf>) + Send>,
}
-fn listen(display: usize, surface: Option<u32>, sink: Box<dyn Fn(Vec<PathBuf>) + Send>, stop: Arc<AtomicBool>) {
+fn listen(
+ display: usize,
+ surface: Option<u32>,
+ sink: Box<dyn Fn(Vec<PathBuf>) + Send>,
+ stop: Arc<AtomicBool>,
+) {
// SAFETY: `display` is winit's live wl_display, which `Listener::start`'s
// caller keeps alive until the listener - and so this thread - is gone.
- let backend = unsafe {
- wayland_client::backend::Backend::from_foreign_display(display as *mut _)
- };
+ let backend =
+ unsafe { wayland_client::backend::Backend::from_foreign_display(display as *mut _) };
let conn = Connection::from_backend(backend);
let mut queue = conn.new_event_queue::<State>();
let qh = queue.handle();
@@ -335,7 +342,8 @@ fn receive(conn: &Connection, offer: &WlDataOffer) -> Vec<PathBuf> {
return Vec::new();
}
// SAFETY: both ends are fresh descriptors this function owns.
- let (read_end, write_end) = unsafe { (OwnedFd::from_raw_fd(fds[0]), OwnedFd::from_raw_fd(fds[1])) };
+ let (read_end, write_end) =
+ unsafe { (OwnedFd::from_raw_fd(fds[0]), OwnedFd::from_raw_fd(fds[1])) };
for fd in [&read_end, &write_end] {
// SAFETY: an open descriptor of ours; the flag only closes it on exec.
unsafe { libc::fcntl(fd.as_raw_fd(), libc::F_SETFD, libc::FD_CLOEXEC) };
diff --git a/src/crates/concat/ui/editor.slint b/src/crates/concat/ui/editor.slint
index 6d6b6a46..46b78575 100644
--- a/src/crates/concat/ui/editor.slint
+++ b/src/crates/concat/ui/editor.slint
@@ -146,6 +146,9 @@ export global Editor {
/// join the user's own fonts, for good, and the title is set in the
/// first of them.
callback import-font();
+ /// The Text tab's "Use for new titles": the selected title's look
+ /// becomes the one new titles and captions start from.
+ callback text-style-default();
// The effect catalogue's shelves, published once, and the selected
// clip's two chains with a row per parameter. See PresetStack.
diff --git a/src/crates/concat/ui/inspector/text-panel.slint b/src/crates/concat/ui/inspector/text-panel.slint
index c78965d2..f47aeaf8 100644
--- a/src/crates/concat/ui/inspector/text-panel.slint
+++ b/src/crates/concat/ui/inspector/text-panel.slint
@@ -8,6 +8,7 @@ import { IconButton, Row, Section, SectionBody, SectionHeader } from "../primiti
import { SegmentedControl } from "../primitives/segmented-control.slint";
import { Select } from "../primitives/select.slint";
import { NumberField } from "../primitives/number-field.slint";
+import { Button } from "../primitives/modal.slint";
import {
ColourField, HelpButton, InspectorFmt, Param, ParamFormat, SwitchRow,
} from "controls.slint";
@@ -42,6 +43,13 @@ export component TextPanel inherits VerticalLayout {
callback commit();
/// The square beside the font picker: bring a font file of your own in.
callback import-font();
+ /// Keep this title's look for new titles and captions.
+ callback set-default();
+
+ /// Several titles selected together: every knob writes to all of them
+ /// and the words, each title's own, are not offered.
+ /// https://github.com/jub0t/Concat/issues/224
+ property <bool> batch: root.selected.batch > 1;
// Local editing state, seeded rather than bound — see the note on
// AdjustPanel, which has the same problem for the same reason.
@@ -148,8 +156,22 @@ export component TextPanel inherits VerticalLayout {
return v <= 0 ? I18n.t("common.autoValue") : "\{Math.round(v)}";
}
+ // ── a batch ──────────────────────────────────────────────────────────
+ if root.batch: SectionBody {
+ padding-left: Theme.pad;
+ padding-right: Theme.pad;
+ padding-top: 10px;
+ padding-bottom: 6px;
+ Text {
+ text: I18n.t1("textPanel.editingTitles", "\{root.selected.batch}");
+ color: Theme.fg-muted;
+ font-size: Theme.fs;
+ wrap: word-wrap;
+ }
+ }
+
// ── content ──────────────────────────────────────────────────────────
- Section {
+ if !root.batch: Section {
first: true;
content := SectionHeader {
title: I18n.t("textPanel.content");
@@ -253,6 +275,18 @@ export component TextPanel inherits VerticalLayout {
}
}
+ // This look, kept: what new titles and generated captions start
+ // from. The words stay this title's own.
+ Row {
+ label: "";
+ label-width: root.label-w;
+ Button {
+ label: I18n.t("textPanel.useForNewTitles");
+ ghost: true;
+ clicked => { root.set-default(); }
+ }
+ }
+
Row {
label: I18n.t("textPanel.fontWeight");
label-width: root.label-w;
diff --git a/src/crates/concat/ui/phone/editor.slint b/src/crates/concat/ui/phone/editor.slint
index 1ed342c9..c7d70b0b 100644
--- a/src/crates/concat/ui/phone/editor.slint
+++ b/src/crates/concat/ui/phone/editor.slint
@@ -1100,6 +1100,7 @@ export component PhoneEditor inherits Rectangle {
set-colour(field, value) => { Editor.clip-set-colour(field, value); }
commit => { Editor.clip-commit(); }
import-font => { Editor.import-font(); }
+ set-default => { Editor.text-style-default(); }
}
if root.sheet == "clip-layer": FilterPanel {
diff --git a/src/crates/concat/ui/timeline/model.slint b/src/crates/concat/ui/timeline/model.slint
index cc97cacf..833922f6 100644
--- a/src/crates/concat/ui/timeline/model.slint
+++ b/src/crates/concat/ui/timeline/model.slint
@@ -255,6 +255,9 @@ export enum ClipTextField {
/// is how a panel ends up showing two clips at once.
export struct SelectedClipData {
present: bool,
+ /// how many clips the panel writes to: one, or every selected title
+ /// when several are selected together, shown by the first's values
+ batch: int,
id: string,
/// the output frame's size, so a fraction can be shown in pixels
frame-width: int,
diff --git a/src/crates/concat/ui/workspace/config-pane.slint b/src/crates/concat/ui/workspace/config-pane.slint
index 92baf0cd..3f30948a 100644
--- a/src/crates/concat/ui/workspace/config-pane.slint
+++ b/src/crates/concat/ui/workspace/config-pane.slint
@@ -186,6 +186,7 @@ export component ConfigPane inherits Rectangle {
/// The Text tab's font picker and its import button; see Editor.
in property <[string]> font-families;
callback import-font();
+ callback text-style-default();
/// The cutout's brush and controls; see Editor.
in property <int> brush-tool;
@@ -589,6 +590,7 @@ export component ConfigPane inherits Rectangle {
set-colour(field, value) => { root.clip-set-colour(field, value); }
commit => { root.clip-commit(); }
import-font => { root.import-font(); }
+ set-default => { root.text-style-default(); }
}
// Audio: the level and fades, then the voice and room chain
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index ffc936f7..2b9f6e81 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -272,6 +272,7 @@ export component Seat inherits Rectangle {
clip-commit => { Editor.clip-commit(); }
font-families: Editor.font-families;
import-font => { Editor.import-font(); }
+ text-style-default => { Editor.text-style-default(); }
}
// Declared before the views, so anything inside one of them that takes