PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Separate print queue status from generic cancellable progress controls
skylar taylor-barricke3d118e0f3ec
diff --git a/crates/ui-egui/src/jobs_ui.rs b/crates/ui-egui/src/jobs_ui.rsindex f15a464a8..6e03a11ca 100644--- a/crates/ui-egui/src/jobs_ui.rs+++ b/crates/ui-egui/src/jobs_ui.rs@@ -568,6 +568,24 @@ pub fn bar(ui: &egui::Ui, rect: Rect, frac: Option<f32>, t: &Tokens) {}}+/// A print job has already reached the spool worker; cancellation belongs to the system queue.+fn print_status_progress(app: &PhotocraftApp, ui: &mut egui::Ui, j: &JobInfo) {+ let t = Tokens::get(ui.ctx());+ let (bar_w, bar_h) = if t.pro { (120.0, 6.0) } else { (140.0, 6.0) };+ let more = app.session.jobs().len().saturating_sub(1);+ let (xr, xresp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::hover());+ if xresp.hovered() {+ ui.painter().rect_filled(xr, t.radius_sm, t.hover);+ }+ crate::icons::paint(ui, xr, "x", 11.0, if xresp.hovered() { t.text } else { t.text_dim });+ xresp.on_hover_text(tl!("Manage submitted jobs in the system print queue"));+ ui.label(RichText::new(percent(j)).color(t.text_dim).size(11.5).monospace());+ let (br, _) = ui.allocate_exact_size(vec2(bar_w, bar_h), Sense::hover());+ bar(ui, br, shown_fraction(j), &t);+ let label = if more > 0 { format!("{} (+{more})", tl!(&j.label)) } else { tl!(&j.label).to_owned() };+ ui.label(RichText::new(label).color(t.text_dim).size(12.0));+}+/// Progress that has been reported, or `None` (indeterminate) while it's still 0.fn shown_fraction(j: &JobInfo) -> Option<f32> {(j.progress > 0.0).then_some(j.progress)@@ -584,14 +602,17 @@ pub fn status_progress(app: &mut PhotocraftApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());let (bar_w, bar_h) = if t.pro { (120.0, 6.0) } else { (140.0, 6.0) };let more = app.session.jobs().len().saturating_sub(1);+ if matches!(j.command.as_str(), "file.print" | "file.printOneCopy") {+ print_status_progress(app, ui, &j);+ return;+ }// Right to left: ×, percentage, bar, label.- let print = matches!(j.command.as_str(), "file.print" | "file.printOneCopy");- let (xr, xresp) = ui.allocate_exact_size(vec2(18.0, 18.0), if print { Sense::hover() } else { Sense::click() });+ let (xr, xresp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::click());if xresp.hovered() {ui.painter().rect_filled(xr, t.radius_sm, t.hover);}crate::icons::paint(ui, xr, "x", 11.0, if xresp.hovered() { t.text } else { t.text_dim });- let xresp = xresp.on_hover_text(if print { tl!("Manage submitted jobs in the system print queue") } else { tl!("Cancel (Esc)") });+ let xresp = xresp.on_hover_text(tl!("Cancel (Esc)"));ui.label(RichText::new(percent(&j)).color(t.text_dim).size(11.5).monospace());let (br, _) = ui.allocate_exact_size(vec2(bar_w, bar_h), Sense::hover());bar(ui, br, shown_fraction(&j), &t);