From 7360d50e722feab30ec0195958d4c9c852aa9503 Mon Sep 17 00:00:00 2001 From: SlavenDj Date: Mon, 19 Oct 2026 20:09:16 +0200 Subject: [PATCH] #2958: the Print page's button leads the settings, in the primary accent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File › Print put "Print" between the printer settings and the page settings, styled like every other button there, so the page's one action was hard to find and didn't read as an immediate action. The button now comes first in the settings column, above the printer and the settings it prints with, as Word has it, and wears the accent the app gives a dialog's primary button (the file browser's Open and Save, OK and Save in dialogs): the first thing seen, and plainly the action. It still prints through `ui.print`, and it is still disabled while a native print job is busy. --- crates/ui-egui/src/lib.rs | 33 ++++++++++++++++++++++++++++++++ crates/ui-egui/src/print_page.rs | 23 +++++++++++----------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index c7f687a4e..2b959f8b1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -5270,6 +5270,39 @@ mod tests { } } + /// #2958: the Print button leads the settings, above the printer and the settings it prints + /// with (as in Word), and it wears the accent the app gives a dialog's primary button, so the + /// page's one action is found first and reads as one rather than as another setting. + #[test] + fn the_print_button_leads_the_settings_and_is_the_primary_action() { + use egui::accesskit::Role; + use egui_kittest::kittest::{By, Queryable}; + const BLURB: &str = "Send the document straight to the system print dialog, or save a copy in another format below."; + let mut a = app(); + a.services.print = Some(Box::new(|_| Ok(()))); + a.run("file.print", json!({})).unwrap(); + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state( + |ui, app: &mut WordApp| { + let ctx = ui.ctx().clone(); + app.logic(&ctx); + app.ui(ui); + }, + a, + ); + for _ in 0..4 { + h.step(); + } + // The page's own Print button (the backstage list has a Print entry too): the last. + let print = h.query_all(By::new().role(Role::Button).label("Print")).last().expect("a Print button").rect(); + let blurb = h.get_by_label(BLURB).rect(); + assert!(print.min.y < blurb.min.y, "the Print button leads the settings: {print:?} above {blurb:?}"); + let accent = crate::theme::Tokens::get(&h.ctx).accent; + assert!( + h.output().shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Rect(r) if r.rect == print && r.fill == accent)), + "the Print button is the primary (accent) button" + ); + } + /// #1156: the Print page's preview fills the pane beside the settings, zooms from its own /// bar, scrolls both ways once the page outgrows the pane, and One Page fits it again. #[test] diff --git a/crates/ui-egui/src/print_page.rs b/crates/ui-egui/src/print_page.rs index 9d093887f..a963bc57e 100644 --- a/crates/ui-egui/src/print_page.rs +++ b/crates/ui-egui/src/print_page.rs @@ -147,6 +147,17 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) { ui.spacing_mut().item_spacing.y = 8.0; let native = app.services.print_native.is_some(); let hook = native || app.services.print.is_some(); + // #2958: as in Word, the page's action leads the settings, in the accent the app + // gives a dialog's primary button: the first thing seen, and plainly a button + // that prints now rather than one more setting in the list below. + if hook + && ui + .add_enabled(!native || app.printing.ready(), crate::widgets::primary_button(ui, tl!("Print")).min_size(vec2(320.0, 34.0))) + .clicked() + { + let params = app.ui.print.params(); + let _ = app.run("ui.print", params); + } if native { if let Some(discover) = &app.services.printers { crate::printing::show(&mut app.printing, ui, discover, |label| crate::i18n::t(label).to_owned()); @@ -160,18 +171,6 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) { } else { ui.label(tl!("Save a copy in another format. Printing goes through a PDF you can print from any viewer.")); } - ui.add_space(4.0); - if hook - && ui - .add_enabled( - !native || app.printing.ready(), - egui::Button::new(egui::RichText::new(tl!("Print")).font(medium(13.5))).min_size(vec2(320.0, 34.0)), - ) - .clicked() - { - let params = app.ui.print.params(); - let _ = app.run("ui.print", params); - } if ui .add(egui::Button::new(egui::RichText::new(tl!("Save these pages as PDF…")).font(medium(13.5))).min_size(vec2(320.0, 34.0))) .clicked()