Skip to content

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

Merge main into #873: the clip Label menu keeps main's enablement, ids and errors, with the user's names and swatches

Brandon Thomas1d35f5d39bac
diff --cc crates/ui-egui/src/panels/project_views.rs
index f29bb59b8,02a63b164..3d99e9f80
--- a/crates/ui-egui/src/panels/project_views.rs
+++ b/crates/ui-egui/src/panels/project_views.rs
@@@ -264,7 -262,13 +264,14 @@@ fn item_menu(app: &mut FilmcraftApp, ui
}
}
});
+ app.auto.add("project.itemMenu.label", r.response.rect, tl!("Label"));
+ let can_reveal = app.session.project.resolve_media(id).is_some_and(|(_, m, _)| matches!(m.media, filmcraft_project::MediaRef::File { .. }));
+ let b = ui.add_enabled(can_reveal, egui::Button::new(tl!("Reveal in Finder")));
+ app.auto.add("project.itemMenu.file.reveal", b.rect, "Reveal in Finder");
+ if b.clicked() {
+ actions.push(("file.reveal".into(), json!({"items": [id.0]})));
+ ui.close();
+ }
if matches!(kind, ItemKind::Media(m) if matches!(m.media, filmcraft_project::MediaRef::File { .. })) {
ui.separator();
for (label, cmd) in [(tl!("Link Media…"), "media.linkMedia"), (tl!("Make Offline…"), "media.makeOffline")] {
diff --cc crates/ui-egui/src/panels/timeline.rs
index 8440aa58a,3e39f437e..19a31764f
--- a/crates/ui-egui/src/panels/timeline.rs
+++ b/crates/ui-egui/src/panels/timeline.rs
@@@ -2469,17 -2641,21 +2641,21 @@@ fn interact(app: &mut FilmcraftApp, ui
}
for &(label, cmd) in *group {
if cmd == "edit.label" {
- let r = ui.menu_button(crate::i18n::t(label), |ui| {
- // the user's label names and colours, as in Edit ▸ Label (#786)
- let labels = app.session.prefs.labels.clone();
- for l in filmcraft_project::Label::ALL {
- if crate::menus::label_choice(ui, &mut app.auto, &labels, l, "timeline.clipMenu.edit.label").clicked() {
- let _ = app.session.execute("edit.label", json!({"label": l.name()}));
- ui.close();
+ ui.add_enabled_ui(!picked.is_empty(), |ui| {
+ let menu = ui.menu_button(crate::i18n::t(label), |ui| {
++ // the user's label names and colours, as in Edit ▸ Label (#786)
++ let labels = app.session.prefs.labels.clone();
+ for l in filmcraft_project::Label::ALL {
- let r = ui.button(crate::i18n::t(l.name()));
- app.auto.add_response(&format!("timeline.clipMenu.label.{}", l.name()), &r, crate::i18n::t(l.name()));
- if r.clicked() {
++ if crate::menus::label_choice(ui, &mut app.auto, &labels, l, "timeline.clipMenu.label").clicked() {
+ if let Err(error) = app.session.execute("edit.label", json!({"label":l.name()})) {
+ app.ui.status = error.to_string();
+ }
+ ui.close();
+ }
}
- }
+ });
+ app.auto.add_response("timeline.clipMenu.edit.label", &menu.response, crate::i18n::t(label));
});
- app.auto.add("timeline.clipMenu.edit.label", r.response.rect, crate::i18n::t(label));
continue;
}
if cmd == "clip.multicam" {
diff --cc crates/ui-egui/tests/clip_dialogs_ui.rs
index 4589d7b37,1fb29479f..68249a2c7
--- a/crates/ui-egui/tests/clip_dialogs_ui.rs
+++ b/crates/ui-egui/tests/clip_dialogs_ui.rs
@@@ -289,24 -289,22 +289,40 @@@ fn speed_duration_from_the_clip_menu_op
assert_eq!(got.time_interpolation, filmcraft_project::TimeInterpolation::FrameBlending);
}
+/// #786: the clip's right-click Label menu lists the labels by the user's names (with their
+/// colours, as Edit ▸ Label does) and each choice labels the clip.
+#[test]
+fn the_clip_menu_label_choices_use_the_user_names() {
+ let mut d = Driver::new();
+ let key = filmcraft_engine::settings::label_id(Label::Iris);
+ d.app().session.prefs.labels.colors.get_mut(&key).unwrap().name = "Interviews".into();
+ let c = d.v1(0);
+ d.exec("timeline.select", json!({"clips": [c.id.0]}));
+ d.ok("ui.click", json!({"id": format!("timeline.clip.{}", c.id.0), "button": "right"}));
+ d.frames(3);
+ d.click("timeline.clipMenu.edit.label");
- let choice = d.ok("ui.elements", json!({"prefix": "timeline.clipMenu.edit.label.Iris"}));
++ let choice = d.ok("ui.elements", json!({"prefix": "timeline.clipMenu.label.Iris"}));
+ assert_eq!(choice[0]["label"], json!("Interviews"), "{choice}");
- d.click("timeline.clipMenu.edit.label.Iris");
++ d.click("timeline.clipMenu.label.Iris");
+ assert_eq!(d.v1(0).label, Label::Iris);
+}
+
+ /// #1018: Scene Edit Detection… is in the clip's right-click menu and opens its dialog.
+ #[test]
+ fn scene_edit_detection_from_the_clip_menu_opens_the_dialog() {
+ let mut d = Driver::new();
+ let c = d.v1(0);
+ d.exec("timeline.select", json!({"clips": [c.id.0]}));
+ d.ok("ui.click", json!({"id": format!("timeline.clip.{}", c.id.0), "button": "right"}));
+ d.frames(3);
+ d.click("timeline.clipMenu.clip.sceneEditDetection");
+ for id in ["sceneDetect.applyCuts", "sceneDetect.createSubclips", "sceneDetect.generateMarkers", "sceneDetect.ok"] {
+ assert!(d.has(id), "{id}");
+ }
+ d.click("sceneDetect.cancel");
+ assert!(!d.has("sceneDetect.ok"));
+ }
+
#[test]
fn quitting_with_unsaved_changes_asks_to_save() {
let mut d = Driver::new();