1use crate::render::Rect;
2
3use super::Panel;
4
5pub fn compute_grid_panels(
7 row_levels: &[String],
8 col_levels: &[String],
9 total_area: &Rect,
10 strip_height: f64,
11 strip_width: f64,
12) -> Vec<Panel> {
13 let nrow = row_levels.len().max(1);
14 let ncol = col_levels.len().max(1);
15
16 let panel_width = (total_area.width - strip_width) / ncol as f64;
17 let panel_height = (total_area.height - strip_height) / nrow as f64;
18
19 let mut panels = Vec::new();
20
21 for (ri, rl) in row_levels.iter().enumerate() {
22 for (ci, cl) in col_levels.iter().enumerate() {
23 panels.push(Panel {
24 row: ri,
25 col: ci,
26 label: format!("{rl} | {cl}"),
27 row_label: Some(rl.clone()),
28 col_label: Some(cl.clone()),
29 rect: Rect {
30 x: total_area.x + ci as f64 * panel_width,
31 y: total_area.y + strip_height + ri as f64 * panel_height,
32 width: panel_width,
33 height: panel_height,
34 },
35 });
36 }
37 }
38
39 panels
40}