Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

#1487: the Text panel's Graphics tab lists and edits the sequence's graphic text

irgendwasmitfelixdcbb001948d7
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 0af8835d1..c855c6b6c 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -3610,3 +3610,6 @@
Shows the version, community links and credits in a FilmCraft window. Muestra la versión, los enlaces de la comunidad y los créditos en una ventana de FilmCraft.
Couldn't open your web browser No se pudo abrir el navegador web
Open this address in your browser yourself: Abre esta dirección tú mismo en el navegador:
+ Open a sequence to search its graphics Abre una secuencia para buscar en sus gráficos
+ No text graphics in this sequence. Add text with the Type tool. Esta secuencia no tiene gráficos con texto. Añade texto con la herramienta Texto.
+ No matching text. Ningún texto coincide.
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 1075b0c15..3afa61278 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -3577,3 +3577,6 @@
Export the labels to a preset file… Exporter les étiquettes dans un fichier de paramètre prédéfini…
Show the presets folder Afficher le dossier des paramètres prédéfinis
Delete this preset Supprimer ce paramètre prédéfini
+ Open a sequence to search its graphics Ouvrez une séquence pour rechercher dans ses graphiques
+ No text graphics in this sequence. Add text with the Type tool. Aucun graphique avec du texte dans cette séquence. Ajoutez du texte avec l'outil Texte.
+ No matching text. Aucun texte ne correspond.
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 508a6e9d4..0cc020b8a 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -3575,3 +3575,6 @@
Appearance Settings… Pengaturan Tampilan…
Add to favorites Tambahkan ke favorit
Remove from favorites Hapus dari favorit
+ Open a sequence to search its graphics Buka sekuens untuk mencari di grafisnya
+ No text graphics in this sequence. Add text with the Type tool. Tidak ada grafis teks di sekuens ini. Tambahkan teks dengan alat Teks.
+ No matching text. Tidak ada teks yang cocok.
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 22d47ccbd..38d0e7936 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -3601,3 +3601,6 @@
Shows the version, community links and credits in a FilmCraft window. Mostra la versione, i link della community e i riconoscimenti in una finestra di FilmCraft.
Couldn't open your web browser Impossibile aprire il browser web
Open this address in your browser yourself: Apri tu questo indirizzo nel browser:
+ Open a sequence to search its graphics Apri una sequenza per cercare nelle sue grafiche
+ No text graphics in this sequence. Add text with the Type tool. Nessuna grafica con testo in questa sequenza. Aggiungi testo con lo strumento Testo.
+ No matching text. Nessun testo corrispondente.
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index b6a7fb8a2..3a1d97c7b 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3609,3 +3609,6 @@
Shows the version, community links and credits in a FilmCraft window. バージョン、コミュニティへのリンク、クレジットを FilmCraft のウィンドウに表示します。
Couldn't open your web browser ウェブブラウザーを開けませんでした
Open this address in your browser yourself: このアドレスをご自身でブラウザーで開いてください:
+ Open a sequence to search its graphics シーケンスを開くとグラフィックスを検索できます
+ No text graphics in this sequence. Add text with the Type tool. このシーケンスにはテキストのグラフィックスがありません。文字ツールでテキストを追加してください。
+ No matching text. 一致するテキストはありません。
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 20341b9a6..e49db8a57 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3596,3 +3596,6 @@
Shows the version, community links and credits in a FilmCraft window. FilmCraft 창에 버전, 커뮤니티 링크, 제작진을 보여 줍니다.
Couldn't open your web browser 웹 브라우저를 열 수 없습니다
Open this address in your browser yourself: 이 주소를 브라우저에서 직접 여세요:
+ Open a sequence to search its graphics 그래픽을 검색하려면 시퀀스를 여세요
+ No text graphics in this sequence. Add text with the Type tool. 이 시퀀스에는 텍스트 그래픽이 없습니다. 문자 도구로 텍스트를 추가하세요.
+ No matching text. 일치하는 텍스트가 없습니다.
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index aeb0e0691..14258bfc3 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3578,3 +3578,6 @@
# The native macOS application menu (Settings…).
Settings Preferências
+ Open a sequence to search its graphics Abra uma sequência para pesquisar nos gráficos dela
+ No text graphics in this sequence. Add text with the Type tool. Esta sequência não tem gráficos com texto. Adicione texto com a ferramenta Texto.
+ No matching text. Nenhum texto corresponde.
diff --git a/crates/ui-egui/src/i18n/zh-cn.tsv b/crates/ui-egui/src/i18n/zh-cn.tsv
index 066279eef..0c922075b 100644
--- a/crates/ui-egui/src/i18n/zh-cn.tsv
+++ b/crates/ui-egui/src/i18n/zh-cn.tsv
@@ -3585,3 +3585,6 @@
Shows the version, community links and credits in a FilmCraft window. 在 FilmCraft 窗口中显示版本、社区链接和致谢。
Couldn't open your web browser 无法打开网页浏览器
Open this address in your browser yourself: 请自行在浏览器中打开此地址:
+ Open a sequence to search its graphics 打开序列以搜索其中的图形
+ No text graphics in this sequence. Add text with the Type tool. 此序列中没有文本图形。请用文字工具添加文本。
+ No matching text. 没有匹配的文本。
diff --git a/crates/ui-egui/src/panels/text.rs b/crates/ui-egui/src/panels/text.rs
index 6de9c6139..f1325aac3 100644
--- a/crates/ui-egui/src/panels/text.rs
+++ b/crates/ui-egui/src/panels/text.rs
@@ -1,4 +1,6 @@
-//! The Text panel: Transcript / Captions / Graphics tabs. The Captions tab lists the caption
+//! The Text panel: Transcript / Captions / Graphics tabs. The Graphics tab lists the text of every
+//! text layer in the sequence's graphics (#1487), with a search; clicking an entry goes to its clip
+//! and selects the layer, and the text edits in place (`graphics.set`). The Captions tab lists the caption
//! segments of a caption track with editable in/out timecodes and text, a toolbar (add, split,
//! merge, delete), track choice and the track style. Every edit dispatches a `captions.*` engine
//! command; every widget registers an automation id (`text.*`). The Transcript tab shows the
@@ -57,7 +59,7 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
match app.ui.text_tab.as_str() {
"Captions" => captions(app, ui, body),
"Transcript" => transcript(app, ui, body),
- _ => crate::dock::placeholder(ui, body, &t, tl!("Graphics text search arrives with M10.1–M10.2")),
+ _ => graphics(app, ui, body),
}
}
@@ -282,6 +284,159 @@ fn captions(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
run(app, ui, actions);
}
+/// A text layer of a graphic clip in the active sequence, for the Graphics tab.
+#[derive(Clone, Debug, PartialEq)]
+pub struct GraphicText {
+ pub clip: filmcraft_project::ClipId,
+ /// The layer's number among the clip's layers (what `graphics.set` / `graphics.selectLayer` take).
+ pub layer: usize,
+ pub start: filmcraft_time::Tick,
+ /// The track's label (`V2`).
+ pub track: String,
+ /// The layer's own name, when it has one.
+ pub name: Option<String>,
+ pub text: String,
+}
+
+/// Every text layer of every graphic clip in `seq`, in timeline order (then lower tracks first,
+/// then paint order), with its text at `at` when that falls in the clip (Source Text keyframes
+/// hold), else at the clip's first frame.
+pub fn graphic_texts(seq: &filmcraft_project::Sequence, at: filmcraft_time::Tick) -> Vec<GraphicText> {
+ use filmcraft_project::graphic::{TEXT_LAYER, layer_indices};
+ let mut out = Vec::new();
+ for (ti, track) in seq.video_tracks.iter().enumerate() {
+ for it in &track.items {
+ let t = if it.start <= at && at < it.end() { at } else { it.start };
+ let mt = it.effect_time_at(t);
+ for (layer, ei) in layer_indices(&it.effects).into_iter().enumerate() {
+ let Some(e) = it.effects.get(ei).filter(|e| e.effect == TEXT_LAYER) else { continue };
+ let text = match e.param("text").map(|p| p.value_at(mt)) {
+ Some(filmcraft_project::ParamValue::Text(s)) => s,
+ _ => String::new(),
+ };
+ let name = match e.param("name").map(|p| p.value.clone()) {
+ Some(filmcraft_project::ParamValue::Text(n)) if !n.trim().is_empty() => Some(n),
+ _ => None,
+ };
+ out.push((ti, GraphicText { clip: it.id, layer, start: it.start, track: format!("V{}", ti + 1), name, text }));
+ }
+ }
+ }
+ out.sort_by(|(ta, a), (tb, b)| a.start.cmp(&b.start).then(ta.cmp(tb)).then(a.layer.cmp(&b.layer)));
+ out.into_iter().map(|(_, g)| g).collect()
+}
+
+/// The Graphics tab (#1487): the text of every text layer in the sequence, searchable. The
+/// timecode goes to the clip and selects the layer; the text edits in place.
+fn graphics(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
+ let t = app.tokens;
+ let project = app.session.project.clone();
+ let Some(seq) = app.session.state.active_sequence.and_then(|id| project.sequence(id)) else {
+ crate::dock::placeholder(ui, rect, &t, tl!("Open a sequence to search its graphics"));
+ return;
+ };
+ let (rate, df) = (seq.settings.frame_rate, seq.settings.drop_frame);
+ let tc = |x: filmcraft_time::Tick| format_time(x, rate, df, TimeDisplay::Timecode, 48_000);
+ let ph = app.session.playhead();
+ let entries = graphic_texts(seq, ph);
+ let mut actions: Vec<(String, Value)> = Vec::new();
+ // search
+ let bar = Rect::from_min_size(rect.min + vec2(10.0, 2.0), vec2(rect.width() - 20.0, 26.0));
+ let skey = egui::Id::new("text-gfx-search");
+ let mut search = ui.data(|d| d.get_temp::<String>(skey)).unwrap_or_default();
+ let w = 220.0f32.min(bar.width());
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(Rect::from_min_size(bar.min, vec2(w, 24.0))));
+ let sresp = crate::widgets::search_field(&mut child, &mut search, tl!("Search"), w, &t);
+ app.auto.add("text.graphics.search", sresp.rect, "Search graphics text");
+ ui.data_mut(|d| d.insert_temp(skey, search.clone()));
+ let q = search.to_lowercase();
+ // list
+ let list = Rect::from_min_max(pos2(rect.min.x + 6.0, bar.max.y + 8.0), pos2(rect.max.x - 6.0, rect.max.y - 4.0));
+ ui.painter().rect_filled(list, 3.0, t.app_bg);
+ let sel_clips = app.session.state.selection.clone();
+ let sel_layers = app.session.state.graphic_layers.clone();
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(list.shrink(4.0)).id_salt("graphics-text-list"));
+ egui::ScrollArea::vertical().auto_shrink([false, false]).id_salt("graphics-text-scroll").show(&mut child, |ui| {
+ ui.set_width(list.width() - 12.0);
+ let mut shown = 0;
+ for (n, g) in entries.iter().enumerate() {
+ if !q.is_empty() && !g.text.to_lowercase().contains(&q) && !g.name.as_deref().unwrap_or("").to_lowercase().contains(&q) {
+ continue;
+ }
+ shown += 1;
+ let key = format!("{}.{}", g.clip.0, g.layer);
+ let selected = sel_clips.contains(&g.clip) && sel_layers.contains(&g.layer);
+ let fill = if selected {
+ t.row_selected
+ } else if n % 2 == 1 {
+ t.row_alt
+ } else {
+ Color32::TRANSPARENT
+ };
+ let select = |actions: &mut Vec<(String, Value)>| {
+ actions.push(("timeline.select".into(), json!({"clips": [g.clip.0]})));
+ actions.push(("graphics.selectLayer".into(), json!({"clip": g.clip.0, "layers": [g.layer]})));
+ };
+ let frame = egui::Frame::NONE.fill(fill).inner_margin(egui::Margin::symmetric(6, 4)).corner_radius(3.0);
+ let fr = frame.show(ui, |ui| {
+ ui.horizontal_top(|ui| {
+ ui.vertical(|ui| {
+ ui.set_width(92.0);
+ let goto = ui.add(egui::Button::new(egui::RichText::new(tc(g.start)).font(Tokens::mono(11.0)).color(t.hot_text)).frame(false));
+ app.auto.add(&format!("text.graphics.{key}.goto"), goto.rect, "Go to graphic");
+ if goto.clicked() {
+ actions.push(("playhead.set".into(), json!({"time": g.start.0})));
+ select(&mut actions);
+ }
+ let label = match &g.name {
+ Some(name) => format!("{} · {name}", g.track),
+ None => g.track.clone(),
+ };
+ ui.label(egui::RichText::new(label).size(11.0).color(t.text_dim));
+ });
+ ui.vertical(|ui| {
+ let tkey = egui::Id::new(("gfx-text", g.clip.0, g.layer));
+ let mut buf = ui.data(|d| d.get_temp::<String>(tkey)).unwrap_or_else(|| g.text.clone());
+ let resp = ui.add(
+ egui::TextEdit::multiline(&mut buf)
+ .id(tkey.with("te"))
+ .desired_rows(1)
+ .desired_width(ui.available_width())
+ .font(Tokens::ui(12.5))
+ .frame(egui::Frame::NONE),
+ );
+ app.auto.add(&format!("text.graphics.{key}.text"), resp.rect, "Graphic text");
+ if resp.has_focus() {
+ ui.data_mut(|d| d.insert_temp(tkey, buf.clone()));
+ if !selected {
+ select(&mut actions);
+ }
+ } else {
+ ui.data_mut(|d| d.remove::<String>(tkey));
+ }
+ if resp.lost_focus() && buf != g.text {
+ actions.push(("graphics.set".into(), json!({"clip": g.clip.0, "layer": g.layer, "props": {"text": buf}})));
+ }
+ });
+ });
+ });
+ app.auto.add(&format!("text.graphics.{key}.row"), fr.response.rect, &g.text);
+ ui.add_space(2.0);
+ }
+ if shown == 0 {
+ ui.label(
+ egui::RichText::new(if entries.is_empty() {
+ tl!("No text graphics in this sequence. Add text with the Type tool.")
+ } else {
+ tl!("No matching text.")
+ })
+ .color(t.text_faint),
+ );
+ }
+ });
+ run(app, ui, actions);
+}
+
/// Whether a caption is selected, so the Properties panel shows [`caption_properties`].
pub fn caption_selected(app: &FilmcraftApp) -> bool {
app.session.active_sequence().is_some_and(|q| app.session.state.caption_selection.iter().any(|c| q.find_caption(*c).is_some()))
diff --git a/crates/ui-egui/tests/graphics_ui.rs b/crates/ui-egui/tests/graphics_ui.rs
index c7aa5138e..0352cf5bd 100644
--- a/crates/ui-egui/tests/graphics_ui.rs
+++ b/crates/ui-egui/tests/graphics_ui.rs
@@ -230,3 +230,55 @@ fn shadow_color_drag_is_one_undo_step() {
d.exec("edit.undo", json!({}));
assert_eq!(color(&mut d), before, "one undo restores the original color");
}
+
+/// Text panel ▸ Graphics (#1487): the text of every text layer in the sequence, in timeline
+/// order, searchable; the timecode goes to the clip and selects the layer, and the text edits in
+/// place as one undo step.
+#[test]
+fn the_text_panels_graphics_tab_lists_and_edits_graphic_text() {
+ let mut d = Driver::demo();
+ d.ok("ui.set", json!({"workspace": "Captions and Graphics"}));
+ let mut clips = Vec::new();
+ for (sec, text) in [(6.0, "Closing credits"), (1.0, "Opening title")] {
+ d.exec("playhead.set", json!({"seconds": sec}));
+ let r = d.exec("graphics.newText", json!({"text": text, "seconds": 2}));
+ clips.push(r["clip"].as_u64().unwrap());
+ }
+ let (credits, title) = (clips[0], clips[1]);
+ d.exec("playhead.set", json!({"seconds": 10.0}));
+ d.ok("ui.click", json!({"id": "text.tab.Graphics"}));
+ d.frames(3);
+ let rows = |d: &mut Driver| -> Vec<String> {
+ let v = d.ok("ui.elements", json!({"prefix": "text.graphics."}));
+ v.as_array().unwrap().iter().filter(|e| e["id"].as_str().unwrap().ends_with(".row")).map(|e| e["label"].as_str().unwrap_or("").to_string()).collect()
+ };
+ assert_eq!(rows(&mut d), ["Opening title", "Closing credits"], "in timeline order");
+ // search
+ d.ok("ui.click", json!({"id": "text.graphics.search"}));
+ d.ok("ui.type", json!({"text": "CRED"}));
+ d.frames(3);
+ assert_eq!(rows(&mut d), ["Closing credits"]);
+ d.ok("ui.key", json!({"key": "A", "command": true}));
+ d.ok("ui.key", json!({"key": "Backspace"}));
+ d.frames(3);
+ assert_eq!(rows(&mut d).len(), 2);
+ // the timecode goes to the clip and selects its layer
+ d.ok("ui.click", json!({"id": format!("text.graphics.{credits}.0.goto")}));
+ d.frames(3);
+ let start = d.harness.state().session.active_sequence().unwrap().find_item(filmcraft_project::ClipId(credits)).unwrap().1.start;
+ assert_eq!(d.harness.state().session.playhead(), start);
+ assert_eq!(d.harness.state().session.state.selection, vec![filmcraft_project::ClipId(credits)]);
+ assert_eq!(d.harness.state().session.state.graphic_layers, vec![0]);
+ // edit the title's text in place
+ let undo0 = d.exec("history.list", json!({}))["undo"].as_array().unwrap().len();
+ d.ok("ui.click", json!({"id": format!("text.graphics.{title}.0.text")}));
+ d.ok("ui.key", json!({"key": "A", "command": true}));
+ d.ok("ui.type", json!({"text": "Night Drive"}));
+ d.ok("ui.click", json!({"id": "text.graphics.search"}));
+ d.frames(3);
+ let text = text_param(&mut d, title, "text");
+ assert_eq!(text, Some(filmcraft_project::ParamValue::Text("Night Drive".into())));
+ assert_eq!(d.exec("history.list", json!({}))["undo"].as_array().unwrap().len(), undo0 + 1, "one undo step");
+ assert_eq!(rows(&mut d), ["Night Drive", "Closing credits"]);
+ d.shot("text-panel-graphics");
+}