| ... | ... | @@ -60,6 +60,14 @@ fn popup(name: &str) -> Id { |
| 60 | 60 | /// Spacing the dialog offers above and below a style, in points. |
| 61 | 61 | const SPACING: [f32; 9] = [0.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 12.0, 18.0]; |
| 62 | 62 | |
| 63 | /// The largest a style's text shows in the Styles gallery, in pixels. |
| 64 | const GALLERY_LARGEST: f32 = 24.0; |
| 65 | |
| 66 | /// The pixel size `preview` shows `style` at: as a page shows it, up to `largest`. |
| 67 | fn shown_size(style: &ThemeStyle, largest: f32) -> f32 { |
| 68 | (style.size * 1.2).clamp(10.0, largest) |
| 69 | } |
| 70 | |
| 63 | 71 | /// A line of `text` in `style` as a page in a section coloured `section` shows it, scaled |
| 64 | 72 | /// down to fit a menu row up to `largest` pixels, its colour moved onto the popup's paper so |
| 65 | 73 | /// it reads in either scheme. |
| ... | ... | @@ -86,7 +94,7 @@ pub(crate) fn preview( |
| 86 | 94 | size: [fill(), fill()], |
| 87 | 95 | text: Some(text), |
| 88 | 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 | 98 | bold: style.bold, |
| 91 | 99 | italic: style.italic, |
| 92 | 100 | color: Some(color), |
| ... | ... | @@ -739,20 +747,24 @@ pub(crate) fn gallery( |
| 739 | 747 | current: Option<&str>, |
| 740 | 748 | ) -> Option<crate::commands::Id> { |
| 741 | 749 | 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, |
| 746 | 758 | 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 { |
| 750 | 762 | heading: "", |
| 751 | 763 | cells: 1, |
| 752 | 764 | columns: 1, |
| 753 | | size: [240.0, 24.0], |
| 754 | | }, |
| 755 | | ]; |
| 765 | size: row(16.0), |
| 766 | }]) |
| 767 | .collect(); |
| 756 | 768 | let shown: Vec<usize> = STYLES |
| 757 | 769 | .iter() |
| 758 | 770 | .position(|(name, _)| Some(*name) == current) |
| ... | ... | @@ -762,7 +774,14 @@ pub(crate) fn gallery( |
| 762 | 774 | .get(index) |
| 763 | 775 | { |
| 764 | 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 | 785 | if let Some(node) = ui.access(ui.id("preview")) { |
| 767 | 786 | node.set_label(*label); |
| 768 | 787 | } |