From 489810d03b315b86161f60b8605d6718789fbbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 14:38:20 -0500 Subject: [PATCH 1/2] feat(ui): the Publication Layout Wizard offers the inset and globe locators together --- .../ui-egui/src/publicationwizard/arrange.rs | 7 ++- .../ui-egui/src/publicationwizard/elements.rs | 63 ++++++++++++++++--- docs/user-guide/layouts.md | 2 +- 3 files changed, 61 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/publicationwizard/arrange.rs b/crates/ui-egui/src/publicationwizard/arrange.rs index b18b7e3c4b..30ea849e2c 100644 --- a/crates/ui-egui/src/publicationwizard/arrange.rs +++ b/crates/ui-egui/src/publicationwizard/arrange.rs @@ -422,7 +422,7 @@ mod tests { fn draft_of(app: &mut RustGisApp) -> &mut Draft { app.dialogs.publication.as_mut().unwrap() } - let cases: [(&str, Set, [bool; 4]); 7] = [ + let cases: [(&str, Set, [bool; 4]); 8] = [ ("no locator", |a| draft_of(a).elements.locator = LocatorChoice::None, [false, true, true, true]), ("no north arrow", |a| draft_of(a).elements.north = NorthChoice::None, [true, false, true, true]), ("no scale bar", |a| draft_of(a).elements.scale_bar = false, [true, true, true, false]), @@ -432,6 +432,11 @@ mod tests { |a| (draft_of(a).size, draft_of(a).elements.locator) = ("figure-1col".into(), LocatorChoice::Inset), [true, true, true, true], ), + ( + "a figure with both locators", + |a| (draft_of(a).size, draft_of(a).elements.locator) = ("figure-1col".into(), LocatorChoice::InsetAndGlobe), + [true, true, true, true], + ), ("a whole globe", |a| a.session.map_mut().projection = rustgis_engine::map::Projection::Globe, [false, false, true, false]), ( "a whole globe with an arrow asked for", diff --git a/crates/ui-egui/src/publicationwizard/elements.rs b/crates/ui-egui/src/publicationwizard/elements.rs index 93bebbbe08..4ad8be0f42 100644 --- a/crates/ui-egui/src/publicationwizard/elements.rs +++ b/crates/ui-egui/src/publicationwizard/elements.rs @@ -16,6 +16,8 @@ pub enum LocatorChoice { Default, Globe, Inset, + /// Both side by side, the globe outlining the inset. + InsetAndGlobe, None, } @@ -132,7 +134,7 @@ impl Draft { match self.elements.locator { LocatorChoice::Default => self.default_locator(s), LocatorChoice::None => false, - LocatorChoice::Globe | LocatorChoice::Inset => true, + LocatorChoice::Globe | LocatorChoice::Inset | LocatorChoice::InsetAndGlobe => true, } } @@ -225,9 +227,10 @@ impl Draft { let mut p = self.params(); let locator = match e.locator { LocatorChoice::Default => None, - LocatorChoice::Globe => Some("globe"), - LocatorChoice::Inset => Some("inset"), - LocatorChoice::None => Some("none"), + LocatorChoice::Globe => Some("globe".into()), + LocatorChoice::Inset => Some("inset".into()), + LocatorChoice::InsetAndGlobe => Some(json!(["inset", "globe"])), + LocatorChoice::None => Some("none".into()), }; // A look makes its element an object; without one it goes as its mode alone. let north = match (e.north, self.north_look(s)) { @@ -252,7 +255,7 @@ impl Draft { object([("title", title.map(Value::from)), ("columns", columns.map(Value::from)), ("exclude", exclude)]) }; for (key, value) in [ - ("locator", locator.map(Value::from)), + ("locator", locator), ("northArrow", north), ("legend", legend), ("legendBox", (e.legend_box && self.usable(Control::LegendBox, s)).then(|| "always".into())), @@ -338,6 +341,7 @@ pub(super) fn elements_value(s: &Session, d: &Draft) -> String { let which = match e.locator { LocatorChoice::Globe => tl_raw!("Globe"), LocatorChoice::Inset => tl_raw!("Inset"), + LocatorChoice::InsetAndGlobe => tl_raw!("Inset and globe"), _ => tl_raw!("Default (globe)"), }; on.push(i18n::fmt("{surround}: {choice}", &[("surround", surround_labels()[LOCATOR]), ("choice", which)])); @@ -389,6 +393,7 @@ pub(super) fn elements_step(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { ui.radio_value(choice, LocatorChoice::Default, default_locator); ui.radio_value(choice, LocatorChoice::Globe, tl!("Globe")); ui.radio_value(choice, LocatorChoice::Inset, tl!("Inset")); + ui.radio_value(choice, LocatorChoice::InsetAndGlobe, tl!("Inset and globe")); ui.radio_value(choice, LocatorChoice::None, tl!("None")); }); ui.label(tl!("North arrow")); @@ -625,11 +630,12 @@ mod tests { let mut app = app(); raster(&mut app); type Set = fn(&mut Elements); - let cases: [(Set, Value); 13] = [ + let cases: [(Set, Value); 14] = [ (|e| e.frame_grid = false, json!({"grid": "none"})), (|e| e.locator = LocatorChoice::Globe, json!({"locator": "globe"})), (|e| e.locator = LocatorChoice::Inset, json!({"locator": "inset"})), (|e| e.locator = LocatorChoice::None, json!({"locator": "none"})), + (|e| e.locator = LocatorChoice::InsetAndGlobe, json!({"locator": ["inset", "globe"]})), (|e| e.north = NorthChoice::Always, json!({"northArrow": "always"})), (|e| e.north = NorthChoice::None, json!({"northArrow": "none"})), (|e| e.legend = false, json!({"legend": "none"})), @@ -1139,7 +1145,7 @@ mod tests { #[test] fn the_controls_set_the_answers() { let mut h = step_of(raster); - pick(&mut h, "Inset", 0); + pick(&mut h, "Inset and globe", 0); pick(&mut h, "None", 1); pick(&mut h, "Comma (1,5)", 0); for label in [ @@ -1152,7 +1158,7 @@ mod tests { click_box(&mut h, label); } let want = Elements { - locator: LocatorChoice::Inset, + locator: LocatorChoice::InsetAndGlobe, north: NorthChoice::None, legend: true, legend_box: true, @@ -1194,7 +1200,7 @@ mod tests { app.dialogs.publication.as_mut().unwrap().step = Step::Elements; app.dialogs.publication.as_mut().unwrap().style = "panel".into(); let h = harness_sized(app, egui::vec2(320.0, 900.0)); - for label in ["Default: Globe", "Inset", "Comma (1,5)"] { + for label in ["Default: Globe", "Inset and globe", "Comma (1,5)"] { let rect = h.get_by_role_and_label(Role::RadioButton, label).rect(); assert!(rect.left() >= 0.0 && rect.right() <= 320.0, "{label} at {rect:?}"); } @@ -1246,6 +1252,26 @@ mod tests { assert!(h.query_by_label(want).is_some()); } + /// Both locators are named in the review and sent, on a sheet, a figure and a whole globe. + #[test] + fn the_review_names_both_locators() { + type Prepare = fn(&mut RustGisApp); + let cases: [(&str, Prepare); 3] = [ + ("a sheet", |_| {}), + ("a figure", |app| app.dialogs.publication.as_mut().unwrap().size = "figure-1col".into()), + ("a whole globe", globe), + ]; + for (case, prepare) in cases { + let h = step_of(|app| { + prepare(app); + let d = app.dialogs.publication.as_mut().unwrap(); + (d.step, d.elements.locator) = (Step::Review, LocatorChoice::InsetAndGlobe); + }); + assert!(h.query_by_label_contains("Locator: Inset and globe").is_some(), "{case}"); + assert_eq!(draft(&h).sent(&h.state().session)["locator"], json!(["inset", "globe"]), "{case}"); + } + } + /// The frame grid's box is on, and unticked it sends no grid, on a whole globe too. #[test] fn the_frame_grid_box_sets_the_answer() { @@ -1291,4 +1317,23 @@ mod tests { h.state_mut().run("edit.undo", Value::Null).unwrap(); assert_eq!(h.state().session.project.layouts.len(), before); } + + /// Create draws both locators asked for; Undo takes them away with the layout. + #[test] + fn create_draws_both_locators() { + let mut app = app(); + open(&mut app); + let d = app.dialogs.publication.as_mut().unwrap(); + d.step = Step::Review; + d.elements.locator = LocatorChoice::InsetAndGlobe; + let before = app.session.project.layouts.len(); + let mut h = harness(app); + click(&mut h, "Create"); + assert_eq!(h.state().session.project.layouts.len(), before + 1); + let l = h.state().session.project.layouts.last().unwrap(); + let locators = l.elements.iter().filter(|e| matches!(e.kind, ElementKind::MapFrame { extent_of: Some(_), .. })); + assert_eq!(locators.map(|e| e.name.as_str()).collect::>(), ["Locator Inset", "Locator Globe"]); + h.state_mut().run("edit.undo", Value::Null).unwrap(); + assert_eq!(h.state().session.project.layouts.len(), before); + } } diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index 6aabcf72d1..8197b1e5ca 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -56,7 +56,7 @@ Layouts open as tabs next to the maps; while one is open, its groups lead the Pu switched or the map renamed, is said and nothing is made); without a name the layout is `Publication`; the review says when a layout has that name, so the new one is numbered. The **elements** are what is drawn around the map: the locator (the default, named as what it will - be, a globe, an inset or none), the north arrow (auto, always or none), the legend or not, which + be, a globe, an inset, both or none), the north arrow (auto, always or none), the legend or not, which can be set always on a box and to list the context layers, the colorbar, the scale bar and the frame grid or not (without it the default reference leaves the graticule out; the map's own graticule is still drawn when on), whether the map may be veiled for the legend's room, and the From dd1ade3f56dedf7ede45eaaf1c8371bf4bb049d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 15:04:12 -0500 Subject: [PATCH 2/2] test(ui): keep checking that the Inset radio fits a narrow screen --- crates/ui-egui/src/publicationwizard/elements.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/publicationwizard/elements.rs b/crates/ui-egui/src/publicationwizard/elements.rs index 4ad8be0f42..6f8513fb62 100644 --- a/crates/ui-egui/src/publicationwizard/elements.rs +++ b/crates/ui-egui/src/publicationwizard/elements.rs @@ -1200,7 +1200,7 @@ mod tests { app.dialogs.publication.as_mut().unwrap().step = Step::Elements; app.dialogs.publication.as_mut().unwrap().style = "panel".into(); let h = harness_sized(app, egui::vec2(320.0, 900.0)); - for label in ["Default: Globe", "Inset and globe", "Comma (1,5)"] { + for label in ["Default: Globe", "Inset", "Inset and globe", "Comma (1,5)"] { let rect = h.get_by_role_and_label(Role::RadioButton, label).rect(); assert!(rect.left() >= 0.0 && rect.right() <= 320.0, "{label} at {rect:?}"); }