HeaderStrength::Overline: a small capitals group name; the print dialog's section names use it (trial; print test premise updated to the capitals)

This commit is contained in:
Dylan M. Taylor
2026-11-22 19:18:44 -05:00
parent d5b7993417
commit e0bbb110d6
5 changed files with 22 additions and 5 deletions
+1 -1
View File
@@ -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 {
+3 -1
View File
@@ -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);
+1 -1
View File
@@ -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
}
+8 -2
View File
@@ -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);
@@ -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");
}