Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

docs(print): explain dialog settings and submission lifecycle

FartmanAndBurpsf545b39e9814
diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs
index 8350a1b1b..14b5a2a0d 100644
--- a/crates/ui-egui/src/file_ui.rs
+++ b/crates/ui-egui/src/file_ui.rs
@@ -723,6 +723,10 @@ fn download_for_web(app: &mut PhotocraftApp, mut p: Value) -> Result<Value, Stri
// ---------- Print ----------
+/// Opens a Print dialog seeded from the last print, filling missing fields with defaults.
+/// Refreshes the printer list on each opening; when native driver enumeration succeeds,
+/// an unavailable saved printer is replaced and its stale driver settings are discarded.
+/// Returns the dialog ID without submitting a print job.
pub fn open_print(app: &mut PhotocraftApp) -> u64 {
let mut f = Map::new();
f.insert("__print".into(), json!(true));
@@ -875,6 +879,9 @@ fn print_paper_size(value: Option<&Value>) -> (f64, f64) {
}
}
+/// Edits the paper preset, orientation and custom dimensions, remembering custom sizes
+/// across preset switches. Dimensions are displayed in the selected units but stored as
+/// unrotated print points; the engine applies orientation and validates the final size.
fn print_paper_controls(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let previous = f.get("paper").cloned();
let mut selected = if previous.as_ref().is_some_and(Value::is_array) { "custom".to_string() } else { s(f, "paper", "letter") };
@@ -1289,6 +1296,8 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
}
}
+/// Submits the dialog parameters to `file.print`, propagating command errors unchanged.
+/// Updates the status for completed results only; pending jobs report completion later.
fn print_confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Value, String> {
let r = app.run("file.print", params(f))?;
if r["pending"] != json!(true) {