authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-02 17:55:52-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-02 19:55:46-07:00
logb58ce1faf590fd325dd35a8489ce67900b202c38
tree341c8d7d2db75064b5663dc2f12b9cd18cffdd14
parent8bfedcad86c706463601020a107b0cad26ad75ae
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

fix: the Styles gallery's styles sit close together

Each style's row is as tall as its text rather than a fixed 34 px. Assisted-by: claude-opus-5.5

1 files changed, 31 insertions(+), 12 deletions(-)

crates/snowbound/src/themes.rs+31-12
......@@ -60,6 +60,14 @@ fn popup(name: &str) -> Id {
6060/// Spacing the dialog offers above and below a style, in points.
6161const SPACING: [f32; 9] = [0.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 12.0, 18.0];
6262
63/// The largest a style's text shows in the Styles gallery, in pixels.
64const GALLERY_LARGEST: f32 = 24.0;
65
66/// The pixel size `preview` shows `style` at: as a page shows it, up to `largest`.
67fn shown_size(style: &ThemeStyle, largest: f32) -> f32 {
68 (style.size * 1.2).clamp(10.0, largest)
69}
70
6371/// A line of `text` in `style` as a page in a section coloured `section` shows it, scaled
6472/// down to fit a menu row up to `largest` pixels, its colour moved onto the popup's paper so
6573/// it reads in either scheme.
......@@ -86,7 +94,7 @@ pub(crate) fn preview(
8694 size: [fill(), fill()],
8795 text: Some(text),
8896 font: Some(&style.font),
89 font_size: Some((style.size * 1.2).clamp(10.0, largest)),
97 font_size: Some(shown_size(style, largest)),
9098 bold: style.bold,
9199 italic: style.italic,
92100 color: Some(color),
......@@ -739,20 +747,24 @@ pub(crate) fn gallery(
739747 current: Option<&str>,
740748) -> Option<crate::commands::Id> {
741749 use crate::commands::Id as Cmd;
742 let groups = [
743 ui::popup::Group {
744 heading: &sheet.name,
745 cells: STYLES.len(),
750 // Each style's row is as tall as its text, without the style's spacing.
751 let row = |height: f32| [240.0, height + 8.0];
752 let groups: Vec<ui::popup::Group> = STYLES
753 .iter()
754 .enumerate()
755 .map(|(at, (name, _))| ui::popup::Group {
756 heading: if at == 0 { &sheet.name } else { "" },
757 cells: 1,
746758 columns: 1,
747 size: [240.0, 34.0],
748 },
749 ui::popup::Group {
759 size: row(shown_size(&sheet.styles[*name], GALLERY_LARGEST) * 1.25),
760 })
761 .chain([ui::popup::Group {
750762 heading: "",
751763 cells: 1,
752764 columns: 1,
753 size: [240.0, 24.0],
754 },
755 ];
765 size: row(16.0),
766 }])
767 .collect();
756768 let shown: Vec<usize> = STYLES
757769 .iter()
758770 .position(|(name, _)| Some(*name) == current)
......@@ -762,7 +774,14 @@ pub(crate) fn gallery(
762774 .get(index)
763775 {
764776 Some((name, label)) => {
765 preview(ui, "preview", label, &sheet.styles[*name], section, 24.0);
777 preview(
778 ui,
779 "preview",
780 label,
781 &sheet.styles[*name],
782 section,
783 GALLERY_LARGEST,
784 );
766785 if let Some(node) = ui.access(ui.id("preview")) {
767786 node.set_label(*label);
768787 }