From e0bbb110d65d71b5e6837aed3ddd1faca42157f3 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 19:18:44 -0500 Subject: [PATCH] HeaderStrength::Overline: a small capitals group name; the print dialog's section names use it (trial; print test premise updated to the capitals) --- crates/print/src/ui/dialog.rs | 2 +- crates/print/tests/it/dialog.rs | 4 +++- crates/ui-panels/src/sections/section.rs | 2 +- crates/ui-panels/src/sections/title_row.rs | 10 ++++++++-- crates/ui-panels/tests/it/sections/caption.rs | 9 +++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/crates/print/src/ui/dialog.rs b/crates/print/src/ui/dialog.rs index 4005fd84d..ce507227c 100644 --- a/crates/print/src/ui/dialog.rs +++ b/crates/print/src/ui/dialog.rs @@ -308,7 +308,7 @@ impl PrintSection { }); } if inline { - section = section.strength(HeaderStrength::Caption); + section = section.strength(HeaderStrength::Overline); } section.id_salt(("section", at)).show(ui, |ui, _| rows(ui, values, requests)); if let Some(id) = pressed { diff --git a/crates/print/tests/it/dialog.rs b/crates/print/tests/it/dialog.rs index 33ed6db07..2d4d0b2f9 100644 --- a/crates/print/tests/it/dialog.rs +++ b/crates/print/tests/it/dialog.rs @@ -514,7 +514,9 @@ fn a_document_print_dialog_has_compact_inline_rows() { let count = |text: &str| texts.iter().filter(|run| run.text == text).count(); assert_eq!(count("Printer Setup"), 0, "the printer rows carry no heading"); assert_eq!(fixture.by_label("Refresh").is_none(), true, "the printers are found as the dialog opens: no Refresh"); - assert_eq!(count("Pages to Print"), 1, "the heading is shown once, not again as the radio's caption"); + // The heading is an overline, in capitals (production's "PAGES TO PRINT"); the radio's caption is not repeated. + assert_eq!(count("PAGES TO PRINT") + count("Pages to Print"), 1, "the heading is shown once, not again as the radio's caption"); + assert_eq!(count("PAGES TO PRINT"), 1, "the heading is an overline in capitals"); let all = texts.iter().find(|run| run.text == "All pages").expect("the first option is painted"); let current = texts.iter().find(|run| run.text == "Current page").expect("the second option is painted"); assert!((all.rect.center().y - current.rect.center().y).abs() < 2.0, "the options stand on one line: {:?} {:?}", all.rect, current.rect); diff --git a/crates/ui-panels/src/sections/section.rs b/crates/ui-panels/src/sections/section.rs index f566f5a0c..055dda05d 100644 --- a/crates/ui-panels/src/sections/section.rs +++ b/crates/ui-panels/src/sections/section.rs @@ -163,7 +163,7 @@ impl<'a> Section<'a> { #[must_use] pub fn strength(mut self, strength: HeaderStrength) -> Self { self.strength = strength; - self.update_header(|header| header.rule_above(strength != HeaderStrength::Caption)); + self.update_header(|header| header.rule_above(!matches!(strength, HeaderStrength::Caption | HeaderStrength::Overline))); self } diff --git a/crates/ui-panels/src/sections/title_row.rs b/crates/ui-panels/src/sections/title_row.rs index 7a5a7e745..9d0d7087f 100644 --- a/crates/ui-panels/src/sections/title_row.rs +++ b/crates/ui-panels/src/sections/title_row.rs @@ -37,6 +37,9 @@ pub enum HeaderStrength { Heading, /// A quiet heading over a group of controls: label text, faint, as written, with no rule. Caption, + /// A small overline over a group of controls: the caption role, faint, in capitals, with no rule. A document + /// dialog's group names ("PAGES TO PRINT"). + Overline, } /// What a title row's action parts ask the container to do. @@ -344,6 +347,7 @@ impl Component for TitleRow<'_> { HeaderStrength::Section => (cx.tokens.size.panel_header, TypeRole::BodyStrong, text.normal), HeaderStrength::Heading => (cx.tokens.size.panel_header, TypeRole::Heading, text.normal), HeaderStrength::Caption => (cx.control().height, TypeRole::Label, text.faint), + HeaderStrength::Overline => (cx.control().height, TypeRole::Caption, text.faint), }; let shade = key.tone.map_or_else(|| cx.color(shade), |tone| cx.tone_on_fill(tone)); let (ink, disabled) = (cx.ink(key.icon_ink), cx.color(text.disabled)); @@ -496,8 +500,10 @@ impl Component for TitleRow<'_> { } ui.draw().icon(rect, icon); } - let mut title = TextRun::new(cx.resolved.label).role(role).elide(); - if self.strength == HeaderStrength::Caption { + let overline = self.strength == HeaderStrength::Overline; + let capitals = overline.then(|| cx.resolved.label.to_uppercase()); + let mut title = TextRun::new(capitals.as_deref().unwrap_or(cx.resolved.label)).role(role).elide(); + if matches!(self.strength, HeaderStrength::Caption | HeaderStrength::Overline) { title = title.color(cx.resolve(&cx.style.text.color)); } ui.draw().text_on_centre_line(placed.title, &title); diff --git a/crates/ui-panels/tests/it/sections/caption.rs b/crates/ui-panels/tests/it/sections/caption.rs index be6ca69e9..d45449990 100644 --- a/crates/ui-panels/tests/it/sections/caption.rs +++ b/crates/ui-panels/tests/it/sections/caption.rs @@ -33,3 +33,12 @@ fn a_caption_section_shows_its_title_as_written_with_no_rule_while_a_section_has let (_, section_lines) = rules("Blend mode", HeaderStrength::Section); assert!(section_lines > caption_lines, "a section draws a rule above its title; a caption draws none"); } + +/// An overline section reads its title in capitals, with no rule above it. +#[trial] +fn an_overline_section_shows_its_title_in_capitals_with_no_rule() { + let (overline, lines) = rules("Pages to print", HeaderStrength::Overline); + assert!(overline.texts().iter().any(|run| run.text == "PAGES TO PRINT"), "the overline is in capitals"); + let (_, section_lines) = rules("Pages to print", HeaderStrength::Section); + assert!(section_lines > lines, "no rule above an overline"); +}