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 {...@@ -60,6 +60,14 @@ fn popup(name: &str) -> Id {
60/// Spacing the dialog offers above and below a style, in points.60/// Spacing the dialog offers above and below a style, in points.
61const SPACING: [f32; 9] = [0.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 12.0, 18.0];61const 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
63/// A line of `text` in `style` as a page in a section coloured `section` shows it, scaled71/// A line of `text` in `style` as a page in a section coloured `section` shows it, scaled
64/// down to fit a menu row up to `largest` pixels, its colour moved onto the popup's paper so72/// down to fit a menu row up to `largest` pixels, its colour moved onto the popup's paper so
65/// it reads in either scheme.73/// it reads in either scheme.
...@@ -86,7 +94,7 @@ pub(crate) fn preview(...@@ -86,7 +94,7 @@ pub(crate) fn preview(
86 size: [fill(), fill()],94 size: [fill(), fill()],
87 text: Some(text),95 text: Some(text),
88 font: Some(&style.font),96 font: Some(&style.font),
89 font_size: Some((style.size * 1.2).clamp(10.0, largest)),97 font_size: Some(shown_size(style, largest)),
90 bold: style.bold,98 bold: style.bold,
91 italic: style.italic,99 italic: style.italic,
92 color: Some(color),100 color: Some(color),
...@@ -739,20 +747,24 @@ pub(crate) fn gallery(...@@ -739,20 +747,24 @@ pub(crate) fn gallery(
739 current: Option<&str>,747 current: Option<&str>,
740) -> Option<crate::commands::Id> {748) -> Option<crate::commands::Id> {
741 use crate::commands::Id as Cmd;749 use crate::commands::Id as Cmd;
742 let groups = [750 // Each style's row is as tall as its text, without the style's spacing.
743 ui::popup::Group {751 let row = |height: f32| [240.0, height + 8.0];
744 heading: &sheet.name,752 let groups: Vec<ui::popup::Group> = STYLES
745 cells: STYLES.len(),753 .iter()
754 .enumerate()
755 .map(|(at, (name, _))| ui::popup::Group {
756 heading: if at == 0 { &sheet.name } else { "" },
757 cells: 1,
746 columns: 1,758 columns: 1,
747 size: [240.0, 34.0],759 size: row(shown_size(&sheet.styles[*name], GALLERY_LARGEST) * 1.25),
748 },760 })
749 ui::popup::Group {761 .chain([ui::popup::Group {
750 heading: "",762 heading: "",
751 cells: 1,763 cells: 1,
752 columns: 1,764 columns: 1,
753 size: [240.0, 24.0],765 size: row(16.0),
754 },766 }])
755 ];767 .collect();
756 let shown: Vec<usize> = STYLES768 let shown: Vec<usize> = STYLES
757 .iter()769 .iter()
758 .position(|(name, _)| Some(*name) == current)770 .position(|(name, _)| Some(*name) == current)
...@@ -762,7 +774,14 @@ pub(crate) fn gallery(...@@ -762,7 +774,14 @@ pub(crate) fn gallery(
762 .get(index)774 .get(index)
763 {775 {
764 Some((name, label)) => {776 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 );
766 if let Some(node) = ui.access(ui.id("preview")) {785 if let Some(node) = ui.access(ui.id("preview")) {
767 node.set_label(*label);786 node.set_label(*label);
768 }787 }