From d3234bde112fbe29666207baf83b8806bffb39d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 17:07:41 -0500 Subject: [PATCH 1/3] feat(ui): keep the Publication Layout Wizard's fine element settings in a collapsed Advanced section --- .../ui-egui/src/publicationwizard/elements.rs | 260 ++++++++++++++---- docs/user-guide/layouts.md | 16 +- 2 files changed, 218 insertions(+), 58 deletions(-) diff --git a/crates/ui-egui/src/publicationwizard/elements.rs b/crates/ui-egui/src/publicationwizard/elements.rs index 6f8513fb62..ed649abd02 100644 --- a/crates/ui-egui/src/publicationwizard/elements.rs +++ b/crates/ui-egui/src/publicationwizard/elements.rs @@ -9,6 +9,9 @@ use rustgis_engine::render::layout::{legend_lists, tile_listed}; /// The longest legend title `layout.publication` takes, in characters. const MAX_LEGEND_TITLE: usize = 200; +/// The height the layers left out of the legend take before their list scrolls. +const EXCLUDE_HEIGHT: f32 = 140.0; + /// The locator asked for; `Default` leaves it to `layout.publication`. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum LocatorChoice { @@ -101,7 +104,7 @@ pub(super) enum Control { NorthStyle, /// The scale bar's units and style. ScaleLook, - /// The legend's title and columns. + /// The legend's title, in the step, and its columns, in its Advanced section. LegendLook, } @@ -220,6 +223,23 @@ impl Draft { listed(s).into_iter().filter(|l| l.left_out(&self.elements)).map(|l| l.name.to_string()).collect() } + /// How many of the Advanced section's settings are sent other than their default, the layers + /// left out counting as one. + fn advanced_changed(&self, s: &Session) -> usize { + let e = &self.elements; + [ + e.legend_box && self.usable(Control::LegendBox, s), + e.context && self.usable(Control::Context, s), + self.legend_look(s).1.is_some(), + !self.legend_exclude(s).is_empty(), + !e.veil && self.usable(Control::Veil, s), + e.comma, + ] + .into_iter() + .filter(|&changed| changed) + .count() + } + /// What Create sends: [`Draft::params`] and the elements step's answers, a choice left to the /// command not among them. pub fn sent(&self, s: &Session) -> Value { @@ -410,25 +430,8 @@ pub(super) fn elements_step(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { pick_list(ui, "publication_wizard_north_style", tl!("Style"), (usable, why), style, &ArrowStyle::ALL, |v| tl!(v.label())); }); ui.add_space(4.0); - // A box the sheet has no use for is off, its tick kept for one that has. - let tick = |ui: &mut egui::Ui, usable: bool, on: &mut bool, label: &str, why: &str| { - ui.add_enabled(usable, egui::Checkbox::new(on, label)).on_disabled_hover_text(why) - }; ui.checkbox(&mut d.elements.legend, tl!("Legend")); - ui.indent("publication_wizard_legend", |ui| { - let own_box = d.column() || d.cards(); - let usable = d.usable(Control::LegendBox, s); - let own_note = tl!("In this style the legend has a box of its own."); - let why = if own_box { own_note } else { tl!("There is no legend or colorbar to box.") }; - tick(ui, usable, &mut d.elements.legend_box, tl!("Always on a box"), why); - let usable = d.usable(Control::Context, s); - tick(ui, usable, &mut d.elements.context, tl!("List the context layers"), tl!("There is no legend to list them in.")); - if own_box { - ui.label(egui::RichText::new(own_note).small().weak()); - } - legend_look_rows(ui, s, d); - legend_exclude_rows(ui, s, d); - }); + ui.indent("publication_wizard_legend", |ui| legend_title_row(ui, s, d)); let usable = d.usable(Control::Colorbar, s); let why = colorbar_off_reason(s); tick(ui, usable, &mut d.elements.colorbar, tl!("Colorbar"), why) @@ -451,6 +454,34 @@ pub(super) fn elements_step(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { }); }); ui.checkbox(&mut d.elements.frame_grid, tl!("Frame grid")); + ui.add_space(4.0); + // Counted before the section is drawn, so a change shows in its header the next frame. + let header = match d.advanced_changed(s) { + 0 => tl!("Advanced").to_string(), + n => i18n::fmt("Advanced ({count})", &[("count", &n.to_string())]), + }; + egui::CollapsingHeader::new(header).id_salt("publication_wizard_advanced").show(ui, |ui| advanced_rows(ui, s, d)); +} + +/// A box the sheet has no use for is off, its tick kept for one that has. +fn tick(ui: &mut egui::Ui, usable: bool, on: &mut bool, label: &str, why: &str) -> egui::Response { + ui.add_enabled(usable, egui::Checkbox::new(on, label)).on_disabled_hover_text(why) +} + +/// The fine settings: the legend's box, layers and columns, the veil and the decimal mark. +fn advanced_rows(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { + let own_box = d.column() || d.cards(); + let usable = d.usable(Control::LegendBox, s); + let own_note = tl!("In this style the legend has a box of its own."); + let why = if own_box { own_note } else { tl!("There is no legend or colorbar to box.") }; + tick(ui, usable, &mut d.elements.legend_box, tl!("Always on a box"), why); + let usable = d.usable(Control::Context, s); + tick(ui, usable, &mut d.elements.context, tl!("List the context layers"), tl!("There is no legend to list them in.")); + if own_box { + ui.label(egui::RichText::new(own_note).small().weak()); + } + legend_columns_row(ui, s, d); + legend_exclude_rows(ui, s, d); let usable = d.usable(Control::Veil, s); let why = if d.column() { tl!("In this style the map isn't veiled.") } else { tl!("There is no legend or colorbar to make room for.") }; tick(ui, usable, &mut d.elements.veil, tl!("Veil the map outside the extent if the legend needs room"), why); @@ -489,21 +520,36 @@ fn pick_list( }); } -/// The legend's title and columns. -fn legend_look_rows(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { - let usable = d.usable(Control::LegendLook, s); - let why = if !d.elements.legend { - tl!("There is no legend to title or split.") +/// Why the legend's title or columns are off: `no_legend` without one. +fn legend_look_why(s: &Session, d: &Draft, no_legend: &'static str) -> &'static str { + if !d.elements.legend { + no_legend } else if listed(s).is_empty() { tl!("The map has no layer the legend lists.") } else { tl!("Every layer is left out of the legend.") - }; + } +} + +/// The legend's title, with why it is off. +fn legend_title_row(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { + let usable = d.usable(Control::LegendLook, s); + let why = legend_look_why(s, d, tl!("There is no legend to title.")); ui.horizontal_wrapped(|ui| { let caption = ui.label(tl!("Title")); let edit = egui::TextEdit::singleline(&mut d.elements.legend_title).char_limit(MAX_LEGEND_TITLE).desired_width(field_width(ui)); ui.add_enabled(usable, edit).labelled_by(caption.id).on_disabled_hover_text(why); }); + // A legend off says so by its own box. + if d.elements.legend && !usable { + ui.label(egui::RichText::new(why).small().weak()); + } +} + +/// The legend's columns. +fn legend_columns_row(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { + let usable = d.usable(Control::LegendLook, s); + let why = legend_look_why(s, d, tl!("There is no legend to split.")); let columns: Vec> = std::iter::once(None).chain((1..=MAX_LEGEND_COLUMNS).map(Some)).collect(); ui.horizontal_wrapped(|ui| { let caption = ui.label(tl!("Columns")); @@ -521,9 +567,6 @@ fn legend_look_rows(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { .on_disabled_hover_text(why); }); }); - if d.elements.legend && !usable { - ui.label(egui::RichText::new(why).small().weak()); - } } /// A box per name the legend lists, ticked to leave its layers out. @@ -533,17 +576,19 @@ fn legend_exclude_rows(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { return; } ui.label(tl!("Leave out of the legend")); - for l in listed { - let mut out = l.left_out(&d.elements); - let why = tl!("There is no legend to leave it out of."); - let tick = egui::Checkbox::new(&mut out, l.name); - if ui.add_enabled(d.elements.legend, tick).on_disabled_hover_text(why).changed() { - d.elements.legend_exclude.retain(|k| !l.layers.contains(k)); - if out { - d.elements.legend_exclude.extend(l.layers); + let list = egui::ScrollArea::vertical().id_salt("publication_wizard_exclude").max_height(EXCLUDE_HEIGHT); + list.auto_shrink([false, true]).show(ui, |ui| { + for l in listed { + let mut out = l.left_out(&d.elements); + let why = tl!("There is no legend to leave it out of."); + if tick(ui, d.elements.legend, &mut out, l.name, why).changed() { + d.elements.legend_exclude.retain(|k| !l.layers.contains(k)); + if out { + d.elements.legend_exclude.extend(l.layers); + } } } - } + }); } #[cfg(test)] @@ -596,7 +641,31 @@ mod tests { ticked_box(h, label).accesskit_node().is_disabled() } + /// The header of the Advanced section, whatever it counts. + fn advanced(h: &Wizard) -> egui_kittest::Node<'_> { + h.get_all_by_role(Role::DisclosureTriangle).next().expect("the Advanced header") + } + + fn open_advanced(h: &mut Wizard) { + if advanced(h).accesskit_node().data().is_expanded() == Some(true) { + return; + } + advanced(h).scroll_to_me(); + h.run_steps(4); + advanced(h).click(); + h.run_steps(8); + } + fn click_box(h: &mut Wizard, label: &str) { + if h.query_by_role_and_label(Role::CheckBox, label).is_none() { + open_advanced(h); + } + // A scroll reaches the innermost area only: for a layer in the list, the box under the + // list brings the list into view first. + if let Some(under) = h.query_by_role_and_label(Role::CheckBox, "Veil the map outside the extent if the legend needs room") { + under.scroll_to_me(); + h.run_steps(4); + } ticked_box(h, label).scroll_to_me(); h.run_steps(4); ticked_box(h, label).click(); @@ -607,6 +676,9 @@ mod tests { /// north arrow's. fn pick(h: &mut Wizard, label: &str, nth: usize) { // The step scrolls: one below the window is brought into view first. + if h.query_all_by_role_and_label(Role::RadioButton, label).nth(nth).is_none() { + open_advanced(h); + } h.get_all_by_role_and_label(Role::RadioButton, label).nth(nth).expect("the radio").scroll_to_me(); h.run_steps(4); h.get_all_by_role_and_label(Role::RadioButton, label).nth(nth).expect("the radio").click(); @@ -843,6 +915,7 @@ mod tests { choose(&mut h, "Style", 0, "Compass rose"); choose(&mut h, "Units", 0, "Kilometers"); choose(&mut h, "Style", 1, "Single line"); + open_advanced(&mut h); choose(&mut h, "Columns", 0, "3"); h.get_by_role_and_label(Role::TextInput, "Title").focus(); h.run_steps(4); @@ -856,17 +929,22 @@ mod tests { fn a_look_with_no_element_is_off() { let off_combo = |h: &Wizard, caption: &str, nth| combo(h, caption, nth).accesskit_node().is_disabled(); let title_off = |h: &Wizard| h.get_by_role_and_label(Role::TextInput, "Title").accesskit_node().is_disabled(); - let h = step_of(|_| {}); + let opened = |prepare: fn(&mut RustGisApp)| { + let mut h = step_of(prepare); + open_advanced(&mut h); + h + }; + let h = opened(|_| {}); assert!(!off_combo(&h, "Style", 0) && !off_combo(&h, "Style", 1) && !off_combo(&h, "Units", 0)); assert!(!off_combo(&h, "Columns", 0) && !title_off(&h)); - let h = step_of(|app| { + let h = opened(|app| { let e = &mut app.dialogs.publication.as_mut().unwrap().elements; *e = Elements { north: NorthChoice::None, legend: false, scale_bar: false, ..looks() }; }); assert!(off_combo(&h, "Style", 0) && off_combo(&h, "Style", 1) && off_combo(&h, "Units", 0)); assert!(off_combo(&h, "Columns", 0) && title_off(&h)); assert_eq!(draft(&h).elements.legend_title, " Key ", "kept"); - let h = step_of(|app| { + let h = opened(|app| { for l in &mut app.session.map_mut().layers { l.visible = false; } @@ -1004,7 +1082,8 @@ mod tests { let out = out_of(app, &["Hidden", "Drawings", "Heights"]); app.dialogs.publication.as_mut().unwrap().elements.legend_exclude = out; }; - let h = step_of(prepare); + let mut h = step_of(prepare); + open_advanced(&mut h); assert_eq!(added(&h.state().session, draft(&h)), json!({})); for label in ["Cities", "Parcels"] { assert!(h.query_by_role_and_label(Role::CheckBox, label).is_some(), "{label}"); @@ -1018,6 +1097,7 @@ mod tests { #[test] fn one_box_leaves_out_every_layer_of_a_name() { let mut h = step_of(|app| named(app, &["Cities", "cities", "Roads"])); + open_advanced(&mut h); assert!(h.query_by_role_and_label(Role::CheckBox, "cities").is_none(), "one box"); click_box(&mut h, "Cities"); assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": {"exclude": ["Cities"]}})); @@ -1064,12 +1144,13 @@ mod tests { /// With no legend the list is off and nothing is sent; the ticks are kept. #[test] fn without_a_legend_nothing_is_left_out() { - let h = step_of(|app| { + let mut h = step_of(|app| { named(app, &["Cities"]); let out = out_of(app, &["Cities"]); let e = &mut app.dialogs.publication.as_mut().unwrap().elements; (e.legend, e.legend_exclude) = (false, out); }); + open_advanced(&mut h); assert!(off(&h, "Cities")); assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": "none"})); assert_eq!(draft(&h).elements.legend_exclude.len(), 1, "kept"); @@ -1078,12 +1159,13 @@ mod tests { /// With every layer left out the legend has no title or columns, and says why. #[test] fn with_every_layer_left_out_the_legend_has_no_look() { - let h = step_of(|app| { + let mut h = step_of(|app| { named(app, &["Cities"]); let out = out_of(app, &["Cities"]); let e = &mut app.dialogs.publication.as_mut().unwrap().elements; (e.legend_title, e.legend_columns, e.legend_exclude) = ("Key".into(), Some(2), out); }); + open_advanced(&mut h); assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": {"exclude": ["Cities"]}})); assert!(combo(&h, "Columns", 0).accesskit_node().is_disabled()); assert!(h.query_by_label_contains("Every layer is left out").is_some(), "said"); @@ -1093,7 +1175,8 @@ mod tests { /// With nothing to list there is no box to tick, and the step says so once. #[test] fn with_nothing_to_list_no_layer_is_offered() { - let h = step_of(|app| named(app, &[])); + let mut h = step_of(|app| named(app, &[])); + open_advanced(&mut h); assert!(h.query_by_label_contains("Leave out of the legend").is_none()); assert_eq!(h.query_all_by_label_contains("no layer the legend lists").count(), 1); } @@ -1131,6 +1214,76 @@ mod tests { assert_eq!(h.state().session.project.layouts.len(), before); } + /// The fine settings are in the Advanced section, closed until opened. + #[test] + fn the_fine_settings_are_in_a_section_that_starts_closed() { + let mut h = step_of(|app| named(app, &["Cities"])); + let inside = |h: &Wizard| { + [ + (Role::CheckBox, "Always on a box"), + (Role::CheckBox, "List the context layers"), + (Role::ComboBox, "Columns"), + (Role::CheckBox, "Cities"), + (Role::CheckBox, "Veil the map outside the extent if the legend needs room"), + (Role::RadioButton, "Comma (1,5)"), + ] + .map(|(role, label)| h.query_by_role_and_label(role, label).is_some()) + }; + assert_eq!(advanced(&h).accesskit_node().data().is_expanded(), Some(false)); + assert_eq!(inside(&h), [false; 6]); + assert!(h.query_by_role_and_label(Role::TextInput, "Title").is_some(), "the title stays out"); + open_advanced(&mut h); + assert_eq!(advanced(&h).accesskit_node().data().is_expanded(), Some(true)); + assert_eq!(inside(&h), [true; 6]); + } + + /// The header counts the settings sent that differ from their default: the layers left out as + /// one, and none the sheet can't use. + #[test] + fn the_header_counts_the_settings_changed() { + let header = |prepare: fn(&mut RustGisApp), want: &str| { + let h = step_of(prepare); + assert!(h.query_by_role_and_label(Role::DisclosureTriangle, want).is_some(), "{want}"); + }; + header(|_| {}, "Advanced"); + header( + |app| { + named(app, &["Cities", "Roads", "Rivers"]); + let out = out_of(app, &["Cities", "Roads"]); + let e = &mut app.dialogs.publication.as_mut().unwrap().elements; + (e.comma, e.veil, e.legend_exclude) = (true, false, out); + }, + "Advanced (3)", + ); + fn every() -> Elements { + Elements { legend_box: true, context: true, legend_columns: Some(2), veil: false, comma: true, ..Elements::default() } + } + header(|app| app.dialogs.publication.as_mut().unwrap().elements = every(), "Advanced (5)"); + header( + |app| { + let d = app.dialogs.publication.as_mut().unwrap(); + (d.style, d.elements) = ("panel".into(), every()); + }, + "Advanced (3)", + ); + header(|app| app.dialogs.publication.as_mut().unwrap().elements = Elements { legend: false, ..every() }, "Advanced (1)"); + } + + /// With many layers the list keeps its height and scrolls to the last. + #[test] + fn a_long_list_of_layers_scrolls() { + let mut h = step_of(|app| { + let names: Vec = (0..100).map(|n| format!("Layer {n:02}")).collect(); + named(app, &names.iter().map(String::as_str).collect::>()); + }); + open_advanced(&mut h); + let top = h.get_by_label("Leave out of the legend").rect().top(); + let below = ticked_box(&h, "Veil the map outside the extent if the legend needs room").rect().top(); + assert!(below - top < 220.0, "{}", below - top); + click_box(&mut h, "Layer 99"); + assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": {"exclude": ["Layer 99"]}})); + } + /// The default locator is named as what it will be. #[test] fn the_default_locator_says_what_it_draws() { @@ -1177,17 +1330,22 @@ mod tests { /// What the sheet can't use is off, and says why. #[test] fn what_the_sheet_cant_use_is_off() { - let h = step_of(|_| {}); + let opened = |prepare: fn(&mut RustGisApp)| { + let mut h = step_of(prepare); + open_advanced(&mut h); + h + }; + let h = opened(|_| {}); for label in ["Always on a box", "List the context layers", "Scale bar", "Veil the map outside the extent if the legend needs room"] { assert!(!off(&h, label), "classic: {label}"); } - let h = step_of(|app| app.dialogs.publication.as_mut().unwrap().style = "panel".into()); + let h = opened(|app| app.dialogs.publication.as_mut().unwrap().style = "panel".into()); assert!(off(&h, "Always on a box") && off(&h, "Veil the map outside the extent if the legend needs room")); assert!(h.query_by_label_contains("a box of its own").is_some(), "said"); - let h = step_of(|app| app.dialogs.publication.as_mut().unwrap().elements.legend = false); + let h = opened(|app| app.dialogs.publication.as_mut().unwrap().elements.legend = false); assert!(off(&h, "List the context layers") && off(&h, "Always on a box")); - let h = step_of(globe); + let h = opened(globe); assert!(off(&h, "Scale bar")); assert!(h.query_by_label_contains("whole globe draws no scale bar").is_some(), "said"); } @@ -1199,7 +1357,8 @@ mod tests { open(&mut app); 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)); + let mut h = harness_sized(app, egui::vec2(320.0, 900.0)); + open_advanced(&mut h); 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:?}"); @@ -1215,7 +1374,8 @@ mod tests { named(&mut app, &[long]); open(&mut app); app.dialogs.publication.as_mut().unwrap().step = Step::Elements; - let h = harness_sized(app, egui::vec2(320.0, 900.0)); + let mut h = harness_sized(app, egui::vec2(320.0, 900.0)); + open_advanced(&mut h); let rect = ticked_box(&h, long).rect(); assert!(rect.left() >= 0.0 && rect.right() <= 320.0, "a long name at {rect:?}"); } diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index 4f9ee6a435..d25ea9fa94 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -56,14 +56,14 @@ 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, 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 - decimal mark; a choice the sheet can't use is off and isn't sent. Under them, the north - arrow's style, the scale bar's units and style, and the legend's title and columns (Auto, or 1 - to 6) can be picked, and layers ticked to be left out of the legend (every layer of that - name). The + be, a globe, an inset, both or none), the north arrow (auto, always or none) and its style, the + legend or not and its title, the colorbar, the scale bar with its units and style, 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). **Advanced**, closed at first, holds the finer settings, its header + counting those changed: the legend always on a box, its context layers listed, its columns + (Auto, or 1 to 6) and the layers ticked to be left out of it (every layer of that name, in a + list that scrolls), whether the map may be veiled for the legend's room, and the decimal mark. A + choice the sheet can't use is off and isn't sent. The **placement** is the arrangement (below): `best`, the favourite, one by name or one saved, or **Custom**, a corner for each surround (a corner another has swaps the two; on Panel, Editorial and Modular only the north arrow and scale bar take one, the locator and legend sitting in the From 864e936c9a3f245cbdc6e1d52b5aa6358ba8d3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 17:31:13 -0500 Subject: [PATCH 2/3] test(ui): share the opened Advanced step helper and tie the list height bound --- .../ui-egui/src/publicationwizard/elements.rs | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/src/publicationwizard/elements.rs b/crates/ui-egui/src/publicationwizard/elements.rs index ed649abd02..5080c9d82f 100644 --- a/crates/ui-egui/src/publicationwizard/elements.rs +++ b/crates/ui-egui/src/publicationwizard/elements.rs @@ -540,7 +540,7 @@ fn legend_title_row(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { let edit = egui::TextEdit::singleline(&mut d.elements.legend_title).char_limit(MAX_LEGEND_TITLE).desired_width(field_width(ui)); ui.add_enabled(usable, edit).labelled_by(caption.id).on_disabled_hover_text(why); }); - // A legend off says so by its own box. + // With the legend on and no layer for it to list, the reason is said here. if d.elements.legend && !usable { ui.label(egui::RichText::new(why).small().weak()); } @@ -656,6 +656,13 @@ mod tests { h.run_steps(8); } + /// The elements step prepared by `prepare`, its Advanced section open. + fn opened_step(prepare: impl FnOnce(&mut RustGisApp)) -> Wizard { + let mut h = step_of(prepare); + open_advanced(&mut h); + h + } + fn click_box(h: &mut Wizard, label: &str) { if h.query_by_role_and_label(Role::CheckBox, label).is_none() { open_advanced(h); @@ -929,22 +936,17 @@ mod tests { fn a_look_with_no_element_is_off() { let off_combo = |h: &Wizard, caption: &str, nth| combo(h, caption, nth).accesskit_node().is_disabled(); let title_off = |h: &Wizard| h.get_by_role_and_label(Role::TextInput, "Title").accesskit_node().is_disabled(); - let opened = |prepare: fn(&mut RustGisApp)| { - let mut h = step_of(prepare); - open_advanced(&mut h); - h - }; - let h = opened(|_| {}); + let h = opened_step(|_| {}); assert!(!off_combo(&h, "Style", 0) && !off_combo(&h, "Style", 1) && !off_combo(&h, "Units", 0)); assert!(!off_combo(&h, "Columns", 0) && !title_off(&h)); - let h = opened(|app| { + let h = opened_step(|app| { let e = &mut app.dialogs.publication.as_mut().unwrap().elements; *e = Elements { north: NorthChoice::None, legend: false, scale_bar: false, ..looks() }; }); assert!(off_combo(&h, "Style", 0) && off_combo(&h, "Style", 1) && off_combo(&h, "Units", 0)); assert!(off_combo(&h, "Columns", 0) && title_off(&h)); assert_eq!(draft(&h).elements.legend_title, " Key ", "kept"); - let h = opened(|app| { + let h = opened_step(|app| { for l in &mut app.session.map_mut().layers { l.visible = false; } @@ -1279,7 +1281,8 @@ mod tests { open_advanced(&mut h); let top = h.get_by_label("Leave out of the legend").rect().top(); let below = ticked_box(&h, "Veil the map outside the extent if the legend needs room").rect().top(); - assert!(below - top < 220.0, "{}", below - top); + // The list, with its caption and the spacing around them. + assert!(below - top < EXCLUDE_HEIGHT + 60.0, "{}", below - top); click_box(&mut h, "Layer 99"); assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": {"exclude": ["Layer 99"]}})); } @@ -1330,22 +1333,17 @@ mod tests { /// What the sheet can't use is off, and says why. #[test] fn what_the_sheet_cant_use_is_off() { - let opened = |prepare: fn(&mut RustGisApp)| { - let mut h = step_of(prepare); - open_advanced(&mut h); - h - }; - let h = opened(|_| {}); + let h = opened_step(|_| {}); for label in ["Always on a box", "List the context layers", "Scale bar", "Veil the map outside the extent if the legend needs room"] { assert!(!off(&h, label), "classic: {label}"); } - let h = opened(|app| app.dialogs.publication.as_mut().unwrap().style = "panel".into()); + let h = opened_step(|app| app.dialogs.publication.as_mut().unwrap().style = "panel".into()); assert!(off(&h, "Always on a box") && off(&h, "Veil the map outside the extent if the legend needs room")); assert!(h.query_by_label_contains("a box of its own").is_some(), "said"); - let h = opened(|app| app.dialogs.publication.as_mut().unwrap().elements.legend = false); + let h = opened_step(|app| app.dialogs.publication.as_mut().unwrap().elements.legend = false); assert!(off(&h, "List the context layers") && off(&h, "Always on a box")); - let h = opened(globe); + let h = opened_step(globe); assert!(off(&h, "Scale bar")); assert!(h.query_by_label_contains("whole globe draws no scale bar").is_some(), "said"); } From 830390fb1254f44b563fb38657b687ab4efc0854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Sat, 28 Nov 2026 17:40:27 -0500 Subject: [PATCH 3/3] fix(ui): keep the legend's left-out list at its height inside the wizard step --- crates/ui-egui/src/publicationwizard/elements.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/publicationwizard/elements.rs b/crates/ui-egui/src/publicationwizard/elements.rs index 5080c9d82f..0cfdd77017 100644 --- a/crates/ui-egui/src/publicationwizard/elements.rs +++ b/crates/ui-egui/src/publicationwizard/elements.rs @@ -576,8 +576,10 @@ fn legend_exclude_rows(ui: &mut egui::Ui, s: &Session, d: &mut Draft) { return; } ui.label(tl!("Leave out of the legend")); + // The step scrolls around the list: without a floor of its own the list takes what the window + // has left, a couple of rows. let list = egui::ScrollArea::vertical().id_salt("publication_wizard_exclude").max_height(EXCLUDE_HEIGHT); - list.auto_shrink([false, true]).show(ui, |ui| { + list.min_scrolled_height(EXCLUDE_HEIGHT).auto_shrink([false, true]).show(ui, |ui| { for l in listed { let mut out = l.left_out(&d.elements); let why = tl!("There is no legend to leave it out of."); @@ -1282,7 +1284,8 @@ mod tests { let top = h.get_by_label("Leave out of the legend").rect().top(); let below = ticked_box(&h, "Veil the map outside the extent if the legend needs room").rect().top(); // The list, with its caption and the spacing around them. - assert!(below - top < EXCLUDE_HEIGHT + 60.0, "{}", below - top); + let gap = below - top; + assert!(gap > EXCLUDE_HEIGHT && gap < EXCLUDE_HEIGHT + 60.0, "{gap}"); click_box(&mut h, "Layer 99"); assert_eq!(added(&h.state().session, draft(&h)), json!({"legend": {"exclude": ["Layer 99"]}})); }