diff --git a/crates/ui-egui/src/publicationwizard/accent.rs b/crates/ui-egui/src/publicationwizard/accent.rs index 97fb0458aa..12876c8577 100644 --- a/crates/ui-egui/src/publicationwizard/accent.rs +++ b/crates/ui-egui/src/publicationwizard/accent.rs @@ -1,7 +1,7 @@ //! The wizard's accent step. use super::*; -/// The accent step: the style's own colour, or one picked. +/// The accent step: the style's own colour, or one picked, and an edge sheet's paper. pub(super) fn accent_step(ui: &mut egui::Ui, d: &mut Draft, app_accent: egui::Color32) { let mut ticked = d.accent.is_some(); if ui @@ -26,6 +26,26 @@ pub(super) fn accent_step(ui: &mut egui::Ui, d: &mut Draft, app_accent: egui::Co } else { ui.label(egui::RichText::new(tl!("The style's own colour.")).small().weak()); } + if d.edge() { + paper_row(ui, d); + } +} + +/// An edge sheet's paper, asked here and not left to Page Color: the command picks the texts' ink +/// from it as it makes the sheet. +fn paper_row(ui: &mut egui::Ui, d: &mut Draft) { + ui.separator(); + ui.horizontal(|ui| { + let caption = ui.label(tl!("Paper")); + let mut c = d.paper.unwrap_or(egui::Color32::WHITE); + let swatch = egui::color_picker::color_edit_button_srgba(ui, &mut c, egui::color_picker::Alpha::Opaque).labelled_by(caption.id); + if swatch.changed() { + d.paper = Some(c); + } + if ui.add_enabled(d.paper_sent().is_some(), egui::Button::new(tl!("White"))).clicked() { + d.paper = None; + } + }); } #[cfg(test)] @@ -154,4 +174,38 @@ mod tests { h.run_steps(2); assert_eq!(h.state().dialogs.publication.as_ref().unwrap().accent, Some(red), "custom colour kept"); } + + /// An edge sheet is asked its paper, white until one is picked; White goes back to it. No + /// other style is asked. + #[test] + fn only_an_edge_sheet_is_asked_its_paper() { + use egui::accesskit::Role; + let dark = egui::Color32::from_rgb(0x1B, 0x24, 0x30); + let mut app = app(); + open(&mut app); + { + let d = app.dialogs.publication.as_mut().unwrap(); + d.step = Step::Accent; + d.style = "edge".into(); + } + let mut h = harness(app); + let d = |h: &egui_kittest::Harness<'static, RustGisApp>| h.state().dialogs.publication.as_ref().unwrap().params(); + assert!(h.query_by_role_and_label(Role::ColorWell, "Paper").is_some()); + assert!(d(&h).get("paper").is_none(), "white"); + h.state_mut().dialogs.publication.as_mut().unwrap().paper = Some(dark); + h.run_steps(4); + assert_eq!(d(&h)["paper"], "#1B2430"); + click(&mut h, "White"); + assert!(d(&h).get("paper").is_none()); + h.state_mut().dialogs.publication.as_mut().unwrap().paper = Some(egui::Color32::WHITE); + h.run_steps(4); + assert!(d(&h).get("paper").is_none(), "white picked by hand"); + h.state_mut().dialogs.publication.as_mut().unwrap().paper = Some(dark); + for style in ["classic", "banner", "panel", "editorial", "modular", "poster"] { + h.state_mut().dialogs.publication.as_mut().unwrap().style = style.into(); + h.run_steps(4); + assert!(h.query_by_role_and_label(Role::ColorWell, "Paper").is_none(), "{style}"); + assert!(d(&h).get("paper").is_none(), "{style}"); + } + } } diff --git a/crates/ui-egui/src/publicationwizard/mod.rs b/crates/ui-egui/src/publicationwizard/mod.rs index 3fc22b110a..7f31684291 100644 --- a/crates/ui-egui/src/publicationwizard/mod.rs +++ b/crates/ui-egui/src/publicationwizard/mod.rs @@ -64,6 +64,8 @@ enum LeftOut { NoSources, NoReference, NotEditorial, + NotEdge, + NoFigures, } /// A text field of the wizard that takes a layer statistic. @@ -76,6 +78,10 @@ enum Field { Author, Reference, Heading(usize), + Kicker, + /// A headline figure's value and its label, by the figure's place. + FigureValue(usize), + FigureLabel(usize), } impl Field { @@ -83,6 +89,7 @@ impl Field { fn step(self) -> Step { match self { Field::Title | Field::Subtitle | Field::Note | Field::Author | Field::Heading(2) => Step::Texts, + Field::Kicker | Field::FigureValue(_) | Field::FigureLabel(_) => Step::Texts, Field::Sources | Field::Reference | Field::Heading(_) => Step::Sources, } } @@ -109,6 +116,12 @@ pub struct Draft { pub title: String, /// Whether the title was typed; until then it is the active map's name, as the menu's. pub title_typed: bool, + /// An edge sheet's short line over its title. + pub kicker: String, + /// The headline figures of an edge or panel sheet, each a value and its label. + pub figures: [(String, String); 3], + /// An edge sheet's paper, or `None` for white, as `layout.page` keeps it. + pub paper: Option, pub subtitle: String, pub note: String, pub sources: String, @@ -156,6 +169,9 @@ impl Draft { style: "classic".into(), title: s.map().name.clone(), title_typed: false, + kicker: String::new(), + figures: Default::default(), + paper: None, subtitle: String::new(), note: String::new(), sources: String::new(), @@ -245,6 +261,19 @@ impl Draft { p[key] = json!(text.trim()); } } + if self.left_out(Field::Kicker).is_none() && !self.kicker.trim().is_empty() { + p["kicker"] = json!(self.kicker.trim()); + } + let figures: Vec = self + .figures_sent() + .map(|(value, label)| if label.is_empty() { json!({"value": value}) } else { json!({"value": value, "label": label}) }) + .collect(); + if !figures.is_empty() { + p["figures"] = json!(figures); + } + if let Some(c) = self.paper_sent() { + p["paper"] = json!(hex(c)); + } if self.no_author { p["author"] = json!(""); } @@ -277,6 +306,22 @@ impl Draft { self.style == "editorial" } + fn edge(&self) -> bool { + self.style == "edge" + } + + /// The headline figures sent, in their order: those with a value, each trimmed, none for a + /// sheet that draws none. + fn figures_sent(&self) -> impl Iterator { + let drawn = self.left_out(Field::FigureValue(0)).is_none(); + self.figures.iter().map(|(value, label)| (value.trim(), label.trim())).filter(move |(value, _)| drawn && !value.is_empty()) + } + + /// The paper sent: the one picked, on an edge sheet; white is left to the command. + fn paper_sent(&self) -> Option { + self.paper.filter(|&c| self.edge() && c != egui::Color32::WHITE) + } + /// Why the sheet has no place for `field`'s text, if it hasn't: what is sent, what the review /// says isn't used and which boxes are off all follow from this. fn left_out(&self, field: Field) -> Option { @@ -284,6 +329,8 @@ impl Draft { Field::Heading(0) if lines(&self.sources).next().is_none() => Some(LeftOut::NoSources), Field::Reference | Field::Heading(1) if self.no_reference => Some(LeftOut::NoReference), Field::Heading(2) if !self.editorial() => Some(LeftOut::NotEditorial), + Field::Kicker if !self.edge() => Some(LeftOut::NotEdge), + Field::FigureValue(_) | Field::FigureLabel(_) if !self.edge() && self.style != "panel" => Some(LeftOut::NoFigures), _ => None, } } @@ -291,7 +338,8 @@ impl Draft { /// Whether `field`'s box is switched off or not shown. The sources' heading stays on with no /// sources, which may be typed after it. fn off(&self, field: Field) -> bool { - field == Field::Author && self.no_author || matches!(self.left_out(field), Some(LeftOut::NoReference | LeftOut::NotEditorial)) + field == Field::Author && self.no_author + || matches!(self.left_out(field), Some(LeftOut::NoReference | LeftOut::NotEditorial | LeftOut::NotEdge | LeftOut::NoFigures)) } fn field_mut(&mut self, field: Field) -> &mut String { @@ -306,6 +354,9 @@ impl Draft { Field::Heading(0) => sources, Field::Heading(1) => reference, Field::Heading(_) => column, + Field::Kicker => &mut self.kicker, + Field::FigureValue(at) => &mut self.figures[at].0, + Field::FigureLabel(at) => &mut self.figures[at].1, } } diff --git a/crates/ui-egui/src/publicationwizard/review.rs b/crates/ui-egui/src/publicationwizard/review.rs index 2062c2dff8..5963605b17 100644 --- a/crates/ui-egui/src/publicationwizard/review.rs +++ b/crates/ui-egui/src/publicationwizard/review.rs @@ -33,9 +33,11 @@ pub(super) fn review_step(ui: &mut egui::Ui, s: &Session, d: &Draft) { row(tl!("Style"), style); row(tl!("Elements"), elements_value(s, d)); placement_rows(&mut row, s, d); + kicker_row(&mut row, d); row(tl!("Title"), or_none(&d.title)); row(tl!("Subtitle"), or_none(&d.subtitle)); row(tl!("Note"), or_none(&d.note)); + figures_row(&mut row, d); let sources = lines(&d.sources).collect::>().join("\n"); row(tl!("Sources"), or_none(&sources)); heading_row(&mut row, d, 0, tl!("Sources heading"), PUBLICATION_HEADINGS[0]); @@ -45,6 +47,7 @@ pub(super) fn review_step(ui: &mut egui::Ui, s: &Session, d: &Draft) { row(tl!("Credit line"), credit_value(d)); let accent = d.accent.map(hex).unwrap_or_else(|| tl!("The style's own").to_string()); row(tl!("Accent"), accent); + paper_review_row(&mut row, d); }); if d.figure() { figure_note(ui); @@ -94,13 +97,75 @@ fn heading_row(row: &mut impl FnMut(&str, String), d: &Draft, at: usize, label: None if typed.is_empty() => or.to_string(), None => typed.to_string(), Some(_) if typed.is_empty() => return, - Some(LeftOut::NoSources) => i18n::fmt("{heading} (not used: no sources)", &[("heading", typed)]), - Some(LeftOut::NoReference) => i18n::fmt("{heading} (not used: no reference)", &[("heading", typed)]), - Some(LeftOut::NotEditorial) => i18n::fmt("{heading} (not used: not an editorial sheet)", &[("heading", typed)]), + Some(why) => not_used(why, typed), }; row(label, value); } +/// `typed`, said not to be used and why, rather than dropped unseen. +fn not_used(why: LeftOut, typed: &str) -> String { + let text = [("text", typed)]; + // Each template at its own call, where catalog extraction sees it. + match why { + LeftOut::NoSources => i18n::fmt("{text} (not used: no sources)", &text), + LeftOut::NoReference => i18n::fmt("{text} (not used: no reference)", &text), + LeftOut::NotEditorial => i18n::fmt("{text} (not used: not an editorial sheet)", &text), + LeftOut::NotEdge => i18n::fmt("{text} (not used: not an edge sheet)", &text), + LeftOut::NoFigures => i18n::fmt("{text} (not used: not an edge or panel sheet)", &text), + } +} + +/// The kicker: its text on an edge sheet; on another, said not to be used, and no row with nothing +/// typed. +fn kicker_row(row: &mut impl FnMut(&str, String), d: &Draft) { + let typed = d.kicker.trim(); + let value = match d.left_out(Field::Kicker) { + None if typed.is_empty() => tl!("(none)").to_string(), + None => typed.to_string(), + Some(_) if typed.is_empty() => return, + Some(why) => not_used(why, typed), + }; + row(tl!("Kicker"), value); +} + +/// The headline figures, one per line, as `kicker_row` says the kicker; a label typed with no value +/// is said not to be used. +fn figures_row(row: &mut impl FnMut(&str, String), d: &Draft) { + let left_out = d.left_out(Field::FigureValue(0)); + let typed: Vec = d + .figures + .iter() + .map(|(value, label)| (value.trim(), label.trim())) + .filter_map(|(value, label)| match (value.is_empty(), label.is_empty()) { + (true, true) => None, + (false, true) => Some(value.to_string()), + (false, false) => Some(format!("{value} · {label}")), + (true, false) if left_out.is_some() => Some(label.to_string()), + (true, false) => Some(i18n::fmt("{label} (label without a value isn't used)", &[("label", label)])), + }) + .collect(); + let typed = typed.join("\n"); + let value = match left_out { + None if typed.is_empty() => tl!("(none)").to_string(), + None => typed, + Some(_) if typed.is_empty() => return, + // Each line says it: said once, it would read as the last figure's alone. + Some(why) => typed.lines().map(|line| not_used(why, line)).collect::>().join("\n"), + }; + row(tl!("Figures"), value); +} + +/// An edge sheet's paper; one picked for another style is said not to be used. +fn paper_review_row(row: &mut impl FnMut(&str, String), d: &Draft) { + let value = match (d.paper_sent(), d.paper.filter(|&c| c != egui::Color32::WHITE)) { + (Some(c), _) => hex(c), + _ if d.edge() => tl!("White").to_string(), + (None, Some(c)) => not_used(LeftOut::NotEdge, &hex(c)), + (None, None) => return, + }; + row(tl!("Paper"), value); +} + #[cfg(test)] mod tests { use super::harness::*; @@ -152,4 +217,44 @@ mod tests { assert_eq!(none, others + usize::from(listed == "(none)"), "(none): {author:?}, off {no_author}"); } } + + /// The review lists the kicker, figures and paper a sheet draws, says those typed that its + /// style doesn't, and lists none of them where there is nothing to say. + #[test] + fn the_review_lists_the_kicker_figures_and_paper() { + let mut app = app(); + open(&mut app); + app.dialogs.publication.as_mut().unwrap().step = Step::Review; + let mut h = harness(app); + for key in ["Kicker", "Figures", "Paper"] { + assert!(h.query_by_label(key).is_none(), "{key} on an empty classic sheet"); + } + { + let d = h.state_mut().dialogs.publication.as_mut().unwrap(); + d.style = "edge".into(); + } + h.run_steps(4); + for key in ["Kicker", "Figures", "Paper", "White"] { + assert!(h.query_by_label(key).is_some(), "{key} on an empty edge sheet"); + } + { + let d = h.state_mut().dialogs.publication.as_mut().unwrap(); + d.kicker = " Census ".into(); + d.figures = [(" 12 ".into(), "towns".into()), (String::new(), "lost".into()), ("40".into(), String::new())]; + d.paper = Some(egui::Color32::from_rgb(0x1B, 0x24, 0x30)); + } + h.run_steps(4); + for text in ["Census", "12 · towns\nlost (label without a value isn't used)\n40", "#1B2430"] { + assert!(h.query_by_label(text).is_some(), "{text}"); + } + h.state_mut().dialogs.publication.as_mut().unwrap().style = "classic".into(); + h.run_steps(4); + for text in [ + "Census (not used: not an edge sheet)", + "12 · towns (not used: not an edge or panel sheet)\nlost (not used: not an edge or panel sheet)\n40 (not used: not an edge or panel sheet)", + "#1B2430 (not used: not an edge sheet)", + ] { + assert!(h.query_by_label(text).is_some(), "{text}"); + } + } } diff --git a/crates/ui-egui/src/publicationwizard/sources.rs b/crates/ui-egui/src/publicationwizard/sources.rs index 853f1dbf7c..231412e4ec 100644 --- a/crates/ui-egui/src/publicationwizard/sources.rs +++ b/crates/ui-egui/src/publicationwizard/sources.rs @@ -69,21 +69,21 @@ fn heading(ui: &mut egui::Ui, d: &mut Draft, label: &str, at: usize) { } #[cfg(test)] -mod tests { +pub(super) mod tests { use super::harness::*; use super::*; use egui::accesskit::Role; use egui_kittest::kittest::{NodeT, Queryable}; use rustgis_engine::map::layout::ElementKind; - type Wizard = egui_kittest::Harness<'static, RustGisApp>; + pub(in crate::publicationwizard) type Wizard = egui_kittest::Harness<'static, RustGisApp>; fn draft() -> Draft { Draft::new(&app().session) } /// The wizard on `step`, over the sample project (its map has vector layers). - fn at(step: Step, set: impl FnOnce(&mut Draft)) -> Wizard { + pub(in crate::publicationwizard) fn at(step: Step, set: impl FnOnce(&mut Draft)) -> Wizard { let mut app = app(); open(&mut app); let d = app.dialogs.publication.as_mut().unwrap(); @@ -92,12 +92,12 @@ mod tests { harness(app) } - fn wizard(h: &Wizard) -> &Draft { + pub(in crate::publicationwizard) fn wizard(h: &Wizard) -> &Draft { h.state().dialogs.publication.as_ref().expect("the wizard is open") } /// The first vector layer of the active map, which the statistic menu lists. - fn layer(h: &Wizard) -> String { + pub(in crate::publicationwizard) fn layer(h: &Wizard) -> String { crate::textform::StatLayer::of_map(h.state().session.map()).first().expect("a vector layer").name.clone() } @@ -107,7 +107,7 @@ mod tests { } /// Insert Statistic › the first layer › Count. - fn insert_count(h: &mut Wizard) -> String { + pub(in crate::publicationwizard) fn insert_count(h: &mut Wizard) -> String { let name = layer(h); let token = format!("{{count:{name}}}"); for label in ["Insert Statistic", &name, &format!("Count {token}")] { diff --git a/crates/ui-egui/src/publicationwizard/texts.rs b/crates/ui-egui/src/publicationwizard/texts.rs index 3ddd64489a..ac150c708a 100644 --- a/crates/ui-egui/src/publicationwizard/texts.rs +++ b/crates/ui-egui/src/publicationwizard/texts.rs @@ -1,7 +1,8 @@ //! The wizard's texts step. use super::*; -/// The texts step: the title, subtitle, note, credit line and an editorial sheet's column heading. +/// The texts step: the title, subtitle, note, credit line, an editorial sheet's column heading, an +/// edge sheet's kicker and the headline figures of an edge or panel sheet. pub(super) fn texts_step(ui: &mut egui::Ui, d: &mut Draft, map: &Map) { egui::Grid::new("publication_wizard_texts").num_columns(2).spacing(egui::vec2(8.0, 8.0)).show(ui, |ui| { let line = |ui: &mut egui::Ui, d: &mut Draft, label: &str, field: Field| { @@ -11,6 +12,9 @@ pub(super) fn texts_step(ui: &mut egui::Ui, d: &mut Draft, map: &Map) { d.edited(&r, field); ui.end_row(); }; + if !d.off(Field::Kicker) { + line(ui, d, tl!("Kicker"), Field::Kicker); + } let label = ui.label(tl!("Title")); let title = ui .add( @@ -48,16 +52,30 @@ pub(super) fn texts_step(ui: &mut egui::Ui, d: &mut Draft, map: &Map) { if d.editorial() { line(ui, d, tl!("Column heading"), Field::Heading(2)); } + if !d.off(Field::FigureValue(0)) { + ui.label(egui::RichText::new(tl!("Headline figures")).strong()); + ui.end_row(); + for at in 0..d.figures.len() { + let n = [("n", &*(at + 1).to_string())]; + line(ui, d, &i18n::fmt("Figure {n} value", &n), Field::FigureValue(at)); + line(ui, d, &i18n::fmt("Figure {n} label", &n), Field::FigureLabel(at)); + } + } }); statistic_menu(ui, d, map, Field::Note); - limit_note(ui, d, &[Field::Title, Field::Subtitle, Field::Note, Field::Author, Field::Heading(2)]); + let mut fields = vec![Field::Title, Field::Subtitle, Field::Note, Field::Author, Field::Heading(2), Field::Kicker]; + fields.extend((0..d.figures.len()).flat_map(|at| [Field::FigureValue(at), Field::FigureLabel(at)])); + limit_note(ui, d, &fields); } #[cfg(test)] mod tests { + use super::super::sources::tests::{Wizard, at, insert_count, wizard}; use super::harness::*; use super::*; + use egui::accesskit::Role; use egui_kittest::kittest::Queryable; + use rustgis_engine::map::layout::ElementKind; /// Until the title is edited, it is the active map's name, as the menu titles a sheet: a map /// opened while the wizard is open titles its sheet; a title typed stays. @@ -104,4 +122,171 @@ mod tests { assert!(sub.ends_with("xxab"), "kept up to the limit"); assert!(h.query_by_label(&limit_text).is_some(), "limit notice shown at the cap"); } + + /// The wizard on the texts step of a sheet of `style`. + fn styled(style: &str, set: impl FnOnce(&mut Draft)) -> Wizard { + at(Step::Texts, |d| { + d.style = style.into(); + set(d); + }) + } + + fn figure(value: &str, label: &str) -> (String, String) { + (value.into(), label.into()) + } + + /// An edge sheet is asked its kicker and three figures, a panel the figures alone, the other + /// styles neither. + #[test] + fn only_the_styles_that_draw_them_are_asked_a_kicker_and_figures() { + let mut h = styled("classic", |_| {}); + for (style, kicker, figures) in [ + ("classic", false, false), + ("banner", false, false), + ("panel", false, true), + ("editorial", false, false), + ("modular", false, false), + ("poster", false, false), + ("edge", true, true), + ] { + h.state_mut().dialogs.publication.as_mut().unwrap().style = style.into(); + h.run_steps(4); + assert_eq!(h.query_by_role_and_label(Role::TextInput, "Kicker").is_some(), kicker, "{style}"); + for n in 1..=3 { + for what in ["value", "label"] { + let name = format!("Figure {n} {what}"); + assert_eq!(h.query_by_role_and_label(Role::TextInput, &name).is_some(), figures, "{style}: {name}"); + } + } + } + } + + /// Nothing typed sends none of the three; blanks count as nothing. + #[test] + fn an_edge_sheet_left_empty_sends_no_kicker_figures_or_paper() { + let mut d = Draft::new(&app().session); + d.style = "edge".into(); + for blank in ["", " "] { + d.kicker = blank.into(); + d.figures[0] = figure(blank, blank); + let p = d.params(); + for key in ["kicker", "figures", "paper"] { + assert!(p.get(key).is_none(), "{key}: {blank:?}"); + } + } + } + + /// The kicker and the figures go trimmed, the figures in their order with the empty ones left + /// out, a label only where typed, and a label with no value not at all. + #[test] + fn the_kicker_and_figures_go_trimmed_and_in_order() { + let mut d = Draft::new(&app().session); + d.style = "edge".into(); + d.kicker = " 2026 census ".into(); + d.figures = [figure(" 12 % ", " of land "), figure(" ", "no value"), figure("40", "")]; + let p = d.params(); + assert_eq!(p["kicker"], "2026 census"); + assert_eq!(p["figures"], json!([{"value": "12 %", "label": "of land"}, {"value": "40"}])); + } + + /// A style that draws none of them sends none, and a panel its figures alone; they are kept + /// for the style that takes them. A figure takes none. + #[test] + fn a_style_that_draws_none_is_sent_none() { + let mut d = Draft::new(&app().session); + d.style = "edge".into(); + d.kicker = "K".into(); + d.figures[0] = figure("1", ""); + d.style = "panel".into(); + assert!(d.params().get("kicker").is_none()); + assert_eq!(d.params()["figures"], json!([{"value": "1"}])); + for style in ["classic", "banner", "editorial", "modular", "poster"] { + d.style = style.into(); + assert!(d.params().get("kicker").is_none() && d.params().get("figures").is_none(), "{style}"); + } + d.style = "edge".into(); + d.size = "figure-1col".into(); + assert_eq!(d.params(), json!({"profile": "figure-1col"})); + d.size = "a4".into(); + assert_eq!(d.params()["kicker"], "K", "kept"); + } + + /// A statistic goes to the figure's field last focused. + #[test] + fn a_statistic_goes_to_the_figure_last_focused() { + let mut h = styled("edge", |_| {}); + h.get_by_role_and_label(Role::TextInput, "Figure 2 value").focus(); + h.run_steps(2); + // The menu is under the figures, past the foot of the window until scrolled to. + h.get_by_label("Insert Statistic").scroll_to_me(); + h.run_steps(30); + let token = insert_count(&mut h); + assert_eq!(wizard(&h).figures[1].0, token); + assert!(wizard(&h).note.is_empty()); + } + + /// A field the new style hides takes no statistic: it goes to the note. + #[test] + fn a_statistic_leaves_a_field_the_style_hides() { + for (field, style) in [(Field::Kicker, "classic"), (Field::FigureValue(0), "banner")] { + let mut h = styled(style, |d| d.targets[0] = Some(field)); + let token = insert_count(&mut h); + assert_eq!(wizard(&h).note, token, "{field:?}"); + assert!(wizard(&h).kicker.is_empty() && wizard(&h).figures[0].0.is_empty()); + } + } + + /// A new field at the limit is said; a hidden one full isn't. + #[test] + fn a_full_figure_is_said_only_while_shown() { + let said = format!("Each field takes at most {MAX_PUBLICATION_TEXT} characters."); + let full = "x".repeat(MAX_PUBLICATION_TEXT); + for set in [Field::Kicker, Field::FigureValue(2), Field::FigureLabel(0)] { + let mut h = styled("edge", |d| *d.field_mut(set) = full.clone()); + assert!(h.query_by_label(&said).is_some(), "{set:?}"); + h.state_mut().dialogs.publication.as_mut().unwrap().style = "classic".into(); + h.run_steps(4); + assert!(h.query_by_label(&said).is_none(), "{set:?} hidden"); + } + } + + /// Create puts the kicker, the figures and the paper on the sheet, in one step to undo. + #[test] + fn create_puts_the_kicker_figures_and_paper_on_the_sheet() { + let mut h = at(Step::Review, |d| { + d.style = "edge".into(); + d.kicker = "Census".into(); + d.figures[0] = figure("12", "towns"); + d.paper = Some(egui::Color32::from_rgb(0x1B, 0x24, 0x30)); + }); + let before = h.state().session.project.layouts.len(); + click(&mut h, "Create"); + let l = h.state().session.project.layouts.last().unwrap(); + for name in ["Kicker", "Figure 1 Value", "Figure 1 Label"] { + assert!(l.elements.iter().any(|e| e.name == name && matches!(e.kind, ElementKind::Text { .. })), "{name}"); + } + assert_eq!(l.paper, Some(rustgis_engine::map::Rgba::rgb(0x1B, 0x24, 0x30)), "the paper given"); + h.state_mut().run("edit.undo", Value::Null).unwrap(); + assert_eq!(h.state().session.project.layouts.len(), before); + } + + /// On the smallest window an edge sheet's texts scroll inside it: long figures neither widen + /// it nor move Next. + #[test] + fn long_figures_leave_the_smallest_window_as_it_is() { + let mut app = app(); + open(&mut app); + let d = app.dialogs.publication.as_mut().unwrap(); + d.style = "edge".into(); + 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 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; + h.run_steps(6); + assert!((window(&h).size() - size).abs().max_elem() <= 1.0, "{:?} from {size:?}", window(&h).size()); + assert_eq!(next(&h), at_next); + } } diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index d25ea9fa94..3683cf0f9e 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -45,8 +45,11 @@ Layouts open as tabs next to the maps; while one is open, its groups lead the Pu if it has one, with the accent colour picked, or else its own, where the sheet takes it, which Classic's doesn't; a click on the outline picks the style), the elements, the placement, the texts (title, the active map's name until one is typed; subtitle, note and credit line, or none; - an Editorial sheet's column heading), the sources and reference (each one per line, with its - heading; the reference can be left out) and the accent colour, then shows what was picked; + an Editorial sheet's column heading; an Edge sheet's kicker; the headline figures of an Edge or + Panel sheet, up to three, each a value and its label), the sources and reference (each one per + line, with its heading; the reference can be left out) and the accent colour, with an Edge + sheet's paper (the texts' colour follows it as the sheet is made, which Page Color afterwards + doesn't change), then shows what was picked; **Create** makes the layout as the menu does. **Insert Statistic**, on the texts and sources steps, adds a layer figure of the active map to the field the cursor was last in there (the note or the sources, where it was in none). The map extent is the view, the features one layer shows