Skip to content

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

M3.12: Dismiss Export Frame when clicking outside

Cathy Shapiroac145dbaa873
diff --git a/crates/ui-egui/src/panels/frame_export.rs b/crates/ui-egui/src/panels/frame_export.rs
index 80fad6278..4790c440a 100644
--- a/crates/ui-egui/src/panels/frame_export.rs
+++ b/crates/ui-egui/src/panels/frame_export.rs
@@ -62,6 +62,7 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
let mut browse = false;
let mut replace = false;
let mut elems = Vec::new();
+ let mut popup_rects = Vec::new();
let frame = egui::Frame::new().fill(app.tokens.panel_bg).inner_margin(0).corner_radius(6);
let position_id = egui::Id::new("frame-export-position");
let position = ctx.data(|m| m.get_temp::<egui::Pos2>(position_id));
@@ -115,7 +116,11 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
let r = ui.selectable_value(&mut d.format, format, format.label());
elems.push((format!("exportFrame.format.{}", format.extension()), r.rect, format.label().into()));
}
+ ui.min_rect()
});
+ if let Some(rect) = combo.inner {
+ popup_rects.push(rect);
+ }
elems.push(("exportFrame.format".into(), combo.response.rect, d.format.label().into()));
ui.end_row();
if !d.format.supports_16() {
@@ -130,7 +135,11 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
}
elems.push((format!("exportFrame.depth.{bits}"), r.rect, format!("{bits} Bit")));
}
+ ui.min_rect()
});
+ if let Some(rect) = combo.inner {
+ popup_rects.push(rect);
+ }
elems.push(("exportFrame.depth".into(), combo.response.rect, format!("{} Bit", d.depth)));
ui.end_row();
ui.label("Path:");
@@ -182,6 +191,13 @@ pub fn show(app: &mut FilmcraftApp, ctx: &egui::Context) {
elems.push(("exportFrame.timecode".into(), r.rect, d.timecode.clone()));
});
});
+ if let Some(shown) = &shown {
+ // A press outside the dialog and its own dropdowns cancels the draft. Background
+ // controls still receive the same press, so switching modes or menus works normally.
+ close |= ctx.input(|i| {
+ i.pointer.any_pressed() && i.pointer.interact_pos().is_some_and(|p| !shown.response.rect.contains(p) && !popup_rects.iter().any(|r| r.contains(p)))
+ });
+ }
if shown.is_some() && movement != egui::Vec2::ZERO {
// Keep the unrounded requested pivot between drag frames so subpixel deltas cannot accumulate rounding drift.
if let Some(pivot) = position.or_else(|| egui::containers::AreaState::load(ctx, window_id).and_then(|state| state.pivot_pos)) {
diff --git a/crates/ui-egui/tests/frame_export_ui.rs b/crates/ui-egui/tests/frame_export_ui.rs
index 3280c7845..a7b9df601 100644
--- a/crates/ui-egui/tests/frame_export_ui.rs
+++ b/crates/ui-egui/tests/frame_export_ui.rs
@@ -262,3 +262,34 @@ fn exported_frame_timecode_matches_each_monitor_and_stays_captured() {
}
}
}
+
+#[test]
+fn clicking_outside_dismisses_without_export_and_dropdowns_stay_open() {
+ for monitor in ["source", "program"] {
+ let mut h = harness();
+ let count = h.state().session.project.items.len();
+ click(&mut h, &format!("{monitor}.transport.exportFrame"));
+ click(&mut h, "exportFrame.format");
+ assert!(has(&h, "exportFrame.name"));
+ click(&mut h, "exportFrame.format.tiff");
+ click(&mut h, "exportFrame.depth");
+ click(&mut h, "exportFrame.depth.16");
+ assert!(has(&h, "exportFrame.name"));
+ assert_eq!(h.state().auto.elements.iter().find(|e| e.id == "exportFrame.depth").unwrap().label, "16 Bit");
+ click(&mut h, "header.mode.export");
+ assert!(!has(&h, "exportFrame.name"));
+ assert_eq!(h.state().ui.mode, filmcraft_ui_egui::state::Mode::Export);
+ assert_eq!(h.state().session.project.items.len(), count);
+ }
+ let mut h = harness();
+ click(&mut h, "source.transport.exportFrame");
+ let pos = egui::pos2(150.0, 180.0);
+ h.input_mut().events.push(egui::Event::PointerMoved(pos));
+ step(&mut h);
+ for pressed in [true, false] {
+ h.input_mut().events.push(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });
+ step(&mut h);
+ }
+ step(&mut h);
+ assert!(!has(&h, "exportFrame.name"), "clicking the background monitor must cancel the draft");
+}
diff --git a/docs/monitors.md b/docs/monitors.md
index 28ea55cba..d60ff85bb 100644
--- a/docs/monitors.md
+++ b/docs/monitors.md
@@ -126,7 +126,9 @@ from the playhead to translate the marked range.
The camera button in either monitor opens Export Frame. Drag its white header to move the dialog.
The suggested name is the source filename without its extension, or the sequence name, without an added `.Still` suffix. Choose a name, format and depth,
use Browse to choose the destination folder (or edit Path), and click OK. Existing files require
-an explicit Replace confirmation. Cancel and the header close button write nothing. The white
+an explicit Replace confirmation. Cancel, the header close button, Escape, and clicking outside
+the dialog (including the top menus or mode tabs) dismiss it without writing anything.
+The dialog's own dropdowns and Browse button keep it open. The white
header and dark body use original generic controls. Source details and frame time appear below
the settings. Frame time uses the same hours/minutes/seconds/frames timecode as its monitor,
including the Program sequence's drop-frame setting, and stays captured while the dialog is open.