diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index f4de4e5b25d..ec622d055da 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -729,6 +729,7 @@ pub(crate) mod image_processor_ui; pub mod jpeg_options_ui; pub mod layer_picker; pub mod layer_style; +pub(crate) mod lens_batch_ui; pub mod liquify_ui; pub mod live_shape_prompt; pub mod mask_trash_prompt; diff --git a/crates/ui-egui/src/dialogs/lens_batch_ui.rs b/crates/ui-egui/src/dialogs/lens_batch_ui.rs new file mode 100644 index 00000000000..f893bd03be0 --- /dev/null +++ b/crates/ui-egui/src/dialogs/lens_batch_ui.rs @@ -0,0 +1,45 @@ +//! File › Automate › Lens Correction…, laid out like the reference application's dialog (#13981): +//! the sections Source Files, Destination Folder, Lens Correction Profile and Correction Options, +//! top to bottom, with the reference captions and the Edge entries in the reference order. +//! +//! The rows are the command's params, so OK, `ui.dialog.set` and `ui.dialog.confirm` work as for every form. + +use craft::ui::patterns::form_dialogs::{Param, ParamKind}; +use craft::ui::runtime::env::Label; +use craft::ui::runtime::requests::PathKind; + +pub(crate) const COMMAND: &str = photocraft_engine::lens_cmds::LENS_BATCH; + +const FORMATS: [(&str, &str); 5] = [("same", "Same as Source"), ("png", "PNG"), ("jpg", "JPEG"), ("psd", "PSD"), ("tiff", "TIFF")]; +const PROFILES: [(&str, &str); 3] = [("auto", "Auto"), ("generic", "Generic"), ("none", "None")]; +const EDGES: [(&str, &str); 4] = [("edgeExtension", "Edge Extension"), ("transparency", "Transparency"), ("black", "Black Color"), ("white", "White Color")]; + +/// Choice options whose labels are `tl!` literals here. +fn opts(list: &[(&'static str, &'static str)]) -> Vec<(String, Label)> { + list.iter().map(|(id, label)| ((*id).to_owned(), Label::from(tl!(label)))).collect() +} + +/// A folder field with its Browse button. +fn folder(key: &str, label: &'static str, default: String) -> Param { + Param::new(key, label, ParamKind::text(default)).browse(PathKind::Folder) +} + +/// The rows of the dialog, reading the images from `dir`. Correction Options lists the corrections, then scaling and +/// the edge fill, as the reference's left and right columns read. +pub(crate) fn rows(dir: String) -> Vec { + vec![ + Param::section(tl!("Source Files")), + folder("input", tl!("Input"), dir.clone()), + Param::section(tl!("Destination Folder")), + Param::new("format", tl!("File Type"), ParamKind::choice(opts(&FORMATS), Some("same".into()))), + folder("output", tl!("Output"), format!("{dir}/corrected")), + Param::section(tl!("Lens Correction Profile")), + Param::new("profile", tl!("Profile"), ParamKind::choice(opts(&PROFILES), Some("auto".into()))), + Param::section(tl!("Correction Options")), + Param::new("correctDistortion", tl!("Geometric Distortion"), ParamKind::bool(true)), + Param::new("correctCA", tl!("Chromatic Aberration"), ParamKind::bool(true)), + Param::new("correctVignette", tl!("Vignette"), ParamKind::bool(true)), + Param::new("autoScale", tl!("Auto Scale Image"), ParamKind::bool(true)), + Param::new("edge", tl!("Edge"), ParamKind::choice(opts(&EDGES), Some("transparency".into()))), + ] +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 46b293d0e2b..2042a8d34d1 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -411,32 +411,7 @@ pub(super) fn params_for(app: &mut PhotocraftApp, id: &str) -> Option<(Vec plain(vec![ - folder("input", tl!("Source Folder"), dir.clone()), - folder("output", tl!("Destination"), format!("{dir}/corrected")), - choice( - "format", - tl!("File Type"), - opts(&[("same", tl!("Same as Source")), ("png", tl!("PNG")), ("jpg", tl!("JPEG")), ("psd", tl!("PSD")), ("tiff", tl!("TIFF"))]), - "same", - ), - choice("profile", tl!("Lens Profile"), opts(&[("auto", tl!("Auto")), ("generic", tl!("Generic")), ("none", tl!("None"))]), "auto"), - Param::new("correctDistortion", tl!("Geometric Distortion"), ParamKind::bool(true)), - Param::new("correctVignette", tl!("Vignette"), ParamKind::bool(true)), - Param::new("correctCA", tl!("Chromatic Aberration"), ParamKind::bool(true)), - Param::new("autoScale", tl!("Auto Scale Image"), ParamKind::bool(true)), - choice( - "edge", - tl!("Edge"), - opts(&[ - ("transparency", tl!("Transparency")), - ("edgeExtension", tl!("Edge Extension")), - ("black", tl!("Black Color")), - ("white", tl!("White Color")), - ]), - "transparency", - ), - ]), + crate::dialogs::lens_batch_ui::COMMAND => plain(crate::dialogs::lens_batch_ui::rows(dir.clone())), "file.scripts.imageProcessor" => plain(vec![ choice( "source",