The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(text): the colour field types its hex, the background has padding with a lock, and a box side is px or Auto
Jareer5cba81dee40d
diff --git a/docs/api/types.md b/docs/api/types.mdindex 6c86332c..1635a242 100644--- a/docs/api/types.md+++ b/docs/api/types.md@@ -257,6 +257,8 @@ change; the rest take these defaults.| `shadow` | bool | true | A drop shadow || `background` | string | `""` | A background colour behind the text, `#rrggbb[aa]`, its alpha the opacity; empty is none || `backgroundRadius` | number | 0.0135 | The background's corner radius as a fraction of frame height; 0 is square |+| `backgroundPaddingX` | number | 0.0315 | The background's air either side of the words, as a fraction of frame height; ignored on an axis `maxWidth` sizes |+| `backgroundPaddingY` | number | 0.018 | The same above and below; ignored when `maxHeight` sizes the box || `lineHeight` | number | 1.2 | Multiple of the font size; floored at 0.5 || `tracking` | number | 0 | Extra letter spacing, in frame-height fractions || `maxWidth` | number | 0 | Wrap width as a fraction of frame width; 0 is no wrap |diff --git a/src/crates/concat-host/src/titles.rs b/src/crates/concat-host/src/titles.rsindex 71fd9903..a70976fb 100644--- a/src/crates/concat-host/src/titles.rs+++ b/src/crates/concat-host/src/titles.rs@@ -439,6 +439,8 @@ fn title_style(style: &TextStyle) -> TitleStyle {shadow: style.shadow,background: style.background.clone(),background_radius: style.background_radius,+ background_padding_x: style.background_padding_x,+ background_padding_y: style.background_padding_y,line_height: style.line_height,max_width: style.max_width,max_height: style.max_height,diff --git a/src/crates/concat-project/src/model.rs b/src/crates/concat-project/src/model.rsindex f9fe9bc4..43c049ad 100644--- a/src/crates/concat-project/src/model.rs+++ b/src/crates/concat-project/src/model.rs@@ -876,6 +876,14 @@ pub struct TextStyle {/// the rounding every background wore before it had a dial - 15 % of/// the default size's em - and zero is square.pub background_radius: f64,+ /// The air between the words and the background's left and right+ /// edges, as a fraction of frame height, on an axis the words size+ /// themselves: a box with a width is exactly that wide. The default+ /// is the air every background had before it was a dial, 35 % of the+ /// default size's em.+ pub background_padding_x: f64,+ /// The same above and below; 20 % of the default em by default.+ pub background_padding_y: f64,/// Baseline spacing as a multiple of the font size; the reader floors it/// at 0.5 so lines cannot collapse onto each other.pub line_height: f64,@@ -914,8 +922,11 @@ impl TextStyle {self.tracking = finite(self.tracking, base.tracking);self.max_width = finite(self.max_width, base.max_width).max(0.0);self.max_height = finite(self.max_height, base.max_height).max(0.0);- self.background_radius =- finite(self.background_radius, base.background_radius).max(0.0);+ self.background_radius = finite(self.background_radius, base.background_radius).max(0.0);+ self.background_padding_x =+ finite(self.background_padding_x, base.background_padding_x).max(0.0);+ self.background_padding_y =+ finite(self.background_padding_y, base.background_padding_y).max(0.0);self}}@@ -936,6 +947,8 @@ impl Default for TextStyle {shadow: true,background: String::new(),background_radius: 0.0135,+ background_padding_x: 0.0315,+ background_padding_y: 0.018,line_height: 1.2,tracking: 0.0,max_width: 0.0,diff --git a/src/crates/concat-text/src/lib.rs b/src/crates/concat-text/src/lib.rsindex c6bec6d5..204e723a 100644--- a/src/crates/concat-text/src/lib.rs+++ b/src/crates/concat-text/src/lib.rs@@ -80,6 +80,11 @@ pub struct TitleStyle {/// The plate's corner radius as a fraction of frame height; zero is/// square.pub background_radius: f64,+ /// The plate's air either side of the words, as a fraction of frame+ /// height; only on an axis the style does not size.+ pub background_padding_x: f64,+ /// The same above and below.+ pub background_padding_y: f64,/// Baseline pitch as a multiple of the em.pub line_height: f64,/// Extra advance after every glyph, as a fraction of frame height.@@ -617,12 +622,12 @@ fn paint(// outline, and what the title's neighbours should keep clear of.let plate = colour(&style.background);let pad_x = if plate.is_some() && max_w <= 0.0 {- em * 0.35+ (style.background_padding_x.max(0.0) as f32) * frame_h} else {0.0};let pad_y = if plate.is_some() && max_h <= 0.0 {- em * 0.2+ (style.background_padding_y.max(0.0) as f32) * frame_h} else {0.0};@@ -798,6 +803,8 @@ mod tests {shadow: true,background: String::new(),background_radius: 0.0135,+ background_padding_x: 0.0315,+ background_padding_y: 0.018,line_height: 1.2,tracking: 0.0,max_width: 0.0,@@ -955,7 +962,11 @@ mod tests {(at(161, 109), at(320, 109))};let rendered = render(&fonts, &square, 640, 360).expect("renders");- assert_eq!(probe(&rendered.png), (255, 255), "square corners are painted");+ assert_eq!(+ probe(&rendered.png),+ (255, 255),+ "square corners are painted"+ );let mut round = square.clone();round.background_radius = 0.1;@@ -965,6 +976,36 @@ mod tests {assert_eq!(edge, 255, "and the edge between the corners is painted");}+ /// The plate's air follows the style's padding: the block is the words+ /// plus twice the padding on each axis the words size, and a padding of+ /// nothing is a plate that hugs them.+ #[test]+ fn the_plates_air_follows_the_padding() {+ let fonts = Fonts::new();+ let mut hugging = style("hi");+ hugging.background = "#000000ff".to_owned();+ hugging.shadow = false;+ hugging.background_padding_x = 0.0;+ hugging.background_padding_y = 0.0;+ let tight = render(&fonts, &hugging, 640, 360).expect("renders");++ let mut roomy = hugging.clone();+ roomy.background_padding_x = 0.1;+ roomy.background_padding_y = 0.05;+ let wide = render(&fonts, &roomy, 640, 360).expect("renders");+ // 10 % of 360 either side, and 5 % above and below.+ assert_eq!(+ wide.block_width,+ tight.block_width + 72,+ "the air either side"+ );+ assert_eq!(+ wide.block_height,+ tight.block_height + 36,+ "the air above and below"+ );+ }+/// A box narrower or shorter than the words grows to hold them: a word/// no line can hold is never cut, and never overflows the plate.#[test]diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.jsonindex 9200a365..3269c53e 100644--- a/src/crates/concat/locales/de.json+++ b/src/crates/concat/locales/de.json@@ -488,6 +488,7 @@"Loading the model": "Modell wird geladen","Location": "Speicherort","Lock lane": "Spur sperren",+ "Lock the paddings together": "Beide Abstände koppeln","Lock track": "Spur sperren","long": "lang","longer": "länger",@@ -607,6 +608,7 @@"Outline": "Kontur","Output": "Ausgabe","Output · {0}": "Ausgabe · {0}",+ "Padding": "Innenabstand","Pan tool (H)": "Pan tool (H)","Party & Club": "Party & Club","Paste": "Einfügen",@@ -934,6 +936,7 @@"Undo": "Rückgängig","Undo (⌘Z)": "Rückgängig (⌘Z)","Unlock lane": "Spur entsperren",+ "Unlock the paddings": "Abstände entkoppeln","Unmute lane": "Spur laut schalten","Unpacking…": "Wird entpackt…","Untitled project": "Unbenanntes Projekt",diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.jsonindex 135f7971..82db00da 100644--- a/src/crates/concat/locales/en.json+++ b/src/crates/concat/locales/en.json@@ -488,6 +488,7 @@"Loading the model": "Loading the model","Location": "Location","Lock lane": "Lock lane",+ "Lock the paddings together": "Lock the paddings together","Lock track": "Lock track","long": "long","longer": "longer",@@ -607,6 +608,7 @@"Outline": "Outline","Output": "Output","Output · {0}": "Output · {0}",+ "Padding": "Padding","Pan tool (H)": "Pan tool (H)","Party & Club": "Party & Club","Paste": "Paste",@@ -934,6 +936,7 @@"Undo": "Undo","Undo (⌘Z)": "Undo (⌘Z)","Unlock lane": "Unlock lane",+ "Unlock the paddings": "Unlock the paddings","Unmute lane": "Unmute lane","Unpacking…": "Unpacking…","Untitled project": "Untitled project",diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.jsonindex 12fbf3fb..2c9e7857 100644--- a/src/crates/concat/locales/es.json+++ b/src/crates/concat/locales/es.json@@ -488,6 +488,7 @@"Loading the model": "Cargando el modelo","Location": "Ubicación","Lock lane": "Bloquear pista",+ "Lock the paddings together": "Vincular ambos rellenos","Lock track": "Bloquear pista","long": "larga","longer": "más larga",@@ -607,6 +608,7 @@"Outline": "Contorno","Output": "Salida","Output · {0}": "Salida · {0}",+ "Padding": "Relleno","Pan tool (H)": "Pan tool (H)","Party & Club": "Fiesta y discoteca","Paste": "Pegar",@@ -934,6 +936,7 @@"Undo": "Deshacer","Undo (⌘Z)": "Deshacer (⌘Z)","Unlock lane": "Desbloquear pista",+ "Unlock the paddings": "Desvincular los rellenos","Unmute lane": "Activar el sonido de la pista","Unpacking…": "Desempaquetando…","Untitled project": "Proyecto sin título",diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.jsonindex 8e0a0a18..62cf8d5e 100644--- a/src/crates/concat/locales/fa.json+++ b/src/crates/concat/locales/fa.json@@ -488,6 +488,7 @@"Loading the model": "در حال بارگذاری مدل","Location": "موقعیت","Lock lane": "قفل کردن لاین",+ "Lock the paddings together": "قفل کردن دو حاشیه به هم","Lock track": "قفل کردن ترک","long": "طولانی","longer": "طولانیتر",@@ -607,6 +608,7 @@"Outline": "حاشیه","Output": "خروجی","Output · {0}": "خروجی · {0}",+ "Padding": "حاشیهٔ داخلی","Pan tool (H)": "ابزار Pan (H)","Party & Club": "مهمانی و کلاب","Paste": "چسباندن",@@ -934,6 +936,7 @@"Undo": "واگرد","Undo (⌘Z)": "واگرد (⌘Z)","Unlock lane": "باز کردن قفل لاین",+ "Unlock the paddings": "باز کردن قفل حاشیهها","Unmute lane": "فعالکردن صدا کردن لاین","Unpacking…": "در حال بازکردن بسته…","Untitled project": "پروژه بدون عنوان",diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.jsonindex decff8c0..9c3eb017 100644--- a/src/crates/concat/locales/fr.json+++ b/src/crates/concat/locales/fr.json@@ -488,6 +488,7 @@"Loading the model": "Chargement du modèle","Location": "Emplacement","Lock lane": "Verrouiller la piste",+ "Lock the paddings together": "Lier les deux marges","Lock track": "Verrouiller la piste","long": "longues","longer": "plus longues",@@ -607,6 +608,7 @@"Outline": "Contour","Output": "Sortie","Output · {0}": "Sortie · {0}",+ "Padding": "Marge intérieure","Pan tool (H)": "Pan tool (H)","Party & Club": "Fête et club","Paste": "Coller",@@ -934,6 +936,7 @@"Undo": "Annuler","Undo (⌘Z)": "Annuler (⌘Z)","Unlock lane": "Déverrouiller la piste",+ "Unlock the paddings": "Délier les marges","Unmute lane": "Rétablir le son de la piste","Unpacking…": "Décompression…","Untitled project": "Projet sans titre",diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.jsonindex 4818b1d9..b84df83e 100644--- a/src/crates/concat/locales/hr.json+++ b/src/crates/concat/locales/hr.json@@ -488,6 +488,7 @@"Loading the model": "Učitavanje modela","Location": "Lokacija","Lock lane": "Zaključaj traku",+ "Lock the paddings together": "Zaključaj oba razmaka zajedno","Lock track": "Zaključaj traku","long": "dugo","longer": "duže",@@ -607,6 +608,7 @@"Outline": "Kontura","Output": "Izlaz","Output · {0}": "Izlaz · {0}",+ "Padding": "Unutarnji razmak","Pan tool (H)": "Pan tool (H)","Party & Club": "Party i klub","Paste": "Zalijepi",@@ -934,6 +936,7 @@"Undo": "Poništi","Undo (⌘Z)": "Poništi (⌘Z)","Unlock lane": "Otključaj traku",+ "Unlock the paddings": "Otključaj razmake","Unmute lane": "Uključi zvuk trake","Unpacking…": "Raspakiranje…","Untitled project": "Neimenovani projekt",diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.jsonindex 7b036583..f6f02ac6 100644--- a/src/crates/concat/locales/it.json+++ b/src/crates/concat/locales/it.json@@ -488,6 +488,7 @@"Loading the model": "Caricamento del modello","Location": "Posizione","Lock lane": "Blocca traccia",+ "Lock the paddings together": "Blocca le due spaziature insieme","Lock track": "Blocca traccia","long": "lunghe","longer": "più lunghe",@@ -607,6 +608,7 @@"Outline": "Contorno","Output": "Uscita","Output · {0}": "Uscita · {0}",+ "Padding": "Spaziatura interna","Pan tool (H)": "Pan tool (H)","Party & Club": "Festa e club","Paste": "Incolla",@@ -934,6 +936,7 @@"Undo": "Annulla","Undo (⌘Z)": "Annulla (⌘Z)","Unlock lane": "Sblocca traccia",+ "Unlock the paddings": "Sblocca le spaziature","Unmute lane": "Riattiva il suono della traccia","Unpacking…": "Estrazione…","Untitled project": "Progetto senza titolo",diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.jsonindex c7ecd236..58d29448 100644--- a/src/crates/concat/locales/ja.json+++ b/src/crates/concat/locales/ja.json@@ -488,6 +488,7 @@"Loading the model": "モデルを読み込み中","Location": "場所","Lock lane": "トラックをロック",+ "Lock the paddings together": "2つの余白を連動する","Lock track": "トラックをロック","long": "長い","longer": "より長い",@@ -607,6 +608,7 @@"Outline": "縁取り","Output": "出力","Output · {0}": "出力 · {0}",+ "Padding": "余白","Pan tool (H)": "Pan tool (H)","Party & Club": "パーティーとクラブ","Paste": "ペースト",@@ -934,6 +936,7 @@"Undo": "取り消す","Undo (⌘Z)": "取り消す (⌘Z)","Unlock lane": "トラックのロックを解除",+ "Unlock the paddings": "余白の連動を解除する","Unmute lane": "トラックのミュートを解除","Unpacking…": "展開中…","Untitled project": "無題のプロジェクト",diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.jsonindex d5855148..c58a8aa3 100644--- a/src/crates/concat/locales/ko.json+++ b/src/crates/concat/locales/ko.json@@ -488,6 +488,7 @@"Loading the model": "모델 불러오는 중","Location": "위치","Lock lane": "트랙 잠금",+ "Lock the paddings together": "두 여백을 함께 잠그기","Lock track": "트랙 잠금","long": "길게","longer": "더 길게",@@ -607,6 +608,7 @@"Outline": "외곽선","Output": "출력","Output · {0}": "출력 · {0}",+ "Padding": "여백","Pan tool (H)": "Pan tool (H)","Party & Club": "파티 & 클럽","Paste": "붙여넣기",@@ -934,6 +936,7 @@"Undo": "실행 취소","Undo (⌘Z)": "실행 취소 (⌘Z)","Unlock lane": "트랙 잠금 해제",+ "Unlock the paddings": "여백 잠금 해제","Unmute lane": "트랙 음소거 해제","Unpacking…": "압축 해제 중…","Untitled project": "제목 없는 프로젝트",diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.jsonindex bdc9105f..fb0e12be 100644--- a/src/crates/concat/locales/pt-BR.json+++ b/src/crates/concat/locales/pt-BR.json@@ -488,6 +488,7 @@"Loading the model": "Carregando o modelo","Location": "Local","Lock lane": "Bloquear faixa",+ "Lock the paddings together": "Vincular os dois preenchimentos","Lock track": "Bloquear faixa","long": "longo","longer": "mais longo",@@ -607,6 +608,7 @@"Outline": "Contorno","Output": "Saída","Output · {0}": "Saída · {0}",+ "Padding": "Preenchimento","Pan tool (H)": "Pan tool (H)","Party & Club": "Festa e balada","Paste": "Colar",@@ -934,6 +936,7 @@"Undo": "Desfazer","Undo (⌘Z)": "Desfazer (⌘Z)","Unlock lane": "Desbloquear faixa",+ "Unlock the paddings": "Desvincular os preenchimentos","Unmute lane": "Ativar o som da faixa","Unpacking…": "Descompactando…","Untitled project": "Projeto sem título",diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.jsonindex 4a147dc5..9f10719f 100644--- a/src/crates/concat/locales/ru.json+++ b/src/crates/concat/locales/ru.json@@ -488,6 +488,7 @@"Loading the model": "Загрузка модели","Location": "Расположение","Lock lane": "Заблокировать дорожку",+ "Lock the paddings together": "Связать оба отступа","Lock track": "Заблокировать дорожку","long": "длинные","longer": "ещё длиннее",@@ -607,6 +608,7 @@"Outline": "Обводка","Output": "Вывод","Output · {0}": "Вывод · {0}",+ "Padding": "Отступы","Pan tool (H)": "Инструмент «Рука» (H)","Party & Club": "Вечеринка и клуб","Paste": "Вставить",@@ -934,6 +936,7 @@"Undo": "Отменить","Undo (⌘Z)": "Отменить (⌘Z)","Unlock lane": "Разблокировать дорожку",+ "Unlock the paddings": "Разъединить отступы","Unmute lane": "Включить звук дорожки","Unpacking…": "Распаковка…","Untitled project": "Проект без названия",diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.jsonindex 5a7045e1..fa82e694 100644--- a/src/crates/concat/locales/tr.json+++ b/src/crates/concat/locales/tr.json@@ -488,6 +488,7 @@"Loading the model": "Model yükleniyor","Location": "Konum","Lock lane": "Parçayı kilitle",+ "Lock the paddings together": "İki boşluğu birlikte kilitle","Lock track": "Parçayı kilitle","long": "uzun","longer": "daha uzun",@@ -607,6 +608,7 @@"Outline": "Dış çizgi","Output": "Çıktı","Output · {0}": "Çıkış · {0}",+ "Padding": "İç boşluk","Pan tool (H)": "Pan tool (H)","Party & Club": "Parti ve kulüp","Paste": "Yapıştır",@@ -934,6 +936,7 @@"Undo": "Geri al","Undo (⌘Z)": "Geri al (⌘Z)","Unlock lane": "Parçanın kilidini aç",+ "Unlock the paddings": "Boşlukların kilidini aç","Unmute lane": "Parçanın sesini aç","Unpacking…": "Açılıyor…","Untitled project": "Adsız proje",diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.jsonindex 8945a31b..4c6f3ebe 100644--- a/src/crates/concat/locales/zh-Hans.json+++ b/src/crates/concat/locales/zh-Hans.json@@ -488,6 +488,7 @@"Loading the model": "正在加载模型","Location": "位置","Lock lane": "锁定轨道",+ "Lock the paddings together": "锁定两个内边距一致","Lock track": "锁定轨道","long": "长","longer": "更长",@@ -607,6 +608,7 @@"Outline": "描边","Output": "输出","Output · {0}": "输出 · {0}",+ "Padding": "内边距","Pan tool (H)": "平移工具 (H)","Party & Club": "派对与夜店","Paste": "粘贴",@@ -934,6 +936,7 @@"Undo": "撤销","Undo (⌘Z)": "撤销 (⌘Z)","Unlock lane": "解锁轨道",+ "Unlock the paddings": "解锁内边距","Unmute lane": "取消轨道静音","Unpacking…": "正在解包…","Untitled project": "未命名项目",diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.jsonindex 96defc7a..7456ee39 100644--- a/src/crates/concat/locales/zh-TW.json+++ b/src/crates/concat/locales/zh-TW.json@@ -488,6 +488,7 @@"Loading the model": "正在載入模型","Location": "位置","Lock lane": "鎖定軌道",+ "Lock the paddings together": "鎖定兩個內邊距一致","Lock track": "鎖定軌道","long": "長","longer": "更長",@@ -607,6 +608,7 @@"Outline": "描邊","Output": "輸出","Output · {0}": "輸出 · {0}",+ "Padding": "內邊距","Pan tool (H)": "平移工具 (H)","Party & Club": "派對與夜店","Paste": "貼上",@@ -934,6 +936,7 @@"Undo": "復原","Undo (⌘Z)": "復原 (⌘Z)","Unlock lane": "解除鎖定軌道",+ "Unlock the paddings": "解除鎖定內邊距","Unmute lane": "取消軌道靜音","Unpacking…": "正在解壓縮…","Untitled project": "未命名專案",diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex 03c7908e..60633d40 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -160,7 +160,12 @@ pub fn run() -> Result<(), slint::PlatformError> {}// A picked playhead colour is remembered as its hex; none remembered,// or one that will not parse, is the palette's own.- if let Some(colour) = studio.prefs.playhead.as_deref().and_then(format::parse_colour) {+ if let Some(colour) = studio+ .prefs+ .playhead+ .as_deref()+ .and_then(format::parse_colour)+ {let theme = app.global::<Theme>();theme.set_playhead_custom(colour);theme.set_playhead_is_custom(true);@@ -1479,6 +1484,8 @@ pub fn run() -> Result<(), slint::PlatformError> {format::hex_of(value).into()}});+ app.global::<Fmt>()+ .on_hex_digits(|value| format::hex_of(value)[1..].into());app.global::<Fmt>().on_color_of(|text, fallback| format::parse_colour(text.as_str()).unwrap_or(fallback));app.global::<Fmt>()diff --git a/src/crates/concat/src/presets.rs b/src/crates/concat/src/presets.rsindex d4f87a2f..f675c414 100644--- a/src/crates/concat/src/presets.rs+++ b/src/crates/concat/src/presets.rs@@ -82,6 +82,8 @@ struct PresetStyle {shadow: Option<bool>,background: Option<String>,background_radius: Option<f64>,+ background_padding_x: Option<f64>,+ background_padding_y: Option<f64>,line_height: Option<f64>,tracking: Option<f64>,max_width: Option<f64>,@@ -117,6 +119,14 @@ impl PresetStyle {.background_radius.unwrap_or(base.background_radius).max(0.0),+ background_padding_x: self+ .background_padding_x+ .unwrap_or(base.background_padding_x)+ .max(0.0),+ background_padding_y: self+ .background_padding_y+ .unwrap_or(base.background_padding_y)+ .max(0.0),line_height: self.line_height.unwrap_or(base.line_height).max(0.5),tracking: self.tracking.unwrap_or(0.0),max_width: self.max_width.unwrap_or(0.0).max(0.0),diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 92d2a495..bfe089c8 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -3638,6 +3638,12 @@ impl Studio {));}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 {@@ -7013,6 +7019,8 @@ impl Studio {plated: plate.alpha() > 0,plate_opacity: f32::from(plate.alpha()) / 255.0,plate_radius: text.background_radius as f32,+ plate_padding_x: text.background_padding_x as f32,+ plate_padding_y: text.background_padding_y as f32,line_height: text.line_height as f32,tracking: text.tracking as f32,text_width: text.max_width as f32,diff --git a/src/crates/concat/ui/inspector/controls.slint b/src/crates/concat/ui/inspector/controls.slintindex 2a3c1034..a878714c 100644--- a/src/crates/concat/ui/inspector/controls.slint+++ b/src/crates/concat/ui/inspector/controls.slint@@ -784,14 +784,34 @@ export component SearchField inherits Rectangle {export component ColourField inherits HorizontalLayout {in property <string> label;in property <color> value;- /// The value spelled out, formatted by whoever owns it — Slint cannot- /// print a colour.- in property <string> hex;/// The colour carries an alpha of its own; see ColorPicker.in property <bool> alpha: false;callback changed(value: color);+ /// The digits being typed, held apart from `value` for the reason+ /// the dialog's Field holds its draft: a TextInput writes to whatever+ /// it is bound to, and a republish mid-edit must not yank the caret.+ property <string> draft;+ function seed() {+ root.draft = Fmt.hex-digits(root.value);+ }+ /// What was typed, taken as a colour - "fff" and "cbf53f" alike, and+ /// the value kept when it is neither - with the alpha it already had:+ /// the field is six digits, and an opacity has a dial of its own.+ function adopt() {+ root.changed(Fmt.color-of("#" + root.draft, root.value)+ .with-alpha(root.value.to-hsv().alpha));+ root.seed();+ }++ init => { root.seed(); }+ changed value => {+ if (!input.has-focus) {+ root.seed();+ }+ }+padding-left: Theme.pad;padding-right: Theme.pad;spacing: 8px;@@ -806,33 +826,102 @@ export component ColourField inherits HorizontalLayout {Rectangle { horizontal-stretch: 1; }- Text {- text: root.hex;- color: Theme.fg-dim;- font-family: Theme.font-technical;- font-size: Theme.fs-sm;- vertical-alignment: center;+ // The hex, typed as well as read. The hash sits in a quiet segment on+ // the left - the number field's unit well, mirrored - because every+ // value starts with it and nobody should have to type it; the six+ // digits are the field.+ VerticalLayout {+ alignment: center;++ field := Rectangle {+ width: 86px;+ height: 24px;+ border-radius: Theme.r-sm;+ clip: true;+ background: input.has-focus ? Theme.field-hover+ : hover.has-hover ? Theme.field-hover+ : Theme.field;+ border-width: 1px;+ border-color: input.has-focus ? Theme.accent : Colors.transparent;++ animate background, border-color { duration: 100ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }++ HorizontalLayout {+ Rectangle {+ width: 20px;+ background: Theme.well;++ Rectangle {+ x: parent.width - 1px;+ width: 1px;+ background: Theme.line;+ }+ Text {+ width: parent.width;+ height: parent.height;+ text: "#";+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ horizontal-alignment: center;+ vertical-alignment: center;+ }+ }++ Rectangle {+ horizontal-stretch: 1;++ hover := TouchArea {+ mouse-cursor: MouseCursor.text;+ clicked => { input.focus(); }+ }++ input := TextInput {+ x: 8px;+ y: (parent.height - self.height) / 2;+ width: parent.width - 16px;+ height: self.preferred-height;+ text <=> root.draft;+ color: Theme.fg;+ font-family: Theme.font-technical;+ font-size: Theme.fs;+ single-line: true;+ selection-background-color: Theme.accent;+ selection-foreground-color: Theme.on-accent;++ accepted => { root.adopt(); }+ changed has-focus => {+ if (!self.has-focus) {+ root.adopt();+ }+ }+ }+ }+ }+ }}+ // The swatch: a square the height of the field, and the button that+ // opens the picker.VerticalLayout {alignment: center;swatch := Rectangle {- width: 34px;- height: 20px;- border-radius: Theme.r-xs;+ width: 24px;+ height: 24px;+ border-radius: Theme.r-sm;clip: true;border-width: 1px;border-color: touch.has-hover ? Theme.line-strong : Theme.line;// A checker under a colour that can be see-through, so a faint- // plate looks faint rather than like the panel.+ // stroke looks faint rather than like the panel.if root.alpha: Rectangle {- for cell in 15: Rectangle {- x: Math.floor(cell / 3) * 7px;- y: Math.mod(cell, 3) * 7px;- width: 7px;- height: 7px;+ for cell in 9: Rectangle {+ x: Math.floor(cell / 3) * 8px;+ y: Math.mod(cell, 3) * 8px;+ width: 8px;+ height: 8px;background: Math.mod(cell + Math.floor(cell / 3), 2) == 0 ? #c8c8c8 : #7a7a7a;}}@@ -842,7 +931,7 @@ export component ColourField inherits HorizontalLayout {y: 1px;width: parent.width - 2px;height: parent.height - 2px;- border-radius: Theme.r-xs - 1px;+ border-radius: Theme.r-sm - 1px;background: root.value;}diff --git a/src/crates/concat/ui/inspector/text-panel.slint b/src/crates/concat/ui/inspector/text-panel.slintindex 55afaf5d..00fb600f 100644--- a/src/crates/concat/ui/inspector/text-panel.slint+++ b/src/crates/concat/ui/inspector/text-panel.slint@@ -4,7 +4,7 @@import { I18n } from "../i18n.slint";import { Theme } from "../theme/theme.slint";import { Glyph } from "../icons.slint";-import { Row, Section, SectionBody, SectionHeader } from "../primitives/panel.slint";+import { IconButton, Row, Section, SectionBody, SectionHeader } from "../primitives/panel.slint";import { SegmentedControl } from "../primitives/segmented-control.slint";import { Select } from "../primitives/select.slint";import { NumberField } from "../primitives/number-field.slint";@@ -49,10 +49,24 @@ export component TextPanel inherits VerticalLayout {property <float> stroke-alpha;property <float> plate-alpha;property <float> plate-radius;+ /// The background's air, in pixels of the frame like the box's sides.+ property <float> plate-pad-x;+ property <float> plate-pad-y;+ /// The two paddings are one number: an edit to either sets both. A+ /// choice about how the panel is used, not about the title, so it is+ /// not in the document and survives a change of selection.+ property <bool> pad-locked: false;property <float> line-height;property <float> tracking;property <float> box-w;property <float> box-h;+ /// Each side's unit: 0 is pixels, 1 is Auto, which is zero in the+ /// document - the words size that side, padding and all.+ property <int> w-mode;+ property <int> h-mode;+ /// What a side measured before it went Auto, so px brings it back.+ property <float> last-w;+ property <float> last-h;property <float> offset-x;property <float> offset-y;property <int> weight-index;@@ -71,10 +85,14 @@ export component TextPanel inherits VerticalLayout {root.stroke-alpha = root.selected.stroke-opacity;root.plate-alpha = root.selected.plate-opacity;root.plate-radius = root.selected.plate-radius;+ root.plate-pad-x = root.selected.plate-padding-x * root.frame-h;+ root.plate-pad-y = root.selected.plate-padding-y * root.frame-h;root.line-height = root.selected.line-height;root.tracking = root.selected.tracking;root.box-w = root.selected.text-width * root.frame-w;root.box-h = root.selected.text-height * root.frame-h;+ root.w-mode = root.box-w > 0 ? 0 : 1;+ root.h-mode = root.box-h > 0 ? 0 : 1;root.offset-x = root.selected.offset-x;root.offset-y = root.selected.offset-y;root.weight-index = root.selected.font-weight >= 700 ? 3@@ -88,6 +106,41 @@ export component TextPanel inherits VerticalLayout {init => { root.seed(); }changed selected => { root.seed(); }+ /// Both paddings at once, in pixels of the frame, as one edit: the+ /// echo takes the two sets and the commit lands them together.+ function set-padding(x: float, y: float) {+ root.plate-pad-x = x;+ root.plate-pad-y = y;+ root.set(ClipField.background-padding-x, x / root.frame-h);+ root.set(ClipField.background-padding-y, y / root.frame-h);+ root.commit();+ }++ /// A side's unit picked: Auto is zero in the document, and px is the+ /// size the side last had, or a share of the frame to start from when+ /// it never had one - half the width, a fifth of the height, a lower+ /// third's band.+ function size-mode(width: bool, auto: bool) {+ if (width) {+ if (auto) {+ root.last-w = root.box-w;+ root.box-w = 0;+ } else if (root.box-w <= 0) {+ root.box-w = root.last-w > 0 ? root.last-w : Math.round(root.frame-w / 2);+ }+ root.set(ClipField.text-width, root.box-w / root.frame-w);+ } else {+ if (auto) {+ root.last-h = root.box-h;+ root.box-h = 0;+ } else if (root.box-h <= 0) {+ root.box-h = root.last-h > 0 ? root.last-h : Math.round(root.frame-h / 5);+ }+ root.set(ClipField.text-height, root.box-h / root.frame-h);+ }+ root.commit();+ }+/// A box side in pixels: "auto" at zero, else the whole number.pure function px(v: float) -> string {return v <= 0 ? I18n.t("auto") : "\{Math.round(v)}";@@ -228,7 +281,6 @@ export component TextPanel inherits VerticalLayout {ColourField {label: I18n.t("Color");value: root.selected.fill;- hex: root.selected.fill-hex;alpha: false;changed(colour) => { root.set-colour(ClipTextField.color, colour); root.commit(); }}@@ -278,7 +330,6 @@ export component TextPanel inherits VerticalLayout {if root.selected.plated: ColourField {label: I18n.t("Background color");value: root.selected.plate.with-alpha(1);- hex: root.selected.plate-hex;alpha: false;changed(shade) => {root.set-colour(ClipTextField.background, shade.with-alpha(root.plate-alpha));@@ -314,6 +365,50 @@ export component TextPanel inherits VerticalLayout {unit-scale: 100;changed(v) => { root.set(ClipField.background-radius, v); root.commit(); }}++ // The air between the words and the background's edges, in pixels+ // of the frame like the box's sides, on any axis the words size+ // themselves - a sized box is exactly its size. The lock at the end+ // makes the two one number: locking takes the Y to the X at once,+ // and from then on an edit to either is an edit to both.+ if root.selected.plated: Row {+ label: I18n.t("Padding");+ label-width: root.label-w;++ NumberField {+ prefix: "X";+ unit: "px";+ value <=> root.plate-pad-x;+ minimum: 0;+ maximum: root.frame-h / 2;+ step: 1;+ changed(v) => { root.set-padding(v, root.pad-locked ? v : root.plate-pad-y); }+ }+ NumberField {+ prefix: "Y";+ unit: "px";+ value <=> root.plate-pad-y;+ minimum: 0;+ maximum: root.frame-h / 2;+ step: 1;+ changed(v) => { root.set-padding(root.pad-locked ? v : root.plate-pad-x, v); }+ }+ VerticalLayout {+ alignment: center;+ IconButton {+ glyph: root.pad-locked ? Glyph.lock : Glyph.unlock;+ label: root.pad-locked ? I18n.t("Unlock the paddings")+ : I18n.t("Lock the paddings together");+ checked: root.pad-locked;+ clicked => {+ root.pad-locked = !root.pad-locked;+ if (root.pad-locked && root.plate-pad-x != root.plate-pad-y) {+ root.set-padding(root.plate-pad-x, root.plate-pad-x);+ }+ }+ }+ }+ }}}@@ -348,7 +443,6 @@ export component TextPanel inherits VerticalLayout {if root.selected.stroke-width > 0: ColourField {label: I18n.t("Color");value: root.selected.stroke;- hex: root.selected.stroke-hex;alpha: true;changed(shade) => {root.set-colour(ClipTextField.stroke-color, shade);@@ -395,37 +489,63 @@ export component TextPanel inherits VerticalLayout {}}- // The box, in pixels of the frame. Zero is "auto": that side is- // sized by the words. The stage's grips pull the same two numbers;+ // The box, in pixels of the frame, or Auto: that side is sized by+ // the words, with the background's padding round them, so a title+ // whose words change - a caption made from a transcript - keeps+ // its air whatever is written. The unit is a select joined onto+ // the field where a unit would sit; Auto greys the number, which+ // is nothing then. The stage's grips pull the same two numbers;// here they can be typed exactly.Row {label: I18n.t("Width");label-width: root.label-w;- NumberField {- prefix: "W";- unit: "px";- value <=> root.box-w;- minimum: 0;- maximum: root.frame-w * 2;- step: 1;- format(v) => { return root.px(v); }- parse(t) => { return t.is-float() ? Math.max(0, t.to-float()) : 0; }- changed(v) => { root.set(ClipField.text-width, v / root.frame-w); root.commit(); }+ HorizontalLayout {+ spacing: 0;+ NumberField {+ prefix: "W";+ radius-right: 0px;+ enabled: root.w-mode == 0;+ value <=> root.box-w;+ minimum: 1;+ maximum: root.frame-w * 2;+ step: 1;+ format(v) => { return v <= 0 ? "–" : "\{Math.round(v)}"; }+ parse(t) => { return t.is-float() ? Math.max(1, t.to-float()) : root.box-w; }+ changed(v) => { root.set(ClipField.text-width, v / root.frame-w); root.commit(); }+ }+ Select {+ width: self.natural-width;+ radius-left: 0px;+ options: ["px", I18n.t("Auto")];+ current <=> root.w-mode;+ changed(index) => { root.size-mode(true, index == 1); }+ }}}Row {label: I18n.t("Height");label-width: root.label-w;- NumberField {- prefix: "H";- unit: "px";- value <=> root.box-h;- minimum: 0;- maximum: root.frame-h * 2;- step: 1;- format(v) => { return root.px(v); }- parse(t) => { return t.is-float() ? Math.max(0, t.to-float()) : 0; }- changed(v) => { root.set(ClipField.text-height, v / root.frame-h); root.commit(); }+ HorizontalLayout {+ spacing: 0;+ NumberField {+ prefix: "H";+ radius-right: 0px;+ enabled: root.h-mode == 0;+ value <=> root.box-h;+ minimum: 1;+ maximum: root.frame-h * 2;+ step: 1;+ format(v) => { return v <= 0 ? "–" : "\{Math.round(v)}"; }+ parse(t) => { return t.is-float() ? Math.max(1, t.to-float()) : root.box-h; }+ changed(v) => { root.set(ClipField.text-height, v / root.frame-h); root.commit(); }+ }+ Select {+ width: self.natural-width;+ radius-left: 0px;+ options: ["px", I18n.t("Auto")];+ current <=> root.h-mode;+ changed(index) => { root.size-mode(false, index == 1); }+ }}}diff --git a/src/crates/concat/ui/primitives/select.slint b/src/crates/concat/ui/primitives/select.slintindex 238a4a55..729ebb0f 100644--- a/src/crates/concat/ui/primitives/select.slint+++ b/src/crates/concat/ui/primitives/select.slint@@ -38,6 +38,10 @@ export component Select inherits Rectangle {/// option would reserve is room the tray does not have; the trigger/// then changes width as the choice does, which is the trade.in property <bool> snug;+ /// The corners, a side at a time, so a select can be joined onto a+ /// field as its unit with a square seam between them; see Field.+ in property <length> radius-left: Theme.r;+ in property <length> radius-right: Theme.r;callback changed(index: int);@@ -97,7 +101,10 @@ export component Select inherits Rectangle {height: Theme.h;min-width: 60px;horizontal-stretch: 1;- border-radius: Theme.r;+ border-top-left-radius: root.radius-left;+ border-bottom-left-radius: root.radius-left;+ border-top-right-radius: root.radius-right;+ border-bottom-right-radius: root.radius-right;opacity: root.enabled ? 1.0 : 0.45;background: root.flat && !root.open ? Colors.transparent: (root.open || (trigger.has-hover && root.enabled)) ? Theme.field-hoverdiff --git a/src/crates/concat/ui/timeline/model.slint b/src/crates/concat/ui/timeline/model.slintindex 5deab66e..345f161a 100644--- a/src/crates/concat/ui/timeline/model.slint+++ b/src/crates/concat/ui/timeline/model.slint@@ -164,6 +164,9 @@ export enum ClipField {/// the background's opacity is its colour's alpha, as the stroke's is;/// its corner radius is a fraction of frame heightbackground-opacity, background-radius,+ /// the air between the words and the background's edges, fractions of+ /// frame height on each axis+ background-padding-x, background-padding-y,cutout-feather,/// which of the media's audio tracks the clip plays, as a row of/// Editor.audio-tracks@@ -348,6 +351,10 @@ export struct SelectedClipData {plate-opacity: float,/// the background's corner radius as a fraction of frame heightplate-radius: float,+ /// the background's air either side of and above the words, as+ /// fractions of frame height+ plate-padding-x: float,+ plate-padding-y: float,line-height: float,tracking: float,/// the widest a line runs before wrapping, as a fraction of the frame;diff --git a/src/crates/concat/ui/util.slint b/src/crates/concat/ui/util.slintindex 2dc24027..3df07cb0 100644--- a/src/crates/concat/ui/util.slint+++ b/src/crates/concat/ui/util.slint@@ -15,6 +15,9 @@ export global Fmt {/// A colour spelled as "#rrggbb", or "#rrggbbaa" when `with-alpha` and/// it is not opaque. Slint cannot print a colour; Rust does.pure callback hex-of(value: color, with-alpha: bool) -> string;+ /// The same six digits without the hash, for a field that draws the+ /// hash itself. Never the alpha: a field with one has a dial for it.+ pure callback hex-digits(value: color) -> string;/// The colour a person typed - "#fff", "#cbf53f", "#000000cc", hash/// optional - or `fallback` when it is not one.pure callback color-of(text: string, fallback: color) -> color;