mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Lens Correction batch: four groups like the reference dialog
File > Automate > Lens Correction opened the generic form, which lists the params A to Z (Auto scale, Correct c a, ... Profile). The dialog now draws the reference groups Source Files, Destination Folder, Lens Correction Profile and Correction Options, the last in two columns, with the reference captions and the Edge entries Edge Extension, Transparency, Black Color, White Color. Holding Alt leaves Cancel as Cancel. The command's params and its defaults in the menu arm are unchanged; a missing or mistyped field is set to its default before drawing, so the dialog shows what OK sends.
This commit is contained in:
1 parent
359051359f
commit
be9f00969f
3 files changed
+47
-26
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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<Param> {
|
||||
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()))),
|
||||
]
|
||||
}
|
||||
@@ -411,32 +411,7 @@ pub(super) fn params_for(app: &mut PhotocraftApp, id: &str) -> Option<(Vec<Param
|
||||
Param::new("detail", tl!("Detail"), ParamKind::number(None, None, 30.0, 1.0, 0)),
|
||||
Param::new("saturation", tl!("Saturation"), ParamKind::number(None, None, 20.0, 1.0, 0)),
|
||||
]),
|
||||
"file.automate.lensCorrection" => 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",
|
||||
|
||||
Reference in new issue
Block a user