mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-24 10:46:50 -06:00
Grid: row and column heading labels grow with the zoom
At high zoom the heading labels stopped at 16 points (the outline levels at 14) while the cells kept growing, so at 300-400% the letters and numbers looked tiny in their tall headings. Excel scales them with the zoom. The labels now scale without a cap and keep their readable floor at low zoom (heading_font_size). Signed-off-by: MH <q6rrzz@gmail.com>
This commit is contained in:
@@ -1701,7 +1701,7 @@ pub(crate) fn paint_headers(
|
||||
t: &Tokens,
|
||||
quads: &[((u32, u32), (u32, u32), Rect)],
|
||||
) {
|
||||
let font = theme::ui_font((11.5 * (geo.z / DISPLAY_SCALE).max(0.75)).min(16.0));
|
||||
let font = theme::ui_font(heading_font_size(geo.z));
|
||||
// The headers' own area: inside the outline bands.
|
||||
let r = Rect::from_min_max(pos2(geo.head_left(), geo.head_top()), geo.rect.max);
|
||||
let top = Rect::from_min_max(pos2(geo.cells.left(), r.top()), pos2(r.right(), geo.cells.top()));
|
||||
@@ -3336,8 +3336,23 @@ mod selection_fill_tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Row and column heading labels grow with the zoom as the cells do, as in Excel (at 400% the
|
||||
/// labels are four times their 100% size), and never get smaller than a readable 8.5 points.
|
||||
pub(crate) fn heading_font_size(zoom: f32) -> f32 {
|
||||
(11.5 * (zoom / DISPLAY_SCALE)).max(8.5)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
#[test]
|
||||
fn heading_labels_scale_with_the_zoom_without_a_cap() {
|
||||
use super::{DISPLAY_SCALE, heading_font_size};
|
||||
let at = |percent: f32| heading_font_size(percent / 100.0 * DISPLAY_SCALE);
|
||||
assert!((at(400.0) / at(100.0) - 4.0).abs() < 1e-4, "four times as large at 400%");
|
||||
assert!(at(200.0) > at(100.0) && at(400.0) > at(200.0));
|
||||
assert_eq!(at(10.0), 8.5, "never below a readable size");
|
||||
}
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -261,7 +261,8 @@ pub fn paint(p: &Painter, geo: &Geo, sh: &Sheet, t: &Tokens) {
|
||||
pc.line_segment(tick, ink);
|
||||
}
|
||||
}
|
||||
let font = theme::ui_font((10.0 * (geo.z / DISPLAY_SCALE).max(0.75)).min(14.0));
|
||||
// The outline levels grow with the zoom like the headings beside them.
|
||||
let font = theme::ui_font((10.0 * (geo.z / DISPLAY_SCALE)).max(7.5));
|
||||
for b in &l.buttons {
|
||||
let clip = match b.action {
|
||||
Action::Toggle { rows: true, .. } => row_clip,
|
||||
|
||||
Reference in New Issue
Block a user