diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index b3575b68b5..e70eabe5f9 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -59,7 +59,7 @@ pub struct Dialogs { /// Map-local layer IDs require the dialog to retain its original project and map as well. pub projection_map: Option, pub geometry: Option, - /// Publication Layout Wizard: what it has asked so far (#2850). + /// Layout Wizard: what it has asked so far (#2850). pub publication: Option, pub repair: Option, pub conflicts: Option, diff --git a/crates/ui-egui/src/publicationwizard/mod.rs b/crates/ui-egui/src/publicationwizard/mod.rs index 7f31684291..e7654e3eb4 100644 --- a/crates/ui-egui/src/publicationwizard/mod.rs +++ b/crates/ui-egui/src/publicationwizard/mod.rs @@ -1,4 +1,4 @@ -//! Publication Layout Wizard: `layout.publication` asked step by step (size, map, style, elements, +//! Layout Wizard: `layout.publication` asked step by step (size, map, style, elements, //! placement, texts, sources and reference, accent), then made at once, as the New Layout › //! Publication Layout menu makes it (#2850). mod accent; @@ -546,7 +546,7 @@ pub fn show(app: &mut RustGisApp, ctx: &egui::Context) { let screen = ctx.content_rect(); let width = crate::widgets::dialog_width(ctx, SIZE.x, frame); let list = screen.width() >= LIST_FROM; - egui::Window::new(tl!("Publication Layout Wizard")) + egui::Window::new(tl!("Layout Wizard")) .id(egui::Id::unique("publication_wizard")) .frame(frame) .open(&mut open) @@ -860,7 +860,7 @@ mod tests { } fn window(h: &egui_kittest::Harness<'static, RustGisApp>) -> egui::Rect { - h.get_by_role_and_label(Role::Window, "Publication Layout Wizard").rect() + h.get_by_role_and_label(Role::Window, "Layout Wizard").rect() } /// Drags the window's bottom right corner `by` points. diff --git a/crates/ui-egui/src/publicationwizard/texts.rs b/crates/ui-egui/src/publicationwizard/texts.rs index ac150c708a..c97eee5327 100644 --- a/crates/ui-egui/src/publicationwizard/texts.rs +++ b/crates/ui-egui/src/publicationwizard/texts.rs @@ -281,7 +281,7 @@ mod tests { let long = "a long headline figure of sixty characters, or about as many".to_string(); d.figures = [(long.clone(), long.clone()), (long.clone(), long.clone()), (long.clone(), long)]; let mut h = harness_sized(app, egui::vec2(420.0, 360.0)); - let window = |h: &Wizard| h.get_by_role_and_label(Role::Window, "Publication Layout Wizard").rect(); + let window = |h: &Wizard| h.get_by_role_and_label(Role::Window, "Layout Wizard").rect(); let next = |h: &Wizard| h.get_by_role_and_label(Role::Button, "Next").rect(); let (size, at_next) = (window(&h).size(), next(&h)); h.state_mut().dialogs.publication.as_mut().unwrap().step = Step::Texts; diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 10bc2d758b..5f69e2710c 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -1319,6 +1319,12 @@ fn project_group(app: &mut RustGisApp, ui: &mut Ui) { group(ui, "Project", |ui| { big(ui, app, "new_map", "New\nMap", "Add a new map to the project.", "map.new", Value::Null, false, false); big_menu(ui, app, "new_layout", "New\nLayout", "Add a page layout for printing and exporting the map.", |ui, app| { + // A publication layout asked step by step: its size, style and texts too (#2850). + if ui.button(tl!("Layout Wizard…")).clicked() { + let _ = app.run("ui.dialog", json!({"name": "publicationWizard"})); + ui.close(); + } + ui.separator(); for (id, label, w, h) in rustgis_engine::map::layout::PAGES { if ui.button(page_label(label, *w, *h)).clicked() { let _ = app.run("layout.new", json!({"page": id})); @@ -1350,12 +1356,6 @@ fn project_group(app: &mut RustGisApp, ui: &mut Ui) { ui.close(); } } - // The same layout asked step by step: its texts and accent too (#2850). - ui.separator(); - if ui.button(tl!("Publication Layout Wizard…")).clicked() { - let _ = app.run("ui.dialog", json!({"name": "publicationWizard"})); - ui.close(); - } }); ui.separator(); if ui.button(tl!("Blank Letter page")).clicked() { @@ -2800,16 +2800,34 @@ fn extension_groups(app: &mut RustGisApp, ui: &mut Ui, id: &str) { } } -/// The Publish tab: the open layout's groups first, then reports, presentations, export and -/// sharing. +/// The Publish tab: the open layout's groups first, then the Layout Wizard, reports, +/// presentations, export and sharing. fn publish_tab(app: &mut RustGisApp, ui: &mut Ui) { layout_groups(app, ui); + new_publication_group(app, ui); report_group(app, ui); presentation_group(app, ui); share_groups(app, ui); thumbnail_group(app, ui); } +/// The Layout Wizard, ahead of the reports so it is in reach without scrolling (#3115). +fn new_publication_group(app: &mut RustGisApp, ui: &mut Ui) { + group(ui, "New", |ui| { + big( + ui, + app, + "new_layout", + "Layout\nWizard…", + "Make a publication sheet or figure of the map view, asked step by step.", + "ui.dialog", + json!({"name": "publicationWizard"}), + false, + false, + ); + }); +} + /// The layer selected in Layers. fn active_layer(app: &RustGisApp) -> Option<&rustgis_engine::map::Layer> { app.session.active_layer.and_then(|id| app.session.map().layer(id)) @@ -7080,10 +7098,11 @@ mod tests { assert!(l.elements.iter().all(|e| e.name != "Panel Box" && e.name != "Title"), "a figure, its title left to the caption"); } - /// New Layout › Publication Layout › Publication Layout Wizard… opens the wizard and closes - /// the menu, with nothing made yet (#2850). + /// New Layout › Layout Wizard…, the menu's first row (#3115) and no longer in the + /// Publication Layout submenu, opens the wizard and closes the menu, with nothing made yet + /// (#2850). #[test] - fn the_publication_menu_opens_the_wizard() { + fn the_new_layout_menu_opens_the_wizard() { let mut fonts = false; let mut h = egui_kittest::Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( move |ui, app: &mut RustGisApp| { @@ -7102,12 +7121,34 @@ mod tests { h.run(); h.get_by_label("Publication Layout").hover(); h.run(); - h.get_by_label("Publication Layout Wizard…").click(); + // One row, the submenu open or not, above the first page size. + let wizard = h.get_by_label("Layout Wizard…").rect(); + let (_, first, w, height) = rustgis_engine::map::layout::PAGES[0]; + let page = h.query_all_by_label(&page_label(first, w, height)).next().expect("the page sizes").rect(); + assert!(wizard.max.y <= page.min.y, "the wizard at {wizard:?}, the first page size at {page:?}"); + h.get_by_label("Layout Wizard…").click(); + h.run(); + assert_eq!(h.state().dialogs.open, Some("publicationWizard")); + assert!(h.state().dialogs.publication.is_some()); + assert_eq!(h.state().session.project.layouts.len(), before, "nothing made yet"); + assert!(h.query_by_label("Layout Wizard…").is_none(), "the menu closed"); + } + + /// Publish › New › Layout Wizard… comes before the reports, so it needs no scrolling with no + /// layout open, and opens the wizard, with nothing made yet (#3115). + #[test] + fn the_publish_tab_opens_the_wizard() { + let mut h = tab_harness(cities(), publish_tab); + let before = h.state().session.project.layouts.len(); + let wizard = h.get_by_label("Layout Wizard…").rect(); + let report = h.get_by_label("New Report").rect(); + assert!(wizard.max.x <= report.min.x, "the wizard at {wizard:?}, New Report at {report:?}"); + assert!(wizard.max.x <= 1366.0, "the wizard at {wizard:?}, past a 1366 px window"); + h.get_by_label("Layout Wizard…").click(); h.run(); assert_eq!(h.state().dialogs.open, Some("publicationWizard")); assert!(h.state().dialogs.publication.is_some()); assert_eq!(h.state().session.project.layouts.len(), before, "nothing made yet"); - assert!(h.query_by_label("Publication Layout Wizard…").is_none(), "the menu closed"); } /// A submenu of short rows (a sheet's styles) opens at least SUBMENU_MIN_W wide, not as a diff --git a/docs/getting-started.md b/docs/getting-started.md index edf90c18fb..0cc5852698 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -35,7 +35,8 @@ sample again. **Settings › Start-up › Start With** chooses what opens next t adds a web tile layer, and its **Celestial Bodies** take the map to the Moon or Mars. Right-drag (or ++ctrl++-drag) turns and tilts the map; click the north arrow to reset it. 6. **Share.** **Publish › Export Map** saves a PNG with labels and a scale bar. **Home › New - Layout** offers page sizes and **Publication Layout** presets for sheets (in one of seven styles) and figures. + Layout** offers page sizes and **Publication Layout** presets for sheets (in one of seven styles) and figures; + its **Layout Wizard…**, also on **Publish › New**, builds one step by step. Choose a page size for a page with a map frame, legend, north arrow and scale bar. **Project › Save As** writes a `.rgis` project. diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index a761b38d86..dccc11d323 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -39,7 +39,8 @@ Layouts open as tabs next to the maps; while one is open, its groups lead the Pu thesis (160 × 225 or 160 × 110 mm): the map edge to edge with a line of its projection and datum under it, at 7 pt. A figure's title and sources belong in its caption, so they are left out, and the result says so. - - **Step by step**: **Publication Layout Wizard…**, at the end of the same menu, asks for the size + - **Step by step**: **Layout Wizard…**, first in Home › New Layout and on Publish › New, + asks for the size (a sheet turned Auto, Portrait or Landscape, or a figure), the map extent and the layout's name, the style (each beside an outline of where its title, map and footer go, and its column or panel if it has one, with the accent colour picked, or else its own, where the sheet takes it, which