diff --git a/Cargo.lock b/Cargo.lock index 3a0a5525c5d..37de8f13518 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7009,6 +7009,7 @@ dependencies = [ "photocraft-text", "photocraft-vector", "rayon", + "roxmltree 0.21.2", "rustc-hash 2.1.3", "serde", "serde_json", diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index e91a63dc85c..647e7decb93 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -53,6 +53,8 @@ serde_json = { workspace = true } toml = { version = "1.1", default-features = false, features = ["std", "serde"] } log = { workspace = true } base64 = "0.23" +# Reading Contact Sheet II settings files (`contact_sheet_settings_file.rs`); already linked through photocraft-io. +roxmltree = "0.21" web-time = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index e479c0da5f9..c30bcb0d215 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -93,6 +93,7 @@ pub(crate) mod params { }, ParamFamily { check: Some(contact_sheet_ui::check), + footer: Some(contact_sheet_ui::footer), cancel: Some(filter_dialog::cancel), ..ParamFamily::new(|key| key == contact_sheet_ui::COMMAND, contact_sheet_ui::run) }, @@ -423,6 +424,7 @@ pub(crate) const PROMPTS: &[PromptRow] = &[ preset_group_prompt::answer, open_prompt::answer_prompt, alerts::answer, + contact_sheet_ui::answer, crate::jobs_ui::answer, crate::gpu_status::answer, crate::actions::library::answer, diff --git a/crates/ui-egui/src/dialogs/contact_sheet_settings_file.rs b/crates/ui-egui/src/dialogs/contact_sheet_settings_file.rs new file mode 100644 index 00000000000..cc575e17e16 --- /dev/null +++ b/crates/ui-egui/src/dialogs/contact_sheet_settings_file.rs @@ -0,0 +1,293 @@ +//! The settings file of Contact Sheet II's Load… and Save… (#13698), in the reference +//! application's layout: +//! +//! ```xml +//! +//! +//! +//! +//! +//! ……… +//! +//! ``` +//! +//! Values are the dialog's entry labels, numbers have a dot whatever the locale, the font is its +//! PostScript name and the resolution is in the shown unit. What the dialog has no control for +//! yet is written as today's run has it and is not taken when read: the Files list and the Use +//! dropdown (#13686; `imageSource` is always Folder), the colour profile (#13688; a fixed name +//! per mode) and the spacing (#13689; the field's default, 1 px, which today's run does not use). + +use serde_json::{Map, Value, json}; + +use photocraft_engine::prefs::Unit; + +use super::{MODES, UNITS, unit_of}; + +/// The values here are in the command's shape (`depth` a number, `placeAcrossFirst`), with the resolution's unit +/// under [`RES_UNIT`]; `contact_sheet_ui` turns the dialog's values into it and back. +pub(super) const RES_UNIT: &str = "resolution.unit"; +const RES_UNITS: [(&str, &str); 2] = [("in", "pixels/inch"), ("cm", "pixels/cm")]; +const DEPTHS: [(u64, &str); 2] = [(8, "8-bit"), (16, "16-bit")]; +const PLACES: [(bool, &str); 2] = [(true, "across first"), (false, "down first")]; +/// Centimetres per inch. +const CM: f64 = 2.54; +/// Resolution in pixels/inch. +const RES_MIN: f64 = 1.0; +const RES_MAX: f64 = 10_000.0; + +/// The dialog's defaults in the command's shape, under the values Save… writes. +fn defaults() -> Value { + json!({"input": "", "units": "inches", "width": 8.0, "height": 10.0, "resolution": 300.0, "mode": "rgb", "depth": 8, "columns": 5, "rows": 6, "placeAcrossFirst": true, "autoSpacing": true, "rotateForBestFit": false, "caption": true, "font": photocraft_text::fonts::DEFAULT_FAMILY, "fontSize": 12.0, "flatten": false, "includeSubfolders": true, "groupByFolder": false}) +} + +fn text(f: &Map, key: &str, d: &str) -> String { + f.get(key).and_then(Value::as_str).unwrap_or(d).to_string() +} + +fn number(f: &Map, key: &str, d: f64) -> f64 { + f.get(key).and_then(Value::as_f64).unwrap_or(d) +} + +fn flag(f: &Map, key: &str, d: bool) -> bool { + f.get(key).and_then(Value::as_bool).unwrap_or(d) +} + +const ROOT: &str = "ContactSheetIISettings"; + +/// The file name Save… suggests. +pub(super) const FILE_NAME: &str = "Contact Sheet II.xml"; + +/// Spacing is stored in inches at 72 px/in, whatever the sheet's resolution. +const SPACING_PPI: f64 = 72.0; + +/// What Save… writes after the values. +pub(super) struct Stamp { + pub(super) date: String, + pub(super) version: String, + pub(super) locale: String, +} + +impl Stamp { + /// The time (UTC: the crate has no local clock), this build's version and the UI language + /// code with `_` (`en`, `zh_hans`: the language setting has no region). + pub(super) fn now() -> Self { + let secs = web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).map_or(0, |d| d.as_secs()); + let date = i64::try_from(secs).ok().and_then(|s| chrono::DateTime::from_timestamp(s, 0)).unwrap_or_default(); + Self { + date: date.format("%Y-%m-%dT%H:%M:%S").to_string(), + version: env!("CARGO_PKG_VERSION").into(), + locale: crate::i18n::current().code().replace('-', "_"), + } + } +} + +/// The settings file for the dialog's fields `f`, over the dialog's defaults. +pub(super) fn write(f: &Map, stamp: &Stamp) -> String { + let mut all = defaults().as_object().cloned().unwrap_or_default(); + all.extend(f.iter().map(|(k, v)| (k.clone(), v.clone()))); + let f = &all; + let res_unit = text(f, RES_UNIT, "in"); + let per = if res_unit == "cm" { CM } else { 1.0 }; + let mode = text(f, "mode", ""); + let depth = f.get("depth").and_then(Value::as_f64).map_or(0, |d| d as u64); + let (units, width, height) = size_in_entry_units(f); + let spacing = format!("{:.3} in", 1.0 / SPACING_PPI); + let source = [ + ("imageSource", "Folder".into()), + ("path", text(f, "input", "")), + ("includeSubfolders", flag(f, "includeSubfolders", true).to_string()), + ("groupImages", flag(f, "groupByFolder", false).to_string()), + ]; + let document = [ + ("units", units.into()), + ("width", num(width)), + ("height", num(height)), + ("resolution", num(number(f, "resolution", 0.0) / per)), + ("resUnits", label(&RES_UNITS, res_unit.as_str(), "in").into()), + ("mode", label(&MODES, mode.as_str(), "rgb").into()), + ("bitDepth", label(&DEPTHS, depth, 8).into()), + ("colorProfile", profile(&mode).into()), + ("flattenLayers", flag(f, "flatten", true).to_string()), + ]; + let thumbnail = [ + ("place", label(&PLACES, flag(f, "placeAcrossFirst", true), true).into()), + ("cols", num(number(f, "columns", 0.0))), + ("rows", num(number(f, "rows", 0.0))), + ("bestFit", flag(f, "rotateForBestFit", false).to_string()), + ("useAutospacing", flag(f, "autoSpacing", true).to_string()), + ("horz", spacing.clone()), + ("vert", spacing), + ]; + let font = [("name", postscript_name(&text(f, "font", ""))), ("size", num(number(f, "fontSize", 0.0)))]; + let caption = flag(f, "caption", true); + format!( + "\n<{ROOT}>\n \n \n \n \n \n \n {}\n {}\n {}\n\n", + attrs(&source), + attrs(&document), + attrs(&thumbnail), + attrs(&font), + escape(&stamp.date), + escape(&stamp.version), + escape(&stamp.locale), + ) +} + +/// Units, Width and Height as an entry of the Units dropdown: units it does not list (`mm` set +/// over the control channel) are written as inches, converted at the dialog's resolution. +fn size_in_entry_units(f: &Map) -> (&'static str, f64, f64) { + let (units, width, height) = (text(f, "units", ""), number(f, "width", 0.0), number(f, "height", 0.0)); + if let Some((id, _)) = UNITS.iter().find(|(id, _)| *id == units) { + return (id, width, height); + } + let (from, ppi) = (unit_of(&units), number(f, "resolution", 0.0)); + let inches = |v: f64| Unit::Inches.from_px(from.to_px(v, ppi, 0.0, 72.0), ppi, 0.0, 72.0); + ("inches", inches(width), inches(height)) +} + +/// The dialog's fields `current` with the values of the settings file `xml` over them. A value +/// missing from the file, or one that is not an entry label, a number or `true`/`false`, leaves +/// the current one; the dialog refuses what its rows cannot show. `Err` when `xml` is not XML or +/// not a Contact Sheet II settings file. +pub(super) fn read(xml: &str, current: &Map) -> Result, String> { + let doc = roxmltree::Document::parse(xml).map_err(|e| e.to_string())?; + let root = doc.root_element(); + if !root.has_tag_name(ROOT) { + return Err(tl!("not a Contact Sheet II settings file").into()); + } + let element = |name: &str| root.children().find(|n| n.has_tag_name(name)); + let attr = |name: &str, key: &str| element(name).and_then(|n| n.attribute(key)); + let font = element("caption").and_then(|c| c.children().find(|n| n.has_tag_name("font"))); + let mut f = current.clone(); + // The Files list is not stored, and the dialog has only the folder (#13686). + if attr("source", "imageSource") == Some("Folder") { + put(&mut f, "input", attr("source", "path").map(|p| json!(p))); + } + // A width means nothing without its units: the three only together. + let size = + (attr("document", "units").and_then(|l| id_of(&UNITS, l)), attr("document", "width").and_then(parse), attr("document", "height").and_then(parse)); + if let (Some(units), Some(width), Some(height)) = size { + f.extend([("units".into(), json!(units)), ("width".into(), json!(width)), ("height".into(), json!(height))]); + } + put(&mut f, RES_UNIT, attr("document", "resUnits").and_then(|l| id_of(&RES_UNITS, l)).map(|id| json!(id))); + let per = if text(&f, RES_UNIT, "in") == "cm" { CM } else { 1.0 }; + put(&mut f, "resolution", attr("document", "resolution").and_then(parse).and_then(|r| finite(r * per))); + put(&mut f, "mode", attr("document", "mode").and_then(|l| id_of(&MODES, l)).map(|id| json!(id))); + put(&mut f, "depth", attr("document", "bitDepth").and_then(|l| id_of(&DEPTHS, l)).map(|d| json!(d))); + put(&mut f, "placeAcrossFirst", attr("thumbnail", "place").and_then(|l| id_of(&PLACES, l)).map(|a| json!(a))); + for (key, name, at) in [ + ("includeSubfolders", "source", "includeSubfolders"), + ("groupByFolder", "source", "groupImages"), + ("flatten", "document", "flattenLayers"), + ("rotateForBestFit", "thumbnail", "bestFit"), + ("autoSpacing", "thumbnail", "useAutospacing"), + ("caption", "caption", "enabled"), + ] { + put(&mut f, key, attr(name, at).and_then(|v| v.parse::().ok()).map(|b| json!(b))); + } + for (key, at) in [("columns", "cols"), ("rows", "rows")] { + put(&mut f, key, attr("thumbnail", at).and_then(parse).and_then(finite)); + } + put(&mut f, "font", font.and_then(|n| n.attribute("name")).and_then(family_of).map(|family| json!(family))); + put(&mut f, "fontSize", font.and_then(|n| n.attribute("size")).and_then(parse).and_then(finite)); + // The spacing in the sheet's units, the engine's `horizontal` and `vertical`. The dialog has + // no control for them yet (#13689), so the dialog leaves them out. Only at a resolution the + // dialog takes: a broken one would give a broken spacing. + let units = unit_of(&text(&f, "units", "")); + if let Some(ppi) = f.get("resolution").and_then(Value::as_f64).filter(|r| (RES_MIN..=RES_MAX).contains(r)) { + for (key, at) in [("horizontal", "horz"), ("vertical", "vert")] { + put(&mut f, key, attr("thumbnail", at).and_then(spacing_px).and_then(|px| finite(units.from_px(px, ppi, 0.0, SPACING_PPI)))); + } + } + Ok(f) +} + +fn put(f: &mut Map, key: &str, v: Option) { + if let Some(v) = v { + f.insert(key.into(), v); + } +} + +/// `n` as a JSON number; `None` for infinity and NaN, which JSON would turn into `null`. +fn finite(n: f64) -> Option { + n.is_finite().then(|| json!(n)) +} + +/// A number with a dot (`1,5` is not one). +fn parse(s: &str) -> Option { + s.trim().parse::().ok().filter(|v| v.is_finite()) +} + +/// A spacing string in whole pixels: `0.111 in` (at 72 px/in) is 8, `20 px` is 20. +pub(super) fn spacing_px(s: &str) -> Option { + let (n, unit) = s.trim().split_once(' ')?; + let n = parse(n)?; + match unit.trim() { + "in" => Some((n * SPACING_PPI).round()), + "px" => Some(n.round()), + _ => None, + } +} + +/// `v` as the reference writes numbers: at most 15 significant digits, a dot, no trailing zeros +/// (`96.6666666666667`, `10`). +fn num(v: f64) -> String { + if v == 0.0 { + return "0".into(); + } + let decimals = 14i32.saturating_sub(v.abs().log10().floor() as i32).max(0) as usize; + let s = format!("{v:.decimals$}"); + if s.contains('.') { s.trim_end_matches('0').trim_end_matches('.').to_string() } else { s } +} + +/// The entry label of `v`, else that of `d`. +fn label(options: &[(T, &'static str)], v: T, d: T) -> &'static str { + let find = |x: T| options.iter().find(|(id, _)| *id == x).map(|(_, l)| *l); + find(v).or_else(|| find(d)).unwrap_or_default() +} + +/// The value of the entry labelled `l`. +fn id_of(options: &[(T, &'static str)], l: &str) -> Option { + options.iter().find(|(_, label)| *label == l).map(|(id, _)| *id) +} + +/// The profile a sheet in `mode` gets: the mode's default (the dialog has no Color Profile yet). +fn profile(mode: &str) -> &'static str { + match mode { + "gray" => "Working Gray", + "cmyk" => "Working CMYK", + "lab" => "Lab", + _ => "sRGB IEC61966-2.1", + } +} + +/// The PostScript name of `family`'s upright face nearest regular weight; the family itself when +/// none is installed. +fn postscript_name(family: &str) -> String { + let mut text = photocraft_text::shared().lock().unwrap_or_else(|e| e.into_inner()); + let faces = text.fonts.faces(family); + let regular = faces.iter().filter(|f| f.postscript_name.is_some()).min_by_key(|f| (f.italic, (f.weight - 400.0).abs() as u32)); + regular.and_then(|f| f.postscript_name.clone()).unwrap_or_else(|| family.to_string()) +} + +/// The family a stored font name stands for: an installed family of that name, or the family of +/// the face with that PostScript name. `None` when neither is installed. +fn family_of(name: &str) -> Option { + let mut text = photocraft_text::shared().lock().unwrap_or_else(|e| e.into_inner()); + if text.fonts.has_family(name) { + return Some(name.to_string()); + } + // Only the families the name's guessed family starts with: `resolve_postscript` would read + // every installed family on an unknown name, on the UI thread. + let guess = photocraft_text::fonts::guess_from_postscript(name).family.replace(' ', "").to_lowercase(); + let mut candidates = text.fonts.families().into_iter().filter(|f| !guess.is_empty() && f.replace(' ', "").to_lowercase().starts_with(&guess)); + candidates.find(|family| text.fonts.faces(family).iter().any(|face| face.postscript_name.as_deref() == Some(name))) +} + +fn attrs(pairs: &[(&str, String)]) -> String { + pairs.iter().map(|(k, v)| format!(" {k}=\"{}\"", escape(v))).collect() +} + +fn escape(s: &str) -> String { + // Line breaks and tabs as references: a parser turns literal ones in an attribute into spaces. + s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """).replace('\n', " ").replace('\r', " ").replace('\t', " ") +} diff --git a/crates/ui-egui/src/dialogs/contact_sheet_ui.rs b/crates/ui-egui/src/dialogs/contact_sheet_ui.rs index 5d077b86662..eb6fceb0c93 100644 --- a/crates/ui-egui/src/dialogs/contact_sheet_ui.rs +++ b/crates/ui-egui/src/dialogs/contact_sheet_ui.rs @@ -4,8 +4,11 @@ //! The rows are the command's params, so OK, `ui.dialog.set` and `ui.dialog.confirm` work as for every form. Three //! of them are kept in the shape the dialog shows and turned into the command's at OK ([`command_params`]): the //! resolution's unit (the command takes pixels/inch), Bit Depth (`"8"` or `"16"`) and Place (`"across"` or `"down"`). +//! Load…, Save… and Reset… in the footer read and write the values as a settings file and restore the defaults +//! (#13698). -use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, NumberUnit, Param, ParamKind, ParamResult}; +use craft::ui::dialog::{DialogId, PromptAnswer, PromptChoice, StandardPrompt}; +use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, NumberUnit, Param, ParamKind, ParamResult}; use craft::ui::runtime::env::{Label, UnitKind}; use craft::ui::runtime::requests::PathKind; use photocraft_engine::prefs::Unit; @@ -35,7 +38,11 @@ const KEPT_TEXT: [&str; 2] = ["input", "font"]; /// The rows of the dialog. They open with the values of the last OK (#13695); a fresh dialog has no folder chosen /// (#13692): not the working folder, nor that of the document in front. pub(crate) fn rows(app: &PhotocraftApp) -> Vec { - let saved = app.session.prefs().dialogs.get(COMMAND).cloned().unwrap_or_default(); + build(&app.session.prefs().dialogs.get(COMMAND).cloned().unwrap_or_default()) +} + +/// The rows over the folder and font `saved` keeps (`Null`: the defaults). +fn build(saved: &Value) -> Vec { let kept = |key: &str, default: &str| saved.get(key).and_then(Value::as_str).unwrap_or(default).to_owned(); let resolution = vec![ NumberUnit::new("in", UnitKind::PixelsPerInch, tl!("pixels/inch"), 1.0), @@ -152,6 +159,142 @@ pub(crate) fn command_params(map: &mut Map) { } } +#[path = "contact_sheet_settings_file.rs"] +mod settings_file; + +/// The footer buttons after OK and Cancel, as `(action, label)`. +pub(crate) fn footer_buttons() -> Vec<(String, Label)> { + [("load", tl!("Load…")), ("save", tl!("Save…")), ("reset", tl!("Reset…"))].map(|(id, label)| (id.to_owned(), Label::from(label))).into() +} + +/// The largest settings file Load… reads: the reference's are under 1 KiB. +const SETTINGS_FILE_MAX: usize = 1 << 20; + +/// The `ParamFamily::footer` of the dialog: Load… and Save… read and write its values as a settings file through the +/// platform's file dialog; Reset… asks before restoring the defaults. +pub(crate) fn footer(app: &mut PhotocraftApp, ctx: &egui::Context, id: DialogId, action: &str) { + let outcome = match action { + "load" => { + let ctx = ctx.clone(); + app.pick_file_bytes_filtered(&["xml"], move |app, name, bytes| { + load(app, &ctx, id, &name, &bytes); + Ok(Value::Null) + }) + } + "save" => { + let Some(text) = settings_text(app, id) else { return }; + app.pick_save(settings_file::FILE_NAME, move |app, path| { + let write = app.services.write.as_mut().ok_or("no writer configured")?; + write(&path, text.as_bytes())?; + Ok(json!({"path": path})) + }) + } + "reset" => { + ask_reset(app, id); + Ok(Value::Null) + } + _ => Ok(Value::Null), + }; + if let Err(e) = outcome + && e != crate::file_dialog::CANCELLED + { + crate::dialogs::alerts::report_error(app, e); + } +} + +/// The values of dialog `id` as a settings file; `None` once it closed. +fn settings_text(app: &PhotocraftApp, id: DialogId) -> Option { + let fields = app.framework.dialogs.get_by_id::(id)?.fields(); + Some(settings_file::write(&file_values(fields), &settings_file::Stamp::now())) +} + +/// The dialog's values in the settings file's shape: the command's, with the resolution's unit. +fn file_values(fields: &DialogFields) -> Map { + let mut map = match serde_json::to_value(fields) { + Ok(Value::Object(map)) => map, + _ => Map::new(), + }; + let unit = map.get(settings_file::RES_UNIT).cloned(); + command_params(&mut map); + if let Some(unit) = unit { + map.insert(settings_file::RES_UNIT.into(), unit); + } + map +} + +/// Load…: the values of the settings file `bytes` (named `name`) the dialog can show go into dialog `id`; the others +/// keep the dialog's. A file that is not a settings file shows an alert and changes nothing. +fn load(app: &mut PhotocraftApp, ctx: &egui::Context, id: DialogId, name: &str, bytes: &[u8]) { + // The dialog may close while the picker is open; then there is nothing to fill. + let Some(fields) = app.framework.dialogs.get_by_id::(id).map(|d| d.fields().clone()) else { return }; + let read = if bytes.len() > SETTINGS_FILE_MAX { + Err(tl!("too large").to_string()) + } else { + std::str::from_utf8(bytes).map_err(|e| e.to_string()).and_then(|xml| settings_file::read(xml, &file_values(&fields))) + }; + match read { + Ok(read) => apply(app, ctx, id, read), + Err(e) => { + crate::dialogs::alerts::alert(app, format!("{}: {e}", crate::file_open::display_name(name))); + } + } +} + +/// Sets the values `read` (the settings file's shape) on dialog `id`. A value its row cannot show keeps the current +/// one. Width and Height come in the file's units, so they are not converted. +fn apply(app: &mut PhotocraftApp, ctx: &egui::Context, id: DialogId, read: Map) { + for (key, value) in read { + let (key, value) = match key.as_str() { + "depth" => ("depth".to_owned(), json!(value.as_u64().map(|d| d.to_string()))), + // The file's numbers read as reals; the grid rows hold whole numbers. + "columns" | "rows" => (key, value.as_f64().filter(|n| n.fract() == 0.0).map_or(value, |n| json!(n as i64))), + "placeAcrossFirst" => ("place".to_owned(), json!(if value.as_bool() == Some(false) { "down" } else { "across" })), + // No control yet (#13689). + "horizontal" | "vertical" => continue, + _ => (key, value), + }; + let _ = app.framework.dialogs.set_json_field(ctx, id, &key, value); + } + if let Some(d) = app.framework.dialogs.get_mut_by_id::(id) + && let Some(units) = d.fields().text("units").map(str::to_owned) + { + d.set_field(UNITS_SHOWN, FieldValue::Text(units)); + } +} + +/// The tag of Reset…'s question: the dialog it resets. +struct ResetQuestion(DialogId); + +/// Reset… asks first, as the reference application's script alert does. +fn ask_reset(app: &mut PhotocraftApp, id: DialogId) { + let prompt = StandardPrompt::custom(tl!("Restore default settings?")) + .title(tl!("Script Alert")) + .button(PromptChoice::Proceed, tl!("Yes")) + .button(PromptChoice::Cancel, tl!("No")) + .tag(ResetQuestion(id)); + let _ = crate::dialogs::alerts::open_prompt(app, prompt); +} + +/// The `PROMPTS` entry of Reset…'s question: Yes shows the defaults, with no folder chosen; No changes nothing. `false` +/// for another prompt's answer. +pub(crate) fn answer(app: &mut PhotocraftApp, _ctx: &egui::Context, answer: &mut PromptAnswer) -> bool { + let Some(ResetQuestion(id)) = answer.take_tag::() else { return false }; + if answer.choice == PromptChoice::Proceed + && let Some(d) = app.framework.dialogs.get_mut_by_id::(id) + { + for param in build(&Value::Null) { + if let Some(value) = param.kind.default_value() { + d.set_field(param.key.clone(), value); + } + if let Some(unit) = param.unit_key() { + d.set_field(unit, FieldValue::Text("in".into())); + } + } + d.set_field(UNITS_SHOWN, FieldValue::Text("inches".into())); + } + true +} + #[cfg(test)] #[path = "contact_sheet_layout_tests.rs"] mod contact_sheet_layout_tests; diff --git a/crates/ui-egui/src/dialogs/file_forms.rs b/crates/ui-egui/src/dialogs/file_forms.rs index 78a0132991c..00b05342942 100644 --- a/crates/ui-egui/src/dialogs/file_forms.rs +++ b/crates/ui-egui/src/dialogs/file_forms.rs @@ -62,11 +62,13 @@ fn names(names: &[String]) -> Vec<(String, Label)> { fn open_form(app: &mut PhotocraftApp, key: &'static str, title: &str, rows: Vec) -> DialogId { let title = Label::from(title.to_string()); + // Contact Sheet II's Load…, Save… and Reset… (#13698). + let extra = if key == CONTACT_SHEET { crate::dialogs::contact_sheet_ui::footer_buttons() } else { Vec::new() }; params::open_param(app, key, DialogFields::new(), Value::Null, move |fields: &mut DialogFields| { if key == CONTACT_SHEET { crate::dialogs::contact_sheet_ui::follow_units(fields); } - ParamDialog::command(key, title.clone(), rows.clone()).values(Bind::bound(fields)) + ParamDialog::command(key, title.clone(), rows.clone()).values(Bind::bound(fields)).extra_buttons(extra.clone()) }) }